sync with master
authorJinkun Jang <jinkun.jang@samsung.com>
Mon, 18 Mar 2013 02:24:17 +0000 (11:24 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Mon, 18 Mar 2013 02:24:17 +0000 (11:24 +0900)
411 files changed:
CMakeLists.txt
inc/FAppApp.h
inc/FAppAppControl.h [changed mode: 0644->0755]
inc/FAppAppManager.h [changed mode: 0644->0755]
inc/FAppAppRegistry.h
inc/FAppAppResource.h [changed mode: 0755->0644]
inc/FAppAppSetting.h [changed mode: 0755->0644]
inc/FAppDataControlProviderManager.h
inc/FAppIActiveAppEventListener.h
inc/FAppMapDataControl.h [changed mode: 0644->0755]
inc/FAppNotificationManager.h [changed mode: 0755->0644]
inc/FAppPkgIPackageInstallationResponseListener.h
inc/FAppPkgIPackageUninstallationResponseListener.h
inc/FAppPkgPackageAppInfo.h
inc/FAppPkgPackageInfo.h [changed mode: 0755->0644]
inc/FAppPkgPackageLicenseManager.h [new file with mode: 0644]
inc/FAppPkgPackageManager.h [changed mode: 0755->0644]
inc/FAppSqlDataControl.h [changed mode: 0644->0755]
inc/FAppTypes.h
inc/FBase.h
inc/FBaseBuffer.h
inc/FBaseBufferBase.h
inc/FBaseByteBuffer.h
inc/FBaseCharacter.h
inc/FBaseCol.h
inc/FBaseColArrayListT.h
inc/FBaseColHashMapT.h
inc/FBaseColIMultiMap.h
inc/FBaseColIMultiMapT.h
inc/FBaseColIteratorT.h [new file with mode: 0644]
inc/FBaseColLinkedList.h
inc/FBaseColLinkedListT.h
inc/FBaseColMultiHashMap.h
inc/FBaseColMultiHashMapT.h
inc/FBaseColPairIteratorT.h [new file with mode: 0644]
inc/FBaseColQueue.h
inc/FBaseColQueueT.h
inc/FBaseColRandomIteratorT.h [new file with mode: 0644]
inc/FBaseColStack.h
inc/FBaseColStackT.h
inc/FBaseColStlConverter.h [new file with mode: 0644]
inc/FBaseComparerT.h
inc/FBaseDateTime.h
inc/FBaseErrors.h
inc/FBaseLog.h
inc/FBaseLongLong.h
inc/FBaseRtIWaitingLoopCondition.h
inc/FBaseRtMonitor.h [changed mode: 0644->0755]
inc/FBaseRtMutex.h [changed mode: 0644->0755]
inc/FBaseRtTimer.h
inc/FBaseRtTypes.h
inc/FBaseRtWaitingLoop.h
inc/FBaseStringHashCodeProvider.h [new file with mode: 0644]
inc/FBaseSysLog.h
inc/FBaseUtil.h
inc/FBaseUtilScanner.h [new file with mode: 0644]
inc/FGrpBitmapCommon.h
inc/FIo.h
inc/FIoDatabase.h
inc/FIoDbEnumerator.h
inc/FIoFile.h
inc/FIoFileLock.h [new file with mode: 0644]
inc/FIoIDbEnumerator.h
inc/FIoLocalMessagePort.h
inc/FIoMessagePortManager.h
inc/FIoMmcStorageManager.h [changed mode: 0755->0644]
inc/FIoRegistry.h
inc/FIoRemoteMessagePort.h
inc/FLclDateTimeSymbols.h
inc/FLclGregorianCalendar.h
inc/FLclLocale.h
inc/FLclTimeZone.h
inc/FSecAccessController.h
inc/FSecCertICertificateStore.h
inc/FSecCertX509CertificateStore.h [changed mode: 0755->0644]
inc/FSecCryptoRsaCipher.h
inc/FSecCryptoRsaSignature.h
inc/FSecKeyPairGenerator.h
inc/FSecPkcs.h [new file with mode: 0644]
inc/FSecPkcsAlgorithmIdentifier.h [new file with mode: 0644]
inc/FSecPkcsIAlgorithmParameters.h [new file with mode: 0644]
inc/FSecPkcsInitialVector.h [new file with mode: 0644]
inc/FSecPkcsPkcs05PbEs2Parameters.h [new file with mode: 0644]
inc/FSecPkcsPkcs05PbKdf2Parameters.h [new file with mode: 0644]
inc/FSecPkcsPkcs05PbMacParameters.h [new file with mode: 0644]
inc/FSecPkcsPkcs05Schemes.h [new file with mode: 0644]
inc/FSecPkcsPkcs08Attribute.h [new file with mode: 0644]
inc/FSecPkcsPkcs08AttributeValue.h [new file with mode: 0644]
inc/FSecPkcsPkcs08EncryptedPrivateKeyInfo.h [new file with mode: 0644]
inc/FSecPkcsPkcs08PrivateKeyInfo.h [new file with mode: 0644]
inc/FSecPkcsRc2CbcParameters.h [new file with mode: 0644]
inc/FSecPkcsTypes.h [new file with mode: 0644]
inc/FSecPrivacyInfo.h [new file with mode: 0755]
inc/FSecPrivacyManager.h [new file with mode: 0755]
inc/FSecPrivilegeInfo.h [new file with mode: 0755]
inc/FSecRsaKeyConverter.h [new file with mode: 0644]
inc/FSecurity.h [changed mode: 0644->0755]
inc/FSysAlarm.h [changed mode: 0755->0644]
inc/FSysDeviceManager.h
inc/FSysEnvironment.h
inc/FSysIBootEventListener.h [new file with mode: 0644]
inc/FSysIScreenEventListener.h
inc/FSysPowerManager.h [changed mode: 0755->0644]
inc/FSysRuntimeInfo.h [changed mode: 0755->0644]
inc/FSysSettingInfo.h [changed mode: 0755->0644]
inc/FSysSystemInfo.h [changed mode: 0755->0644]
inc/FSysSystemTime.h
inc/FSysVibrator.h [changed mode: 0755->0644]
inc/FSystem.h
inc/FTextEncoding.h
inc/Framework.h
osp-appfw.pc.in
packaging/osp-appfw.spec
res/arm/usr/etc/system-info.ini [deleted file]
res/common/usr/share/osp/.external-privilege.ini [new file with mode: 0644]
res/common/usr/share/osp/.privilege-description.db [new file with mode: 0644]
res/x86/usr/etc/system-info.ini [deleted file]
src/CMakeLists.txt [changed mode: 0644->0755]
src/app/CMakeLists.txt
src/app/FAppApp.cpp
src/app/FAppAppManager.cpp
src/app/FAppAppResource.cpp
src/app/FAppNotificationManager.cpp
src/app/FApp_AppArg.cpp [changed mode: 0644->0755]
src/app/FApp_AppControlImpl.cpp
src/app/FApp_AppControlManager.cpp
src/app/FApp_AppControlProviderManagerImpl.h
src/app/FApp_AppControlRegistry.cpp
src/app/FApp_AppImpl.cpp [changed mode: 0644->0755]
src/app/FApp_AppInfo.cpp
src/app/FApp_AppLaunchCondition.cpp
src/app/FApp_AppLaunchConditionHandlerBase.cpp [changed mode: 0644->0755]
src/app/FApp_AppManagerImpl.cpp
src/app/FApp_AppManagerProxy.cpp
src/app/FApp_AppRegistryImpl.cpp
src/app/FApp_AppResourceImpl.cpp
src/app/FApp_AppResourceImpl.h
src/app/FApp_AppResourceString.cpp
src/app/FApp_AppResourceString.h
src/app/FApp_Aul.cpp [changed mode: 0644->0755]
src/app/FApp_ConditionManagerProxy.cpp
src/app/FApp_ConditionManagerProxy.h
src/app/FApp_DataControlProviderManagerImpl.cpp
src/app/FApp_ImeAppImpl.cpp [changed mode: 0644->0755]
src/app/FApp_MapDataControlImpl.cpp
src/app/FApp_MapDataControlImpl.h
src/app/FApp_NotificationManagerImpl.cpp
src/app/FApp_NotificationManagerProxy.cpp [deleted file]
src/app/FApp_NotificationManagerProxy.h [deleted file]
src/app/FApp_ServiceAppImpl.cpp [changed mode: 0644->0755]
src/app/FApp_SqlDataControlImpl.cpp
src/app/FApp_SqlDataControlImpl.h
src/app/inc/FAppNotificationMessage.h [deleted file]
src/app/inc/FAppPkg_PackageAppInfoImpl.h
src/app/inc/FAppPkg_PackageInfoImpl.h
src/app/inc/FAppPkg_PackageManagerImpl.h
src/app/inc/FAppPkg_PackageParser.h [new file with mode: 0755]
src/app/inc/FApp_AppArg.h [changed mode: 0644->0755]
src/app/inc/FApp_AppControlImpl.h
src/app/inc/FApp_AppControlManager.h
src/app/inc/FApp_AppImpl.h [changed mode: 0644->0755]
src/app/inc/FApp_AppInfo.h
src/app/inc/FApp_AppLaunchCondition.h
src/app/inc/FApp_AppLaunchConditionHandlerBase.h [changed mode: 0644->0755]
src/app/inc/FApp_AppManagerImpl.h
src/app/inc/FApp_AppManagerIpcMessage.h
src/app/inc/FApp_AppManagerProxy.h
src/app/inc/FApp_Aul.h
src/app/inc/FApp_ConditionManagerIpcMessages.h
src/app/inc/FApp_IAppEventListener.h [new file with mode: 0644]
src/app/inc/FApp_IAppLaunchConditionEventListener.h [changed mode: 0644->0755]
src/app/inc/FApp_IAppManager.h
src/app/inc/FApp_IAppResourceBitmap.h
src/app/inc/FApp_NotificationManagerEventParamTraits.h [deleted file]
src/app/inc/FApp_NotificationManagerImpl.h
src/app/inc/FApp_NotificationManagerIpcMessages.h [deleted file]
src/app/inc/FApp_TemplateUtil.h [changed mode: 0755->0644]
src/app/package/FAppPkgPackageAppInfo.cpp
src/app/package/FAppPkgPackageInfo.cpp
src/app/package/FAppPkgPackageLicenseManager.cpp [new file with mode: 0644]
src/app/package/FAppPkgPackageManager.cpp
src/app/package/FAppPkg_PackageAppInfoImpl.cpp
src/app/package/FAppPkg_PackageInfoImpl.cpp
src/app/package/FAppPkg_PackageManagerImpl.cpp
src/app/package/FAppPkg_PackageParser.cpp [new file with mode: 0755]
src/appfw/CMakeLists.txt
src/base/CMakeLists.txt
src/base/FBaseByteBuffer.cpp
src/base/FBaseDateTime.cpp
src/base/FBaseLongLong.cpp
src/base/FBaseResult.cpp
src/base/FBaseStringHashCodeProvider.cpp [new file with mode: 0644]
src/base/FBaseSys.cpp
src/base/FBase_NativeError.cpp
src/base/collection/FBaseColArrayList.cpp
src/base/collection/FBaseColLinkedList.cpp
src/base/inc/FBaseRt_Event.h [changed mode: 0644->0755]
src/base/runtime/FBaseRtMutex.cpp [changed mode: 0644->0755]
src/base/runtime/FBaseRtWaitingLoop.cpp
src/base/runtime/FBaseRt_Event.cpp [changed mode: 0644->0755]
src/base/runtime/FBaseRt_MutexImpl.cpp [changed mode: 0644->0755]
src/base/runtime/FBaseRt_MutexImpl.h [changed mode: 0644->0755]
src/base/runtime/FBaseRt_WaitingLoopImpl.cpp
src/base/runtime/FBaseRt_WaitingLoopImpl.h
src/base/utility/FBaseUtilScanner.cpp [new file with mode: 0644]
src/base/utility/FBaseUtil_RegularExpressionImpl.h
src/base/utility/FBaseUtil_ScannerImpl.cpp [new file with mode: 0644]
src/base/utility/FBaseUtil_ScannerImpl.h [new file with mode: 0644]
src/io/CMakeLists.txt [changed mode: 0755->0644]
src/io/FIoFile.cpp
src/io/FIoFileLock.cpp [new file with mode: 0644]
src/io/FIoMmcStorageManager.cpp
src/io/FIoRegistry.cpp
src/io/FIo_ChannelCAppStub.cpp [deleted file]
src/io/FIo_ChannelService.cpp [deleted file]
src/io/FIo_ChannelServiceManager.cpp
src/io/FIo_ChannelServiceStub.cpp [deleted file]
src/io/FIo_ChannelWebAppStub.cpp [deleted file]
src/io/FIo_ClientChannelImpl.cpp
src/io/FIo_DataControlResultSetEnumerator.cpp
src/io/FIo_DataControlResultSetImpl.cpp
src/io/FIo_DataRouter.cpp
src/io/FIo_DatabaseImpl.cpp
src/io/FIo_DbEnumeratorImpl.cpp
src/io/FIo_DirectoryImpl.cpp
src/io/FIo_FileImpl.cpp
src/io/FIo_FileLockImpl.cpp [new file with mode: 0644]
src/io/FIo_FileUtil.cpp
src/io/FIo_IpcClient.cpp
src/io/FIo_LocalMessagePortImpl.cpp
src/io/FIo_MessagePortProxy.cpp
src/io/FIo_MmcStorageManagerImpl.cpp
src/io/FIo_MmcStorageManagerProxy.cpp
src/io/FIo_NormalRegistry.cpp
src/io/FIo_RegistryCore.cpp
src/io/FIo_RegistryImpl.cpp
src/io/FIo_RemoteMessagePortImpl.cpp
src/io/FIo_SecureIoUtil.cpp
src/io/FIo_SecureRegistry.cpp
src/io/FIo_ServerChannelImpl.cpp
src/io/FIo_ZipFileArchive.cpp [new file with mode: 0644]
src/io/inc/FIo_ChannelCAppStub.h [deleted file]
src/io/inc/FIo_ChannelService.h [deleted file]
src/io/inc/FIo_ChannelServiceStub.h [deleted file]
src/io/inc/FIo_ChannelWebAppStub.h [deleted file]
src/io/inc/FIo_DataRouter.h
src/io/inc/FIo_FileImpl.h
src/io/inc/FIo_FileLockImpl.h [new file with mode: 0644]
src/io/inc/FIo_IMmcStorageServiceEventListener.h
src/io/inc/FIo_IpcClient.h
src/io/inc/FIo_IpcCommonParamTraits.h [changed mode: 0644->0755]
src/io/inc/FIo_IpcMessageStart.h
src/io/inc/FIo_MessagePortMessages.h [deleted file]
src/io/inc/FIo_MessagePortProxy.h
src/io/inc/FIo_MmcStorageManagerImpl.h
src/io/inc/FIo_MmcStorageManagerProxy.h
src/io/inc/FIo_RegistryCore.h
src/io/inc/FIo_RegistryImpl.h
src/io/inc/FIo_ZipFileArchive.h [new file with mode: 0644]
src/locales/FLclCalendar.cpp
src/locales/FLclDateTimeSymbols.cpp
src/locales/FLclGregorianCalendar.cpp
src/locales/FLclLocale.cpp
src/locales/FLclNumberSymbols.cpp
src/locales/FLcl_CalendarImpl.cpp
src/locales/FLcl_CurrencyImpl.cpp
src/locales/FLcl_DateTimeSymbolsImpl.cpp
src/locales/FLcl_DateTimeSymbolsImpl.h
src/locales/FLcl_IcuCalendarImpl.cpp
src/locales/FLcl_LocaleData.cpp
src/locales/FLcl_LocaleData.h
src/locales/FLcl_LocaleImpl.cpp
src/locales/FLcl_LocaleImpl.h
src/locales/FLcl_LocaleManagerImpl.cpp
src/locales/FLcl_NumberFormatterImpl.cpp
src/locales/FLcl_TimeZoneImpl.cpp
src/locales/FLcl_TimeZoneImpl.h
src/security/CMakeLists.txt
src/security/FSecAccessController.cpp
src/security/FSecKeyPairGenerator.cpp
src/security/FSecPrivacyInfo.cpp [new file with mode: 0755]
src/security/FSecPrivacyManager.cpp [new file with mode: 0755]
src/security/FSecPrivilegeInfo.cpp [new file with mode: 0755]
src/security/FSecRsaKeyConverter.cpp [new file with mode: 0644]
src/security/FSec_AccessController.cpp
src/security/FSec_PrivacyInfoImpl.cpp [new file with mode: 0755]
src/security/FSec_PrivacyManagerImpl.cpp [new file with mode: 0755]
src/security/FSec_PrivilegeCache.cpp
src/security/FSec_PrivilegeInfo.cpp
src/security/FSec_PrivilegeInfo.h
src/security/FSec_PrivilegeInfoImpl.cpp [new file with mode: 0755]
src/security/FSec_PrivilegeManager.cpp
src/security/cert/CMakeLists.txt
src/security/cert/FSecCertX509Certificate.cpp [changed mode: 0755->0644]
src/security/cert/FSecCertX509CertificatePath.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_Asn1Parser.h [changed mode: 0755->0644]
src/security/cert/FSecCert_Base64.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_Base64.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertChain.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertDbManager.cpp
src/security/cert/FSecCert_CertDbManager.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertDbStore.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_CertDbStore.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertExtension.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertFileStore.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertList.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_CertList.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertManager.cpp
src/security/cert/FSecCert_CertManager.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertMgrMessages.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_CertOidDef.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertPrivateKeyInfo.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertService.cpp
src/security/cert/FSecCert_CertServiceProxy.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_CertServiceStub.cpp [deleted file]
src/security/cert/FSecCert_CertSignature.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_CertSignature.h [changed mode: 0755->0644]
src/security/cert/FSecCert_CertTime.cpp [changed mode: 0755->0644]
src/security/cert/FSecCert_CertTime.h [changed mode: 0755->0644]
src/security/cert/FSecCert_Certificate.h [changed mode: 0755->0644]
src/security/cert/FSecCert_X509CertificateStoreImpl.cpp
src/security/cert/FSecCert_X509CertificateStoreImpl.h [changed mode: 0755->0644]
src/security/crypto/FSecCryptoRsaCipher.cpp
src/security/crypto/FSecCryptoRsaSignature.cpp
src/security/crypto/FSecCrypto_TrustZoneService.cpp [new file with mode: 0755]
src/security/crypto/FSecCrypto_TrustZoneServiceMessage.cpp [moved from src/app/FApp_NotificationManagerIpcMessages.cpp with 62% similarity]
src/security/inc/FSecCert_CertMgrMessages.h [moved from src/security/cert/FSecCert_CertMgrMessages.h with 99% similarity, mode: 0644]
src/security/inc/FSecCert_CertService.h
src/security/inc/FSecCert_CertServiceProxy.h
src/security/inc/FSecCert_CertServiceStub.h [deleted file]
src/security/inc/FSecCert_CertTypes.h [changed mode: 0755->0644]
src/security/inc/FSecCrypto_TrustZoneService.h [new file with mode: 0755]
src/security/inc/FSecCrypto_TrustZoneServiceMessage.h [moved from src/io/FIo_MessagePortMessages.cpp with 60% similarity, mode: 0755]
src/security/inc/FSec_AccessControlTypes.h
src/security/inc/FSec_AccessController.h
src/security/inc/FSec_PrivacyInfoImpl.h [new file with mode: 0755]
src/security/inc/FSec_PrivacyManagerImpl.h [new file with mode: 0755]
src/security/inc/FSec_PrivilegeInfoImpl.h [new file with mode: 0755]
src/security/inc/FSec_PrivilegeManager.h
src/security/inc/FSec_PrivilegeManagerMessage.h
src/security/pkcs/FSecPkcsAlgorithmIdentifier.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsInitialVector.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs05PbEs2Parameters.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs05PbKdf2Parameters.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs05PbMacParameters.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs05Schemes.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs08Attribute.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs08AttributeValue.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs08EncryptedPrivateKeyInfo.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsPkcs08PrivateKeyInfo.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcsRc2CbcParameters.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_AlgorithmIdentifierImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_AlgorithmIdentifierImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_InitialVectorImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_InitialVectorImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05PbEs2ParametersImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05PbEs2ParametersImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05PbKdf2ParametersImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05PbKdf2ParametersImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05PbMacParametersImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05PbMacParametersImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05SchemesImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs05SchemesImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08AttributeValueImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08AttributeValueImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_PkcsUtility.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_PkcsUtility.h [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Rc2CbcParametersImpl.cpp [new file with mode: 0644]
src/security/pkcs/FSecPkcs_Rc2CbcParametersImpl.h [new file with mode: 0644]
src/server/CMakeLists.txt [new file with mode: 0755]
src/server/app/CMakeLists.txt [new file with mode: 0755]
src/server/app/FApp_AulServer.cpp [new file with mode: 0755]
src/server/inc/FApp_AulServer.h [new file with mode: 0755]
src/server/inc/FIo_IpcServer.h [moved from src/io/inc/FIo_IpcServer.h with 92% similarity]
src/server/io/FIo_IpcServer.cpp [moved from src/io/FIo_IpcServer.cpp with 97% similarity]
src/system/CMakeLists.txt
src/system/FSysPowerManager.cpp
src/system/FSysSystemInfo.cpp
src/system/FSysVibrator.cpp
src/system/FSys_AlarmImpl.cpp
src/system/FSys_AlarmManager.cpp [new file with mode: 0644]
src/system/FSys_AlarmManager.h [new file with mode: 0644]
src/system/FSys_CommunicationDispatcherClient.cpp [new file with mode: 0644]
src/system/FSys_CommunicationDispatcherClient.h [new file with mode: 0644]
src/system/FSys_DeviceId.cpp [deleted file]
src/system/FSys_DeviceId.h [deleted file]
src/system/FSys_DeviceManagerImpl.cpp
src/system/FSys_DeviceManagerImpl.h
src/system/FSys_ICommunicationDispatcherListener.h [moved from src/system/FSys_SettingIcu.h with 51% similarity]
src/system/FSys_PowerManagerImpl.cpp
src/system/FSys_RuntimeInfoImpl.cpp
src/system/FSys_SettingClient.cpp [new file with mode: 0644]
src/system/FSys_SettingClient.h [moved from src/system/FSys_SettingManager.h with 52% similarity]
src/system/FSys_SettingIcu.cpp [deleted file]
src/system/FSys_SettingInfoImpl.cpp
src/system/FSys_SettingManager.cpp [deleted file]
src/system/FSys_SystemInfoImpl.cpp
src/system/FSys_Types.h
src/system/FSys_VibratorImpl.cpp
src/system/inc/FSys_AlarmImpl.h
src/system/inc/FSys_PowerManagerImpl.h
src/system/inc/FSys_RuntimeInfoImpl.h
src/system/inc/FSys_SettingInfoImpl.h
src/system/inc/FSys_SystemInfoImpl.h
src/system/inc/FSys_VibratorImpl.h

index c6a3b26..7221f94 100755 (executable)
@@ -34,17 +34,24 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/common/etc/ld.so.conf.d/osp.conf DESTINATI
 
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output/target/generic/root/usr/share/locale DESTINATION share)
 INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp 
-               FILES_MATCHING PATTERN "*.so*" 
+               FILES_MATCHING PATTERN "libosp-appfw.so*"
+               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                      
+                    GROUP_EXECUTE GROUP_READ
+                    WORLD_EXECUTE WORLD_READ)
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp-server 
+               FILES_MATCHING PATTERN "libosp-appfw-server.so*" 
                PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                      
                     GROUP_EXECUTE GROUP_READ
                     WORLD_EXECUTE WORLD_READ)
 INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug 
-               FILES_MATCHING PATTERN "*"
+               FILES_MATCHING PATTERN "*" PATTERN "libosp-appfw-server.so*" EXCLUDE
                PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                                          
                                        GROUP_EXECUTE GROUP_READ
                                        WORLD_EXECUTE WORLD_READ)
                                        
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/opt/usr/share/.osp-compat/share DESTINATION ../opt/usr/share/.osp-compat)
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/usr/share/osp DESTINATION ../usr/share FILES_MATCHING PATTERN ".privilege-description.db")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/usr/share/osp DESTINATION ../usr/share FILES_MATCHING PATTERN ".external-privilege.ini")
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/opt/usr/etc DESTINATION ../opt/usr)
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/usr/etc DESTINATION ../usr)
 IF("${ARCH}" MATCHES "arm")
@@ -61,3 +68,4 @@ INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/locales/inc/ DESTINATION include/osp/l
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/security/inc/ DESTINATION include/osp/security FILES_MATCHING PATTERN "*.h")
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/system/inc/ DESTINATION include/osp/system FILES_MATCHING PATTERN "*.h")
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/text/inc/ DESTINATION include/osp/text FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/server/inc/ DESTINATION include/osp/server/ FILES_MATCHING PATTERN "*.h")
index 2012245..35bee1e 100644 (file)
@@ -129,14 +129,14 @@ public:
        /**
         * @page        CompGetAppNamePage Compatibility for GetAppName()
         * @section     CompGetAppNamePageIssue Issues
-        * Implementing this method in OSP compatible applications has the following issues:   @n
+        * Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
         *
         * -# GetAppName() returns the localized name of the application while the meaning of the application name is ambiguous.
         *  There are different use cases for locale-dependent name and localized name and the platform does not provide
         *  a method for obtaining language-neutral name.
         *
         * @section     CompGetAppNamePageResolution Resolutions
-        * This issue has been resolved in Tizen.  @n 
+        * The issue mentioned above is resolved in %Tizen API version 2.1 as follows: @n
         *
         * -# GetAppDisplayName() is introduced to acquire localized name and GetAppName() returns locale-independent application name.
         */
@@ -199,6 +199,15 @@ public:
        Tizen::Base::String GetAppResourcePath(void) const;
 
        /**
+       * Gets the path of the application's shared directory to export data to other applications.
+       *
+       * @since        2.1
+       *
+       * @return       The application's shared directory path
+       */
+       Tizen::Base::String GetAppSharedPath(void) const;
+
+       /**
         * Terminates the application while it is running. @n
         * The OnAppTerminating() method is called after the %Terminate() method is executed successfully.
         *
old mode 100644 (file)
new mode 100755 (executable)
index a33ef3e..1de000d
@@ -107,7 +107,7 @@ _OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_DIAL;
 * @deprecated This variable is provided only for backward compatibility and will be deleted in the near future.
 *                              Instead of this variable, use the literal, L"tizen.phone" with operation L"http://tizen.org/appcontrol/operation/call".
 * @since       2.0
-* @privilege    %http://tizen.org/privilege/systeminfo
+* @privilege    http://tizen.org/privilege/systeminfo
 *
 * @remarks Privilege is required to use this application control.
 * @endif
@@ -212,7 +212,7 @@ _OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_AUDIO;
 * @deprecated This variable is provided only for backward compatibility and will be deleted in the near future.
 *                              Instead of this variable, use the literal, L"tizen.internet".
 * @since       2.0
-* @privilege    %http://tizen.org/privilege/web.service
+* @privilege    http://tizen.org/privilege/web.service
 * @endif
 */
 _OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_BROWSER;
@@ -312,7 +312,7 @@ _OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_PROVIDER_CALENDAR;
 * @deprecated  This variable is provided only for backward compatibility and will be deleted in the near future.
 *                              Instead of this variable, use the literal, L"tizen.phone".
 * @since                       2.0
-* @privilege    %http://tizen.org/privilege/systeminfo
+* @privilege    http://tizen.org/privilege/systeminfo
 *
 * @remarks Privilege is required to use this application control.
 * @endif
@@ -429,7 +429,7 @@ _OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_PROVIDER_AUDIO;
 * @deprecated  This variable is provided only for backward compatibility and will be deleted in the near future.
 *                              Instead of this variable, use the literal, L"tizen.internet".
 * @since                       2.0
-* @privilege   %http://tizen.org/privilege/web.service
+* @privilege   http://tizen.org/privilege/web.service
 *
 * @remarks Privilege is required to use this application control.
 * @endif
@@ -480,131 +480,6 @@ _OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_PROVIDER_BLUETOOTH;
 */
 _OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_PROVIDER_SETTINGS;
 
-//
-// The AllShare application control provider ID. @n
-//
-// @since              2.0
-// @visibility internal
-// @privlevel  user
-// @privilege    ALLSHARE
-//
-// @remarks Privilege is required to use this application control. @n
-//     'path' is the main key of the all keys. Other keys' value are the extra information for the main key's value. @n
-//     'path' and 'type' values must be filled mandatorily and the others are optional. @n
-//     More than one content can be added if the 'path' key and value item is added in the input list.
-//
-// @li Input dataList : @n
-// <table border=1 cellpadding="1" cellspacing="1">
-// <tr>
-//   <th>Key</th>
-//   <th>value</th>
-//   <th>description</th>
-// </tr>
-// <tr>
-//   <td>path</td>
-//   <td>Path, such as /Media/Images/sampleImage.jpg or http://localhost:8080/sampleVideo.mp4 or http://mycompany.com/sampleImage.jpg"</td>
-//   <td>This is the main key. @n Path to the media file to be shared.</td>
-// </tr>
-// <tr>
-//   <td>type</td>
-//   <td>image|audio|video</td>
-//     <td>Type of the media file.</td>
-// </tr>
-// <tr>
-//   <td>title</td>
-//   <td>Title, such as MyTitle</td>
-//   <td>Title of the media file.</td>
-// </tr>
-// <tr>
-//   <td>duration</td>
-//   <td>Duration in milliseconds, such as 60000 (60secs)</td>
-//     <td>Duration of the media file.</td>
-// </tr>
-// <tr>
-//   <td>bitrate</td>
-//   <td>Bit rate in kilo-bits per second, such as 192</td>
-//     <td>Bit rate of the media file.</td>
-// </tr>
-// <tr>
-//   <td>width</td>
-//   <td>Width in pixel, such as 640</td>
-//     <td>Width of the media file</td>
-// </tr>
-// <tr>
-//   <td>height</td>
-//   <td>Height in pixel, such as 480</td>
-//     <td>Height of the media file</td>
-// </tr>
-//<tr>
-//     <td>size</td>
-//     <td>Size in bytes, such as 512000 (500KB)</td>
-//     <td>Size of the media file.</td>
-//</td>
-//<tr>
-//     <td>mimeType</td>
-//     <td>Mime type, such as audio/mp3</td>
-//     <td>Mime type of the media file.</td>
-//</tr>
-//<tr>
-//     <td>artist</td>
-//     <td>Artist, such as TizenSinger</td>
-//     <td>Artist of media file.</td>
-//</tr>
-//<tr>
-//     <td>albumTitle</td>
-//     <td>Album title, such as TizenAlbum</td>
-//     <td>Album title of media file.</td>
-//</tr>
-// </table>
-//
-// @n
-// @li Example code for AllShare: @n
-// @code
-//     void
-//     MyAppClass::AllShareAppControlSample(void)
-//     {
-//         ArrayList* pDataList = new ArrayList();
-//
-//         pDataList->Construct();
-//         pDataList->Add(*new String(L"path:/mycompany.com/sampleImage.jpg"));
-//         pDataList->Add(*new String(L"type:image"));
-//         pDataList->Add(*new String(L"title:MyImage"));
-//         pDataList->Add(*new String(L"width:640"));
-//         pDataList->Add(*new String(L"height:480"));
-//         pDataList->Add(*new String(L"size:51200"));
-//         pDataList->Add(*new String(L"mimeType:image/jpg"));
-//         pDataList->Add(*new String(L"path:http://mycompany.com/sampleVideo.mp4"));
-//         pDataList->Add(*new String(L"type:video"));
-//         pDataList->Add(*new String(L"title:MyVideo"));
-//         pDataList->Add(*new String(L"duration:600000"));
-//         pDataList->Add(*new String(L"width:320"));
-//         pDataList->Add(*new String(L"height:240"));
-//         pDataList->Add(*new String(L"size:2097152"));
-//         pDataList->Add(*new String(L"mimeType:video/mp4"));
-//         pDataList->Add(*new String(L"path:http://mycompany.com/sampleAudio.mp3"));
-//         pDataList->Add(*new String(L"type:audio"));
-//         pDataList->Add(*new String(L"title:MyAudio"));
-//         pDataList->Add(*new String(L"duration:200000"));
-//         pDataList->Add(*new String(L"size:3565158"));
-//         pDataList->Add(*new String(L"mimeType:audio/mp3"));
-//         pDataList->Add(*new String(L"artist:TizenSinger"));
-//         pDataList->Add(*new String(L"albumTitle:TizenAlbum"));
-//
-//         AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ALLSHARE, APPCONTROL_OPERATION_SHARE);
-//         if (pAc)
-//         {
-//             pAc->Start(pDataList, null);
-//             delete pAc;
-//         }
-//
-//         pDataList->RemoveAll(true);
-//         delete pDataList;
-//     }
-//
-// @endcode
-//
-_OSP_EXPORT_ extern const Tizen::Base::String APPCONTROL_PROVIDER_ALLSHARE;
-
 /**
 * @if OSPDEPREC
 * Operation Add. @n
@@ -1214,7 +1089,7 @@ public:
         *                              IAppControlResponseListener due to lack of argument capability. @n
         *                              Instead of using this method, use Start().
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return              An error code
         * @param[in]   pDataList       The data list to deliver to the resolved application control @n
@@ -1229,6 +1104,7 @@ public:
         *                                       - The target application has already started.
         * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @exception E_ILLEGAL_ACCESS                          The application is not signed with the same certificate of target application. @b Since: @b 2.1
         * @remarks             If the IAppControlEventListener instance (@c pListener) needs to get the
         *               callback result for an application control, it must be valid till
         *               IAppControlEventListener::OnAppControlCompleted() is invoked.
@@ -1246,7 +1122,7 @@ public:
         * application is displayed.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return              An error code
         * @param[in]   pUriData        A pointer to the URI data
@@ -1262,6 +1138,7 @@ public:
         *                                      - The application has already started an %AppControl.
         * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @exception E_ILLEGAL_ACCESS                          The application is not signed with the same certificate of target application. @b Since: @b 2.1
         * @remarks             If the calling application needs to get some result for application control,
         *                              it must be valid till IAppControlResponseListener::OnAppControlCompleteResponseReceived() is invoked.
         *                              For example, a form object listener must not be deleted before the
@@ -1278,7 +1155,7 @@ public:
         * When the found application control is started, the URI pattern, MIME type, and extra data is delivered using IAppControlProviderEventListener.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return  An error code
         * @param[in]   operationId     The operation ID
@@ -1294,6 +1171,7 @@ public:
         * @exception   E_OBJ_NOT_FOUND     The application control is not found.
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @exception E_ILLEGAL_ACCESS                          The application is not signed with the same certificate of target application. @b Since: @b 2.1  
         * @see IAppControlResponseListener
         */
        static result FindAndStart(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriPattern, const Tizen::Base::String* pDataType, const Tizen::Base::String* pCategory, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
old mode 100644 (file)
new mode 100755 (executable)
index f5b1509..fd1efca
@@ -96,7 +96,7 @@ public:
         * @remarks     The specific error code can be accessed using the GetLastResult() method.
         * @remarks     %Tizen platform defines platform-defined alias for application ID and this aliased application ID
         *                      can be used to find the AppControl. For more information, see
-        *                      <a href="../org.tizen.native.appprogramming/html/guide/app/app_controls.htm">here</a>.
+        *                      <a href="../org.tizen.native.appprogramming/html/guide/app/app_control.htm">here</a>.
         *
         * The following example demonstrates how to use the %FindAppControlN() method to find the application control.
         *
@@ -147,7 +147,8 @@ public:
         * @deprecated  This method is deprecated because IAppControlListener is deprecated and replaced by IAppControlResponselistener.
         *                              Instead of using this method, use AppControl::FindAndStart().
         * @since               2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return      An error code
         * @param[in]   uriData                 The URI that has a maximum size of @c 1024 bytes
@@ -187,7 +188,8 @@ public:
         * @deprecated  This method is deprecated because IAppControlListener is deprecated and replaced by IAppControlResponselistener.
         *                              Instead of using this method, use AppControl::FindAndStart().
         * @since               2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return      An error code
         * @param[in]   pOperationId    The operation ID
@@ -285,7 +287,8 @@ public:
         * @deprecated  This method is deprecated because sending argument with %LaunchApplication() is not recommended. @n
         *                              Instead of using this method, use %LaunchApplication() without launch arguments or AppControl::Start().
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return      An error code
         * @param[in]   appId                           The application's ID to execute
@@ -298,6 +301,7 @@ public:
         * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
         * @exception   E_MAX_EXCEEDED          The size of @c appId or @c pArguments has exceeded the maximum limit.
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+        * @exception E_ILLEGAL_ACCESS                          The application is not signed with the same certificate of target application. @b Since: @b 2.1
         * @endif
         */
        result LaunchApplication(const AppId& appId, const Tizen::Base::Collection::IList* pArguments, LaunchOption option = LAUNCH_OPTION_DEFAULT);
@@ -306,7 +310,8 @@ public:
         * Launches the default application with given @c appId.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return      An error code
         * @param[in]   appId                           The application's ID to execute
@@ -315,16 +320,16 @@ public:
         * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
         * @exception   E_APP_NOT_INSTALLED     The target application is not installed.
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+        * @exception E_ILLEGAL_ACCESS                          The application is not signed with the same certificate of target application. @b Since: @b 2.1
         */
        result LaunchApplication(const AppId& appId, LaunchOption option = LAUNCH_OPTION_DEFAULT);
 
        /**
-        * @if VISPARTNER
         * Terminates an application.
         *
         * @since       2.0
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/application.kill
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/application.kill
         *
         * @return      An error code
         * @param[in]   appId                           The application's ID to execute
@@ -332,7 +337,6 @@ public:
         * @exception   E_SYSTEM                        A system error has occurred.
         * @exception   E_OBJ_NOT_FOUND         The application is not installed or not running.
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
-        * @endif
         */
        result TerminateApplication(const AppId& appId);
 
@@ -367,7 +371,8 @@ public:
         * The launch arguments are given as input parameters to %IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return              An error code
         * @param[in]   condition         The launch condition for the application @n
@@ -378,6 +383,8 @@ public:
                                      <td>The specified condition is the local due time.</td></tr>
                                      <tr><td>L"DueTime='mm/dd/yyyy hh:mm:ss' LaunchPeriod='mm'"</td>
                                      <td>The specific condition is the time period after due time.</td></tr>
+                                     <tr><td>L"WeeklyTime='EEE HH:mm:ss'"</td>
+                                     <td>The specified condition is a day of week with specific time to launch an application for every week. For multiple description, "," delimiter can be used like following example.<br>i"Mon 09:00:00, Tue 09:00:00, Wed 09:00:00, Thu 09:00:00, Fir 09:00:00"<br> The format of a day of week is support following string only.<br>Mon: Monday<br>Tue: Tuesday<br>Wed: Wednesday<br>Thu: Thursday<br>Fri: Friday<br>Sat: Saturday<br>Sun: Sunday</td></tr>
                                      <tr><td>L"Serial='command'"</td><td>The specified condition is a serial
                                      communication input command.</td></tr>
                                      <tr><td>L"NFC='command'"</td><td>The specified condition is a Near Field Communication (NFC) tag that has the NFC Data Exchange Format (NDEF) data.
@@ -432,7 +439,8 @@ public:
         * Unregisters the previously registered launch condition.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return              An error code
         * @exception   E_SUCCESS                       The method is successful.
@@ -448,7 +456,8 @@ public:
         * Unregisters the specified launch condition.
         *
         * @since               2.0
-        * @privilege   %http://tizen.org/privilege/application.launch
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/application.launch
         *
         * @return              An error code
         * @param[in]   condition                       The launch condition for the application
@@ -479,14 +488,13 @@ public:
        bool IsAppLaunchRegistered(void) const;
 
        /**
-        * @if VISPARTNER
         * Registers the specified application with a specific condition and launches it if the condition is met. @n
         * If the requested application is already running, the application is notified through IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
         * The launch arguments are given as input parameters to %IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
         *
         * @since               2.0
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appmanager.launch
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appmanager.launch
         *
         * @return     An error code
         * @param[in]  appId          The ID of the application registered for launch
@@ -530,17 +538,15 @@ public:
         * @see        IAppLaunchConditionEventListener::OnAppLaunchConditionMetN()
         * @see        Tizen::Base::DateTime::ToString()
         * @see        Tizen::Io::SerialPort
-        * @endif
         */
        result RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pArguments, LaunchOption option);
 
        /**
-        * @if VISPARTNER
         * Unregisters the launch condition.
         *
         * @since               2.0
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appmanager.launch
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appmanager.launch
         *
         * @return     An error code
         * @param[in]  appId          The application ID
@@ -555,17 +561,15 @@ public:
         *
         * @see         RegisterAppLaunch()
         * @see         IsAppLaunchRegistered()
-        * @endif
         */
        result UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String* pCondition);
 
        /**
-        * @if VISPARTNER
         * Checks whether a previously registered launch condition is present for the specified application.
         *
         * @since               2.0
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appmanager.launch
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appmanager.launch
         *
         * @return     @c true if a condition is already registered to the specified application with the specified condition, @n
         *             else @c false
@@ -581,7 +585,6 @@ public:
         * @remarks     The specific error code can be accessed using the GetLastResult() method.
         * @see         RegisterAppLaunch()
         * @see         UnregisterAppLaunch()
-        * @endif
         */
        bool IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String* pCondition = null) const;
 
@@ -642,14 +645,13 @@ public:
        void SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener);
 
        /**
-        * @if VISPARTNER
         * Adds an IActiveAppEventListener to the %AppManager. @n
         * The listener gets notified when the active application is changed.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appusage
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appusage
         *
         * @return              An error code
         * @param[in]   listener                                The event listener
@@ -662,18 +664,16 @@ public:
         * @see                 GetActiveApp()
         * @see                 RemoveActiveAppEventListener()
         * @see                 IActiveAppEventListener
-        * @endif
         */
        result AddActiveAppEventListener(IActiveAppEventListener& listener);
 
        /**
-        * @if VISPARTNER
         * Removes an IActiveAppEventListener from the %AppManager.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appusage
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appusage
         *
         * @return              An error code
         * @param[in]   listener                                The event listener
@@ -684,18 +684,16 @@ public:
         * @see                 GetActiveApp()
         * @see                 AddActiveAppEventListener()
         * @see                 IActiveAppEventListener
-        * @endif
         */
        result RemoveActiveAppEventListener(IActiveAppEventListener& listener);
 
        /**
-        * @if VISPARTNER
         * Gets the current active application AppId.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appusage
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appusage
         *
         * @return              An error code
         * @param[out]  appId                                   The AppId of the active application
@@ -705,7 +703,6 @@ public:
         * @remarks             Active application is the top most window with focus.
         * @see                 AddActiveAppEventListener()
         * @see                 RemoveActiveAppEventListener()
-        * @endif
         */
        result GetActiveApp(AppId& appId);
 
index 9936a78..9b592dc 100644 (file)
@@ -147,7 +147,7 @@ public:
         * @param[in]   key             A key corresponding to the value
         * @param[in]   value   A string value
         * @exception   E_SUCCESS                               The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_ALREADY_EXIST             The key has already been used in the application preferences.
         * @remarks     In order to save the value in the persistent storage, the AppRegistry::Save() method must be called.
         */
@@ -162,7 +162,7 @@ public:
         * @param[in]   key             A key corresponding to the value
         * @param[in]   value   An integer value
         * @exception   E_SUCCESS                               The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_ALREADY_EXIST             The key has already been used in the application preferences.
         * @remarks     In order to save the value in the persistent storage, the AppRegistry::Save() method must be called.
         */
@@ -177,7 +177,7 @@ public:
         * @param[in]   key             A key corresponding to the value
         * @param[in]   value   A floating point value
         * @exception   E_SUCCESS                               The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_ALREADY_EXIST             The key has already been used in the application preferences.
         * @remarks     In order to save the value in the persistent storage, the AppRegistry::Save() method must be called.
         */
@@ -192,7 +192,7 @@ public:
         * @param[in]   key             A key corresponding to the value
         * @param[in]   value   A string value
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_NOT_FOUND         The specified @c key is not used in the application preferences.
         * @remarks     In order to save the value in the persistent storage, the AppRegistry::Save() method must be called.
         */
@@ -207,7 +207,7 @@ public:
         * @param[in]   key     A key corresponding to the value
         * @param[in]   value   An integer value
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_NOT_FOUND         The specified @c key is not used in the application preferences.
         * @remarks     In order to save the value in the persistent storage, the AppRegistry::Save() method must be called.
         */
@@ -222,7 +222,7 @@ public:
         * @param[in]   key     A key corresponding to the value
         * @param[in]   value   A floating point value
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_NOT_FOUND         The specified @c key is not used in the application preferences.
         * @remarks     In order to save the value in the persistent storage, the AppRegistry::Save() method must be called.
         */
@@ -260,7 +260,7 @@ public:
         * @param[in]   key             The key of the value to retrieve
         * @param[out]  value   A string value to retrieve
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_NOT_FOUND         The specified @c key is not used in the application preferences.
         */
        result Get(const Tizen::Base::String& key, Tizen::Base::String& value) const;
@@ -274,7 +274,7 @@ public:
         * @param[in]   key             The key of the value to retrieve
         * @param[out]  value   An integer value to retrieve
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_NOT_FOUND         The specified @c key is not used in the application preferences.
         */
        result Get(const Tizen::Base::String& key, int& value) const;
@@ -288,7 +288,7 @@ public:
         * @param[in]   key             The key of the value to retrieve
         * @param[out]  value   A floating point value to retrieve
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and '\n'.
+        * @exception   E_INVALID_ARG                   The specified @c key is empty or is string with '\0' and @htmlonly '\n' @endhtmlonly.
         * @exception   E_KEY_NOT_FOUND         The specified @c key is not used in the application preferences.
         */
        result Get(const Tizen::Base::String& key, double& value) const;
old mode 100755 (executable)
new mode 100644 (file)
index cbd70b7..a9c5065
 
 #include <FBaseObject.h>
 #include <FBaseString.h>
-#include <FBaseColHashMap.h>
 #include <FAppTypes.h>
 #include <FGrpBitmapCommon.h>
 
-namespace Tizen { namespace Locales { class Locale; } }
 namespace Tizen { namespace Graphics { class Bitmap; } }
 
 namespace Tizen { namespace App
@@ -117,14 +115,18 @@ public:
        * To load the bitmap image from a file, give the name of the file as the input parameter and not the file path (For example: "img.png").
        * Then, the system will first look for the image file in the folder specific to the current device resolution, such as
        * '720x1280' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
-    * such as 'screen-density-xhigh'. After searching the density folder, all the other density folders are searched in the order high to low.
+       * such as 'screen-density-xhigh'. After searching the density folder, all the other density folders are searched in the order high to low.
+       * If the requested image file is found in a density-specific folder that is different from the current screen density, the bitmap returned from this method is pre-scaled.
+       * But in case of requested image file is nine-patch image saved as ".#.png" (For example : "img.#.png"),
+       * then a bitmap instance which is value of returned pointer is not pre-scaled.
        * Currently supported image formats are: JPEG, GIF, PNG, BMP, TIFF, and WBMP.
+       * For more information on the features, see <a href="../org.tizen.native.appprogramming/html/multiple_screen/autoscale_resource_fallback.htm">Resource Fallback and Prescaling.</a>
        *
        * @since        2.0
        *
-       * @return               A pointer to the Bitmap instance generated from the specified file
+       * @return       A pointer to the Bitmap instance generated from the specified file
        * @param[in]    imagePath                               The relative path starting from the directory @b "res/screen-density-XXX/" or @b "res/AxB", @n
-       *                                                                               where A and B represent the screen width and height of the supported device models, respectively.
+       *                                                                       where A and B represent the screen width and height of the supported device models, respectively.
        * @param[in]    pixelFormat                             The pixel format of the resulting bitmap
        * @exception    E_SUCCESS                               The method is successful.
        * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
@@ -143,16 +145,17 @@ public:
        * Then, the system will first look for the image file in the folder specific to the current device resolution, such as
        * '720x1280' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
        * such as 'screen-density-xhigh'. After searching the density folder, all the other density folders are searched in the order high to low.
+       * If the requested image file is found in a density-specific folder that is different from the current screen density, the bitmap returned from this method is pre-scaled.
+       * But in case of requested image file is nine-patch image saved as ".#.png" (For example : "img.#.png"),
+       * then a bitmap instance which is value of returned pointer is not pre-scaled.
        * Currently supported image formats are: JPEG, GIF, PNG, BMP, TIFF, and WBMP.
-       *
-       * In this method, the system decides the proper pixel format.
-       * Currently supported image formats are: JPEG, GIF, PNG, BMP, TIFF, and WBMP.
+       * For more information on the features, see <a href="../org.tizen.native.appprogramming/html/multiple_screen/autoscale_resource_fallback.htm">Resource Fallback and Prescaling.</a>
        *
        * @since        2.0
        *
-       * @return               A pointer to the Tizen::Graphics::Bitmap instance generated from the specified file
+       * @return       A pointer to the Tizen::Graphics::Bitmap instance generated from the specified file
        * @param[in]    imagePath                               The relative path starting from the density directory @b "res/screen-density-XXX/" or @b "res/AxB", @n
-       *                                                                               where A and B represent the width and height of the screen of the supported device models, respectively
+       *                                                                       where A and B represent the width and height of the screen of the supported device models, respectively
        * @exception    E_SUCCESS                               The method is successful.
        * @exception    E_INVALID_ARG                   The specified input parameter is invalid.
        * @exception    E_UNSUPPORTED_FORMAT    The image file format is not supported.
@@ -174,13 +177,26 @@ public:
        static AppResource* GetInstance(void);
 
        /**
-       * @if VISPARTNER
+        * Gets the resource instance of the specified resource path.
+        * @since       2.0
+        * @return              A pointer to the %AppResource instance, @n
+        *                              else @c null if it fails
+        * @param[in]   resourcePath            The relative path starting from the resource directory path of the current application
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_FILE_NOT_FOUND        The specified resource path does not exist.
+        * @exception   E_INVALID_ARG           The length of the specified path is @c 0 or exceeds system limitations.
+        * @exception   E_SYSTEM                        Initializing string and bitmap resource is failed due to system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+    static AppResource* LoadAppResource(const Tizen::Base::String& resourcePath);
+
+       /**
        * Gets the application resource instance of the specified @c appId.
        *
        * @since        2.0
        *
-       * @visibility  partner
-       * @privilege   %http://tizen.org/privilege/appsetting
+       * @privlevel    partner
+       * @privilege   http://tizen.org/privilege/appsetting
        *
        * @return       A pointer to the %AppResource instance, @n
        *               else @c null if it fails
@@ -192,18 +208,16 @@ public:
        * @exception    E_SYSTEM        Initializing string and bitmap resource has failed due to a system error.
        * @exception    E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
        * @remarks The specific error code can be accessed using the GetLastResult() method.
-       * @endif
        */
        static AppResource* GetInstanceByAppId(const AppId& appId);
 
        /**
-       * @if VISPARTNER
        * Releases the application resource instance of the specified @c appId.
        *
        * @since        2.0
        *
-       * @visibility  partner
-       * @privilege   %http://tizen.org/privilege/appsetting
+       * @privlevel    partner
+       * @privilege   http://tizen.org/privilege/appsetting
        *
        * @return       An error code
        * @param[in]    appId                The AppId of the installed application
@@ -212,7 +226,6 @@ public:
        * @exception    E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
        * @remarks     Individual instances are managed by the platform. @n
        *              It is recommended to release instances to reduce memory usage.
-       * @endif
        */
        static result ReleaseInstanceByAppId(const AppId& appId);
 
@@ -245,26 +258,9 @@ private:
         */
        virtual ~AppResource(void);
 
-       /**
-        * Initializes this instance.
-        *
-        * @since       2.0
-        *
-        * @return      An error code
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        * @exception   E_SYSTEM        A system error has occurred.
-        */
-       result Construct(void);
-       result Construct(const AppId& appId);
-       static void Reinitialize(void);
-       void Reinitialize(const AppId& appId);
-
 private:
-       class _AppResourceImpl* __pAppResourceImpl;
-
        friend class _AppResourceImpl;
-       static Tizen::Base::Collection::HashMap* pContainer;
+       class _AppResourceImpl* __pAppResourceImpl;
 }; // AppResource
 
 } } // Tizen::App
old mode 100755 (executable)
new mode 100644 (file)
index df08c32..7665317
@@ -140,13 +140,12 @@ public:
        static AppSetting* GetInstance(const Tizen::Base::String& settingVersion);
 
        /**
-        * @if VISPARTNER
         * Gets the application setting instance of the specified AppId.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appsetting
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appsetting
         *
         * @return              A pointer to the %AppSetting instance, @n
         *                              else @c null if it fails
@@ -160,18 +159,16 @@ public:
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @remarks             The specific error code can be accessed using the GetLastResult() method.
         * @see                 ReleaseInstanceByAppId()
-        * @endif
         */
        static AppSetting* GetInstanceByAppId(const AppId& appId);
 
        /**
-        * @if VISPARTNER
         * Releases the specified application setting instance.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/appsetting
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/appsetting
         *
         * @return              An error code
         * @param[in]   appId                           The AppId of the application that has a valid application setting
@@ -181,7 +178,6 @@ public:
         * @remarks             Individual instances are managed by the platform. @n
         *                              It is recommended to release instances to reduce memory usage.
         * @see                 GetInstanceByAppId()
-        * @endif
         */
        static result ReleaseInstanceByAppId(const AppId& appId);
 
index fbd6740..a232f23 100644 (file)
@@ -122,6 +122,7 @@ public:
        * @exception    E_IO                            Either of the following conditions has occurred:
        *                                                                       - An unexpected device failure has occurred as the media ejected suddenly.
        *                                                                       - %File corruption is detected.
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
        * @see                  Tizen::App::DataControlProviderManager::SendSqlDataControlInsertResult()
        * @see                  Tizen::App::DataControlProviderManager::SendSqlDataControlUpdateDeleteResult()
@@ -195,8 +196,9 @@ public:
        *                                                                       - The specified @c pResultValueList must not be @c null if the request is
        *                                                                         GetValue() query.
        * @exception    E_OBJ_NOT_FOUND         The data control request specified with the @c reqId does not exist.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        * @see                  Tizen::App::DataControlProviderManager::SendDataControlError()
        * @see                  Tizen::App::IMapDataControlProviderEventListener
        */
@@ -215,8 +217,9 @@ public:
        * @param[in]    errorMsg                        The provider-defined error message
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_OBJ_NOT_FOUND         The data control request specified with the @c reqId did not exist.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        * @see                  Tizen::App::DataControlProviderManager::SendSqlDataControlSelectResult()
        * @see                  Tizen::App::DataControlProviderManager::SendSqlDataControlInsertResult()
        * @see                  Tizen::App::DataControlProviderManager::SendSqlDataControlUpdateDeleteResult()
index 3314787..3a1d20b 100644 (file)
@@ -33,47 +33,36 @@ namespace Tizen { namespace App
 {
 
 /**
- * @if VISPARTNER
  * @interface  IActiveAppEventListener
  * @brief              This interface is the listener interface for receiving the AppId of active application.
  *
  * @since      2.0
  *
- * @visibility partner
  *
  * The %IActiveAppEventListener interface is the listener interface for receiving the active application change events.
  * The class that processes an active application change event implements this interface and registers using
  * the AppManager::AddActiveAppEventListener() method.
  *
- * @endif
  */
 class _OSP_EXPORT_ IActiveAppEventListener
        : virtual public Tizen::Base::Runtime::IEventListener
 {
 public:
        /**
-        * @if VISPARTNER
         * This polymorphic destructor should be overridden if required. This way,
         * the destructors of the derived classes are called when the destructor of this interface is called.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        *
-        * @endif
         */
        virtual ~IActiveAppEventListener(void) {}
 
        /**
-        * @if VISPARTNER
         * Called when the active application is changed.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        *
         * @param[in]   appId           The AppId of the active application
-        * @endif
         */
        virtual void OnActiveAppChanged(const AppId& appId) = 0;
 
old mode 100644 (file)
new mode 100755 (executable)
index 02aa664..2362341
@@ -90,9 +90,12 @@ public:
        * @exception    E_INVALID_ARG           Either of the following conditions has occurred: @n
        *                                                                       - The specified @c pageNo parameter is less than @c 1.
        *                                                                       - The specified @c countPerPage parameter is less than @c 1.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result GetValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, RequestId& reqId, int pageNo = 1, int countPerPage = 20);
 
@@ -114,9 +117,12 @@ public:
        * @param[out]   reqId           The ID of the request
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_STATE         This instance has not been properly constructed as yet.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result AddValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value, RequestId& reqId);
 
@@ -140,9 +146,12 @@ public:
        * @param[out]   reqId           The ID of the request
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_STATE         This instance has not been properly constructed as yet.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result SetValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& oldValue, const Tizen::Base::String& newValue, RequestId& reqId);
 
@@ -164,9 +173,12 @@ public:
        * @param[out]   reqId           The ID of the request
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_STATE         This instance has not been properly constructed as yet.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result RemoveValue(const Tizen::Base::String& dataId, const Tizen::Base::String& key, const Tizen::Base::String& value, RequestId& reqId);
 
old mode 100755 (executable)
new mode 100644 (file)
index bd5b8db..f1435f8
@@ -67,28 +67,6 @@ static const int MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH = 1024;
  */
 static const int MAX_NOTIFICATION_BADGE_NUMBER = 999;
 
-/*
- * The maximum length of the title text.
- *
- * @since      2.0
- */
-static const int MAX_NOTIFICATION_TITLE_LENGTH = 1024;
-
-/*
- * @enum       OngoingActivityType
- *
- * Defines the ongoing activity notification type.
- *
- * @since      2.0
- */
-enum OngoingActivityType
-{
-       ONGOING_ACTIVITY_TYPE_TEXT = 1,                 /**< The text type */
-       ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE,    /**< The progress type in byte */
-       ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE       /**< The progress type in percentage */
-};
-
-
 /**
  * @if OSPDEPREC
  * @class              NotificationManager
@@ -176,7 +154,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              The current badge number
         * @exception   E_SUCCESS                       The method is successful.
@@ -197,7 +175,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   badgeNumber                     The badge number
@@ -219,7 +197,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   messageText                     The notification message
@@ -241,7 +219,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   messageText                     The notification message
@@ -267,7 +245,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   messageText                     The notification message
@@ -295,7 +273,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @exception   E_SUCCESS       The method is successful.
@@ -314,7 +292,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                               2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   messageText                     The notification message
@@ -338,7 +316,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                               2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   messageText                     The notification message
@@ -363,7 +341,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @exception   E_SUCCESS                       The method is successful.
@@ -382,7 +360,7 @@ public:
         *
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/notification
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              The current badge number
         * @param[in]   appId                           The application ID
@@ -398,7 +376,6 @@ public:
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Notifies the user using a badge number on behalf of the specified application.
         *
         * @brief               <i> [Deprecated] </i>
@@ -406,8 +383,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   appId                           The application ID
@@ -420,13 +397,11 @@ public:
         * @exception   E_SYSTEM                        A system error has occurred.
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
         * @endif
-        * @endif
         */
        result NotifyOnBehalf(const AppId& appId, int badgeNumber);
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Notifies the user using a message on behalf of the specified application.
         *
         * @brief               <i> [Deprecated] </i>
@@ -434,8 +409,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   appId                           The application ID
@@ -448,13 +423,11 @@ public:
         * @exception   E_SYSTEM                        A system error has occurred.
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
         * @endif
-        * @endif
         */
        result NotifyOnBehalf(const AppId& appId, const Tizen::Base::String& messageText);
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Notifies the user using a message and badge number on behalf of the specified application.
         *
         * @brief               <i> [Deprecated] </i>
@@ -462,8 +435,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   appId                           The application ID
@@ -479,13 +452,11 @@ public:
         * @exception   E_SYSTEM                        A system error has occurred.
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
         * @endif
-        * @endif
         */
        result NotifyOnBehalf(const AppId& appId, const Tizen::Base::String& messageText, int badgeNumber);
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Notifies the user using a message and badge number on behalf of the specified application. @n
         * If the user checks the message, the @c launchArguments is delivered to the application.
         *
@@ -494,8 +465,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since               2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return             An error code
         * @param[in]  appId                            The application ID
@@ -511,13 +482,11 @@ public:
         * @exception  E_SYSTEM                         A system error has occurred.
         * @exception E_PRIVILEGE_DENIED                The application does not have the privilege to call this method.
         * @endif
-        * @endif
         */
        result NotifyOnBehalf(const AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments);
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Notifies the user about the ongoing activity using a message on behalf of the specified application.
         *
         * @brief               <i> [Deprecated] </i>
@@ -525,8 +494,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                               2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   appId                           The application ID
@@ -539,13 +508,11 @@ public:
         * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the %Tizen platform policy.
         * @exception E_PRIVILEGE_DENIED                The application does not have the privilege to call this method.
         * @endif
-        * @endif
         */
        result NotifyOngoingActivityOnBehalf(const AppId& appId, const Tizen::Base::String& messageText);
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Notifies the user about the ongoing activity using a message on behalf of the specified application.
         *
         * @brief               <i> [Deprecated] </i>
@@ -553,8 +520,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                               2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   appId                           The application ID
@@ -570,13 +537,11 @@ public:
         * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the %Tizen platform policy.
         * @exception E_PRIVILEGE_DENIED                The application does not have the privilege to call this method.
         * @endif
-        * @endif
         */
        result NotifyOngoingActivityOnBehalf(const AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments);
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Removes the notification message for ongoing activity on behalf of the specified application.
         *
         * @brief               <i> [Deprecated] </i>
@@ -584,8 +549,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   appId                           The application ID
@@ -595,13 +560,11 @@ public:
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
         * @remarks             Although there is no outstanding notification for the calling application, this method returns @c E_SUCCESS.
         * @endif
-        * @endif
         */
        result RemoveOngoingActivityNotificationOnBehalf(const AppId& appId);
 
        /**
         * @if OSPDEPREC
-        * @if VISPARTNER
         * Removes the notification message on behalf of the specified application.
         *
         * @brief               <i> [Deprecated] </i>
@@ -609,8 +572,8 @@ public:
         * @deprecated  This class is deprecated. Instead of using this class, use the Tizen::Shell::NotificationManager class.
         * @since                       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/notificationmanager
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/notification
         *
         * @return              An error code
         * @param[in]   appId                           The application ID
@@ -620,7 +583,6 @@ public:
         * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
         * @remarks             Although there is no outstanding notification for the calling application, this method returns @c E_SUCCESS.
         * @endif
-        * @endif
         */
        result RemoveNotificationOnBehalf(const AppId& appId);
 
index 5fd46d6..110e153 100644 (file)
 //
 
 /**
- * @if VISPARTNER-OPERATOR
  * @file       FAppPkgIPackageInstallationResponseListener.h
  * @brief      This is the header file for the %IPackageInstallationResponseListener interface.
  *
  * This header file contains the declarations of the %IPackageInstallationResponseListener interface.
  *
- * @endif
  */
 #ifndef _FAPP_PKG_IPACKAGE_INSTALLATION_RESPONSE_LISTENER_H_
 #define _FAPP_PKG_IPACKAGE_INSTALLATION_RESPONSE_LISTENER_H_
@@ -35,59 +33,47 @@ namespace Tizen { namespace App { namespace Package
 {
 
 /**
- * @if VISPARTNER-OPERATOR
  * @interface  IPackageInstallationResponseListener
  * @brief              This interface defines a listener for the asynchronous package installation operation.
  *
  * @since      2.0
- * @visibility partner-operator
  *
  * The %IPackageInstallationResponseListener interface defines a listener for the asynchronous package installation operation.
  *
- * @endif
  */
 class _OSP_EXPORT_ IPackageInstallationResponseListener
        : virtual public Tizen::Base::Runtime::IEventListener
 {
 public:
        /**
-     * @if VISPARTNER-OPERATOR
      * This polymorphic destructor should be overridden if required.
      * This way, the destructors of the derived classes are called when the destructor of this interface is called.
      *
      * @since  2.0
-     * @visibility  partner-operator\r
-     *\r
-     * @endif
+     *
      */
        virtual ~IPackageInstallationResponseListener(void) {}
 
        /**
-     * @if VISPARTNER-OPERATOR
      * Called when a package installation is completed. @n
         * The value of @c installationResult is @c PACKAGE_INSTALLATION_RESULT_SUCCESS if the installation is successful.
      *
      * @since  2.0
-     * @visibility  partner-operator
      *
      * @param[in]      packageId                       The package ID
      * @param[in]      installationResult              The installation result
-     *\r
-     * @endif
+     *
      */
        virtual void OnPackageInstallationResponseReceived(const PackageId& packageId, PackageInstallationResult installationResult) = 0;
 
        /**
-     * @if VISPARTNER-OPERATOR
      * Called when a package installation is in progress.
      *
      * @since  2.0
-     * @visibility  partner-operator
      *
      * @param[in]      packageId                       The package ID
      * @param[in]      progress                The progress of an installation in percentage
-     *\r
-     * @endif
+     *
      */
        virtual void OnPackageInstallationInProgressResponseReceived(const PackageId& packageId, int progress) = 0;
 
index 2b25b9b..18b0a2b 100644 (file)
 //
 
 /**
- * @if VISPARTNER-OPERATOR
  * @file       FAppPkgIPackageUninstallationResponseListener.h
  * @brief      This is the header file for the %IPackageUninstallationResponseListener interface.
  *
  * This header file contains the declarations of the %IPackageUninstallationResponseListener interface.
  *
- * @endif
  */
 #ifndef _FAPP_PKG_IPACKAGE_UNINSTALLATION_RESPONSE_LISTENER_H_
 #define _FAPP_PKG_IPACKAGE_UNINSTALLATION_RESPONSE_LISTENER_H_
@@ -35,47 +33,38 @@ namespace Tizen { namespace App { namespace Package
 {
 
 /**
- * @if VISPARTNER-OPERATOR
  * @interface  IPackageUninstallationResponseListener
  * @brief              This interface defines a listener for the asynchronous package uninstallation operation.
  *
  * @since      2.0
- * @visibility partner-operator
  *
  * The %IPackageUninstallationResponseListener interface defines a listener for the asynchronous package uninstallation operation.
  *
- * @endif
  */
 class _OSP_EXPORT_ IPackageUninstallationResponseListener
        : virtual public Tizen::Base::Runtime::IEventListener
 {
 public:
        /**
-     * @if VISPARTNER-OPERATOR
      * This polymorphic destructor should be overridden if required.
      * This way, the destructors of the derived classes are called when the destructor of this interface is called.
      *
      * @since  2.0
-     * @visibility  partner-operator\r
-     *\r
-     * @endif
+     *
      */
        virtual ~IPackageUninstallationResponseListener(void) {}
 
-       /**\r
-     * @if VISPARTNER-OPERATOR\r
-     * Called when a package uninstallation is completed. @n\r
+       /**
+     * Called when a package uninstallation is completed. @n
         * The value of @c uninstallationResult is @c true if the uninstallation is successful, else @c false.
-     *\r
-     *@since   2.0\r
-     * @visibility  partner-operator\r
-     *\r
-     * @param[in]      packageId                     The package ID\r
-     * @param[in]      uninstallationResult          Set to @c true if the uninstallation is successful, @n\r
+     *
+     *@since   2.0
+     *
+     * @param[in]      packageId                     The package ID
+     * @param[in]      uninstallationResult          Set to @c true if the uninstallation is successful, @n
         *                                               else @c false
-     *\r
-     * @endif\r
-     */\r
+     *
+     */
        virtual void OnPackageUninstallationResponseReceived(const PackageId& packageId, bool uninstallationResult) = 0;
 
 
index 3a10c76..da87dac 100755 (executable)
 #include <FAppTypes.h>
 #include <FAppPkgPackageManager.h>
 
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+} }
+
 namespace Tizen { namespace App { namespace Package
 {
 
@@ -82,48 +87,64 @@ public:
        Tizen::Base::String GetAppDisplayName(void) const;
 
        /**
-        * @if VISPARTNER-MANUFACTURER
-        * Gets the menu icon path of an application.
-        *
-        * @since       2.0
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/packagesetting
-        *
-        * @return      The menu icon path of an application, @n
-        *          else an empty string is returned if there is no value
-        * @endif
-        */
+       * Gets the menu icon path of an application.
+       *
+       * @since         2.1
+       *
+       * @return        The menu icon path of an application, @n
+       *                else an empty string is returned if there is no value @n
+       */
        Tizen::Base::String GetAppMenuIconPath(void) const;
 
        /**
-        * @if VISPARTNER-MANUFACTURER
-        * Gets the setting icon path of an application.
-        *
-        * @since       2.0
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/packagesetting
-        *
-        * @return      The setting icon path of an application, @n
-        *          else an empty string is returned if there is no value
-        * @endif
-        */
+       * Gets the setting icon path of an application.
+       *
+       * @since         2.1
+       *
+       * @return        The setting icon path of an application, @n
+       *                                else an empty string is returned if there is no value @n
+       */
        Tizen::Base::String GetAppSettingIconPath(void) const;
 
        /**
-        * @if VISPARTNER-MANUFACTURER
-        * Gets the notification icon path of an application.
-        *
-        * @since       2.0
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/packagesetting
-        *
-        * @return      The notification icon path of an application, @n
-        *          else an empty string is returned if there is no value
-        * @endif
-        */
+       * Gets the notification icon path of an application.
+       *
+       * @since         2.1
+       *
+       * @return        The notification icon path of an application, @n
+       *                else an empty string is returned if there is no value @n
+       */
        Tizen::Base::String GetAppNotificationIconPath(void) const;
 
        /**
+       * Gets the menu icon of an application.
+       *
+       * @since         2.1
+       *
+       * @return        A pointer to menu icon of an application, @n
+       *                else @c null if it fails
+       * @exception    E_SUCCESS                     The method is successful.
+       * @exception    E_FILE_NOT_FOUND              The menu icon does not exist.
+       * @exception    E_UNSUPPORTED_FORMAT          The image file format is not supported.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       */
+       Tizen::Graphics::Bitmap* GetAppMenuIconN(void) const;
+
+       /**
+       * Gets the metadata list of an application.
+       *
+       * @since         2.1
+       *
+       * @return       A pointer to a map of key(Tizen::Base::String) and value(Tizen::Base::String) pairs of the metadata, @n
+       *               else @c null if it fails
+       * @exception    E_SUCCESS                     The method is successful.
+       * @exception    E_SYSTEM                      The method cannot proceed due to a severe system error.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       * @remarks      Application can use the metadata to set app-wide information.
+       */
+       Tizen::Base::Collection::IMap* GetAppMetadataListN(void) const;
+
+       /**
         * Gets the category list of an application.
         *
         * @since       2.0
@@ -156,7 +177,7 @@ public:
         *                      else @c false
         */
        bool IsMainApp(void) const;
-
+       
 private:
        /**
         * This is the default constructor for this class. This default constructor is intentionally
@@ -180,6 +201,7 @@ private:
        friend class _PackageAppInfoImpl;
        friend class _PackageInfoImpl;
        friend class _PackageManagerImpl;
+       friend class _PackageParser;
 
 }; // PackageAppInfo
 
old mode 100755 (executable)
new mode 100644 (file)
index 940d80f..d02076e
@@ -221,21 +221,32 @@ public:
         * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
         * @remarks             The specific error code can be accessed using the GetLastResult() method.
         */
-       Tizen::App::Package::PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
+       PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
 
        /**
-        * @if VISPARTNER-MANUFACTURER
         * Gets the type of a package.
         *
         * @since       2.0
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/packagesetting
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/packagesetting
         *
         * @return The package type
-        * @endif
         */
        PackageType GetType(void) const;
 
+       /**
+       * Gets the privilege information list of a package.
+       *
+       * @since         2.1
+       *
+       * @return        A pointer to the list of Tizen::Security::PrivilegeInfo instances, @n
+       *                else @c null if it fails
+       * @exception            E_SUCCESS             The method is successful.
+       * @exception            E_SYSTEM            The method cannot proceed due to a severe system error.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       */
+       Tizen::Base::Collection::IList* GetPrivilegeListN(void) const;
+
 private:
        /**
         * This is the default constructor for this class. This default constructor is intentionally
diff --git a/inc/FAppPkgPackageLicenseManager.h b/inc/FAppPkgPackageLicenseManager.h
new file mode 100644 (file)
index 0000000..11e137f
--- /dev/null
@@ -0,0 +1,149 @@
+//
+// 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       FAppPkgPackageLicenseManager.h
+ * @brief      This is the header file for the %PackageLicenseManager class.
+ *
+ * This header file contains the declarations of the %PackageLicenseManager class.
+ */
+
+#ifndef _FAPP_PKG_PACKAGE_LICENSE_MANAGER_H_
+#define _FAPP_PKG_PACKAGE_LICENSE_MANAGER_H_
+
+#include <FBase.h>
+#include <FAppTypes.h>
+
+namespace Tizen { namespace App { namespace Package
+{
+
+/**
+ * @class   PackageLicenseManager
+ * @brief   This class gets the information of package's license and manages its installation.
+ *
+ * @since 2.1
+ *
+ * @remarks  Do not use this class without obtaining prior permissions from the %Tizen platform team.
+ *
+ * The %PackageLicenseManager class gets the information of package's license and manages its installation.
+ */
+class _OSP_EXPORT_ PackageLicenseManager
+{
+public:
+
+       /**
+       * Generates a license request and URL.
+       *
+       * @since 2.1
+       * @privlevel    platform
+       * @privilege    http://tizen.org/privilege/packagelicensemanager
+       *
+       * @return               An error code
+       * @param[in]    licenseRequestInfo      The string buffer of license request information
+       * @param[out]   licenseRequest          The string buffer of Package DRM license request
+       * @param[out]   licenseUrl                      The URL for Package DRM license
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_ARG           A specified input parameter is invalid.
+       * @exception    E_INVALID_DATA          A specified XML field of input string is invalid. @n
+       *                                                                       For example, the requested ID is invalid.
+       * @exception    E_PARSING_FAILED        An error has occurred when parsing the input string.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks      Do not use this method without obtaining prior permissions from the %Tizen platform team.
+       */
+       static result GenerateDrmLicenseRequest(const Tizen::Base::String& licenseRequestInfo, Tizen::Base::String& licenseRequest, Tizen::Base::String& licenseUrl);
+
+       /**
+       * Saves Package DRM license(Right Object) to DRM repository. @n
+       * It stores the DRM license (Right Object) when it does not exist in the DRM repository.
+       * When the same @c packgeId of DRM license(Right Object) already exists in the DRM repository, it is overwritten.
+       *
+       * @since 2.1
+       * @privlevel    platform
+       * @privilege    http://tizen.org/privilege/packagelicensemanager
+       *
+       * @return               An error code
+       * @param[in]    rightObject                     The Package DRM license (right object)
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_ARG           The specified input parameter is invalid.
+       * @exception    E_DATABASE                      An error has occurred when handling the rights object repository.
+       * @exception    E_INVALID_BINDING       The input right object is not binded to the device.
+       * @exception    E_INVALID_SIGNATURE             The signature verification of the input string has failed.
+       * @exception    E_INVALID_CERTIFICATE   The certificate chain verification of the input string has failed.
+       * @exception    E_INVALID_DATA          A specified XML field of input string is invalid. @n
+       *                                                                       For example, the @c appId field is empty.
+       * @exception    E_PARSING_FAILED        An error has occurred when parsing the input string.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks      Do not use this method without obtaining prior permissions from the %Tizen platform team.
+       */
+       static result SaveDrmLicense(const Tizen::Base::String& rightObject);
+
+       /**
+       * Gets the remaining time of the package until the DRM license expiration.
+       *
+       * @since 2.1
+       * @privlevel    platform
+       * @privilege    http://tizen.org/privilege/packagelicensemanager
+       *
+       * @return               The remaining time of the DRM license @n
+       *                               If the remaining time is unlimited, the return value of Tizen::Base::TimeSpan's days will be set to @c 9999.
+       * @param[in]    pkgId                           The package ID with which to get the information of time-based constraint
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_ARG           The specified input parameter is invalid.
+       * @exception    E_DATABASE                      An error has occurred when handling the rights object repository.
+       * @exception    E_OBJ_NOT_FOUND         The input PackageId does not exist in the rights management repository.
+       * @exception    E_RIGHT_EXPIRED         The DRM license has expired.
+       * @exception    E_RIGHT_UNLIMITED       The DRM license is unlimited.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks      Do not use this method without obtaining prior permissions from the %Tizen platform team.
+       */
+       static Tizen::Base::TimeSpan GetRemainingTimeUntilDrmExpiration(const Tizen::App::PackageId& pkgId);
+
+       /**
+       * Saves CEK (Contents Encryption Key) to DRM repository. @n
+       * It stores the CEK when it does not exist in the DRM repository.
+       * When the same @c PackageId of CEK already exists in the DRM repository, it is overwritten.
+       *
+       * @since 2.1
+       * @privlevel    platform
+       * @privilege    http://tizen.org/privilege/packagelicensemanager
+       *
+       * @return               An error code
+       * @param[in]    licenseInfo                     The CEK (Contents Encryption Key)
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_ARG           The specified input parameter is invalid.
+       * @exception    E_INVALID_DATA          A specified XML field of input string is invalid. @n
+       *                                                                       For example, the @c appId field is empty.
+       * @exception    E_DATABASE                      An error has occurred when handling the rights object repository.
+       * @exception    E_PARSING_FAILED        An error has occurred when parsing the input string.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks      Do not use this method without obtaining prior permissions from the %Tizen platform team.
+       */
+       static result SaveLicenseInfoForPackage(const Tizen::Base::String& licenseInfo);
+
+private:
+       PackageLicenseManager(void);
+       ~PackageLicenseManager(void);
+
+       PackageLicenseManager(const PackageLicenseManager& rhs);
+       PackageLicenseManager& operator = (const PackageLicenseManager);
+
+}; // PackageLicenseManager
+
+}}} // Tizen::App::Package
+
+#endif // _FAPP_PKG_PACKAGE_LICENSE_MANAGER_H_
old mode 100755 (executable)
new mode 100644 (file)
index 7d08468..a489814
@@ -38,14 +38,11 @@ class IPackageInstallationResponseListener;
 class IPackageUninstallationResponseListener;
 
 /**
- * @if VISPARTNER-MANUFACTURER
  * @enum PackageType
  *
  * Defines the package types.
   *
  * @since      2.0
- * @visibility partner-manufacturer
- * @endif
  */
 enum PackageType
 {
@@ -63,6 +60,9 @@ enum PackageType
  * @final              This class is not intended for extension.
  *
  * The %PackageManager class provides methods to install or uninstall the packages, retrieves the information of the packages that are installed on the device.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/package_namespace.htm">Package Management</a>.
+ *
  */
 class _OSP_EXPORT_ PackageManager
        : public Tizen::Base::Object
@@ -86,7 +86,8 @@ public:
         * Adds a package installation event listener.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/packageinfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/packageinfo
         *
         * @return              An error code
         * @param[in]   listener                        The package installation event listener
@@ -100,7 +101,8 @@ public:
         * Removes a package installation event listener.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/packageinfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/packageinfo
         *
         * @return              An error code
         * @param[in]   listener                        The package installation event listener
@@ -114,7 +116,8 @@ public:
         * Gets a package information with the specific package ID.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/packageinfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/packageinfo
         *
         * @return              A pointer to PackageInfo
         * @param[in]   packageId                               The package ID
@@ -125,13 +128,14 @@ public:
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @remarks             The specific error code can be accessed using the GetLastResult() method.
         */
-       Tizen::App::Package::PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
+       PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
 
        /**
         * Gets the application information with the specific application ID.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/packageinfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/packageinfo
         *
         * @return              A pointer to PackageAppInfo
         * @param[in]   appId                           The application ID
@@ -141,13 +145,14 @@ public:
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @remarks             The specific error code can be accessed using the GetLastResult() method.
         */
-       Tizen::App::Package::PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
+       PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
 
        /**
         * Gets the package information list.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/packageinfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/packageinfo
         *
         * @return              A pointer to the list of the PackageInfo instances, @n
         *                              else @c null if it fails
@@ -162,7 +167,8 @@ public:
         * Checks whether a package is installed.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/packageinfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/packageinfo
         *
         * @return      @c true if a package is installed, @n
         *                      else @c false
@@ -176,13 +182,12 @@ public:
        bool IsPackageInstalled(const PackageId& packageId) const;
 
        /**
-        * @if VISPARTNER-OPERATOR
         * Installs a package. @n
         * The %InstallPackage() method operates asynchronously, that is, it ends immediately without an installation response. The application is notified when the installation is completed, so the response is available through the IPackageInstallationResponseListener::OnPackageInstallationCompleted() method, if this method returns @c E_SUCCESS.
         *
         * @since       2.0
-        * @visibility  partner-operator
-        * @privilege   %http://tizen.org/privilege/packagemanager.install
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/packagemanager.install
         *
         * @return              An error code
         * @param[in]   packageId                       The package ID
@@ -194,18 +199,16 @@ public:
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @remarks             A listener instance ownership is transferred to the platform. After notifying result, the listener instance is removed automatically. A reuse of the listener instance is not allowed.
         * @see                 IPackageInstallationResponseListener
-        * @endif
         */
        result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
 
        /**
-        * @if VISPARTNER-OPERATOR
         * Uninstalls a package with the specified package ID. @n
         * The %UninstallPackage() method operates asynchronously, that is, it ends immediately without an uninstallation response. The application is notified when the uninstallation is completed, so the response is available through the IPackageUninstallationResponseListener::OnPackageUninstallationCompleted() method, if this method returns @c true.
         *
         * @since       2.0
-        * @visibility  partner-operator
-        * @privilege   %http://tizen.org/privilege/packagemanager.install
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/packagemanager.install
         *
         * @return              An error code
         * @param[in]   packageId                               The package ID
@@ -217,17 +220,15 @@ public:
         * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
         * @remarks             A listener instance ownership is transferred to the platform. After notifying result, the listener instance is removed automatically. A reuse of the listener instance is not allowed.
         * @see                 IPackageUninstallationResponseListener
-        * @endif
         */
        result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
 
        /**
-        * @if VISPARTNER-MANUFACTURER
         *  Moves a package with the specified package ID to an external storage.
         *
         * @since       2.0
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/packagesetting
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/packagesetting
         *
         * @return              An error code
         * @param[in]   packageId                               The package ID
@@ -238,17 +239,15 @@ public:
         * @exception   E_PKG_NOT_INSTALLED             The package is not installed.
         * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
         * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
-        * @endif
         */
        result MoveToExternalStorage(const PackageId& packageId);
 
        /**
-        * @if VISPARTNER-MANUFACTURER
         * Moves a package with the specified package ID to an internal storage.
         *
         * @since       2.0
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/packagesetting
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/packagesetting
         *
         * @return              An error code
         * @param[in]   packageId                               The package ID
@@ -259,11 +258,96 @@ public:
         * @exception   E_PKG_NOT_INSTALLED             The package is not installed.
         * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
         * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
-        * @endif
         */
        result MoveToInternalStorage(const PackageId& packageId);
 
        /**
+       * Gets a package information from the specific file. The supported file extensions are tpk and wgt.
+       *
+       * @since         2.1
+       * @privlevel     platform
+       * @privilege     http://tizen.org/privilege/packagemanager.info
+       *
+       * @return        A pointer to the %PackageInfo instance, @n
+       *               else @c null if it fails
+       * @param[in]    filePath                           The package file path
+       * @exception    E_SUCCESS                          The method is successful.
+       * @exception    E_INVALID_ARG                      A specified input parameter is invalid.
+       * @exception    E_FILE_NOT_FOUND                   The specified file cannot be found or accessed.
+       * @exception    E_UNSUPPORTED_FORMAT               The specified format is invalid or not supported.
+       * @exception    E_PARSING_FAILED                   The method has failed to parse the package file or xml file(s) inside the package.
+       * @exception    E_PRIVILEGE_DENIED                 The application does not have the privilege to call this method.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       */
+       PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const;
+
+       /**
+       * Gets the package information list with the package filter.
+       *
+       * @since         2.1
+       * @privlevel     public
+       * @privilege     http://tizen.org/privilege/package.info
+       *
+       * @return        A pointer to the list of the %PackageInfo instances, @n
+       *                else @c null if it fails
+       * @param[in]     packageFilterMap         The predefined key(Tizen::Base::String)-value(Tizen::Base::Boolean) pairs for the package filter @n
+       * For more information on the predefined key-value pairs for package filter,
+       *       see <a href="../org.tizen.native.appprogramming/html/guide/app/packagefilter.htm">the predefined key-value pairs for package filter</a>.
+       * @exception    E_SUCCESS                            The method is successful.
+       * @exception    E_INVALID_ARG                        A specified input parameter is invalid.
+       * @exception    E_SYSTEM                             The method cannot proceed due to a severe system error.
+       * @exception    E_PRIVILEGE_DENIED                   The application does not have the privilege to call this method.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       */
+       Tizen::Base::Collection::IList* GetPackageInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap) const;
+
+       /**
+       * Gets the application information list with the package app filter.
+       *
+       * @since         2.1
+       * @privlevel     public
+       * @privilege     http://tizen.org/privilege/package.info
+       *
+       * @return        A pointer to the list of the %PackageAppInfo instances, @n
+       *                else @c null if it fails
+       * @param[in]     packageAppFilterMap      The predefined key(Tizen::Base::String)-value(Tizen::Base::String or Tizen::Base::Boolean) pairs for the package app filter @n
+       * For more information on the predefined key-value pairs for package app filter,
+       *       see <a href="../org.tizen.native.appprogramming/html/guide/app/packageappfilter.htm">the predefined key-value pairs for package app filter</a>.
+       * @exception    E_SUCCESS                            The method is successful.
+       * @exception    E_INVALID_ARG                        A specified input parameter is invalid.
+       * @exception    E_SYSTEM                             The method cannot proceed due to a severe system error.
+       * @exception    E_PRIVILEGE_DENIED                   The application does not have the privilege to call this method.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       */
+       Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
+
+       /**
+       * Gets the application information list with the package filter and package app filter.
+       *
+       * @since         2.1
+       * @privlevel     public
+       * @privilege     http://tizen.org/privilege/package.info
+       *
+       * @return        A pointer to the list of the %PackageAppInfo instances, @n
+       *                              else @c null if it fails
+       * @param[in] packageFilterMap        The predefined key(Tizen::Base::String)-value(Tizen::Base::Boolean) pairs for the package filter @n
+       * @param[in] packageAppFilterMap     The predefined and user defined key(Tizen::Base::String)-value(Tizen::Base::String or Tizen::Base::Boolean) pairs for the package app filter @n
+       *                                    The user defined key-value pairs can be added in <Metadata> of manifest.xml.
+       *
+       * For more information on the predefined key-value pairs for package filter,
+       *              see <a href="../org.tizen.native.appprogramming/html/guide/app/packagefilter.htm">the predefined key-value pairs for package filter</a>.
+       * For more information on the predefined key-value pairs for package app filter,
+       *              see <a href="../org.tizen.native.appprogramming/html/guide/app/packageappfilter.htm">the predefined key-value pairs for package app filter</a>.
+       *
+       * @exception    E_SUCCESS                            The method is successful.
+       * @exception    E_INVALID_ARG                        A specified input parameter is invalid.
+       * @exception    E_SYSTEM                             The method cannot proceed due to a severe system error.
+       * @exception    E_PRIVILEGE_DENIED                   The application does not have the privilege to call this method.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       */
+       Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
+
+       /**
         * Gets the package manager instance.
         *
         * @since       2.0
old mode 100644 (file)
new mode 100755 (executable)
index f5445ab..d757aaa
@@ -105,12 +105,15 @@ public:
        *                                                                       - The specified @c pColumnList is empty.
        *                                                                       - The specified @c pageNo parameter is less than @c 1.
        *                                                                       - The specified @c countPerPage parameter is less than @c 1.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
        * @remarks              If the value specified in the @c pWhere is string, the value must be wrapped in
        *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
        *                               For more information on the SQL statement, see SQLite SQL documents.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result Select(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IList* pColumnList,
                        const Tizen::Base::String* pWhere, const Tizen::Base::String *pOrder, RequestId& reqId,
@@ -136,12 +139,15 @@ public:
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_STATE         This instance has not been properly constructed.
        * @exception    E_INVALID_ARG           The specified @c insertMap is empty.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
        * @remarks              If the value specified in the @c insertMap is string, the value must be wrapped in
        *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
        *                               For more information on the SQL statement, see SQLite SQL documents.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result Insert(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& insertMap, RequestId& reqId);
 
@@ -168,12 +174,15 @@ public:
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_STATE         This instance has not been properly constructed.
        * @exception    E_INVALID_ARG           The specified @c updateMap is empty.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
        * @remarks              If the value specified in the @c pWhere or @c updateMap is string, the value must be wrapped in
        *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
        *                               For more information on the SQL statement, see SQLITE SQL documents.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result Update(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& updateMap,
                        const Tizen::Base::String* pWhere, RequestId& reqId);
@@ -199,12 +208,15 @@ public:
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_STATE         This instance has not been properly constructed.
        * @exception    E_INVALID_ARG           A specified parameter is invalid.
-       * @exception    E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
-       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_ILLEGAL_ACCESS        Either of the following conditions has occurred: @n
+       *                                                                       - Access is denied due to insufficient permission.
+       *                                                                       - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
+       * @exception    E_MAX_EXCEEDED          The size of sending buffer has exceeded the maximum limit.
        * @exception    E_SYSTEM                        A system error has occurred.
        * @remarks              If the value specified in the @c pWhere is string, the value must be wrapped in
        *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
        *                               For more information on the SQL statement, see SQLITE SQL documents.
+       * @remarks              The recommended data size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEED may be returned for messages over 16KB size.
        */
        result Delete(const Tizen::Base::String& dataId, const Tizen::Base::String* pWhere, RequestId& reqId);
 
index 7385171..0ab72f7 100644 (file)
@@ -104,7 +104,7 @@ enum AppCtrlResult
  * Represents the application launch arguments in App::App::OnUserEventReceivedN().
  *
  * @brief      <i> [Deprecated] </i>
- * @deprecated This variable is deprecated. From %Tizen, App::App::OnUserEventReceivedN()
+ * @deprecated This variable is deprecated. From %Tizen API version 2.1, App::App::OnUserEventReceivedN()
  *                             is not invoked for the request from application and %AppLaunchRequestId is not used anymore.
  *                             Instead, use IAppControlProviderEventListener.
  * @since      2.0
index 95723ad..ba85af3 100644 (file)
@@ -50,6 +50,7 @@
 #include <FBaseFloatComparer.h>
 #include <FBaseDoubleComparer.h>
 #include <FBaseStringComparer.h>
+#include <FBaseStringHashCodeProvider.h>
 #include <FBaseComparerT.h>
 #include <FBaseDateTime.h>
 #include <FBaseTimeSpan.h>
index 7140393..b0101cc 100644 (file)
@@ -19,7 +19,7 @@
  * @file               FBaseBuffer.h
  * @brief              This is the header file for the %Buffer class.
  *
- * This header file contains the declarations of the %Buffer<Type> classes.
+ * This header file contains the declarations of the %Buffer classes.
  */
 
 #ifndef _FBASE_BUFFER_H_
index 7db19df..24cf3f3 100644 (file)
@@ -56,7 +56,8 @@ enum PositionTo
  *
  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/buffer.htm">Buffer</a>.
  *
- * @see                Tizen::Base::ByteBuffer, Tizen::Base::Buffer< Type >
+ * @see                Tizen::Base::ByteBuffer
+ * @see                Tizen::Base::Buffer< Type >
  */
 
 class _OSP_EXPORT_ BufferBase
index a85c68e..825362c 100644 (file)
@@ -1246,6 +1246,16 @@ public:
        const byte* GetPointer(void) const;
 
        /**
+        * Gets the pointer to the raw array of the calling buffer. @n
+        * If the capacity is zero, it returns @c null.
+        *
+        * @since 2.1
+        *
+        * @return              A pointer(non-const) to the raw array of the calling buffer
+        */
+       byte* GetPointer(void);
+
+       /**
         * Compares the input Object with the calling %ByteBuffer instance.
         *
         * @since 2.0
index 6c65f7f..61966cc 100644 (file)
@@ -619,7 +619,7 @@ public:
         *
         * @since 2.0
         */
-       static const double NO_NUMERIC_VALUE = -123456789;
+       static const double NO_NUMERIC_VALUE = -123456789.0;
 
 private:
        friend class Int8;
index ba0cf21..bf353ca 100644 (file)
 #include <FBaseColMultiHashMapT.h>
 #include <FBaseColMapEntryT.h>
 #include <FBaseColAllElementsDeleter.h>
+#include <FBaseColStlConverter.h>
+#include <FBaseColIteratorT.h>
+#include <FBaseColPairIteratorT.h>
+#include <FBaseColRandomIteratorT.h>
 
 /**
  * @namespace  Tizen::Base::Collection
index af74afe..050cead 100644 (file)
@@ -55,7 +55,7 @@ template< class Type > class __ArrayListEnumeratorT;
  *     void
  *     MyClass::ArrayListTSample(void)
  *     {
- *             ArrayListT<int> list;
+ *             ArrayListT< int > list;
  *
  *             list.Construct();
  *
@@ -76,7 +76,7 @@ template< class Type > class __ArrayListEnumeratorT;
  *
  *             list.InsertAt(int4, 1);         // 1,4,2,3
  *
- *             ComparerT<int>* pIntComparer = new ComparerT<int>();
+ *             ComparerT< int >* pIntComparer = new ComparerT<int>();
  *             list.Sort(*pIntComparer);       // 1,2,3,4
  *
  *             delete pIntComparer;
@@ -86,7 +86,7 @@ template< class Type > class __ArrayListEnumeratorT;
  *             list.RemoveAt(0);                       // 2,4
  *
  *             // Uses an enumerator to access elements in the list
- *             IEnumeratorT<int>* pEnum = list.GetEnumeratorN();
+ *             IEnumeratorT< int >* pEnum = list.GetEnumeratorN();
  *             while (pEnum->MoveNext() == E_SUCCESS)
  *             {
  *                     pEnum->GetCurrent(temp);
index 1b609e2..206f163 100644 (file)
@@ -68,7 +68,7 @@ template< class KeyType > class __HashMapDefaultProviderT;
  *     void
  *     MyClass::HashMapTSample(void)
  *     {
- *             HashMapT<int, int> map;
+ *             HashMapT< int, int > map;
  *
  *             // Constructs a %HashMapT instance with default capacity, load factor, hash code provider, and comparer
  *             map.Construct();
@@ -88,7 +88,7 @@ template< class KeyType > class __HashMapDefaultProviderT;
  *             map.Remove(key);
  *
  *             // Uses an enumerator to access elements in the map
- *             IMapEnumeratorT<int, int>*      pMapEnum = map.GetMapEnumeratorN();
+ *             IMapEnumeratorT< int, int >*    pMapEnum = map.GetMapEnumeratorN();
  *             while (pMapEnum->MoveNext() == E_SUCCESS)
  *             {
  *                     pMapEnum->GetKey(key);
index eb97e67..1aa230a 100644 (file)
@@ -144,13 +144,12 @@ public:
        virtual IEnumerator* GetValuesN(const Object& key) const = 0;
 
        /**
-        * Gets a list of all the keys in the map.
+        * Gets a list of all unique keys in the map.
         *
         * @since 2.0
         *
-        * @return              A pointer to a list of all the keys in the map, @n
+        * @return              A pointer to a list of all unique keys in the map, @n
         *                              else @c null if an exception occurs
-        * @remarks             The order of the keys is the same as the corresponding values in the IList interface returned by the GetValuesN() method.
         * @remarks             The %IList stores just the pointers to the elements in the map, not the elements themselves.
         * @remarks             The specific error code can be accessed using the GetLastResult() method.
         * @see                 GetValuesN()
index ef1c2e1..d8e9558 100644 (file)
@@ -120,16 +120,15 @@ public:
        virtual IEnumeratorT< ValueType >* GetValuesN(const KeyType& key) const = 0;
 
        /**
-        * Gets a list of all the keys in the map.
+        * Gets a list of all unique keys in the map.
         *
         * @since 2.0
         *
-        * @return              A pointer to a list of all the keys in the map, @n
+        * @return              A pointer to a list of all unique keys in the map, @n
         *                              else @c null if an exception occurs
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        * @remarks             The order of the keys is the same as the corresponding values in the IListT interface returned by the GetValuesN() method.
-        *              The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
         * @see                 GetValuesN()
         */
        virtual IListT< KeyType >* GetKeysN(void) const = 0;
diff --git a/inc/FBaseColIteratorT.h b/inc/FBaseColIteratorT.h
new file mode 100644 (file)
index 0000000..689d60e
--- /dev/null
@@ -0,0 +1,325 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FBaseColIteratorT.h
+ * @brief              This is the header file for the %IteratorT class.
+ *
+ * This header file contains the declarations of the %IteratorT class.
+ */
+
+#ifndef _FBASE_COL_ITERATOR_T_H_
+#define _FBASE_COL_ITERATOR_T_H_
+
+#include <algorithm>   // std::swap (Before C++11)
+#include <iterator>
+#include <unique_ptr.h>
+#include <FBaseLog.h>
+#include <FBaseColIList.h>
+#include <FBaseColIBidirectionalEnumerator.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+/**
+ * @class      IteratorT
+ * @brief      This class provides an iterator that is used to convert IList to STL containers.
+ *                     StlConverter provides static methods to get this iterator from IList.
+ *
+ * @since      2.1
+ *
+ * @remarks    This class satisfies only requirements of C++ standard library InputIterator concept due to limitations of Tizen Collection.
+ *                     So, this class can be used with C++ standard library algorithms which requires only InputIterator concept for their arguments.
+ */
+
+template < typename T >
+class IteratorT
+       : public std::iterator< std::input_iterator_tag, T >
+{
+public:
+       /**
+        * Initializes this instance of %IteratorT class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   list             A reference to the IList instance to convert
+        * @param[in]   isPostEnd        A boolean value to check the end
+        */
+       explicit IteratorT(const IList& list, bool isPostEnd = false)
+               : __pList(&list)
+               , __isPostEnd(isPostEnd)
+               , __index(0)
+               , __pEnum(__pList->GetBidirectionalEnumeratorN())
+               , __currentObj(null)
+       {
+               if (!isPostEnd)
+               {
+                       __pEnum->MoveNext();
+                       __currentObj = static_cast< T >(__pEnum->GetCurrent());
+               }
+               else
+               {
+                       __index = __pList->GetCount();
+                       __pEnum->MovePrevious();
+               }
+       }
+
+       /**
+        * This is copy constructor of %IteratorT class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   rhs     A reference to the %IteratorT instance
+        */
+       IteratorT(const IteratorT< T >& rhs)
+               : __pList(rhs.__pList)
+               , __isPostEnd(rhs.__isPostEnd)
+               , __index(rhs.__index)
+               , __pEnum(__pList->GetBidirectionalEnumeratorN())
+               , __currentObj(rhs.__currentObj)
+       {
+               if (!__isPostEnd)
+               {
+                       for (int i = 0; i <= __index; ++i)
+                       {
+                               __pEnum->MoveNext();
+                       }
+               }
+               else
+               {
+                       __pEnum->MovePrevious();
+               }
+       }
+
+       /**
+        * This is assignment operator of %IteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %IteratorT instance
+        * @param[in]   rhs     A reference to the %IteratorT instance on the right-hand side of the operator
+        */
+       IteratorT< T >& operator=(const IteratorT< T >& rhs)
+       {
+               IteratorT< T > tmp(rhs);
+               tmp.swap(*this);
+               return *this;
+       }
+
+       /**
+        * This is the indirection operator for %IteratorT class.
+        *
+        * @since       2.1
+        *
+        * @return              A T type reference
+        */
+       T& operator*(void) const
+       {
+               AppAssertf(!__isPostEnd && __index >= 0, "It is out of range.");
+               return const_cast< T& >(__currentObj);
+       }
+
+       /**
+        * This is the structure dereference operator for %IteratorT class.
+        *
+        * @since       2.1
+        *
+        * @return              A T type pointer equivalent to the pointer address
+        */
+       T* operator->(void) const
+       {
+               return &(operator*());
+       }
+
+       /**
+        * Moves to the next element of the collection.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %IteratorT type instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       IteratorT< T >& operator++(void)
+       {
+               const int PRE_BEGIN_IDX = -1;
+               TryCatchResult(__index >= PRE_BEGIN_IDX, , E_OUT_OF_RANGE, "[%s] It is out of range.", GetErrorMessage(E_OUT_OF_RANGE));
+
+               if (__index != PRE_BEGIN_IDX)
+               {
+                       result r = __pEnum->MoveNext();
+                       TryCatchResult(r == E_SUCCESS, __isPostEnd = true; __currentObj = null, r, "[%s] It already reached the end.", GetErrorMessage(r));
+               }
+
+               __currentObj = static_cast< T >(__pEnum->GetCurrent());
+
+       CATCH:
+               ++__index;
+               return *this;
+       }
+
+       /**
+        * Moves to the next element of the collection and returns the previous state.
+        *
+        * @since       2.1
+        *
+        * @return              An IteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             It takes O(n) time to get current Enumerate point to return. So use this operator as little as possible.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       IteratorT< T > operator++(int)
+       {
+               IteratorT< T > tempIter = *this;
+               operator++();
+               return tempIter;
+       }
+
+       /**
+        * Moves to the previous element of the collection.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %IteratorT type instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       IteratorT< T >& operator--(void)
+       {
+               TryCatchResult(__index <= __pList->GetCount(), , E_OUT_OF_RANGE, "[%s] It is out of range.", GetErrorMessage(E_OUT_OF_RANGE));
+
+               if (!__isPostEnd)
+               {
+                       result r = __pEnum->MovePrevious();
+                       TryCatchResult(r == E_SUCCESS, __currentObj = null, r, "[%s] It already reached the front.", GetErrorMessage(r));
+               }
+               else
+               {
+                       __isPostEnd = false;
+               }
+
+               __currentObj = static_cast< T >(__pEnum->GetCurrent());
+
+CATCH:
+               --__index;
+               return *this;
+       }
+
+       /**
+        * Moves to the previous element of the collection and returns the previous state.
+        *
+        * @since               2.1
+        *
+        * @return              An IteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             It takes O(n) time to get current Enumerate point to return. So use this operator as little as possible.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       IteratorT< T > operator--(int)
+       {
+               IteratorT< T > tempIter = *this;
+               operator--();
+               return tempIter;
+       }
+
+       /**
+        *      Checks the two %IteratorT instances for equality
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if every member of the specified %IteratorT instance equals the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %IteratorT instance on the right-hand side of the operator
+        */
+       bool operator==(const IteratorT< T >& rhs) const
+       {
+               if (__pList != rhs.__pList)
+               {
+                       return false;
+               }
+
+               if (__index != rhs.__index)
+               {
+                       return false;
+               }
+
+               if (__isPostEnd != rhs.__isPostEnd)
+               {
+                       return false;
+               }
+               else if (__isPostEnd && rhs.__isPostEnd)
+               {
+                       // In this case, __currentObj state is invalid
+                       return true;
+               }
+
+               // If both this->__isPostEnd and rhs.__isPostEnd are false, then reach here. This means both iterators are in the middle of the list.
+               return __currentObj == rhs.__currentObj;
+       }
+
+       /**
+        *      Checks the two %IteratorT instances for inequality.
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if every member of the specified %IteratorT instance is not equal to the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %IteratorT instance on the right-hand side of the operator
+        */
+       bool operator!=(const IteratorT< T >& rhs) const
+       {
+               return !operator==(rhs);
+       }
+
+       /**
+        *      Exchanges values of the two %IteratorT instances
+        *
+        *      @since          2.1
+        *
+        *      @param[in]      rhs     A reference to the %IteratorT instance to swap
+        */
+       void swap(IteratorT< T >& rhs)
+       {
+               std::swap(__pList, rhs.__pList);
+               std::swap(__isPostEnd, rhs.__isPostEnd);
+               std::swap(__index, rhs.__index);
+               std::swap(__pEnum, rhs.__pEnum);
+               std::swap(__currentObj, rhs.__currentObj);
+       }
+
+private:
+       const IList* __pList;
+       bool __isPostEnd;
+       int __index;
+       std::unique_ptr< IBidirectionalEnumerator > __pEnum;
+       T __currentObj;
+}; // IteratorT
+
+}}} // Tizen::Base::Collection
+
+#endif //_FBASE_COL_ITERATOR_T_H_
index 29e8f41..65ca493 100644 (file)
@@ -60,7 +60,7 @@ class _ListNode;
  *             list.Add(new Integer(2));       // 1,2
  *             list.Add(new Integer(3));       // 1,2,3
  *
- *             Integer*        pInt = static_cast<Integer*> (list.GetAt(0));
+ *             Integer*        pInt = static_cast< Integer* > (list.GetAt(0));
  *
  *             if (pValue->Equals(Integer(1))
  *             {
index 7d0ea43..8307b3a 100644 (file)
@@ -57,7 +57,7 @@ template< class Type > class __LinkedListNodeT;
  *     void
  *     MyClass::LinkedListTSample(void)
  *     {
- *             LinkedListT<int> list;
+ *             LinkedListT< int > list;
  *
  *             int int1 = 1;
  *             int int2 = 2;
@@ -76,7 +76,7 @@ template< class Type > class __LinkedListNodeT;
  *
  *             list.InsertAt(int4, 1); // 1,4,2,3
  *
- *             ComparerT<int>* pIntComparer = new ComparerT<int>();
+ *             ComparerT< int >* pIntComparer = new ComparerT<int>();
  *             list.Sort(*pIntComparer);       // 1,2,3,4
  *
  *             delete pIntComparer;
@@ -85,7 +85,7 @@ template< class Type > class __LinkedListNodeT;
  *             list.RemoveAt(0);       // 2,4
  *
  *             // Uses an enumerator to access elements in the list
- *             IEnumeratorT<int>* pEnum = list.GetEnumeratorN();;
+ *             IEnumeratorT< int >* pEnum = list.GetEnumeratorN();;
  *             while (pEnum->MoveNext() == E_SUCCESS)
  *             {
  *                     pEnum->GetCurrent(temp);
index 8a823a7..028df54 100644 (file)
@@ -73,7 +73,7 @@ class _MultiHashMapEntry;
  *             IEnumerator *pValueEnum = map.GetValuesN(String(L"Two"));
  *             while(pValueEnum->MoveNext() == E_SUCCESS)
  *             {
- *                     pValue = static_cast<Integer*> (pValueEnum->GetCurrent());
+ *                     pValue = static_cast< Integer* > (pValueEnum->GetCurrent());
  *             }
  *
  *             delete pValueEnum;
@@ -277,14 +277,13 @@ public:
        virtual IEnumerator* GetValuesN(const Object& key) const;
 
        /**
-        * Gets a list of all the keys in this map.
+        * Gets a list of all unique keys in this map.
         *
         * @since 2.0
         *
-        * @return              A list of all the keys in this map
-        * @remarks             The order of the keys is the same as the corresponding values in the IList interface returned by the GetValuesN() method.
-        *              The %IList stores just the pointers to the elements in the map, not the elements themselves.
-        *              The specific error code can be accessed using the GetLastResult() method.
+        * @return              A list of all unique keys in this map
+        * @remarks             The %IList stores just the pointers to the elements in the map, not the elements themselves.
+        *                      The specific error code can be accessed using the GetLastResult() method.
         * @see                 GetValuesN()
         */
        virtual IList* GetKeysN(void) const;
index b0d26ab..ddeae3a 100644 (file)
@@ -70,7 +70,7 @@ template< class ValueType > class __ValueNodeT;
  *     void
  *     MyClass::MultiHashMapTSample(void)
  *     {
- *             MultiHashMapT<int, int> map;
+ *             MultiHashMapT< int, int > map;
  *
  *             // Constructs a MultiHashMap instance with default capacity, load factor, hash code provider, and comparer
  *             map.Construct();
@@ -85,7 +85,7 @@ template< class ValueType > class __ValueNodeT;
  *
  *             // Gets values with the specified key
  *             key = 1;
- *             IEnumeratorT<int>*      pValueEnum = map.GetValuesN(key);
+ *             IEnumeratorT< int >*    pValueEnum = map.GetValuesN(key);
  *             while (pValueEnum->MoveNext() == E_SUCCESS)
  *             {
  *                     pValueEnum->GetCurrent(value);
@@ -98,7 +98,7 @@ template< class ValueType > class __ValueNodeT;
  *             map.Remove(key);                // 30, 3000 removed
  *
  *             // Uses an enumerator to access elements in the map
- *             IMapEnumeratorT<int, int>*      pMapEnum = map.GetMapEnumeratorN();
+ *             IMapEnumeratorT< int, int >*    pMapEnum = map.GetMapEnumeratorN();
  *             while (pMapEnum->MoveNext() == E_SUCCESS)
  *             {
  *                     pMapEnum->GetKey(key);
@@ -598,16 +598,15 @@ CATCH:
        }
 
        /**
-        * Gets a list of all the keys in this map.
+        * Gets a list of all unique keys in this map.
         *
         * @since 2.0
         *
-        * @return              A list of all the keys in this map, @n
+        * @return              A list of all unique keys in this map, @n
         *                              else @c null if an exception occurs
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        * @remarks             The order of the keys is the same as the corresponding values in the IListT interface returned by the GetValuesN() method.
-        *                      The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
         * @see                 GetValuesN()
         */
        virtual IListT< KeyType >* GetKeysN(void) const
diff --git a/inc/FBaseColPairIteratorT.h b/inc/FBaseColPairIteratorT.h
new file mode 100644 (file)
index 0000000..0e371db
--- /dev/null
@@ -0,0 +1,324 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FBaseColPairIteratorT.h
+ * @brief              This is the header file for the %PairIteratorT class.
+ *
+ * This header file contains the declarations of the %PairIteratorT class.
+ */
+
+#ifndef _FBASE_COL_PAIR_ITERATOR_T_H_
+#define _FBASE_COL_PAIR_ITERATOR_T_H_
+
+#include <algorithm>   // std::swap (Before C++11)
+#include <iterator>
+#include <utility>
+#include <unique_ptr.h>
+#include <FBaseLog.h>
+#include <FBaseColIMap.h>
+#include <FBaseColIMultiMap.h>
+#include <FBaseColIMapEnumerator.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+/**
+ * @class      PairIteratorT
+ * @brief      This class provides an iterator that is used to convert IMap or IMultiMap to STL containers.
+ *                     StlConverter provides static methods to get this iterator from IMap or IMultiMap.
+ *
+ * @since      2.1
+ *
+ * @remarks    This class satisfies only requirements of C++ standard library InputIterator concept due to limitations of Tizen Collection.
+ *                     So, this class can be used with C++ standard library algorithms which requires only InputIterator concept for their arguments.
+ */
+
+template < typename K, typename V >
+class PairIteratorT
+       : public std::iterator< std::input_iterator_tag, std::pair< K, V > >
+{
+public:
+       /**
+        * Initializes this instance of %PairIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   map                     A reference to the IMap instance to convert
+        * @param[in]   isPostEnd       A boolean value to check the end
+        */
+       explicit PairIteratorT(const IMap& map, bool isPostEnd = false)
+               : __pMap(&map)
+               , __pMultiMap(null)
+               , __isPostEnd(isPostEnd)
+               , __index(0)
+               , __pEnum(__pMap->GetMapEnumeratorN())
+               , __currentObj()
+       {
+               if (!isPostEnd)
+               {
+                       __pEnum->MoveNext();
+                       __currentObj.first = static_cast< K >(__pEnum->GetKey());
+                       __currentObj.second = static_cast< V >(__pEnum->GetValue());
+               }
+               else
+               {
+                       __index = __pMap->GetCount();
+               }
+       }
+
+       /**
+        * Initializes this instance of %PairIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   multiMap        A reference to the IMultiMap instance to convert
+        * @param[in]   isPostEnd       A boolean value to check the end
+        */
+       PairIteratorT(const IMultiMap& multiMap, bool isPostEnd = false)
+               : __pMap(null)
+               , __pMultiMap(&multiMap)
+               , __isPostEnd(isPostEnd)
+               , __index(0)
+               , __pEnum(__pMultiMap->GetMapEnumeratorN())
+               , __currentObj()
+       {
+               if (!__isPostEnd)
+               {
+                       __pEnum->MoveNext();
+                       __currentObj.first = static_cast< K >(__pEnum->GetKey());
+                       __currentObj.second = static_cast< V >(__pEnum->GetValue());
+               }
+               else
+               {
+                       __index = __pMultiMap->GetCount();
+               }
+       }
+
+       /**
+        * This is copy constructor of %PairIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   rhs                                     A reference to the %PairIteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           Both @c __pMap and @c __pMultiMap are null.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, or
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       PairIteratorT(const PairIteratorT< K, V >& rhs)
+               : __pMap(rhs.__pMap)
+               , __pMultiMap(rhs.__pMultiMap)
+               , __isPostEnd(rhs.__isPostEnd)
+               , __index(rhs.__index)
+               , __currentObj(rhs.__currentObj)
+       {
+               TryReturnVoidResult(__pMap != null || __pMultiMap != null, E_INVALID_ARG, "[%s] __pMap or __pMultiMap should not be null.", GetErrorMessage(E_INVALID_ARG));
+
+               if (__pMap != null)
+               {
+                       __pEnum.reset(__pMap->GetMapEnumeratorN());
+               }
+               else if (__pMultiMap != null)
+               {
+                       __pEnum.reset(__pMultiMap->GetMapEnumeratorN());
+               }
+
+               if (!__isPostEnd)
+               {
+                       for (int i = 0; i <= __index; ++i)
+                       {
+                               __pEnum->MoveNext();
+                       }
+               }
+       }
+
+       /**
+        * This is assignment operator of %PairIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %PairIteratorT instance
+        * @param[in]   rhs                                     A reference to the %PairIteratorT instance on the right-hand side of the operator
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           Both @c __pMap and @c __pMultiMap are null.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       PairIteratorT< K, V >& operator=(const PairIteratorT< K, V >& rhs)
+       {
+               PairIteratorT< K, V > tmp(rhs);
+               tmp.swap(*this);
+               return *this;
+       }
+
+       /**
+        * This is the indirection operator for %PairIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A std::pair type reference with K and V type
+        */
+       std::pair< K, V >& operator*(void) const
+       {
+               AppAssertf(!__isPostEnd, "It is out of range.");
+               return const_cast< std::pair< K, V >& >(__currentObj);
+       }
+
+       /**
+        * This is the const version structure dereference operator for %PairIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A std::pair type pointer equivalent to the pointer address
+        */
+       std::pair< K, V >* operator->(void) const
+       {
+               return &(operator*());
+       }
+
+       /**
+        * Moves to the next element of the collection.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %PairIteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The enumerator has passed the end of the collection.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       PairIteratorT< K, V >& operator++(void)
+       {
+               TryReturnResult(!__isPostEnd, *this, E_OUT_OF_RANGE, "[%s] It already reached the end.", GetErrorMessage(E_OUT_OF_RANGE));
+
+               result r = __pEnum->MoveNext();
+               TryCatchResult(r == E_SUCCESS, __isPostEnd = true; __currentObj.first = null; __currentObj.second = null,
+                       r, "[%s] It already reached the end.", GetErrorMessage(r));
+
+               __currentObj.first = static_cast< K >(__pEnum->GetKey());
+               __currentObj.second = static_cast< V >(__pEnum->GetValue());
+
+CATCH:
+               ++__index;
+               return *this;
+       }
+
+       /**
+        * Moves to the next element of the collection and returns the previous state.
+        *
+        * @since       2.1
+        *
+        * @return              A %PairIteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The enumerator has passed the end of the collection.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        *                                                                      the collection is modified after the enumerator is created.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       PairIteratorT< K, V > operator++(int)
+       {
+               PairIteratorT< K, V > tempIter = *this;
+               operator++();
+               return tempIter;
+       }
+
+       /**
+        *      Checks the two %PairIteratorT instances for equality
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if every member of the specified %PairIteratorT instance equals the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %PairIteratorT instance on the right-hand side of the operator
+        */
+       bool operator==(const PairIteratorT< K, V >& rhs) const
+       {
+               if (__pMap != rhs.__pMap)
+               {
+                       return false;
+               }
+
+               if (__pMultiMap != rhs.__pMultiMap)
+               {
+                       return false;
+               }
+
+               if (__index != rhs.__index)
+               {
+                       return false;
+               }
+
+               if (__isPostEnd != rhs.__isPostEnd)
+               {
+                       return false;
+               }
+               else if (__isPostEnd && rhs.__isPostEnd)
+               {
+                       // In this case, __currentObj state is invalid
+                       return true;
+               }
+
+               // If both this->__isPostEnd and rhs.__isPostEnd are false, then reach here. This means both iterators are in the middle of the list.
+               return __currentObj == rhs.__currentObj;
+       }
+
+       /**
+        *      Checks the two %PairIteratorT instances for inequality.
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if every member of the specified %PairIteratorT instance is not equal to the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %PairIteratorT instance on the right-hand side of the operator
+        */
+       bool operator!=(const PairIteratorT< K, V >& rhs) const
+       {
+               return !operator==(rhs);
+       }
+
+       /**
+        *      Exchanges values of the two %PairIteratorT instances
+        *
+        *      @since          2.1
+        *
+        *      @param[in]      rhs     A reference to the %PairIteratorT instance to swap
+        */
+       void swap(PairIteratorT< K, V >& rhs)
+       {
+               std::swap(__pMap, rhs.__pMap);
+               std::swap(__pMultiMap, rhs.__pMultiMap);
+               std::swap(__isPostEnd, rhs.__isPostEnd);
+               std::swap(__index, rhs.__index);
+               std::swap(__pEnum, rhs.__pEnum);
+               std::swap(__currentObj, rhs.__currentObj);
+       }
+
+private:
+       const IMap* __pMap;
+       const IMultiMap* __pMultiMap;
+       bool __isPostEnd;
+       int __index;
+       std::unique_ptr< IMapEnumerator > __pEnum;
+       std::pair< K, V > __currentObj;
+};     // PairIteratorT
+
+}}} // Tizen::Base::Collection
+
+#endif //_FBASE_COL_PAIR_ITERATOR_T_H_
index 36b5d5d..902fc5c 100644 (file)
@@ -64,7 +64,7 @@ namespace Tizen { namespace Base { namespace Collection
  *             const Object* pObj = queue.Peek();              // pObj: "First", queue.GetCount(): 3
  *
  *             // Reads and removes the element at the beginning
- *             String* pStr = static_cast<String*> (queue.Dequeue());  // pStr: "First", queue.GetCount(): 2
+ *             String* pStr = static_cast< String* > (queue.Dequeue());        // pStr: "First", queue.GetCount(): 2
  *
  *             delete pStr;     // Because the queue does not have the Ownership of this pStr after dequeueing
  *
index fae7659..62a94c4 100644 (file)
@@ -56,7 +56,7 @@ template< class Type > class __QueueEnumeratorT;
  *     void
  *     MyClass::QueueTSample(void)
  *     {
- *             QueueT<String> queue;
+ *             QueueT< String > queue;
  *             queue.Construct();
  *
  *             String str1(L"First");
diff --git a/inc/FBaseColRandomIteratorT.h b/inc/FBaseColRandomIteratorT.h
new file mode 100644 (file)
index 0000000..c9e1df1
--- /dev/null
@@ -0,0 +1,351 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FBaseColRandomIteratorT.h
+ * @brief              This is the header file for the %RandomIteratorT class.
+ *
+ * This header file contains the declarations of the %RandomIteratorT class.
+ */
+
+#ifndef _FBASE_COL_RANDOM_ITERATOR_T_H_
+#define _FBASE_COL_RANDOM_ITERATOR_T_H_
+
+#include <algorithm>   // std::swap (Before C++11)
+#include <iterator>
+#include <FBaseColIList.h>
+#include <FBaseLog.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+/**
+ * @class      RandomIteratorT
+ * @brief      This class provides an random iterator that is used to convert IList to STL containers.
+ *                     StlConverter provides static methods to get this random iterator from IList.
+ *
+ * @since      2.1
+ *
+ * @remarks    This class satisfies only requirements of C++ standard library InputIterator concept due to limitations of Tizen Collection.
+ *                     So, this class can be used with C++ standard library algorithms which requires only InputIterator concept for their arguments.
+ */
+
+template < typename T >
+class RandomIteratorT
+       : public std::iterator< std::input_iterator_tag, T >
+{
+public:
+       /**
+        * Initializes this instance of %RandomIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   list            A reference to the IList instance to convert
+        * @param[in]   position        A start position
+        * @remarks                     RandomIteratorT only supports random accessible collection for performance.
+        * @see                         Tizen::Base::Collection::IList::IsRandomAccessible()
+        */
+       explicit RandomIteratorT(const IList& list, int index = 0)
+               : __pList(&list)
+               , __index(index)
+               , __currentObj(static_cast< T >(const_cast< Object* >(__pList->GetAt(__index))))
+       {
+               AppAssertf(list.IsRandomAccessible(), "The list is not randomly accessible. RandomIteratorT only supports random accessible collection.");
+       }
+
+       /**
+        * This is copy constructor of %RandomIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   rhs     A reference to the %RandomIteratorT instance
+        */
+       RandomIteratorT(const RandomIteratorT< T >& rhs)
+               : __pList(rhs.__pList)
+               , __index(rhs.__index)
+               , __currentObj(rhs.__currentObj)
+       {
+       }
+
+       /**
+        * This is the assignment operator of %RandomIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %RandomIteratorT instance
+        * @param[in]   rhs     A reference to the %RandomIteratorT instance on the right-hand side of the operator
+        */
+       RandomIteratorT< T >& operator=(const RandomIteratorT< T >& rhs)
+       {
+               RandomIteratorT< T > tmp(rhs);
+               tmp.swap(*this);
+               return *this;
+       }
+
+       /**
+        * This is the indirection operator for %RandomIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A T type reference
+        */
+       T& operator*(void) const
+       {
+               AppAssertf(__index >= 0 && __index < __pList->GetCount(), "It is out of range.");
+               return const_cast< T& >(__currentObj);
+       }
+
+       /**
+        * This is the structure dereference operator for %RandomIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A T type pointer equivalent to the pointer address
+        */
+       T* operator->(void) const
+       {
+               return &(operator*());
+       }
+
+       /**
+        * Increases __index by 1.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %RandomIteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure,
+        *                                                                      or the specified index is either equal to or greater than the number of elements in the list or less than 0.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       RandomIteratorT< T >& operator++(void)
+       {
+               ++__index;
+
+               // GetAt() will return null if __index is out of range.
+               __currentObj = static_cast< T >(const_cast< Object* >(__pList->GetAt(__index)));
+               TryReturnResult(__currentObj != null, *this, GetLastResult(), "[%s] It is out of range.", GetErrorMessage(GetLastResult()));
+               return *this;
+       }
+
+       /**
+        * Increases __index by 1 and returns the previous state.
+        *
+        * @since               2.1
+        *
+        * @return              A %RandomIteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure,
+        *                                                                      or the specified index is either equal to or greater than the number of elements in the list or less than 0.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       RandomIteratorT< T > operator++(int)
+       {
+               RandomIteratorT< T > tempIter = *this;
+               operator++();
+               return tempIter;
+       }
+
+       /**
+        * Decrease __index by 1.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the %RandomIteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure,
+        *                                                                      or the specified index is either equal to or greater than the number of elements in the list or less than 0.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       RandomIteratorT< T >& operator--(void)
+       {
+               --__index;
+
+               // GetAt() will return null if __index is out of range.
+               __currentObj = static_cast< T >(const_cast< Object* >(__pList->GetAt(__index)));
+               TryReturnResult(__currentObj != null, *this, GetLastResult(), "[%s] It is out of range.", GetErrorMessage(GetLastResult()));
+               return *this;
+       }
+
+       /**
+        * Decrease __index by 1 and returns the previous state.
+        *
+        * @since               2.1
+        *
+        * @return              A %RandomIteratorT instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure,
+        *                                                                      or the specified index is either equal to or greater than the number of elements in the list or less than 0.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       RandomIteratorT< T > operator--(int)
+       {
+               RandomIteratorT< T > tempIter = *this;
+               operator--();
+               return tempIter;
+       }
+
+       /**
+        *      Checks two %RandomIteratorT instances for equality
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if every member of the specified %RandomIteratorT instance equals the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %RandomIteratorT instance on the right-hand side of the operator
+        */
+       bool operator==(const RandomIteratorT< T >& rhs) const
+       {
+               return ((__pList == rhs.__pList) && (__index == rhs.__index) && (__currentObj == rhs.__currentObj));
+       }
+
+       /**
+        *      Checks two %RandomIteratorT instances for inequality.
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if every member of the specified %RandomIteratorT instance is not equal to the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %RandomIteratorT instance on the right-hand side of the operator
+        */
+       bool operator!=(const RandomIteratorT< T >& rhs) const
+       {
+               return !operator==(rhs);
+       }
+
+       /**
+        *      Checks l-value is less than r-value
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if l-value of the specified %RandomIteratorT instance is less than the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %RandomIteratorT instance on the right-hand side of the operator
+        */
+       bool operator<(const RandomIteratorT< T >& rhs) const
+       {
+               return __index < rhs.__index;
+       }
+
+       /**
+        *      Checks whether l-value is greater than r-value
+        *
+        *      @since          2.1
+        *
+        *      @return         @c true if l-value of the specified %RandomIteratorT instance is greater than the calling instance's members, @n
+        *                              else @c false
+        *      @param[in]      rhs     A reference to the %RandomIteratorT instance on the right-hand side of the operator
+        */
+       bool operator>(const RandomIteratorT< T >& rhs) const
+       {
+               return __index > rhs.__index;
+       }
+
+       /**
+        * Increases __index as many as diff
+        *
+        * @since               2.1
+        *
+        * @return              A %RandomIteratorT instance
+        * @param[in]   diff            The length to move forward
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure,
+        *                                                                      or the specified index is either equal to or greater than the number of elements in the list or less than 0.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       RandomIteratorT< T > operator+(int diff)
+       {
+               RandomIteratorT< T > tempIter = *this;
+               tempIter.__index += diff;
+
+               // GetAt() will return null if __index is out of range.
+               tempIter.__currentObj = static_cast< T >(const_cast< Object* >(tempIter.__pList->GetAt(tempIter.__index)));
+               TryReturnResult(tempIter.__currentObj != null, tempIter, GetLastResult(), "[%s] It is out of range.", GetErrorMessage(GetLastResult()));
+               return tempIter;
+       }
+
+       /**
+        * Decrease __index as many as diff
+        *
+        * @since               2.1
+        *
+        * @return              A %RandomIteratorT instance
+        * @param[in]   diff            The length to move backward
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure,
+        *                                                                      or the specified index is either equal to or greater than the number of elements in the list or less than 0.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       RandomIteratorT< T > operator-(int diff)
+       {
+               RandomIteratorT< T > tempIter = *this;
+               tempIter.__index -= diff;
+
+               // GetAt() will return null if __index is out of range.
+               tempIter.__currentObj = static_cast< T >(const_cast< Object* >(tempIter.__pList->GetAt(tempIter.__index)));
+               TryReturnResult(tempIter.__currentObj != null, tempIter, GetLastResult(), "[%s] It is out of range.", GetErrorMessage(GetLastResult()));
+               return tempIter;
+       }
+
+       int operator-(const RandomIteratorT< T >& rhs)
+       {
+               return __index - rhs.__index;
+       }
+
+       /**
+        * This is the index operator for %RandomIteratorT class.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the T type instance
+        * @param[in]   index   An index to reach
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure,
+        *                                                                      or the specified index is either equal to or greater than the number of elements in the list or less than 0.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        */
+       T& operator[](int index) const
+       {
+               // GetAt() will return null if __index is out of range.
+               const T& tempObj = static_cast< T >(const_cast< Object* >(__pList->GetAt(index)));
+               TryReturnResult(tempObj != null, const_cast< T& >(tempObj), GetLastResult(), "[%s] It is out of range.", GetErrorMessage(GetLastResult()));
+               return const_cast< T& >(tempObj);
+       }
+
+       /**
+        *      Exchanges values of the two %RandomIteratorT instances
+        *
+        *      @since          2.1
+        *
+        *      @param[in]      rhs     A reference to the %RandomIteratorT instance to swap
+        */
+       void swap(RandomIteratorT< T >& rhs)
+       {
+               std::swap(__pList, rhs.__pList);
+               std::swap(__index, rhs.__index);
+               std::swap(__currentObj, rhs.__currentObj);
+       }
+
+private:
+       const IList* __pList;
+       int __index;
+       T __currentObj;
+}; // RandomIteratorT
+
+}}} // Tizen::Base::Collection
+
+#endif //_FBASE_COL_RANDOM_ITERATOR_T_H_
index 8cd8ce9..65e8085 100644 (file)
@@ -65,7 +65,7 @@ namespace Tizen { namespace Base { namespace Collection
  *             const Object* pObj = stack.Peek();                              // pObj: "Third", stack.GetCount(): 3
  *
  *             // Reads and removes the element at the top
- *             String* pStr = static_cast<String*> (stack.Pop());      // pStr: "Third", stack.GetCount(): 2
+ *             String* pStr = static_cast< String* > (stack.Pop());    // pStr: "Third", stack.GetCount(): 2
  *
  *             delete pStr;    // Because the stack does not have the ownership of this pStr after popping
  *
index 991085a..a6b8d2c 100644 (file)
@@ -56,7 +56,7 @@ template< class Type > class __StackEnumeratorT;
  *     void
  *     MyClass::StackTSample(void)
  *     {
- *             StackT<String> stack;
+ *             StackT< String > stack;
  *             stack.Construct();
  *
  *             String str1(L"First");
diff --git a/inc/FBaseColStlConverter.h b/inc/FBaseColStlConverter.h
new file mode 100644 (file)
index 0000000..14e2e83
--- /dev/null
@@ -0,0 +1,419 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FBaseColStlConverter.h
+ * @brief              This is the header file for the %StlConverter class.
+ *
+ * This header file contains the declarations of the %StlConverter class.
+ */
+
+#ifndef _FBASE_COL_STL_CONVERTER_H_
+#define _FBASE_COL_STL_CONVERTER_H_
+
+#include <utility>
+#include <unique_ptr.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColLinkedList.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColMultiHashMap.h>
+#include <FBaseColIteratorT.h>
+#include <FBaseColPairIteratorT.h>
+#include <FBaseColRandomIteratorT.h>
+#include <FBaseColTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+class IMap;
+class IMultiMap;
+
+/**
+ *     @class  StlConverter
+ *     @brief  This class provides static methods to convert Tizen Collection to STL Container and vice versa.
+ *
+ *     @since  2.1
+ *
+ *     This %StlConverter class provides static methods to convert Tizen Collection to STL Container and vice versa.
+ *     The following example demonstrates how to use the %StlConverter class.
+ *
+ *     @code
+ *     #include <vector>
+ *     #include <FBase.h>
+ *     #include <FBaseCol.h>
+ *
+ *     using namespace std;
+ *     using namespace Tizen::Base;
+ *     using namespace Tizen::Base::Collection;
+ *
+ *     void
+ *     MyClass::StlConverterSample
+ *     {
+ *             // The case of Collection to STL Container
+ *             IList* pList1 = someNativeObject.GetSomeIntegerListN();
+ *
+ *             // vector may be created through IteratorT
+ *             vector< Integer* > vec1(
+ *                     StlConverter::GetBeginIterator< Integer* >(pList1),
+ *                     StlConverter::GetEndIterator< Integer* >(pList1));
+ *
+ *             // vec1 can be used here.
+ *
+ *             // The case of STL Container to Collection
+ *             vector< Integer* > vec2;
+ *
+ *             vec2.push_back(new Integer(1));
+ *             vec2.push_back(new Integer(2));
+ *             vec2.push_back(new Integer(3));
+ *
+ *             unique_ptr< ArrayList > pList2(StlConverter::GetArrayListN(vec2.begin(), vec2.end(), SingleObjectDeleter));
+ *
+ *             // call SomeNativeAPI(pList2.get());
+ *     }
+ *     @endcode
+ */
+
+class StlConverter
+{
+public:
+       /**
+        * Gets the STL compatible iterator referring to the first element in the IList instance.
+        *
+        * @since               2.1
+        *
+        * @return              An IteratorT instance
+        * @param[in]   pList                   A pointer to the IList instance to convert
+        */
+       template < typename T >
+       static IteratorT< T > GetBeginIterator(const IList* pList)
+       {
+               return IteratorT< T >(*pList);
+       }
+
+       /**
+        * Gets the STL compatible iterator referring to the post-end element in the IList instance.
+        *
+        * @since               2.1
+        *
+        * @return              An IteratorT instance
+        * @param[in]   pList                   A pointer to the IList instance to convert
+        */
+       template < typename T >
+       static IteratorT< T > GetEndIterator(const IList* pList)
+       {
+               return IteratorT< T >(*pList, true);
+       }
+
+       /**
+        * Gets the STL compatible random iterator referring to the first element in the IList instance.
+        *
+        * @since               2.1
+        *
+        * @return              A RandomIteratorT instance
+        * @param[in]   pList                   A pointer to the IList instance to convert
+        */
+       template < typename T >
+       static RandomIteratorT< T > GetBeginRandomIterator(const IList* pList)
+       {
+               return RandomIteratorT< T >(*pList, 0);
+       }
+
+       /**
+        * Gets the STL compatible random iterator referring to the post-end element in the IList instance.
+        *
+        * @since               2.1
+        *
+        * @return              A RandomIteratorT instance
+        * @param[in]   pList                   A pointer to the IList instance to convert
+        */
+       template < typename T >
+       static RandomIteratorT< T > GetEndRandomIterator(const IList* pList)
+       {
+               return RandomIteratorT< T >(*pList, pList->GetCount());
+       }
+
+       /**
+        * Gets the STL compatible iterator referring to the first element in the IMap instance.
+        * This iterator can be used in algorithms which requires paired iterator.
+        *
+        * @since               2.1
+        *
+        * @return              A PairIteratorT instance
+        * @param[in]   pMap            A pointer to the IMap instance to convert
+        */
+       template < typename K, typename V >
+       static PairIteratorT< K, V > GetBeginPairIterator(const IMap* pMap)
+       {
+               return PairIteratorT< K, V >(*pMap);
+       }
+
+       /**
+        * Gets the STL compatible iterator referring to the post-end element in the IMap instance.
+        * This iterator can be used in algorithms which requires paired iterator.
+        *
+        * @since               2.1
+        *
+        * @return              A PairIteratorT instance
+        * @param[in]   pMap            A pointer to the IMap instance to convert
+        */
+       template < typename K, typename V >
+       static PairIteratorT< K, V > GetEndPairIterator(const IMap* pMap)
+       {
+               return PairIteratorT< K, V >(*pMap, true);
+       }
+
+       /**
+        * Gets the STL compatible iterator referring to the first element in the IMultiMap instance.
+        * This iterator can be used in algorithms which requires paired iterator.
+        *
+        * @since               2.1
+        *
+        * @return              A PairIteratorT instance
+        * @param[in]   pMultiMap       A pointer to the IMultiMap instance to convert
+        */
+       template < typename K, typename V >
+       static PairIteratorT< K, V > GetBeginPairIterator(const IMultiMap* pMultiMap)
+       {
+               return PairIteratorT< K, V >(*pMultiMap);
+       }
+
+       /**
+        * Gets the STL compatible iterator referring to the post-end element in the IMultiMap instance.
+        * This iterator can be used in algorithms which requires paired iterator.
+        *
+        * @since               2.1
+        *
+        * @return              A PairIteratorT instance
+        * @param[in]   pMultiMap       A pointer to the IMultiMap instance to convert
+        */
+       template < typename K, typename V >
+       static PairIteratorT< K, V > GetEndPairIterator(const IMultiMap* pMultiMap)
+       {
+               return PairIteratorT< K, V >(*pMultiMap, true);
+       }
+
+       /**
+        * Gets an ArrayList instance from the begin and end iterators of STL container.
+        *
+        * @since               2.1
+        *
+        * @return              A std::unique_ptr to the ArrayList instance, @n
+        *                              else @c std::unique_ptr< ArrayList >() if error occurs
+        * @param[in]   begin           begin() of STL container
+        * @param[in]   end                     end() of STL container
+        * @param[in]   deleter         The function pointer to type of the element deleter
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   A specified input parameter is invalid.
+        * @remarks             To create an owing collection, set the element deleter value as @c SingleObjectDeleter.
+        *                              This gives the collection the ownership of elements and the collection will destroy elements. @n
+        *                              On the other hand, to create a non-owning collection, you don't need to set the element deleter value,
+        *                              as @c NoOpDeleter is the default element deleter.
+        *                              It means that you don't transfer the ownership of elements to the collection.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        * @see                 NoOpDeleter()
+        * @see                 SingleObjectDeleter()
+        * @see                 ArrayDeleter()
+        */
+       template < typename FwdIter >
+       static std::unique_ptr< ArrayList > GetArrayListN(FwdIter begin, FwdIter end, DeleterFunctionType deleter = NoOpDeleter)
+       {
+               std::unique_ptr< ArrayList > pArrayList(new (std::nothrow) ArrayList(deleter));
+               TryReturnResult(pArrayList, std::unique_ptr< ArrayList >(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pArrayList->Construct();
+               TryReturnResult(r == E_SUCCESS, std::unique_ptr< ArrayList >(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               for (FwdIter iter = begin; iter != end; ++iter)
+               {
+                       r = pArrayList->Add(*iter);
+                       if (IsFailed(r))
+                       {
+                               pArrayList->RemoveAll(false);
+                               TryReturnResult(false, std::unique_ptr< ArrayList >(), r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+
+               return std::move(pArrayList);
+       }
+
+       /**
+        * Gets a LinkedList instance from the begin and end iterators of STL container.
+        *
+        * @since               2.1
+        *
+        * @return              A std::unique_ptr to the LinkedList instance @n
+        *                              else @c std::unique_ptr< LinkedList >() if error occurs
+        * @param[in]   begin           begin() of STL container
+        * @param[in]   end                     end() of STL container
+        * @param[in]   deleter         The function pointer to type of the element deleter
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   A specified input parameter is invalid.
+        * @remarks             To create an owing collection, set the element deleter value as @c SingleObjectDeleter.
+        *                              This gives the collection the ownership of elements and the collection will destroy elements. @n
+        *                              On the other hand, to create a non-owning collection, you don't need to set the element deleter value,
+        *                              as @c NoOpDeleter is the default element deleter.
+        *                              It means that you don't transfer the ownership of elements to the collection.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        * @see                 NoOpDeleter()
+        * @see                 SingleObjectDeleter()
+        * @see                 ArrayDeleter()
+        */
+       template < typename FwdIter >
+       static std::unique_ptr< LinkedList > GetLinkedListN(FwdIter begin, FwdIter end, DeleterFunctionType deleter = NoOpDeleter)
+       {
+               std::unique_ptr< LinkedList > pLinkedList(new (std::nothrow) LinkedList(deleter));
+               TryReturnResult(pLinkedList, std::unique_ptr< LinkedList >(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               for (FwdIter iter = begin; iter != end; ++iter)
+               {
+                       result r = pLinkedList->Add(*iter);
+                       if (IsFailed(r))
+                       {
+                               pLinkedList->RemoveAll(false);
+                               TryReturnResult(false, std::unique_ptr< LinkedList >(), r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+
+               return std::move(pLinkedList);
+       }
+
+       /**
+        * Gets a HashMap instance from the begin and end iterators of STL container.
+        *
+        * @since               2.1
+        *
+        * @return              A std::unique_ptr to the HashMap instance @n
+        *                              else @c std::unique_ptr< HashMap >() if error occurs
+        * @param[in]   begin           begin() of STL container
+        * @param[in]   end                     end() of STL container
+        * @param[in]   deleter         The function pointer to type of the element deleter
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   A specified input parameter is invalid.
+        * @remarks             To create an owing collection, set the element deleter value as @c SingleObjectDeleter.
+        *                              This gives the collection the ownership of elements and the collection will destroy elements. @n
+        *                              On the other hand, to create a non-owning collection, you don't need to set the element deleter value,
+        *                              as @c NoOpDeleter is the default element deleter.
+        *                              It means that you don't transfer the ownership of elements to the collection.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        * @see                 NoOpDeleter()
+        * @see                 SingleObjectDeleter()
+        * @see                 ArrayDeleter()
+        */
+       template < typename PairedFwdIter >
+       static std::unique_ptr< HashMap > GetHashMapN(PairedFwdIter begin, PairedFwdIter end, DeleterFunctionType deleter = NoOpDeleter)
+       {
+               std::unique_ptr< HashMap > pMap(new (std::nothrow) HashMap(deleter));
+               TryReturnResult(pMap, std::unique_ptr< HashMap >(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pMap->Construct();
+               TryReturnResult(r == E_SUCCESS, std::unique_ptr< HashMap >(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               for (PairedFwdIter pairIter = begin; pairIter != end; ++pairIter)
+               {
+                       r = pMap->Add(pairIter->first, pairIter->second);
+                       if (IsFailed(r))
+                       {
+                               pMap->RemoveAll(false);
+                               TryReturnResult(false, std::unique_ptr< HashMap >(), r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+
+               return std::move(pMap);
+       }
+
+       /**
+        * Gets a MultiHashMap instance from the begin and end iterators of STL container.
+        *
+        * @since               2.1
+        *
+        * @return              A std::unique_ptr to the MultiHashMap instance @n
+        *                              else @c std::unique_ptr< MultiHashMap >() if error occurs
+        * @param[in]   begin           begin() of STL container
+        * @param[in]   end                     end() of STL container
+        * @param[in]   deleter         The function pointer to type of the element deleter
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   A specified input parameter is invalid.
+        * @remarks             To create an owing collection, set the element deleter value as @c SingleObjectDeleter.
+        *                              This gives the collection the ownership of elements and the collection will destroy elements. @n
+        *                              On the other hand, to create a non-owning collection, you don't need to set the element deleter value,
+        *                              as @c NoOpDeleter is the default element deleter.
+        *                              It means that you don't transfer the ownership of elements to the collection.
+        * @remarks             The specific error code can be accessed using GetLastResult() method.
+        * @see                 NoOpDeleter()
+        * @see                 SingleObjectDeleter()
+        * @see                 ArrayDeleter()
+        */
+       template < typename PairedFwdIter >
+       static std::unique_ptr< MultiHashMap > GetMultiHashMapN(PairedFwdIter begin, PairedFwdIter end, DeleterFunctionType deleter = NoOpDeleter)
+       {
+               std::unique_ptr< MultiHashMap > pMultiMap(new (std::nothrow) MultiHashMap(deleter));
+               TryReturnResult(pMultiMap, std::unique_ptr< MultiHashMap >(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pMultiMap->Construct();
+               TryReturnResult(r == E_SUCCESS, std::unique_ptr< MultiHashMap >(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               for (PairedFwdIter pairIter = begin; pairIter != end; ++pairIter)
+               {
+                       r = pMultiMap->Add(pairIter->first, pairIter->second);
+                       if (IsFailed(r))
+                       {
+                               pMultiMap->RemoveAll(false);
+                               TryReturnResult(false, std::unique_ptr< MultiHashMap >(), r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+
+               return std::move(pMultiMap);
+       }
+
+private:
+       //
+       // This default constructor is intentionally declared as private because this class is not constructible.
+       //
+       // @since               2.1
+       //
+       StlConverter(void);
+
+       //
+       // This destructor is intentionally declared as private because this class is not constructible.
+       //
+       // @since               2.1
+       //
+       virtual ~StlConverter(void);
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       //
+       // @param[in]   rhs             A reference to the %StlConverter instance
+       //
+       StlConverter(const StlConverter& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       //
+       // @return              A reference to the %StlConverter instance
+       // @param[in]   rhs             A reference to the %StlConverter instance
+       //
+       StlConverter& operator=(const StlConverter& rhs);
+};
+
+}}} // Tizen::Base::Collection
+
+#endif //_FBASE_COL_STL_CONVERTER_H_
index 596e25d..3450165 100644 (file)
@@ -41,7 +41,7 @@ namespace Tizen { namespace Base
  *
  * The following example demonstrates how to use the %ComparerT class.
  *
- *     @code
+ * @code
  *
  *     #include <FBase.h>
  *
@@ -62,7 +62,7 @@ namespace Tizen { namespace Base
  *                     // ...
  *             }
  *     }
- *     @endcode
+ * @endcode
  */
 template<class Type>
 class ComparerT
@@ -75,7 +75,7 @@ public:
         *
         * @since 2.0
         */
-       ComparerT(void) {}
+       ComparerT(void) { }
 
 
        /**
@@ -122,17 +122,65 @@ public:
        }
 
 private:
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       ComparerT(const ComparerT& obj);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       ComparerT& operator =(const ComparerT& rhs);
+
+}; // ComparerT
+
+template<>
+class ComparerT <Tizen::Base::String>
+       : public virtual Tizen::Base::Collection::IComparerT <Tizen::Base::String>
+       , public Object
+{
+public:
        /**
-        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        * This constructor initializes a new instance of the %ComparerT class.
+        *
+        * @since 2.1
         */
-       ComparerT(const ComparerT& obj);
+       ComparerT(void) { }
 
        /**
-        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.1
         */
+       virtual ~ComparerT(void) { }
+
+       /**
+        * Compare two String instance
+        *
+        * @since 2.1
+        *
+        * @return       Always returns E_SUCCESS
+        * @param[in]    str1     String instance to compare
+        * @param[in]    str2     String instance to compare
+        * @param[in]    cmp      Integer value for result
+        */
+       virtual result Compare(const Tizen::Base::String& str1, const Tizen::Base::String& str2, int& cmp) const
+       {
+               cmp = String::Compare(str1, str2);
+               return E_SUCCESS;
+       }
+private:
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       ComparerT(const ComparerT& obj);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
        ComparerT& operator =(const ComparerT& rhs);
 
-}; // ComparerT
+}; // ComparerT <Tizen::Base::String>
 
 }} // Tizen::Base
 
index 9675d18..4f7fdf7 100644 (file)
@@ -38,8 +38,8 @@ namespace Tizen { namespace Base
  *
  *     @since 2.0
  *
- *     The %DateTime class represents dates and times with values ranging from 12:00:00 midnight,
- *     January 1, 1 to 11:59:59 P.M., December 31, 9999 in the Gregorian calendar. It
+ *     The %DateTime class represents dates and times with values ranging from 12:00:00.000 midnight,
+ *     January 1, 1 to 11:59:59.999 P.M., December 31, 9999 in the Gregorian calendar. It
  *     provides methods for conversion between the time formats.
  *
  *     For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/datetime_timespan.htm">DateTime and TimeSpan</a>.
@@ -51,7 +51,7 @@ namespace Tizen { namespace Base
  *     #include <FBase.h>
  *
  *     using namespace Tizen::Base;
- *     
+ *
  *     // This method sets both current local time and UTC time.
  *     void
  *     MyClass::DateTimeSample(void)
@@ -138,13 +138,52 @@ public:
         *      @exception      E_SUCCESS                       The method is successful.
         *      @exception      E_OUT_OF_RANGE          The value of the argument is outside the valid range defined by the method. @n
         *                                                                       Either the arguments are greater than the value returned by GetMaxValue() or
-        *                                                                      are less than the value returned by GetMinValue(), or 
+        *                                                                      are less than the value returned by GetMinValue(), or
         *                                                                       the arguments contain invalid values.
         *                                                                      For example, day is 31 when month is 2.
         */
        result SetValue(int year, int month, int day, int hour = 0, int minute = 0, int second = 0);
 
        /**
+        *      Sets the current instance of %DateTime to the specified year, month, day, hour, minute, second and millisecond.
+        *
+        *      @since 2.1
+        *
+        *      @return                 An error code
+        *      @param[in]      year                            The year to set
+        *      @param[in]      month                           The month to set
+        *      @param[in]      day                                     The day to set
+        *      @param[in]      hour                            The hour to set
+        *      @param[in]      minute                          The minute set
+        *      @param[in]      second                          The second to set
+        *      @param[in]      millisecond                     The millisecond to set
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_OUT_OF_RANGE          The value of the argument is outside the valid range defined by the method. @n
+        *                                                                       Either the arguments are greater than the value returned by GetMaxValue() or
+        *                                                                      are less than the value returned by GetMinValue(), or
+        *                                                                       the arguments contain invalid values.
+        *                                                                      For example, day is 31 when month is 2.
+        */
+       result SetValue(int year, int month, int day, int hour, int minute, int second, int millisecond);
+
+       /**
+        *      Sets the current instance of %DateTime with the specified number of ticks.
+        *      The tick value represents dates and times with long long type ranging from January 1, 1 A.D. 00:00:00.000 am.
+        *
+        *      @since  2.1
+        *
+        *      @return                 An error code
+        *      @param[in]      ticks   The number of ticks (in milliseconds)
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_OUT_OF_RANGE          The value of the argument is outside the valid range defined by the method.
+        *                                                                       Either the arguments are greater than the value returned by GetMaxValue() or
+        *                                                                      are less than the value returned by GetMinValue(), or
+        *                                                                       the arguments contain invalid values.
+        *                                                                      For example, day is 31 when month is 2.
+        */
+       result SetValue(long long ticks);
+
+       /**
         *      Copying of objects using this copy assignment operator is allowed.
         *
         *      @since 2.0
@@ -305,6 +344,34 @@ public:
        result AddSeconds(int seconds);
 
        /**
+        *      Adds the specified number of milliseconds to the instance of %DateTime.
+        *
+        *      @since 2.1
+        *
+        *      @return An error code
+        *      @param[in]      milliseconds            The number of milliseconds to add
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_OUT_OF_RANGE          The value of the argument is outside the valid range defined by the method. @n
+        *                                                                      The resulting value of %DateTime is greater than the value returned by GetMaxValue() or @n
+        *                                                                      is less than the value returned by GetMinValue().
+        */
+       result AddMilliseconds(long long milliseconds);
+
+       /**
+        *      Adds the specified number of ticks to the instance of %DateTime.
+        *
+        *      @since 2.1
+        *
+        *      @return An error code
+        *      @param[in]      ticks                           The number of ticks to add
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_OUT_OF_RANGE          The value of the argument is outside the valid range defined by the method. @n
+        *                                                                      The resulting value of %DateTime is greater than the value returned by GetMaxValue() or @n
+        *                                                                      is less than the value returned by GetMinValue().
+        */
+       result AddTicks(long long ticks);
+
+       /**
         *      Adds the specified number of years to the instance of %DateTime.
         *
         *      @since 2.0
@@ -438,7 +505,7 @@ public:
         *                                                                          or is less than the value returned by GetMinValue(). @n
         *                                                                           2) The specified string contains an invalid value.
         *                                                                          For example, day is 31 when the month is 2.
-        * @remarks             The format of the string is "mm/dd/yyyy hh:mm:ss".
+        * @remarks             The format of the string is "mm/dd/yyyy hh:mm:ss.mmm".
         */
        static result Parse(const String& str, DateTime& dt);
 
@@ -497,6 +564,34 @@ public:
        int GetSecond(void) const;
 
        /**
+        *      Gets the millisecond of the current instance of %DateTime.
+        *
+        *      @since  2.1
+        *
+        *      @return         An integer value indicating the millisecond of the current instance of %DateTime
+        */
+       int GetMillisecond(void) const;
+
+       /**
+        *      Gets the number of ticks in 1 second.
+        *
+        *      @since  2.1
+        *
+        *      @return         The number of ticks in 1 second.
+        */
+       static int GetTicksPerSecond(void);
+
+       /**
+        *      Gets the tick of the current instance of %DateTime.
+        *      The tick value represents dates and times with long long ranging from January 1, 1 A.D. 00:00:00.000 am.
+        *
+        *      @since  2.1
+        *
+        *      @return         An long long value indicating the tick of the current instance of %DateTime
+        */
+       long long GetTicks(void) const;
+
+       /**
         *      Gets the number of milliseconds (in TimeSpan) since the minimum date (GetMinValue()).
         *
         *      @since 2.0
@@ -507,7 +602,7 @@ public:
        TimeSpan GetTime(void) const;
 
        /**
-        *      Gets the maximum allowable value of %DateTime (that is, "December 31 9999 23:59:59").
+        *      Gets the maximum allowable value of %DateTime (that is, "December 31 9999 23:59:59.999").
         *
         *      @since 2.0
         *
@@ -516,7 +611,7 @@ public:
        static const DateTime& GetMaxValue(void);
 
        /**
-        *      Gets the minimum allowable value of %DateTime (that is, "January 1 1 00:00:00").
+        *      Gets the minimum allowable value of %DateTime (that is, "January 1 1 00:00:00.000").
         *
         *      @since 2.0
         *
@@ -545,19 +640,18 @@ public:
         */
        static bool IsLeapYear(int year);
 
-
 private:
-       DateTime(int year, int month, int day, int hour, int minute, int second);
+       DateTime(int year, int month, int day, int hour, int minute, int second, int tick);
 
        int CountLeapYear(int year) const
        {
-               return (int) ((year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400);
+               return static_cast< int >((year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400);
 
        }
 
        int CountDays(int year) const
        {
-               return (int) ((year - 1) * 365 + CountLeapYear(year));
+               return static_cast< int >((year - 1) * 365 + CountLeapYear(year));
        }
 
        int CountYears(int day) const
@@ -572,26 +666,47 @@ private:
                }
                else
                {
-                       return(year != (int) year ? 1 + (int) year : (int) year);
+                       year = (year != static_cast< int >(year) ? 1 + static_cast< int >(year) : static_cast< int >(year));
+                       int tempDays = day - CountDays(year);
+
+                       // Check the boundary of days
+                       if (IsLeapYear(year))
+                       {
+                               if (tempDays > 366)
+                               {
+                                       year += 1;
+                               }
+                       }
+                       else
+                       {
+                               if (tempDays > 365)
+                               {
+                                       year += 1;
+                               }
+                       }
+
+                       return year;
                }
        }
 
        typedef struct
        {
-               int year;       /**<The year (1 ~ 9999)*/
-               int month;      /**<The month (-12)*/
+               int year;       /**<The year (1-9999)*/
+               int month;      /**<The month (1-12)*/
                int day;        /**<The day (1-31)*/
                int hour;       /**<The hour (0-23)*/
                int minute;     /**<The minute (0-59)*/
-               int second;     /**<The second (0-59)*/
+               int second;     /**<The first 16 bits store tick (0-999) and the last 16 bits store second (0-59)*/
        } TmDateTime;
 
+       result ConvertTicksToDate(long long ticks, TmDateTime* pDateTime);
+       long long ConvertDateToTicks(const TmDateTime* pDateTime) const;
+
        result ConvertSecondsToDate(long long seconds, TmDateTime* pDateTime);
        long long ConvertDateToSeconds(const TmDateTime* pDateTime) const;
 
        TmDateTime __dateTime;
 
-
        friend class _DateTimeImpl;
        class _DateTimeImpl * __pDateTimeImpl;
 
@@ -600,3 +715,4 @@ private:
 }}  // Tizen::Base
 
 #endif // _FBASE_DATE_TIME_H_
+
index 86ac53e..ea38b49 100644 (file)
@@ -6,7 +6,7 @@
 // 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
+//     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,
@@ -78,6 +78,9 @@
 /** The server certificate verification has failed. */
 #define E_CERTIFICATE_VERIFICATION_FAILED      (ERR_SRC_FRAMEWORK + SET_E_CAUSE(1305))
 
+/** Thrown when the context data is not available. */
+#define E_CONTEXT_UNAVAILABLE           (ERR_SRC_FRAMEWORK + SET_E_CAUSE(1306))
+
 //----------------------------------------------------------------------------D
 /** Thrown when the requested data does not exist. */
 #define E_DATA_NOT_FOUND                (ERR_SRC_FRAMEWORK + SET_E_CAUSE(1400))
 /** Thrown when the right is for future use. */
 #define E_RIGHT_FUTURE_USE                     (ERR_SRC_FRAMEWORK + SET_E_CAUSE(2807))
 
-
 //----------------------------------------------------------------------------S
 /** Thrown when the specified section already exists. */
 #define E_SECTION_ALREADY_EXIST         (ERR_SRC_FRAMEWORK + SET_E_CAUSE(2900))
  * completed immediately. */
 #define E_WOULD_BLOCK                   (ERR_SRC_FRAMEWORK + SET_E_CAUSE(3300))
 
+/** Thrown when the specified object would cause a deadlock. */
+#define E_WOULD_DEADLOCK                (ERR_SRC_FRAMEWORK + SET_E_CAUSE(3301))
+
+
 //----------------------------------------------------------------------------X
 
 //----------------------------------------------------------------------------Y
index 33b7585..dce4a69 100644 (file)
@@ -448,6 +448,28 @@ extern "C" {
        else {;}
 
 /**
+* If the condition is @c false, it prints a message, sets the last result, evaluates a cleanup expression
+* and goes to label.
+*
+* @since 2.1
+*
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    expr                   Expressions that are evaluated before going to catchLabel
+* @param[in]    catchLabel             The label for goto operation
+* @param[in]    r                      The last result to set
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryCatchLabelResult(condition, expr, catchLabel, r, ...) \
+       if (!(condition)) { \
+               SetLastResult(r); \
+               AppLogException(__VA_ARGS__); \
+               expr; \
+               goto catchLabel;        \
+       } \
+       else {;}
+
+/**
  * If the condition is @c false, the message is printed and a value is returned.
  *
  * @since 2.0
@@ -532,6 +554,22 @@ extern "C" {
        } \
        else {;}
 
+/**
+* If the condition is @c false, the informative log message is printed and a value is returned.
+*
+* @since 2.1
+*
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    returnValue            The value to return when the condition is @c false
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryLogReturn(condition, returnValue, ...) \
+       if (!(condition)) { \
+               AppLog(__VA_ARGS__); \
+               return returnValue;     \
+       } \
+       else {;}
 
 // TryTag Macros
 
@@ -578,6 +616,29 @@ extern "C" {
        else {;}
 
 /**
+* If the condition is @c false, it prints a message with a tag, sets the last result, evaluates a cleanup expression
+* and goes to label.
+*
+* @since 2.1
+*
+* @param[in]    tag                    Used to identify the source of a log message
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    expr                   Expressions that are evaluated before going to catchLabel
+* @param[in]    catchLabel             The label for goto operation
+* @param[in]    r                      The last result to set
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryCatchLabelResultTag(tag, condition, expr, catchLabel, r, ...) \
+       if (!(condition)) { \
+               SetLastResult(r); \
+               AppLogExceptionTag(tag, __VA_ARGS__); \
+               expr; \
+               goto catchLabel;        \
+       } \
+       else {;}
+
+/**
  * If the condition is @c false, the message is printed with a tag and a value is returned.
  *
  * @since 2.0
@@ -667,6 +728,148 @@ extern "C" {
        } \
        else {;}
 
+/**
+* If the condition is @c false, the informative log message is printed with a tag and a value is returned.
+*
+* @since 2.1
+*
+* @param[in]    tag                    Used to identify the source of a log message
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    returnValue            The value to return when the condition is @c false
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryLogReturnTag(tag, condition, returnValue, ...) \
+       if (!(condition)) { \
+               AppLogTag(tag, __VA_ARGS__); \
+               return returnValue;     \
+       } \
+       else {;}
+
+/** @} */
+
+
+// Secure Macros
+/**
+ * @addtogroup  GroupMacros
+ *
+ * @{
+ */
+#if (defined(_APP_LOG) || defined(_OSP_DEBUG_) || defined(_DEBUG)) && defined(_SECURE_LOG)
+
+#define AppSecureLog(...)                      AppLogInternal(__PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+#define AppSecureLogException(...)             AppLogExceptionInternal(__PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+
+#define AppSecureLogTag(tag, ...)              AppLogTagInternal(tag, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+#define AppSecureLogExceptionTag(tag, ...)     AppLogExceptionTagInternal(tag, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+
+#else
+/**
+* This macro is to protect informative log messages which needs to keep security.
+* It allows display of informative log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLog macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           AppSecureLog("User ID : 'JoneDoe'");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLog(...)
+
+/**
+* This macro is to protect exception log messages which needs to keep security.
+* It allows display of exception log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLogException macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           //...
+*           if (something_wrong)
+*           {
+*              AppSecureLogException("User ID : 'JoneDoe' mismatch.");
+*
+*              return false;
+*           }
+*   //...
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLogException(...)
+
+/**
+* This macro is to protect informative log messages which needs to keep security, with a tag.
+* It allows display of informative log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   tag                     The user defined tag
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLogTag macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           AppSecureLogTag("MyTag", "User ID : 'JoneDoe'");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLogTag(tag, ...)
+
+/**
+* This macro is to protect exception log messages which needs to keep security, with a tag.
+* It allows display of exception log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   tag                     The user defined tag
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLogExceptionTag macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           AppSecureLogExceptionTag("MyTag", "User ID : 'JoneDoe' mismatch.");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLogExceptionTag(tag, ...)
+
+#endif
 /** @} */
 
 _OSP_EXPORT_ void AppLogInternal(const char* pFunction, int lineNumber, const char* pFormat, ...);
index 8fe692b..a403b7b 100644 (file)
@@ -279,7 +279,7 @@ public:
         *      Parses the specified string representing a numeric value using the specified radix and
         *      returns the value as a @c signed @c long @c long (as out parameter).
         *
-        *      @since                  2.0
+        *      @since                  2.1
         *
         *  @return                     An error code
         *  @param[in]  s                               A string representing a numeric value
@@ -288,7 +288,7 @@ public:
         *  @param[out] ret                             The result of the operation
         *  @exception  E_SUCCESS               The method is successful.
         *  @exception  E_NUM_FORMAT    The specified string does not contain a number that can be parsed.
-        *  @excpetion  E_OUT_OF_RANGE  The specified @c radix is invalid.
+        *  @exception  E_OUT_OF_RANGE  The specified @c radix is invalid.
         */
        static result Parse(const String& s, int radix, long long& ret);
 
index c58e632..84770cd 100755 (executable)
@@ -54,4 +54,4 @@ public:
 
 } } } // Tizen::Runtime
 
-#endif // _FBASE_RT_WAITING_LOOP_CONDITION_H_
+#endif // _FBASE_RT_I_WAITING_LOOP_CONDITION_H_
old mode 100644 (file)
new mode 100755 (executable)
index 3f6b8d0..7d8590c
@@ -336,7 +336,8 @@ public:
         * @exception   E_SUCCESS       The method is successful.
         * @exception   E_SYSTEM        A system error has occurred.
         * @remarks             This method should be called only after acquiring lock by Enter() call
-        * @see                 Notify(), NotifyAll()
+        * @see                 Notify()
+        * @see                 NotifyAll()
         */
        result Wait(void);
 
@@ -349,7 +350,8 @@ public:
         * @return              An error code
         * @exception   E_SUCCESS       The method is successful.
         * @exception   E_SYSTEM        A system error has occurred.
-        * @see                 NotifyAll(), Wait()
+        * @see                 NotifyAll()
+        * @see                 Wait()
         */
        result Notify(void);
 
@@ -362,7 +364,8 @@ public:
         * @return              An error code
         * @exception   E_SUCCESS       The method is successful.
         * @exception   E_SYSTEM        A system error has occurred.
-        * @see                 Notify(), Wait()
+        * @see                 Notify()
+        * @see                 Wait()
         */
        result NotifyAll(void);
 
old mode 100644 (file)
new mode 100755 (executable)
index 843761a..7fee0be
 
 namespace Tizen { namespace Base { namespace Runtime
 {
+/**
+ * @struct     NonRecursiveMutexTag
+ *
+ * This struct is used only for providing the non-recursive type of mutex.
+ * A non-recursive mutex is a mutex that can not be acquired multiple times by the locking thread. It returns an exception if the locking thread tries to lock the same mutex.
+ *
+ * @since 2.1
+ *
+ * @see                Mutex
+ */
+ struct NonRecursiveMutexTag
+ {
+ };
+
+/**
+ * This is a constant instance of NonRecursiveMutexTag.
+ *
+ * @code
+ * Mutex m;
+ * result r = m.Create(NonRecursiveMutex); 
+ * @endcode
+ */
+ static const NonRecursiveMutexTag NonRecursiveMutex = {};
 
 /**
  *  @class Mutex
@@ -45,7 +68,8 @@ namespace Tizen { namespace Base { namespace Runtime
  *
  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/mutex_and_semaphore.htm">Mutex and Semaphore</a>.
  *
- *     @see Semaphore, Thread
+ *     @see Semaphore
+ *     @see Thread
  *
  * The following example demonstrates how to use the %Mutex class.
  *
@@ -111,7 +135,8 @@ public:
        virtual ~Mutex(void);
 
        /**
-        *      Creates an unnamed mutex.
+        *      Creates an unnamed mutex which is a recursive mutex that can be acquired multiple times by the locking thread. 
+        *     It keeps the number of getting locked and you must unlock it the same number of times.
         *
         *      @since 2.0
         *
@@ -123,7 +148,19 @@ public:
        result Create(void);
 
        /**
-        *      Creates a named mutex. @n
+        *      Creates a non-recursive mutex.
+        *
+        *      @since 2.1
+        *
+        *      @return                 An error code
+        *      @exception      E_SUCCESS               The method is successful.
+        *      @exception      E_SYSTEM                A system error has occurred.
+        */
+       result Create(NonRecursiveMutexTag);
+
+       /**
+        *      Creates a named mutex which is a recursive mutex that can be acquired multiple times by the locking thread. 
+        *     It keeps the number of getting locked and you must unlock it the same number of times. @n
         *      If a mutex with the specified name already exists, this creates a mutex which references that particular mutex.
         *
         *      @since 2.0
index dd15295..0f82436 100644 (file)
@@ -156,7 +156,7 @@ public:
         * @since 2.0
         *
         * @if OSPCOMPACT
-         * @compatibility     This method has compatibility issues with OSP compatibile applications. @n
+         * @compatibility     This method has compatibility issues with Tizen API versions @b prior @b to @b 2.1. @n
          *                              For more information, see @ref CompTimerStartPage "here".
         * @endif
         *
@@ -174,11 +174,11 @@ public:
        /**
        * @page                    CompTimerStartPage Compatibility for Start(int timeout)
        * @section                 CompTimerStartPageIssueSection Issues
-       * Implementing this method in OSP compatible applications has the following issues:   @n
+       * Implementation of this method in Tizen API versions prior to 2.1 has the following issue: @n
        * -# The method returns E_INVALID_ARG if timeout is equal to zero.
        *
        * @section                 CompTimerStartPageSolutionSection Resolutions
-       * This issue has been resolved in Tizen.  @n 
+       * The issue mentioned above is resolved in Tizen API version 2.1, and it is recommended to use Tizen API version 2.1 or above.
        * -# In case of zero, Timer sets timeout to the best-effort minimum interval without returning E_INVALID_ARG.
        */
 
index 9c9b324..5233176 100644 (file)
@@ -53,7 +53,9 @@ enum TimerStatus
 *
 * @since 2.0
 *
-* @see         MutexGuard, SemaphoreGuard, Try
+* @see         MutexGuard
+* @see         SemaphoreGuard
+* @see         Try
 */
 struct TryTag
 {
index 5ec4eb5..e0f57aa 100755 (executable)
@@ -64,7 +64,8 @@ public:
         * @exception E_TIMEOUT    The time is expired.
         * @exception E_INVALID_STATE    The waiting loop has already been waiting on a callback event. In order to wait again, you must quit the waiting loop.
         * @remarks The timeout set to min(timeout, maximum), where the maximum is set using SetMaxTimeoutForWaiting().
-        * @see Notify(), SetMaxTimoutForWaiting()
+        * @see Notify()
+        * @see SetMaxTimoutForWaiting()
         */
        result Wait(int timeout);
 
diff --git a/inc/FBaseStringHashCodeProvider.h b/inc/FBaseStringHashCodeProvider.h
new file mode 100644 (file)
index 0000000..6dc3072
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FBaseStringHashCodeProvider.h
+ * @brief              This is the header file for the %StringHashCodeProvider class.
+ *
+ * This file contains declarations of the %StringHashCodeProvider class.
+ */
+#ifndef _FBASE_STRING_HASH_CODE_PROVIDER_H_
+#define _FBASE_STRING_HASH_CODE_PROVIDER_H_
+
+#include <FBaseObject.h>
+#include <FBaseColIHashCodeProvider.h>
+#include <FBaseColIHashCodeProviderT.h>
+
+namespace Tizen { namespace Base
+{
+/**
+ * @class      StringHashCodeProvider
+ * @brief      This is the header file for the %StringHashCodeProvider class.
+ *
+ * @since      2.1
+ *
+ * The %StringHashCodeProvider class provides the hash code of instance of the String type.
+ *
+ * The following example demonstrates how to use the %StringHashCodeProvider class.
+ *
+ * @code
+ *
+ *     #include <FBase.h>
+ *
+ *     using namespace Tizen::Base;
+ *     using namespace Tizen::Base::Collection;
+ *
+ *     void
+ *     MyClass::StringHashCodeProviderSample(void)
+ *     {
+ *             HashMapT<String, int> map;
+ *
+ *             ComparerT<String> comparer;
+ *             StringHashCodeProvider strHashCodeProvider;
+ *
+ *             map.Construct(0, 0, strHashCodeProvider, comparer);
+ *
+ *             map.Add(String(L"Zero"), 0);
+ *             map.Add(String(L"One"), 1);
+ *             map.Add(String(L"Two"), 2);
+ *
+ *             ...
+ *     }
+ * @endcode
+ */
+class _OSP_EXPORT_ StringHashCodeProvider
+       : public virtual Tizen::Base::Collection::IHashCodeProvider
+       , public virtual Tizen::Base::Collection::IHashCodeProviderT <Tizen::Base::String>
+       , public Tizen::Base::Object
+{
+public:
+       using Object::GetHashCode;
+
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.1
+        */
+       StringHashCodeProvider(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object()
+        *
+        * @since       2.1
+        */
+       virtual ~StringHashCodeProvider(void);
+
+       /**
+        * Gets the hash code of instance of the String type.
+        *
+        * @since       2.1
+        *
+        * @return              The hash code of instance of the String type
+        * @param[in]   str             The String instance whose hash code is requested
+        * @remarks             The hash algorithm is usually specific to a type.
+        *                              Two equal instances must return the same hash value.
+        *                              For better performance, the used hash function must generate a random distribution for all inputs.
+        */
+       virtual int GetHashCode(const Tizen::Base::String& str) const;
+
+       /**
+        * Gets the hash code of the specified object.
+        *
+        * @since       2.1
+        *
+        * @return              The hash code of the specified object
+        * @param[in]   obj             The Object whose hash code is requested
+        * @remarks             The hash algorithm is usually specific to a type.
+        *                              Two equal instances must return the same hash value.
+        *                              For better performance, the used hash function must generate a random distribution for all inputs.
+        */
+       virtual int GetHashCode(const Tizen::Base::Object& obj) const;
+
+private:
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       StringHashCodeProvider(const StringHashCodeProvider& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       StringHashCodeProvider& operator =(const StringHashCodeProvider& rhs);
+
+}; // StringHashCodeProvider
+
+}} // Tizen::Base
+
+#endif // _FBASE_STRING_HASH_CODE_PROVIDER_H_
index 762783a..e435ea9 100644 (file)
@@ -594,6 +594,133 @@ case condition: \
  */
 #define SysPropagate(NID, r)        SysPropagateInternal(__PRETTY_FUNCTION__, __LINE__, NID, r)
 
+// Secure Macros
+#if defined(_SECURE_LOG)
+
+#define SysSecureLog(NID, ...)                         SysLogInternal(NID, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+#define SysSecureLogException(NID, r,...)              SysLogExceptionInternal(NID, r, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+
+#define SysSecureLogTag(NID, tag, ...)                 SysLogTagInternal(NID, tag, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+#define SysSecureLogExceptionTag(NID, tag, r, ...)     SysLogExceptionTagInternal(NID, tag, r, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+
+#else
+
+/**
+* This macro is to protect informative log messages which needs to keep security.
+* It allows display of informative log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+* This system log macro is for the platform modules.
+*
+* @since 2.1
+*
+* @param[in]   NID                     The Tizen namespace ID
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the SysSecureLog macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           SysSecureLog(NID, "User ID : 'JoneDoe'");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define SysSecureLog(NID, ...)
+
+/**
+* This macro is to protect exception log messages which needs to keep security, and sets the last result.
+* It allows display of exception log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+* This system log macro is for the platform modules.
+*
+* @since 2.1
+*
+* @param[in]   NID                     The Tizen namespace ID
+* @param[in]   r                       The last result to set
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the SysSecureLogException macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           //...
+*           if (something_wrong)
+*           {
+*              SysSecureLogException(NID,  E_INVALID_ARG, "User ID : 'JoneDoe' mismatch.");
+*
+*              return false;
+*           }
+*   //...
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define SysSecureLogException(NID, r,...)
+
+/**
+* This macro is to protect informative log messages which needs to keep security, with a tag.
+* It allows display of informative log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+* This system log macro is for the platform modules.
+*
+* @since 2.1
+*
+* @param[in]   NID                     The Tizen namespace ID
+* @param[in]   tag                     The user defined tag
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the SysSecureLogTag macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           SysSecureLogTag(NID, "MyTag", "User ID : 'JoneDoe'");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define SysSecureLogTag(NID, tag, ...)
+
+/**
+* This macro is to protect exception log messages which needs to keep security, with a tag and sets the last result.
+* It allows display of exception log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+* This system log macro is for the platform modules.
+*
+* @since 2.1
+*
+* @param[in]   NID                     The Tizen namespace ID
+* @param[in]   tag                     The user defined tag
+* @param[in]   r                       The last result to set
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the SysSecureLogExceptionTag macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           SysSecureLogExceptionTag(NID, "MyTag", E_INVALID_ARG, "User ID : 'JoneDoe' mismatch.");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define SysSecureLogExceptionTag(NID, tag, r, ...)
+
+#endif
 
 /**
  * Defines the log ID.
index 1ac4782..d26ebef 100644 (file)
@@ -64,6 +64,9 @@
 // LinkInfo
 #include <FBaseUtilLinkInfo.h>
 
+//Scanner
+#include <FBaseUtilScanner.h>
+
 /**
  * @namespace          Tizen::Base::Utility
  * @brief                              This namespace contains classes for various utilities.
diff --git a/inc/FBaseUtilScanner.h b/inc/FBaseUtilScanner.h
new file mode 100644 (file)
index 0000000..456deb2
--- /dev/null
@@ -0,0 +1,626 @@
+//
+// 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       FBaseUtilScanner.h
+ * @brief      This is the header file for the %Scanner class.
+ *
+ * This header file contains declarations and definitions of the %Scanner class.
+ *
+ */
+
+#ifndef _FBASE_UTIL_SCANNER_H_
+#define _FBASE_UTIL_SCANNER_H_
+
+#include <FBaseString.h>
+#include <FBaseUtilRegularExpression.h>
+
+namespace Tizen { namespace Base { namespace Utility
+{
+/**
+ * @class      Scanner
+ * @brief      This class provides to parse primitive types and strings, and supports to use regular expressions and various encoding schemes.
+ * @since 2.1
+ *
+ * The %Scanner class breaks the input, which can be either a %String instance or strings from a file, into tokens using a delimiter.
+ * The delimiter is set by whitespace as a default value. The resulting tokens are converted into values of different types according
+ * to the methods in %Scanner.
+ *
+ * The following example demonstrates how to use the %Scanner class.
+ * @code
+ *
+ *     String str = L"1 12 34.5 58 false";
+ *     Scanner scan;
+ *     bool ret = false;
+ *
+ *     scan.Construct(str);
+ *
+ *     ret = scan.IsNextTokenConvertibleToSignedChar();        //ret true
+ *     signed char val;
+ *  scan.GetNextSignedChar(val);       //val 1
+ *
+ *     ret = scan.IsNextTokenConvertibleToShort(10);   //ret true
+ *     short shortVal;
+ *  scan.GetNextShort(shortVal);       //shortVal 12
+ *
+ *     ret = scan.IsNextTokenConvertibleToInt(10);     //ret false
+ *     ret = scan.IsNextTokenConvertibleToFloat();     //ret true
+ *     float floatVal;
+ *  scan.GetNextFloat(floatVal);       //floatVal 34.5
+ *
+ *     ret = scan.IsNextTokenConvertibleToInt(16);     //ret true
+ *     int intVal;
+ *  scan.GetNextInt(intVal, 16);       //intVal 88
+ *
+ *     ret = scan.IsNextTokenConvertibleToBool();      //ret true
+ *     scan.GetNextBool(ret);  //ret false
+ *
+ * @endcode
+ */
+class _OSP_EXPORT_ Scanner
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+       * The object is not fully constructed after this constructor is called. @n
+       * For full construction, the Construct() method must be called right after calling this constructor.
+       *
+       * @since 2.1
+       */
+       Scanner(void);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since 2.1
+       */
+       virtual ~Scanner(void);
+
+       /**
+       * Initializes the current instance of %Scanner with the specified instance of string.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[in]    inputStr       The string to scan.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_INVALID_ARG  The length of the specified @c string parameter is @c 0.
+       */
+       result Construct(const String& inputStr);
+
+       /**
+       * Initializes the current instance of %Scanner with a file which includes the strings being scanned.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[in]    inputFilePath  The file to be read to construct input data
+       * @param[in]    encodingScheme The encoding type of the file.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_FILE_NOT_FOUND        The input file does not exist.
+       * @exception    E_IO     Invalid file operation
+       * @exception    E_INVALID_ARG  The specified encoding scheme does not exist.
+       * @remarks      The supported encoding schemes are ASCII, GSM, UCS-2, UCS-2LE, UCS-2BE, UCS-4, UCS-4LE, UCS-4BE, UTF-8, UTF-16, UTF-16LE, UTF-16BE, UTF-32, UTF-32LE, UTF-32BE, ISO-8859-1~16 (except ISO-8859-12), Windows-874, Windows-1250 ~ Windows-1258,KSC5601, BIG5, GB2312, Shift_JIS and ISO-2022-jp.
+       */
+       result Construct(const String& inputFilePath, const String& encodingScheme);
+
+       /**
+       * Gets the substring of the input data matching to the pattern constructed from the specified string.
+       * Delimiter will be ignored and the returned string does not include any line terminator.
+       * If not found such pattern in the input data up to the next line terminator, return an empty string through the out parameter, matchedStr.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[in]    patternStr       The string to construct the pattern.
+       * @param[out]   matchedStr       The matched string or empty string.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_INVALID_ARG  The length of the specified @c string parameter is @c 0.
+       * @exception    E_DATA_NOT_FOUND  No substring is found in the input data of current instance.
+       */
+       result FindInLine(const String& patternStr, String& matchedStr);
+
+       /**
+       * Gets the substring matching the pattern from the input data.
+       * Delimiter will be ignored and the returned string does not include any line terminator.
+       * If not found such pattern in the input data up to the next line terminator, return an empty string through the out parameter, matchedStr.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[in]    pattern  The pattern to be compiled for finding substring from input data.
+       * @param[out]   matchedStr       The matched string or empty string.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_DATA_NOT_FOUND  No substring is found in the input data of current instance.
+       */
+
+       result FindInLine(const RegularExpression& pattern, String& matchedStr);
+
+       /**
+       * Gets the next token as %signed char. Next token is converted to signed char using default radix.
+       * The signed char can hold value from -128 to 127.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextSignedChar  The next token as a signed char.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT    The next token cannot be translated into a valid %signed char value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextSignedChar(signed char& nextSignedChar) const;
+
+       /**
+       * Gets the next token as %signed char. Next token is converted to signed char using specified radix.
+       * The signed char can hold value from -128 to 127.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextSignedChar  The next token as a signed char.
+       * @param[in]    radix     The radix to be used for conversion.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT    The next token cannot be translated into a valid %signed char value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+
+       result GetNextSignedChar(signed char& nextSignedChar, int radix) const;
+
+       /**
+       * Gets the next token as %int. Next token is converted to signed integer using default radix.
+       * The signed integer can hold value from -2^31 to 2^31-1.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextInt  The next token as a signed integer.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT     The next token cannot be translated into a valid %integer value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextInt(int& nextInt) const;
+
+       /**
+       * Gets the next token as %int. Next token is converted to signed integer using specified radix.
+       * The signed integer can hold value from -2^31 to 2^31-1.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextInt  The next token as a signed integer.
+       * @param[in]    radix     The radix to be used for conversion.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT     The next token cannot be translated into a valid %integer value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextInt(int& nextInt, int radix) const;
+
+       /**
+       * Gets the next token as %short. Next token is converted to signed short using default radix.
+       * The signed short can hold value from -2^15 to 2^15-1.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextShort         The next token as a signed short.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT     The next token cannot be translated into a valid %short value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextShort(short& nextShort) const;
+
+       /**
+       * Gets the next token as %short. Next token is converted to signed short using specified radix.
+       * The signed short can hold value from -2^15 to 2^15-1.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextShort         The next token as a signed short.
+       * @param[in]    radix     The radix to be used for conversion.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT     The next token cannot be translated into a valid %short value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextShort(short& nextShort, int radix) const;
+
+       /**
+       * Gets the next token as %long long. Next token is converted to signed long long using default radix.
+       * The signed long can hold value from -2^63 to 2^63-1.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextLongLong    The next token as a signed long long.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT     The next token cannot be translated into a valid %long long value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextLongLong(long long& nextLongLong) const;
+
+       /**
+       * Gets the next token as %long long. Next token is converted to signed long long using specified radix.
+       * The signed long can hold value from -2^63 to 2^63-1.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextLongLong    The next token as a signed short.
+       * @param[in]    radix     The radix to be used for conversion.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT     The next token cannot be translated into a valid %short value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextLongLong(long long& nextLongLong, int radix) const;
+
+       /**
+       * Gets the next token as %float. Next token is converted to float.
+       * The signed float can hold a single-precision 32-bit floating number.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextFloat          The next token as a float.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT     The next token cannot be translated into a valid %float value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextFloat(float& nextFloat) const;
+
+       /**
+       * Gets the next token as %double. Next token is converted to double.
+       * The signed double can hold a double-precision 64-bit floating number.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextDouble       The next token as a double.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT    The next token cannot be translated into a valid %double value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextDouble(double& nextDouble) const;
+
+       /**
+       * Gets the next token as %bool. Next token is converted to boolean.
+       * Nothing can be converted, except true/TRUE or false/FALSE.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextBool        The next token as bool.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_NUM_FORMAT    The next token cannot be translated into a valid %bool value.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextBool(bool& nextBool) const;
+
+       /**
+       * Gets the input string up to next line delimiter and advances the %Scanner to the beginning of the next line.
+       * The returned string does not include any line terminator.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextLine The next line as an instance of string.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining line.
+       *
+       * The following example demonstrates how to use this method.
+       *
+       * @code
+       *
+       *       String str = "1 hundred bricks\n2 bricks\n3 hundred bricks\n4 bricks";
+       *       bool res = false;
+       *       String out;
+       *       Scanner scan;
+       *
+       *       scan.Construct(str);
+       *
+       *       if (scan.HasNextLine())
+       *       {
+       *               scan.GetNextLine(out); //returns 1 hundred bricks
+       *       }
+       *       else
+       *       {
+       *               return;
+       *       }
+       *
+       * @endcode
+       */
+       result GetNextLine(String& nextLine) const;
+
+       /**
+       * Gets the next token as %String.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[out]   nextTok  The next token as an instance of string.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       *
+       * The following example demonstrates how to use this method.
+       * @code
+       *
+       *       String str = "1 hundred bricks 2 bricks 3 hundred bricks 4 bricks";
+       *       bool res =  false;
+       *       String out;
+       *       Scanner scan;
+       *
+       *       scan.Construct(str);
+       *       String delimiter(L"\\s*bricks\\s*");
+       *       scan.SetDelimiter(delimiter);
+       *
+       *       if (scan.HasNext())
+       *       {
+       *               scan.GetNextToken(out); //returns 1 hundred
+       *       }
+       *       else
+       *       {
+       *               return;
+       *       }
+       *
+       * @endcode
+       */
+       result GetNextToken(String& nextTok) const;
+
+       /**
+       * Gets the next token as %String if it matches to the pattern constructed from the specified string.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[in]    pattern  The string to construct the pattern.
+       * @param[out]   nextTok  The next token as an instance of string, or empty string if not matched.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_DATA_NOT_FOUND        The next token does not match to the pattern.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextToken(const String& pattern, String& nextTok) const;
+
+       /**
+       * Gets the next token as %String if it matches to the pattern.
+       *
+       * @since 2.1
+       * @return       An error code
+       * @param[in]    pattern  The pattern to find.
+       * @param[out]   nextTok  The next token as an instance of string, or empty string if not matched.
+       * @exception    E_SUCCESS        The method is successful.
+       * @exception    E_DATA_NOT_FOUND        The next token does not match to the pattern.
+       * @exception    E_DATA_NOT_ENOUGH          The current instance of %Scanner has no remaining token.
+       */
+       result GetNextToken(const RegularExpression& pattern, String& nextTok) const;
+
+       /**
+       * Gets the radix of this %Scanner.
+       *
+       * @since 2.1
+       * @return       The current radix value
+       */
+       int GetRadix(void) const;
+
+       /**
+       * Gets the delimiter of this %Scanner.
+       *
+       * @since 2.1
+       * @return       The current delimiter string
+       */
+       String GetDelimiter(void) const;
+
+       /**
+       * Checks whether the current instance of %Scanner has another token.
+       *
+       * @since 2.1
+       * @return       @c true if the current instance has another token, @n
+       *               else @c false
+       */
+       bool HasNextToken(void) const;
+
+       /**
+       * Checks whether the next token matches to the pattern constructed from the specified string.
+       *
+       * @since 2.1
+       * @return       @c true if the next token matches to the pattern constructed from the specified string, @n
+       *               else @c false
+       * @param[in]    pattern  The string to construct the pattern.
+       */
+       bool HasNextToken(const String& pattern) const;
+
+       /**
+       * Checks whether the next token matches to the pattern.
+       *
+       * @since 2.1
+       * @return       @c true if the next token matches to the pattern, @n
+       *               else @c false
+       * @param[in]    pattern  The pattern to find.
+       */
+       bool HasNextToken(const RegularExpression& pattern) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %signed char value in the default radix.
+       * The signed char can hold value from -128 to 127.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %signed char value in the current radix, @n
+       *               else @c false
+       */
+       bool IsNextTokenConvertibleToSignedChar(void) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %signed char value in the specified radix.
+       * The signed char can hold value from -128 to 127.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %signed char value in the current radix, @n
+       *                       else @c false
+       * @param[in]    radix     The radix used to translate the token as a valid %signed char value
+       */
+       bool IsNextTokenConvertibleToSignedChar(int radix) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %int value in the default radix.
+       * The signed integer can hold value from -2^31 to 2^31-1.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %int value in the current radix, @n
+       *               else @c false
+       */
+       bool IsNextTokenConvertibleToInt(void) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %int value in the specified radix.
+       * The signed integer can hold value from -2^31 to 2^31-1.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %int value in the current radix, @n
+       *               else @c false
+       * @param[in]    radix     The radix used to translate the token as a valid %int value
+       */
+       bool IsNextTokenConvertibleToInt(int radix) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %short value in the default radix.
+       * The signed short can hold value from -2^15 to 2^15-1.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %short value in the current radix, @n
+       *               else @c false
+       */
+       bool IsNextTokenConvertibleToShort(void) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %short value in the specified radix.
+       * The signed short can hold value from -2^15 to 2^15-1.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %short value in the current radix, @n
+       *               else @c false
+       * @param[in]    radix     The radix used to translate the token as a valid %short value
+       */
+       bool IsNextTokenConvertibleToShort(int radix) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %long long value.
+       * The signed long can hold value from -2^63 to 2^63-1.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %long long value in the current radix, @n
+       *               else @c false
+       */
+       bool IsNextTokenConvertibleToLongLong(void) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %float value.
+       * The signed float can hold a single-precision 32-bit floating number.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %float value in the current radix, @n
+       *               else @c false
+       */
+       bool IsNextTokenConvertibleToFloat(void) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %double value.
+       * The signed double can hold a double-precision 64-bit floating number.
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %double value in the current radix, @n
+       *               else @c false
+       */
+       bool IsNextTokenConvertibleToDouble(void) const;
+
+       /**
+       * Checks whether the next token can be translated into a valid %bool value.
+       * Nothing can be converted except true/TRUE or false/FALSE
+       *
+       * @since 2.1
+       * @return       @c true if the next token can be translated into a valid %bool value, @n
+       *               else @c false
+       */
+       bool IsNextTokenConvertibleToBool(void) const;
+
+       /**
+       * Checks whether the input data of the current instance of %Scanner has another line.
+       *
+       * @since 2.1
+       * @return       @c true if the input data of the current instance of %Scanner has another line, @n
+       *               else @c false
+       */
+       bool HasNextLine(void) const;
+
+       /**
+       * Sets the radix of the current instance of %Scanner to the specified radix
+       *
+       * @since 2.1
+       * @param[in]    radix     The radix used for conversion.
+       *
+       */
+       void SetRadix(int radix);
+
+       /**
+       * Sets the delimiter of the current instance of %Scanner to the pattern constructed from the specified delimiter.
+       *
+       * @since 2.1
+       * @param[in]    patternStr      The delimiter to construct the pattern.
+       */
+       void SetDelimiter(const String& patternStr);
+
+       /**
+       * Sets the delimiter of the current instance of %Scanner to the specified pattern.
+       *
+       * @since 2.1
+       * @param[in]    pattern  The pattern used as a delimiter.
+       */
+       void SetDelimiter(const RegularExpression& pattern);
+
+       /**
+       * Skips the pattern constructed from the specified string.
+       *
+       * @since 2.1
+       * @param[in]    patternStr  The string to construct the pattern.
+       * @remarks      If no match to the specified pattern is found at the current position, nothing is skipped.
+       *
+       * The following example demonstrates how to use this method.
+       *
+       * @code
+       *
+       *       const String str("28 1   Ball 2 Ball 3.4 Ball 5 Ball red Ball blue Ball 8 89  67 21474836899.11 NaN 3.4e+5 +23   89 01010 456 123.456");
+       *       const String skipStr("28 1   ");
+       *       bool res = false;
+       *       String out;
+       *       Scanner scan;
+       *
+       *       scan.Construct(str);
+       *
+       *       //Skips "28 1" from input string
+       *       scan.Skip(skipStr);
+       *
+       *       if (scan1.HasNextToken())
+       *       {
+       *               scan.GetNextToken(out); //returns Ball
+       *       }
+       *       else
+       *       {
+       *               return;
+       *       }
+       *
+       * @endcode
+       */
+       void Skip(const String& patternStr);
+
+       /**
+       * Skips the specified pattern.
+       *
+       * @since 2.1
+       * @param[in]    pattern  The pattern used to skip.
+       * @remarks      If no match to the specified pattern is found at the current position, nothing is skipped.
+       */
+       void Skip(const RegularExpression& pattern);
+
+private:
+       friend class _ScannerImpl;
+       class _ScannerImpl* __pScannerImpl;
+}; // Scanner
+
+}}}   // Tizen::Base::Utility
+
+#endif // _FBASE_UTIL_SCANNER_H_
index 6076372..8b12184 100644 (file)
@@ -1,15 +1,15 @@
 //
 // Open Service Platform
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Apache License, Version 2.0 (the License);
+// Licensed under the Flora License, Version 1.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
+//     http://floralicense.org/license/
 //
 // Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// 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.
index 10dcef2..f7daecf 100644 (file)
--- a/inc/FIo.h
+++ b/inc/FIo.h
 #include <FIoFileEventManager.h>
 #include <FIoChannel.h>
 #include <FIoMessagePortManager.h>
-#include <FIoIMessagePortListener.h>
 #include <FIoSerialPort.h>
+#include <FIoMmcStorageManager.h>
 #include <FIoIDbEnumerator.h>
 #include <FIoIFileEventListener.h>
+#include <FIoIMessagePortListener.h>
 #include <FIoISerialPortEventListener.h>
+#include <FIoIMmcStorageMountListener.h>
+#include <FIoIMmcStorageFormatListener.h>
+#include <FIoFileLock.h>
 
 /**
  * @namespace  Tizen::Io
index 32670d2..a89f95e 100644 (file)
@@ -394,7 +394,7 @@ public:
        *                                                                       It can be one of the following:
        *                                                                       - r : Open for reading.
        *                                                                       - r+: Open for reading and writing.
-       *                                                                       - a+: Open for appending and reading. The database file is created if it does not exist.
+       *                                                                       - a+: Open for writing and reading. The database file is created if it does not exist.
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_ARG           Either of the following conditions has occurred: @n
        *                                                                       - The overall length of the specified @c dbPath is equal to @c 0 or
@@ -428,7 +428,7 @@ public:
        *                                                                               It can be one of the following: @n
        *                                                                               - r : Open for reading @n
        *                                                                               - r+: Open for reading and writing @n
-       *                                                                               - a+: Open for appending and reading. The database file is created if it does not exist. @n
+       *                                                                               - a+: Open for writing and reading. The database file is created if it does not exist. @n
        * @param[in]    secretKey                               A key used to encrypt data of a database file or decrypt a secure database file @n
        *                                                                               If a secure database file is created with a specific key value,
        *                                                                               other applications can access the same secure database file with the identical key value.
index 8cab8cb..613610b 100644 (file)
@@ -88,12 +88,12 @@ public:
        *                                                                         (the query did not yield any result). @n
        *                                                                       - The Database or DbStatement instance associated with this instance is deleted.
        * @exception    E_OUT_OF_RANGE          The enumerator has reached out of the result set returned by the SELECT query.
-       * @exception    E_OBJECT_LOCKED         The database instance is locked. 
-       * @exception    E_INVALID_FORMAT        The database file is malformed. 
+       * @exception    E_OBJECT_LOCKED         The database instance is locked.
+       * @exception    E_INVALID_FORMAT        The database file is malformed.
        * @exception    E_IO                            Either of the following conditions has occurred:  @n
        *                                                                       - An unexpected device failure has occurred as the media ejected suddenly. @n
        *                                                                       - %File corruption is detected.
-       * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error. 
+       * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
        * @see          Tizen::Io::Database::ExecuteStatementN()
        * @see         Tizen::Io::Database::QueryN()
        * @see          Tizen::Io::DbEnumerator::MovePrevious()
@@ -200,7 +200,7 @@ public:
        *                                                                       - The method has tried to reset the enumerator of the result set that is not activated
        *                                                                         (the query did not yield any result). @n
        *                                                                       - The Database or DbStatement instance associated with this instance is deleted.
-       * @exception    E_OBJECT_LOCKED         The database instance is locked. 
+       * @exception    E_OBJECT_LOCKED         The database instance is locked.
        * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
        * @remarks              After this method is called, if MoveNext() is called the cursor goes to the first position.
        */
@@ -348,9 +348,8 @@ public:
        * @exception            E_TYPE_MISMATCH         The operation has attempted to access columns of different types.
        * @exception            E_INVALID_FORMAT        The date is not correctly formatted, or the method is trying to access column of type String. @n
        *                                                                               The date format should be 'mm/dd/yyyy hh:mm:ss'.
-       * @exception            E_OUT_OF_RANGE          Either the year(%d), month(%d), day(%d), hour(%d), minute(%d), or second(%d) value is out of range,
+       * @exception            E_OUT_OF_RANGE          Either the year, month, day, hour, minute, or second value is out of range,
        *                                                                               or the method is trying to access a column of type String.
-       * @remarks                      Note that the DateTime is constructed inside the method.
        */
        virtual result GetDateTimeAt(int columnIndex, Tizen::Base::DateTime& value) const;
 
index d4297b0..e7361e9 100644 (file)
@@ -32,6 +32,7 @@
 #include <FBaseColIList.h>
 #include <FBaseResult.h>
 #include <FIoFileAttributes.h>
+#include <FIoFileLock.h>
 
 namespace Tizen { namespace Io
 {
@@ -553,7 +554,7 @@ public:
        result Write(const Tizen::Base::String& buffer);
 
        /**
-       * Flushes the internally buffered data into a permanent storage immediately.
+       * Flushes the internally buffered data.
        *
        * @since                        2.0
        *
@@ -652,6 +653,128 @@ public:
        Tizen::Base::String GetName(void) const;
 
        /**
+       * Acquires the file lock on the current opened whole file if it is not acquired.
+       * If the file lock is already acquired by another process, the current process is blocked until the file lock is
+       * released.
+       *
+       * @since                        2.1
+       *
+       * @return           The pointer to %FileLock instance, @n
+       *                                               else @c null pointer in case of failure
+       * @param[in]            lockType                                The type of file lock to be created
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_INVALID_ARG                   The specified @c lockType is invalid.
+       * @exception            E_INVALID_OPERATION             Either of the following conditions has occurred: @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
+       *                                                                                                 file is not open for reading. @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
+       *                                                                                                 file is not open for writing. @n
+       * @exception            E_WOULD_DEADLOCK                The method would cause a deadlock. @n
+       *                                                                                               The lock is blocked by a lock from another process, and putting the
+       *                                                                                               calling process to sleep to wait for that lock to become free would
+       *                                                                                               cause a deadlock.
+       * @exception            E_MAX_EXCEEDED                  The number of file lock exceeds system limitations.
+       * @exception            E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks                      The %FileLock instance is invalid if the associated %File instance is deleted. @n
+       *                                               The specific error code can be accessed using the GetLastResult() method.
+       * @see                          Tizen::Io::File::FileLockType
+       */
+       FileLock* LockN(FileLockType lockType);
+
+       /**
+       * Acquires the file lock on the specified region of the current opened file if it is not acquired.
+       * If the file lock is already acquired by another process, the current process is blocked until the file lock is
+       * released.
+       *
+       * @since                        2.1
+       *
+       * @return                       The pointer to %FileLock instance, @n
+       *                                               else @c null pointer in case of failure
+       * @param[in]            lockType                                The type of file lock to be created
+       * @param[in]            offset                                  The starting offset for the locked region
+       * @param[in]            length                                  The length of the locked region in bytes
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_INVALID_ARG                   Either of the following conditions has occurred: @n
+       *                                                                                       - The specified @c lockType is invalid.
+       *                                                                                       - The specified @c offset or @c length is negative or is greater than
+       *                                                                                         the system limitation.
+       * @exception            E_INVALID_OPERATION             Either of the following conditions has occurred: @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
+       *                                                                                                 file is not open for reading. @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
+       *                                                                                                 file is not open for writing. @n
+       * @exception            E_WOULD_DEADLOCK                The method would cause a deadlock. @n
+       *                                                                                               The lock is blocked by a lock from another process, and putting the
+       *                                                                                               calling process to sleep to wait for that lock to become free would
+       *                                                                                               cause a deadlock.
+       * @exception            E_MAX_EXCEEDED                  The number of file lock exceeds system limitations.
+       * @exception            E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks                      The %FileLock instance is invalid if the associated %File instance is deleted. @n
+       *                                               The specific error code can be accessed using the GetLastResult() method.
+       * @see                          Tizen::Io::File::FileLockType
+       */
+       FileLock* LockN(FileLockType lockType, int offset, int length);
+
+       /**
+       * Tries to acquire the file lock on the current opened whole file.
+       * If the file lock is already acquired by another process, E_OBJECT_LOCKED is returned.
+       *
+       * @since                        2.1
+       *
+       * @return                       The pointer to %FileLock instance, @n
+       *                                               else @c null pointer in case of failure
+       * @param[in]            lockType                                The type of file lock to be created
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_INVALID_ARG                   The specified @c lockType is invalid.
+       * @exception            E_INVALID_OPERATION             Either of the following conditions has occurred: @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
+       *                                                                                                 file is not open for reading. @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
+       *                                                                                                 file is not open for writing. @n
+       * @exception            E_OBJECT_LOCKED                 Either of the following conditions has occurred: @n
+       *                                                                                               - The file lock is already held by another process. @n
+       *                                                                                               - The file to be locked has been memory-mapped by another process.
+       * @exception            E_MAX_EXCEEDED                  The number of file lock exceeds system limitations.
+       * @exception            E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks                      The %FileLock instance is invalid if the associated %File instance is deleted. @n
+       *                                               The specific error code can be accessed using the GetLastResult() method.
+       * @see                          Tizen::Io::File::FileLockType
+       */
+       FileLock* TryToLockN(FileLockType lockType);
+
+       /**
+       * Tries to acquire the file lock on the specified region of the current opened file.
+       * If the file lock is already acquired by another process, E_OBJECT_LOCKED is returned.
+       *
+       * @since                        2.1
+       *
+       * @return                       The pointer to %FileLock instance, @n
+       *                                               else @c null pointer in case of failure
+       * @param[in]            lockType                                The type of file lock to be created
+       * @param[in]            offset                                  The starting offset for the locked region
+       * @param[in]            length                                  The length of the locked region in bytes
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_INVALID_ARG                   Either of the following conditions has occurred: @n
+       *                                                                                               - The specified @c lockType is invalid.
+       *                                                                                               - The specified @c offset or @c length is negative or is greater than
+       *                                                                                                 the system limitation.
+       * @exception            E_INVALID_OPERATION             Either of the following conditions has occurred: @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
+       *                                                                                                 file is not open for reading. @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
+       *                                                                                                 file is not open for writing. @n
+       * @exception            E_OBJECT_LOCKED                 Either of the following conditions has occurred: @n
+       *                                                                                               - The file lock is already held by another process. @n
+       *                                                                                               - The file to be locked has been memory-mapped by another process.
+       * @exception            E_MAX_EXCEEDED                  The number of file lock exceeds system limitations.
+       * @exception            E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks                      The %FileLock instance is invalid if the associated %File instance is deleted. @n
+       *                                               The specific error code can be accessed using the GetLastResult() method.
+       * @see                          Tizen::Io::File::FileLockType
+       */
+       FileLock* TryToLockN(FileLockType lockType, int offset, int length);
+
+       /**
        * Deletes the file specified. @n
        * The opened file cannot be deleted. This method is static.
        *
diff --git a/inc/FIoFileLock.h b/inc/FIoFileLock.h
new file mode 100644 (file)
index 0000000..2493a25
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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            FIoFileLock.h
+* @brief          This is the header file for the %FileLock class.
+*
+* This header file contains the declarations of the %FileLock class.
+*/
+
+#ifndef _FIO_FILE_LOCK_H_
+#define _FIO_FILE_LOCK_H_
+
+namespace Tizen { namespace Io
+{
+
+class _FileImpl;
+/**
+* @enum FileLockType
+*
+* Defines the file lock type
+*
+* @since         2.1
+*/
+enum FileLockType
+{
+       FILE_LOCK_SHARED,               /**< More than one process can hold a shared file lock on a file region.
+                                                     A shared lock prevents any other process from setting an exclusive lock on the file
+                                                     region . */
+       FILE_LOCK_EXCLUSIVE            /**< Only one process can hold an exclusive lock on a file region.
+                                                     An exclusive lock prevents any other process from setting both shared and exclusive
+                                                     lock on the file region. */
+};
+
+class _OSP_EXPORT_ FileLock
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * This destructor releases the file lock on the current opened file if acquired
+       *
+       * @since          2.1
+       */
+       virtual ~FileLock(void);
+
+       /**
+       * Checks whether the file lock is shared.
+       *
+       * @since          2.1
+       *
+       * @return         @c true if the file lock is shared, @n
+       *                    else @c false
+       */
+       bool IsShared(void) const;
+
+       /**
+       * Checks whether the file lock is exclusive.
+       *
+       * @since          2.1
+       *
+       * @return         @c true if the file lock is exclusive, @n
+       *                    else @c false
+       */
+       bool IsExclusive(void) const;
+
+       /**
+       * Checks whether the file lock is valid. @n
+       * The lock is valid unless the associated %File has been closed.
+       *
+       * @since          2.1
+       *
+       * @return         @c true if the file lock is valid, @n
+       *                    else @c false
+       */
+       bool IsValid(void) const;
+
+private:
+       //
+       // This default constructor is intentionally declared as private so that only the platform can create an instance.
+       //
+       FileLock(void);
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       FileLock(const FileLock& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       FileLock& operator =(const FileLock& rhs);
+
+       //
+       // Constructs the instance of this class.
+       //
+       // @since       2.1
+       //
+       // @return          An error code
+       // @param[in]   fileImpl        Am instance of _FileImpl
+       // @param[in]   lockType        The type of file lock to be created
+       // @param[in]   offset          The starting offset for the locked region
+       // @param[in]   size            The size of the locked region in bytes
+       // @param[in]   pid                     process id of the proccess aquiring this lock
+       // @exception   E_SUCCESS               The method is successful.
+       // @exception   E_OUT_OF_MEMORY The memory is insufficient.
+       // @exception   E_SYSTEM                A system error has occurred.
+       //
+       result Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid);
+
+       class _FileLockImpl* __pFileLockImpl;
+
+       friend class _FileLockImpl;
+
+}; // FileLock
+
+}} // Tizen::Io
+
+#endif // _FIO_FILE_LOCK_H_
index d45f1c2..5bc923e 100644 (file)
@@ -286,9 +286,8 @@ public:
        * @exception            E_TYPE_MISMATCH         The operation has attempted to access columns of different types.
        * @exception            E_INVALID_FORMAT        The date is not correctly formatted, or the method is trying to access column of type String. @n
        *                                                                               The date format should be 'mm/dd/yyyy hh:mm:ss'.
-       * @exception            E_OUT_OF_RANGE          Either the year(%d), month(%d), day(%d), hour(%d), minute(%d), or second(%d) value is out of range,
+       * @exception            E_OUT_OF_RANGE          Either the year, month, day, hour, minute, or second value is out of range,
        *                                                                               or the method is trying to access a column of type String.
-       * @remarks                      Note that the DateTime is constructed inside the method.
        */
        virtual result GetDateTimeAt(int columnIndex, Tizen::Base::DateTime& value) const = 0;
 
index a3bebbe..8d071e9 100644 (file)
@@ -82,7 +82,7 @@ class IMessagePortListener;
 * void
 * MyAppClass::OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage);
 * {
-*      String* pValue = pMessage->GetValue(L"Request");
+*   String* pValue = static_cast<String*> (pMessage->GetValue(String(L"Request")));
 *
 *      if (*pValue == L"Friend")
 *      {
index 74e88ba..182a617 100644 (file)
@@ -65,6 +65,7 @@ public:
        * @exception     E_SUCCESS           The method is successful.
        * @exception     E_INVALID_ARG       The @c localMessagePortName is empty.
        * @exception     E_SYSTEM            The method has failed due to a severe system error.
+       * @remarks       It is not recommended to use the message port names which start with "http://tizen.org/messageport". E_INVALID_ARG may be returned because they are reserved by platform.
        * @remarks       The specific error code can be accessed using the GetLastResult() method.
        */
        static LocalMessagePort* RequestLocalMessagePort(const Tizen::Base::String& localMessagePortName);
@@ -100,6 +101,7 @@ public:
        * @exception     E_SUCCESS           The method is successful.
        * @exception     E_INVALID_ARG       The @c localMessagePortName is empty.
        * @exception     E_SYSTEM            The method has failed due to a severe system error.
+       * @remarks       It is not recommended to use the message port names which start with "http://tizen.org/messageport". E_INVALID_ARG may be returned because they are reserved by platform.
        * @remarks       The specific error code can be accessed using the GetLastResult() method.
        */
        static LocalMessagePort* RequestTrustedLocalMessagePort(const Tizen::Base::String& localMessagePortName);
old mode 100755 (executable)
new mode 100644 (file)
index c013b5a..e993346
@@ -65,12 +65,11 @@ public:
        static MmcStorageManager* GetInstance(void);
 
        /**
-       * @if VISPARTNER-MANUFACTURER
        * Mounts file system of external MMC.
        *
        * @since                2.0
-       * @visibility   partner-manufacturer
-       * @privilege    %http://tizen.org/privilege/systemsetting.read
+       * @privlevel    platform
+       * @privilege    http://tizen.org/privilege/systemsetting.read
        *
        * @return               An error code
        * @exception    E_SUCCESS                       Mount operation is successfully started.
@@ -80,17 +79,15 @@ public:
        * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
        * @remarks              The directory path of the mounted external MMC can be obtained by calling
        *                               Environment::GetExternalStoragePath().
-       * @endif
        */
        result Mount(void);
 
        /**
-       * @if VISPARTNER-MANUFACTURER
        * Unmounts file system of external MMC.
        *
        * @since                2.0
-       * @visibility   partner-manufacturer
-       * @privilege    %http://tizen.org/privilege/systemsetting.read
+       * @privlevel    platform
+       * @privilege    http://tizen.org/privilege/systemsetting.read
        *
        * @return               An error code
        * @exception    E_SUCCESS                       Unmount operation is successfully started.
@@ -98,17 +95,15 @@ public:
        * @exception    E_INVALID_OPERATION     The external MMC has already been unmounted.
        * @exception    E_SERVICE_BUSY          One of mount, unmount and format operations is ongoing.
        * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
-       * @endif
        */
        result Unmount(void);
 
        /**
-       * @if VISPARTNER-MANUFACTURER
        * Formats file system of external MMC.
        *
        * @since                2.0
-       * @visibility   partner-manufacturer
-       * @privilege    %http://tizen.org/privilege/systemsetting.read
+       * @privlevel    platform
+       * @privilege    http://tizen.org/privilege/systemsetting.read
        *
        * @return               An error code
        * @exception    E_SUCCESS                       Format operation is successfully started.
@@ -116,7 +111,6 @@ public:
        * @exception    E_INVALID_OPERATION     The external MMC should be unmounted for format operation.
        * @exception    E_SERVICE_BUSY          One of mount, unmount and format operations is ongoing.
        * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
-       * @endif
        */
        result Format(void);
 
index c6e448f..284b98d 100644 (file)
@@ -31,6 +31,7 @@
 #include <FBaseColArrayList.h>
 #include <FBaseResult.h>
 #include <FBaseColIMap.h>
+#include <FIoFileLock.h>
 
 namespace Tizen {namespace Base
 {
@@ -272,8 +273,8 @@ public:
        *                                                                                 otherwise it is truncated to zero length.
        *                                                                       - w+: Open for writing and reading. The registry file is created if it does not exist,
        *                                                                                 otherwise it is truncated to zero length.
-       *                                                                       - a : Open for appending. The registry file is created if it does not exist.
-       *                                                                       - a+: Open for appending and reading. The registry file is created if it does not exist.
+       *                                                                       - a : Open for writing. The registry file is created if it does not exist.
+       *                                                                       - a+: Open for writing and reading. The registry file is created if it does not exist.
        * @exception    E_SUCCESS                       The method is successful.
        * @exception    E_INVALID_ARG           Either of the following conditions has occurred: @n
        *                                                                       - The overall length of the specified @c regPath is equal to @c 0 or
@@ -317,8 +318,8 @@ public:
        *                                                                                 otherwise it is truncated to zero length.
        *                                                                       - w+: Open for writing and reading. The registry file is created if it does not exist,
        *                                                                                 otherwise it is truncated to zero length.
-       *                                                                       - a : Open for appending. The registry file is created if it does not exist.
-       *                                                                       - a+: Open for appending and reading. The registry file is created if it does not exist.
+       *                                                                       - a : Open for writing. The registry file is created if it does not exist.
+       *                                                                       - a+: Open for writing and reading. The registry file is created if it does not exist.
        * @param[in]    secretKey                       A key used to encrypt data of a registry file or decrypt a secure registry file @n
        *                                                                       If a secure registry file is created with a specific key value,
        *                                                                       other applications can access the same secure registry file with the identical key value.
@@ -345,7 +346,7 @@ public:
        result Construct(const Tizen::Base::String& regPath, const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey);
 
        /**
-       * Writes the current contents of a registry in memory to the non-volatile storage. @n
+       * Flushes the current contents of a registry in memory. @n
        * If the secure mode is set to be @c true, the contents of the registry are automatically encrypted
        * and saved by the platform.
        *
@@ -360,7 +361,6 @@ public:
        * @exception    E_IO                                    Either of the following conditions has occurred: @n
        *                                                                               - An unexpected device failure has occurred as the media ejected suddenly. @n
        *                                                                               - %File corruption is detected. @n
-       *                                                                               - The memory is insufficient.
        */
        result Flush(void);
 
@@ -868,6 +868,62 @@ public:
        result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
 
        /**
+       * Acquires the file lock on the current opened whole file if it is not acquired.
+       * If the file lock is already acquired by another process, the current process is blocked until the file lock is
+       * released.
+       *
+       * @since                        2.1
+       *
+       * @return           The pointer to %FileLock instance, @n
+       *                                               else @c null pointer in case of failure
+       * @param[in]            lockType                                The type of file lock to be created
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_INVALID_ARG                   The specified @c lockType is invalid.
+       * @exception            E_INVALID_OPERATION             Either of the following conditions has occurred: @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
+       *                                                                                                 file is not open for reading. @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
+       *                                                                                                 file is not open for writing. @n
+       * @exception            E_WOULD_DEADLOCK                The method would cause a deadlock. @n
+       *                                                                                               The lock is blocked by a lock from another process, and putting the
+       *                                                                                               calling process to sleep to wait for that lock to become free would
+       *                                                                                               cause a deadlock.
+       * @exception            E_MAX_EXCEEDED                  The number of file lock exceeds system limitations.
+       * @exception            E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks                      The %FileLock instance is invalid if the associated %File instance is deleted. @n
+       *                                               The specific error code can be accessed using the GetLastResult() method.
+       * @see                          Tizen::Io::File::FileLockType
+       */
+       FileLock* LockN(FileLockType lockType);
+
+       /**
+       * Tries to acquire the file lock on the current opened whole file.
+       * If the file lock is already acquired by another process, E_OBJECT_LOCKED is returned.
+       *
+       * @since                        2.1
+       *
+       * @return                       The pointer to %FileLock instance, @n
+       *                                               else @c null pointer in case of failure
+       * @param[in]            lockType                                The type of file lock to be created
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_INVALID_ARG                   The specified @c lockType is invalid.
+       * @exception            E_INVALID_OPERATION             Either of the following conditions has occurred: @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
+       *                                                                                                 file is not open for reading. @n
+       *                                                                                               - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
+       *                                                                                                 file is not open for writing. @n
+       * @exception            E_OBJECT_LOCKED                 Either of the following conditions has occurred: @n
+       *                                                                                               - The file lock is already held by another process. @n
+       *                                                                                               - The file to be locked has been memory-mapped by another process.
+       * @exception            E_MAX_EXCEEDED                  The number of file lock exceeds system limitations.
+       * @exception            E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks                      The %FileLock instance is invalid if the associated %File instance is deleted. @n
+       *                                               The specific error code can be accessed using the GetLastResult() method.
+       * @see                          Tizen::Io::File::FileLockType
+       */
+       FileLock* TryToLockN(FileLockType lockType);
+
+       /**
        * Removes the specified registry file.
        *
        * @if OSPCOMPAT
index a2c735e..2f955a2 100644 (file)
@@ -84,7 +84,7 @@ class LocalMessagePort;
 * void
 * MyAppClass::OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage);
 * {
-*      String* pValue = static_cast<String*>(pMessage->GetValue(L"Reply"));
+*   String* pValue = static_cast<String*>(pMessage->GetValue(String(L"Reply")));
 *
 *      AppLog("My friend's name is %ls", pValue->GetPointer());
 *
@@ -146,11 +146,14 @@ public:
         * @since    2.0
         *
         * @return       An error code
-        * @param[in]     pMessage            A pointer to an argument map of key (String) and value (String or ByteBuffer) pair
+        * @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.
         * @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_EXCEED may be returned for messages over 4KB size.
         */
        result SendMessage(const Tizen::Base::Collection::IMap* pMessage);
 
@@ -162,13 +165,16 @@ public:
         *
         * @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
+        * @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.
         * @exception     E_SUCCESS           The method is successful.
         * @exception     E_INVALID_ARG       Either of the following conditions has occurred: @n
         *                                                                        - The local message port is null. @n
         *                                                                        - 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_EXCEED may be returned for messages over 4KB size.
         */
        result SendMessage(const LocalMessagePort* pLocalMessagePort, const Tizen::Base::Collection::IMap* pMessage);
 
index 18a0c19..1bbed2f 100644 (file)
@@ -367,16 +367,6 @@ public:
         */
        result AddTimeZoneName(const Tizen::Base::String& timeZoneId, const Tizen::Base::String& concatenatedTimeZoneName);
 
-
-       /*
-        * Gets the non-localized date-time pattern characters.
-        *
-        * @since                               2.0
-        *
-        * @return                              The non-localized date-time pattern characters
-        */
-       static Tizen::Base::WcharBuffer* GetNonLocalizedDateTimePatternN(void);
-
 private:
        /**
         * The implementation of this copy constructor is intentionally blank and declared as private to
index c4f1ddb..9c3ca2d 100644 (file)
@@ -492,7 +492,7 @@ public:
        static void DayToFields(int day, int& year, int& month, int& dayOfMonth, int& dayOfWeek, int& dayOfYear);
 
 private:
-       /**
+       /*
         * @enum                GregorianCalendarEras
         *
         * Defines Era for Gregorian calendar. The indexing is 0-based.
@@ -506,13 +506,13 @@ private:
                GREGORIAN_CALENDAR_CE = 1,      // CE
        };
 
-       /**
+       /*
         * The implementation of this copy constructor is intentionally blank and declared as private to
         * prohibit copying of objects.
         */
        GregorianCalendar(const GregorianCalendar& gregorianCalendar);
 
-       /**
+       /*
         * The implementation of this copy assignment operator is intentionally blank and declared as private
         * to prohibit copying of objects.
         */
@@ -527,49 +527,49 @@ private:
        virtual Calendar* CloneN(void) const;
 
 public:
-       /**
+       /*
         * Defines the length of months.
         *
         * @since 2.0
         */
        static const int MONTH_LENGTH[24];
 
-       /**
+       /*
         * Defines the days of a year.
         *
         * @since 2.0
         */
        static const int NUM_DAYS[24];
 
-       /**
+       /*
         * The Gregorian cutover number for Julian day.
         *
         * @since 2.0
         */
        static const int CUTOVER_JULIAN_DAY = 2299161;      // Oct 15, 1582
 
-       /**
+       /*
         * The epoch year.
         *
         * @since 2.0
         */
        static const int EPOCH_YEAR = 1970;
 
-       /**
+       /*
         * The epoch start for Julian day.
         *
         * @since 2.0
         */
        static const int EPOCH_START_AS_JULIAN_DAY = 2440588; // Jan 1, 1970(Gregorian)
 
-       /**
+       /*
         * Jan 1, 1 epoch start for Julian day.
         *
         * @since 2.0
         */
        static const int JAN_1_1_JULIAN_DAY = 1721426;  // Jan 1, 1 CE Gregorian
 
-       /**
+       /*
         * Temporary value for the Gregorian cutover.
         *
         * @since 2.0
@@ -578,56 +578,56 @@ public:
                ((long long) (GregorianCalendar::CUTOVER_JULIAN_DAY -
                                          GregorianCalendar::EPOCH_START_AS_JULIAN_DAY) * (long long) ONE_DAY_IN_MILLISEC);
 
-       /**
+       /*
         * Maximum value for longlong.
         *
         * @since 2.0
         */
        static const long long MAX_LONGLONG = (2 ^ 63) - 1;
 
-       /**
+       /*
         * Minimum value for longlong.
         *
         * @since 2.0
         */
        static const long long MIN_LONGLONG = -1 * (2 ^ 63);
 
-       /**
+       /*
         * Maximum value for Julian day.
         *
         * @since 2.0
         */
        static const int MAX_JULIAN = 0x7F000000;
 
-       /**
+       /*
         * Minimum value for Julian day.
         *
         * @since 2.0
         */
        static const int MIN_JULIAN = -0x7F000000;
 
-       /**
+       /*
         * Maximum millisecond value for Julian day.
         *
         * @since 2.0
         */
        static const long long MAX_MILLISEC = ((GregorianCalendar::MAX_JULIAN - GregorianCalendar::EPOCH_START_AS_JULIAN_DAY) * (long long) ONE_DAY_IN_MILLISEC);
 
-       /**
+       /*
         * Minimum millisecond value for Julian day.
         *
         * @since 2.0
         */
        static const long long MIN_MILLISEC = ((GregorianCalendar::MIN_JULIAN - GregorianCalendar::EPOCH_START_AS_JULIAN_DAY) * (long long) ONE_DAY_IN_MILLISEC);
 
-       /**
+       /*
         * Epoch offset in millisecond value.
         *
         * @since 2.0
         */
        static const long long EPOCH_OFFSET_IN_MILLISEC = 62135596800000LL; // Jan 1, 1970
 
-       /**
+       /*
         * Default Gregorian cutover.
         *
         * @since 2.0
index b2a1950..1c4db52 100644 (file)
@@ -62,12 +62,14 @@ enum CalendarType
  *
  * Defines the ISO 639-2 language code. @n
  * The LanguageCode enumerator represents the ISO 639-2 language codes. @n
- * The specified LanguageCode represents the language code with the locale's ISO-15924 abbreviation script code. 
+ * The specific LanguageCode represents the language code with the locale's ISO-15924 abbreviation script code. @n
+ * The supported ISO-15924 script codes are Arabic, Cyrillic, Latin, Hans, Hant and Gurmukhi.
  *
  * @since              2.0
  */
 enum LanguageCode
 {
+       LANGUAGE_INVALID = -1, /**< An invalid language code */
        LANGUAGE_AAR, /**< Afar */
        LANGUAGE_ABK, /**< Abkhazian */
        LANGUAGE_ACE, /**< Achinese */
@@ -571,7 +573,8 @@ enum LanguageCode
        LANGUAGE_ZXX, /**< No linguistic content; Not applicable */
        LANGUAGE_ZZA, /**< Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki */
        LANGUAGE_MAX, // Language max count
-       LANGUAGE_INVALID /**< An invalid language code */
+
+    LANGUAGE_INVALID_RESERVED = LANGUAGE_ZZA + 2, // An invalid language code for internal (LANGUAGE_ZZA+2)
 }; // LanguageCode
 
 
@@ -580,11 +583,13 @@ enum LanguageCode
  *
  * Defines the ISO 3166-1 alpha-2 country code. @n
  * The CountryCode enumerator represents the ISO 3166-1 alpha-2 country codes.
+ * The area code for Latin america and the Caribbean represents the ISO 3166-1 numeric-3.
  *
  * @since              2.0
  */
 enum CountryCode
 {
+    COUNTRY_INVALID = -1, /**< An invalid country code */
        COUNTRY_AF, /**< AFGHANISTAN  */
        COUNTRY_AX, /**< ALAND ISLANDS */
        COUNTRY_AL, /**< ALBANIA */
@@ -826,8 +831,12 @@ enum CountryCode
        COUNTRY_ZW, /**< ZIMBABWE */
        COUNTRY_RS, /**< SERBIA */
        COUNTRY_ME, /**< MONTENEGRO */
+       COUNTRY_BL, /**< SAINT BARTHELEMY @b Since: @b 2.1  */
+       COUNTRY_MF, /**< SAINT MARTIN (FRENCH PART) @b Since: @b 2.1 */
+       COUNTRY_AREA_419, /**< Latin America and the Caribbean @b Since: @b 2.1  */
        COUNTRY_MAX,    //< Country max count
-       COUNTRY_INVALID, //< invalid country code
+
+    COUNTRY_INVALID_RESERVED = COUNTRY_ME + 2, // An invalid country code for internal (COUNTRY_ME+2)
 };
 
 
@@ -948,6 +957,8 @@ public:
         * @since               2.0
         *
         * @return              The language code enum value of the instance
+        *
+        * @remark              The specific LanguageCode represents the language code with the locale's ISO-15924 abbreviation script code.
         */
        LanguageCode GetLanguageCode(void) const;
 
@@ -965,7 +976,8 @@ public:
         *
         * @since               2.0
         *
-        * @return              The language code
+        * @return              The language code, @n
+        *                      The specific language code string has the locale's ISO-15924 abbreviation script code.
         */
        Tizen::Base::String GetLanguageCodeString(void) const;
 
@@ -1071,7 +1083,7 @@ public:
         *
         * @since                                       2.0
         *
-        * @param[in]                           pVariantCode                    A pointer to the variant code   
+        * @param[in]                           pVariantCode                    A pointer to the variant code
         */
        void SetVariantCodeString(const Tizen::Base::String* pVariantCode = null);
 
@@ -1080,7 +1092,11 @@ public:
         *
         * @since                       2.0
         *
-        * @param[in]           languageCodeString                              The language code 
+        * @param[in]           languageCodeString                              The language code, @n
+        *                                                                      To get the specfied LanguageCode with the locale's ISO-15924 abbreviation script code, @n
+        *                                                                      the form of languageCodeString should combine the ISO 639-2 language codes and the locale's ISO-15924 abbreviation script code by "-". @n
+        *                                                                      For example, if the language code is "aze" and the script code is "latn", @n
+        *                                                                      the languageCodeString is "aze-latn", and the LanguageCode is LANGUAGE_AZE_LATIN.
         * @return              An instance of LanguageCode associated with the @c languageCodeString.
         */
        static LanguageCode StringToLanguageCode(const Tizen::Base::String& languageCodeString);
@@ -1103,6 +1119,7 @@ public:
         * @param[in]           languageCode                                    The language code
         * @return              The language code string associated with the @c languageCode, @n
         *                              else an empty string if languageCode is invaild.
+        * @see StringToLanguageCode()
         */
        static Tizen::Base::String LanguageCodeToString(LanguageCode languageCode);
 
@@ -1113,7 +1130,7 @@ public:
         *
         * @param[in]           countryCode                                             The country code
         * @return              The ISO 3166-1 alpha-2 country code string associated with the @c countryCode, @n
-        *                              else an empty string if countryCode is invaild. 
+        *                              else an empty string if countryCode is invaild.
         */
        static Tizen::Base::String CountryCodeToString(CountryCode countryCode);
 
@@ -1124,6 +1141,8 @@ public:
         *
         * @param[in]           languageCode                                    The language code
         * @return              The ISO 639-2 language code string associated with the @c languageCode, @n
+        *                              or The ISO 639-2 language code string with the ISO-15924 script code @n
+        *                              if the @c languageCode represents The ISO 639-2 language code with the ISO-15924 script code, @n
         *                              else an empty string if languageCode is invaild.
         */
        static Tizen::Base::String LanguageCodeToTwoLetterLanguageCodeString(LanguageCode languageCode);
@@ -1135,6 +1154,7 @@ public:
         *
         * @param[in]           languageCodeString                              The language code string
         * @return              An instance of LanguageCode associated with the @c languageCodeString.
+        * @see                 StringToLanguageCode()
         */
        static LanguageCode TwoLetterLanguageCodeStringToLanguageCode(const Tizen::Base::String& languageCodeString);
 
@@ -1145,8 +1165,9 @@ public:
         *
         * @param[in]           countryCode                                             The country code
         * @return              The ISO 3166-1 alpha-3 country code string associated with the @c countryCode, @n
-        *                              else an empty string if countryCode is invaild 
+        *                              else an empty string if countryCode is invaild
         * @see                 CountryCodeToString()
+        * @remark              COUNTRY_AREA_419 returns an empty string, since it is not defined in the ISO 3166-1 alpha-3.
         */
        static Tizen::Base::String CountryCodeToThreeLetterCountryCodeString(CountryCode countryCode);
 
@@ -1157,7 +1178,7 @@ public:
         *
         * @param[in]           countryCodeString                                The country code string
         * @return              An instance of CountryCode associated with the @c countryCodeString.
-        * @see                 StringToCountryCode() 
+        * @see                 StringToCountryCode()
         */
        static CountryCode ThreeLetterCountryCodeStringToCountryCode(const Tizen::Base::String& countryCodeString);
 
index be6043e..3758226 100644 (file)
@@ -43,9 +43,11 @@ namespace Tizen { namespace Locales
  *
  * The %TimeZone class represents a time zone offset and figures out Daylight Saving Time (DST).
  *
- * The form of time zone ID is "Area/Location". However, the specialized time zone IDs have the different form.@n
+ * The form of time zone ID is "Area/Location". @n
  *
- * The IDs are defined in <a href="http://www.iana.org/time-zones" target="_blank">Time Zone Database</a>. @n
+ * However, the specialized time zone IDs have the different form, such as CST6CDT, EST5EDT and so on.@n
+ *
+ * For more information on IDs, refer <a href="http://www.iana.org/time-zones" target="_blank">Time Zone Database</a>. @n
  * 
  * The supported time zone list depends on the device. Therefore, it must be checked by using LocaleManager::GetAvailableTimeZonesN().
  *
@@ -55,6 +57,8 @@ namespace Tizen { namespace Locales
  *
 @code
 
+#include <FBase.h>
+#include <FSystem.h>
 #include <FLocales.h>
 
 using namespace Tizen::Locales;
@@ -73,8 +77,10 @@ MyClass::MyTimeZone(void)
        int dstSavings = timeZone.GetDstSavings();
 
        // Gets the special time zone.
+       DateTime utcTime;
        TimeZone timeZone2;
-       Tizen::Locales::TimeZone::GetTimeZone(L"Europe/Zurich", timeZone2);
+       Tizen::System::SystemTime::GetCurrentTime(utcTime);
+       Tizen::Locales::TimeZone::GetTimeZone(L"Europe/Zurich", utcTime, timeZone2);
 }
 @endcode
  *
@@ -131,7 +137,7 @@ public:
         *
         * @param[in]           rawOffset                                               The base time zone offset to GMT in minutes
         * @param[in]           id                                                              The time zone ID
-        * @remarks                     The form of time zone @c id is "Area/Location". @n For more information on IDs, refer <a href="http://www.iana.org/time-zones">here</a>. @n
+        * @remarks                     The form of time zone @c id is "Area/Location". @n For more information on IDs, refer <a href="http://www.iana.org/time-zones" target="_blank">here</a>. @n
         *                                      However, the supported time zone list depends on the device. Therefore, it must be checked before using this method.
         * @see                         LocaleManager::GetAvailableTimeZonesN()
         */
@@ -148,7 +154,7 @@ public:
         * @param[in]           startRule                                               The DST starting rule
         * @param[in]           endRule                                                 The DST end rule
         * @param[in]           dstOffset                                               The amount of time in minutes saved during DST
-        * @remarks                     The form of time zone @c id is "Area/Location". @n For more information on IDs, refer <a href="http://www.iana.org/time-zones">here</a>. @n
+        * @remarks                     The form of time zone @c id is "Area/Location". @n For more information on IDs, refer <a href="http://www.iana.org/time-zones" target="_blank">here</a>. @n
         *                                      However, the supported time zone list depends on the device. Therefore, it must be checked before using this method.
         * @see                         LocaleManager::GetAvailableTimeZonesN()
         */
@@ -368,7 +374,7 @@ public:
         *
         * @return                      An error code
         * @param[in]           ticks                                           The time ticks value @n
-        *                                                                                              The value can be either GMT time or local wall time.
+        *                                                                                              The value is GMT time.
         * @param[out]          offset                                          The offset between the local standard time and GMT, taking into consideration DST
         * @exception           E_SUCCESS                                       The method is successful.
         * @exception           E_INVALID_ARG                                   The specified @c ticks is invalid. 
index 7d526c3..08d52aa 100644 (file)
 #define _FSEC_ACCESS_CONTROLLER_H_
 
 #include <FOspConfig.h>
+#include <FAppTypes.h>
 
 namespace Tizen { namespace Security
 {
 
+class _PrivilegeManager;
+
 /**
- * @if VISPARTNER
  * @class      AccessController
- * @brief      This class provides a way to check the privilege and visibility of privileged API.
- * @since 2.0
- * @visibility partner
+ * @brief      This class provides a way to check the privilege of privileged API.
+ * @since      2.0
  *
- * The %AccessController class provides a way to check the privilege and visibility of privileged API.
- * @endif
+ * The %AccessController class provides a way to check the privilege of privileged API.
  */
 class _OSP_EXPORT_ AccessController
 {
@@ -48,23 +48,52 @@ class _OSP_EXPORT_ AccessController
 public:
 
        /**
-        * @if VISPARTNER
-        *
-        * Checks whether the application has a privilege and a visibility to invoke the privileged API.
+        * Checks whether the application has a privilege to invoke the privileged API.
         *
         * @since 2.0
-        * @visibility  partner
         * @return              An error code
-        * @param[in]   privilege                       A value of enumerator of the specified @c privilege
-        * @exception   E_SUCCESS                       The method is successful and the request is granted.
-        * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
-        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
-        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
-        * @exception   E_SYSTEM                        An unexpected system error has occurred.
-        * @endif
+        * @param[in]   privilege                               A value of enumerator of the specified @c privilege
+        * @exception   E_SUCCESS                               The method is successful and the request is granted.
+        * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+     * @exception      E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+        * @exception   E_SYSTEM                                An unexpected system error has occurred.
         */
        static result CheckPrivilege(int privilege);
 
+    /**
+    * Checks whether the application has a privilege to invoke the privileged API.
+    *
+    * @since 2.1
+    * @return          An error code
+    * @param[in]       privilege                               A string of the specified privilege
+    * @exception       E_SUCCESS                               The method is successful and the request is granted.
+    * @exception       E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
+    * @exception       E_DATA_NOT_FOUND                The privilege information does not exist.
+    * @exception       E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
+    * @exception       E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+    * @exception       E_SYSTEM                                The method cannot proceed due to a severe system error.
+    */
+    static result CheckPrivilege(const Tizen::Base::String& privilege);
+
+
+    /**
+    * Checks whether the client application which has @c appId has a privilege to invoke the privileged API.
+    *
+    * @since 2.1
+    * @return          An error code
+    * @param[in]       appId                                   The package ID
+    * @param[in]       privilege                               A string of the specified privilege
+    * @exception       E_SUCCESS                               The method is successful and the request is granted.
+    * @exception       E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
+    * @exception       E_DATA_NOT_FOUND                The privilege information does not exist.
+    * @exception       E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
+    * @exception       E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+    * @exception       E_SYSTEM                                The method cannot proceed due to a severe system error.
+    */
+    static result CheckPrivilege(const Tizen::App::PackageId& packageId, const Tizen::Base::String& privilege);
+
 private:
 
     /**
@@ -89,6 +118,9 @@ private:
 
        static void Initialize(void);
 
+private:
+       static _PrivilegeManager* __pPrivilegeManager;
+
 };  // AccessController
 
 }} // Tizen::Security
index 45a74cf..585726b 100644 (file)
 //
 
 /**
- * @if VISPARTNER
  * @file                       FSecCertICertificateStore.h
  * @brief              This is the header file for the %ICertificateStore interface.
  *
  * This header file contains the declarations of the %ICertificateStore interface.
  *
- * @endif
  */
 #ifndef _FSEC_CERT_ICERTIFICATE_STORE_H_
 #define _FSEC_CERT_ICERTIFICATE_STORE_H_
@@ -38,16 +36,12 @@ namespace Tizen { namespace Security { namespace Cert
 {
 
 /**
- *     @if VISPARTNER
  *     @interface      ICertificateStore
  *     @brief          This is the interface for retrieving and managing the certificates from a repository.
  *
- *     @since                  2.0
- *
- *     @visibility     partner
+ *     @since          2.0
  *
  *     The %ICertificateStore interface is used for retrieving and managing the certificates from a repository.
- *  @endif
  */
 class _OSP_EXPORT_ ICertificateStore
 {
old mode 100755 (executable)
new mode 100644 (file)
index 15c1139..6d8d194
 //
 
 /**
- * @if VISPARTNER
  * @file               FSecCertX509CertificateStore.h
  * @brief              This is the header file for the %X509CertificateStore class.
  *
  * This header file contains the declarations of the %X509CertificateStore class.
- *
- * @endif
  */
 #ifndef _FSEC_CERT_X509_CERTIFICATE_STORE_H_
 #define _FSEC_CERT_X509_CERTIFICATE_STORE_H_
@@ -39,16 +36,12 @@ namespace Tizen { namespace Security { namespace Cert
 class _CertMgrSvcProxy;
 
 /**
- *  @if VISPARTNER
  *     @class  X509CertificateStore
  *     @brief  This class is used for retrieving and managing certificates from a repository.
  *
  *     @since  2.0
  *
- *     @visibility     partner
- *
  *     The %X509CertificateStore class is used for retrieving and managing certificates from a repository.
- *     @endif
  */
 class _OSP_EXPORT_ X509CertificateStore
        : public virtual ICertificateStore
@@ -71,30 +64,27 @@ public:
        virtual ~X509CertificateStore(void);
 
        /**
-        *      @if VISPARTNER
         *      Gets the name of the current certificate store.
         *
         *      @since                  2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.read
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.read
         *
         *      @return                 An error code
         *      @param[out]             name                            The name of the certificate store
         *      @exception              E_SUCCESS                       The method is successful.
         *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
-        *      @endif
         */
        virtual result GetName(Tizen::Base::String& name) const;
 
        /**
-        *      @if VISPARTNER
         *      Sets a list of certificates that match the specified @c selector.
         *
         *      @since                  2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.read
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.read
         *
         *      @return                 An error code
         *      @param[in]              selector                        A selector that defines a set of criterion for selecting certificates
@@ -104,35 +94,31 @@ public:
         *                                                                              The IPC operation has failed.
         *      @exception              E_INVALID_ARG           The specified @c selector is invalid.
         *      @exception              E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
-        *      @endif
         */
        virtual result SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector);
 
        /**
-        *      @if VISPARTNER
         *      Gets a count of certificates that match the specified selector.
         *
         *      @since                  2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.read
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.read
         *
         *      @return                 An error code
         *      @param[out]             count                                   The count of certificates
         *      @exception              E_SUCCESS                               The method is successful.
         *      @exception              E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
-        *      @endif
         */
        virtual result GetCertificateCount(int& count) const;
 
        /**
-        *      @if VISPARTNER
         *      Gets each certificate that matches the specified selector.
         *
         *      @since                  2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.read
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.read
         *
         *      @return                 The certificates that matches the specified selector
         *      @exception              E_SUCCESS                       The method is successful.
@@ -141,18 +127,16 @@ public:
         *      @exception              E_SYSTEM                        A system error has occurred. @n
         *                                                                              The Tizen::Base::ByteBuffer operation has failed.
         *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
-        *  @endif
         */
        virtual Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const;
 
        /**
-        *      @if VISPARTNER
         *      Inserts the certificate into the certificate store.
         *
         *      @since                  2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.write
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.write
         *
         *      @return                 An error code
         *      @param[in]              certificateType         The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
@@ -164,18 +148,16 @@ public:
         *      @exception              E_SYSTEM                        A system error has occurred. @n
         *                                      Either the IPC operation or the file operation or the DB operation has failed.
         *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
-        *  @endif
         */
        virtual result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
 
        /**
-        *  @if VISPARTNER
         *  Updates the certificate in the certificate store.
         *
         *      @since                  2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.write
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.write
         *
         *      @return                 An error code
         *      @param[in]              certificateType         The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
@@ -189,18 +171,16 @@ public:
         *      @exception              E_SYSTEM                        A system error has occurred. @n
         *                                      Either the IPC operation or the file operation or the DB operation has failed.
         *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
-        *      @endif
         */
        virtual result Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert);
 
        /**
-        *  @if VISPARTNER
         *  Removes the certificate from the certificate store.
         *
         *      @since                  2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.write
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.write
         *
         *      @return                 An error code
         *      @param[in]              certificateType         The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, TRUSTED_THIRD_PARTY_DOMAIN)
@@ -213,18 +193,16 @@ public:
         *      @exception              E_SYSTEM                        A system error has occurred. @n
         *                                      Either the IPC operation or the file operation or the DB operation has failed.
         *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
-        *      @endif
         */
        virtual result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
 
        /**
-        *      @if VISPARTNER
         *  Inserts the user certificate of PKCS 12 format into the certificate store.
         *
         *      @since 2.0
         *
-        *      @visibility             partner
-        *      @privilege              %http://tizen.org/privilege/certificate.write
+        *      @privlevel              partner
+        *      @privilege              http://tizen.org/privilege/certificate.write
         *
         *      @return                 An error code
         *  @param[in]          filePath                        The file path of PKCS 12 certificate to insert
@@ -233,7 +211,6 @@ public:
         *      @exception              E_INVALID_ARG           The specified @c certificate or the certificate data is invalid.
         *      @exception              E_SYSTEM                        The method cannot proceed due to a severe system error.
         *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
-        *  @endif
         */
        result InsertPkcs12(const Tizen::Base::String& filePath, const Tizen::Base::String& password);
 
index 42d0800..857ef9f 100644 (file)
@@ -75,6 +75,7 @@ public:
         *
         *      @return         An error code
         *      @param[in]      key                                             An instance of IKey
+        *                                                                              Key can be in PEM/DER/PKCS8 format only.
         *      @exception      E_SUCCESS                               The method is successful.
         *      @exception      E_INVALID_ARG                   The specified @c key is invalid.
         *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
@@ -88,6 +89,7 @@ public:
         *
         *      @return         An error code
         *      @param[in]      key                                             An instance of IKey
+        *                                                                              Key can be in PEM/DER/X509 public key format only.
         *      @exception      E_SUCCESS                               The method is successful.
         *      @exception      E_INVALID_ARG                   The specified @c key is invalid.
         *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
index 09c9db0..f258984 100644 (file)
@@ -75,7 +75,8 @@ public:
         *      @since          2.0
         *
         *      @return         An error code
-        *      @param[in]      key                                                     An instance of IKey
+        *      @param[in]      key                                                     An instance of IKey.
+        *                                                                                      Key can be in PEM/DER/PKCS8 format only.
         *      @exception      E_SUCCESS                                       The method is successful.
         *      @exception      E_INVALID_ARG                           The specified @c key is invalid.
         *      @exception      E_OUT_OF_MEMORY                         The memory is insufficient.
@@ -89,6 +90,7 @@ public:
         *
         *      @return         An error code
         *      @param[in]      key                                                     An instance of IKey
+        *                                                                                      Key can be in PEM/DER/X509 public key format only.
         *      @exception      E_SUCCESS                                       The method is successful.
         *      @exception      E_INVALID_ARG                           The specified @c key is invalid.
         *      @exception      E_OUT_OF_MEMORY                         The memory is insufficient.
@@ -96,8 +98,8 @@ public:
        virtual result SetPublicKey(const Tizen::Security::IKey& key);
 
        /**
-        *      Signs the data.
-        *
+        *      Signs the data. @n
+        *      This API only supports sha1withRsa for signing the data
         *      @since          2.0
         *
         *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
@@ -115,8 +117,32 @@ public:
        virtual Tizen::Base::ByteBuffer* SignN(const Tizen::Base::ByteBuffer& input);
 
        /**
+        *      Signs the data. @n
+        *      This API provides the additional option to developer for setting digest algorithm that is needed for signing the data
+        *
+        *      @since          2.0
+        *
+        *      @return         A pointer to the Tizen::Base::ByteBuffer class that contains the output, @n
+        *                              else @c null if an error occurs
+        * @param[in]   input                                           An instance of Tizen::Base::ByteBuffer
+        *      @param[in]      algorithm                                       An instance of Tizen::Base::String that contains the digest algorithm,
+        *                                                                                      valid values are MD5, MD5WITHSHA1, SHA1, SHA2/224, SHA2/256, SHA2/384, SHA2/512.
+        *      @exception      E_SUCCESS                                       The method is successful.
+        *      @exception      E_INVALID_ARG                           The input Tizen::Base::ByteBuffer is empty or contains invalid data.
+        *      @exception      E_OUT_OF_MEMORY                         The memory is insufficient.
+        *      @exception      E_KEY_NOT_FOUND                         The specified key is not found.
+        *      @exception      E_UNSUPPORTED_ALGORITHM         The specified algorithm is not supported.
+        *      @exception      E_SYSTEM                                        A system error has occurred. @n
+        *                                                                                      The method has failed to operate with the OpenSSL library, or
+        *                                                                                      the Tizen::Base::ByteBuffer operation has failed.
+        *  @remarks    The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* SignN(const Tizen::Base::ByteBuffer& input, const Tizen::Base::String& algorithm);
+
+       /**
         *      Verifies the data. @n
-        *      The verification is done by comparing the @c signedData to the signature created by the @c data.
+        *      The verification is done by comparing the @c signedData to the signature created by the @c data. @
+        *      This API only supports sha1withRsa for verifying the signed data
         *
         *      @since          2.0
         *
@@ -135,6 +161,31 @@ public:
         */
        virtual bool Verify(const Tizen::Base::ByteBuffer& data, const Tizen::Base::ByteBuffer& signedData);
 
+       /**
+        *      Verifies the data. @n
+        *      The verification is done by comparing the @c signedData to the signature created by the @c data. @n
+        *      This API provides the additional option to developer for setting digest algorithm that is needed for verifying the signed data
+        *
+        *      @since          2.0
+        *
+        *      @return         @c true if the signed data is correct, @n
+        *                              else @c false
+        *      @param[in]      data                                            An instance of Tizen::Base::ByteBuffer that contains the original data
+        *      @param[in]      signedData                                      A instance of Tizen::Base::ByteBuffer that contains the signed data
+        *      @param[in]      algorithm                                       An instance of Tizen::Base::String that contains the digest algorithm,
+        *                                                                                      valid values are MD5, MD5WITHSHA1, SHA1, SHA2/224, SHA2/256, SHA2/384, SHA2/512.
+        *      @exception      E_SUCCESS                                       The method is successful.
+        *      @exception      E_INVALID_ARG                           The input Tizen::Base::ByteBuffer is empty or contains invalid data.
+        *      @exception      E_OUT_OF_MEMORY                         The memory is insufficient.
+        *      @exception      E_KEY_NOT_FOUND                         The specified key is not found.
+        *      @exception      E_UNSUPPORTED_ALGORITHM         The specified algorithm is not supported.
+        *      @exception      E_SYSTEM                                        A system error has occurred. @n
+        *                                                                                      The method has failed to operate with the OpenSSL library, or
+        *                                                                                      the Tizen::Base::ByteBuffer operation has failed.
+        *  @remarks    The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool Verify(const Tizen::Base::ByteBuffer& data, const Tizen::Base::ByteBuffer& signedData, const Tizen::Base::String& algorithm);
+
 private:
 
        //
index c3ad392..150b20e 100644 (file)
@@ -28,7 +28,6 @@
 #include <FSecISecureRandom.h>
 #include <FSecIKeyParameters.h>
 
-
 namespace Tizen { namespace Security
 {
 
@@ -99,32 +98,31 @@ public:
        result Construct(int modulusBitSize, const Tizen::Base::String algorithm);
 
        /**
-       *       Generates the key parameters based on the underlying key pair algorithm. @n
-       *       For example, in case of the DH or KEA algorithm, this method generates key parameters based on the DSA
-       *       algorithm (X186.3 specification).
-       *       The supported algorithms are RSA, DH, and KEA.
-       *       The generated key parameters may be required to create a key pair. The RSA algorithm
-       *       does not call this method to generate a key pair.
-       *
-       *       @since                  2.0
-       *
-       *       @return                 A pointer to the IKeyParameters class that contains a subset of the domain parameters ('p' prime
-       *                                       number, 'g' generator) that are used to generate a key pair, @n
-       *                                       else @c null if the method fails to create the key parameters
-       *       @param[in]      lInBits         The size of 'p', a prime number in bits @n
-       *                                                       The size must be @c 1024 bits, @c 2048 bits, or @c 3072 bits.
-       *       @param[in]      nInBits         The size of 'g', a generator value in bits @n
-       *                                                       The size must be:
-       *                                                       - 160 bits, when @c lInBits is @c 1024 bits.
-       *                                                       - 254 or 256 bits, when @c lInBits is @c 2048 bits.
-       *                                                       - 256 bits, when @c lInBits is @c 3072 bits.
-       *       @exception      E_SUCCESS                                       The method is successful.
-        *      @exception      E_UNSUPPORTED_ALGORITHM         The requested algorithm is not supported.
-       *       @exception      E_OUT_OF_MEMORY                         The memory is insufficient.
-       *       @exception      E_SYSTEM                                        A system error has occurred. @n
-       *                                                                                       The method has failed to operate with the OpenSSL library, or the Tizen::Base::ByteBuffer operation has failed.
-       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
-       */
+        *      Generates the key parameters based on the underlying key pair algorithm. @n
+        *      For example, in case of the DH or KEA algorithm, this method generates key parameters based on the DSA
+        *      algorithm (X186.3 specification).
+        *      The supported algorithms are RSA, DH, and KEA.
+        *      The generated key parameters may be required to create a key pair. The RSA algorithm
+        *      does not call this method to generate a key pair.
+        *
+        *      @since                  2.0
+        *
+        *      @return                 A pointer to the IKeyParameters class that contains a subset of the domain parameters ('p' prime
+        *                                      number, 'g' generator) that are used to generate a key pair, @n
+        *                                      else @c null if the method fails to create the key parameters
+        *      @param[in]      lInBits         The size of 'p', a prime number in bits @n
+        *                                                      The size must be @c 1024 bits, @c 2048 bits, or @c 3072 bits.
+        *      @param[in]      nInBits         The size of 'g', a generator value in bits @n
+        *                                                      The size must be:
+        *                                                      - 160 bits, when @c lInBits is @c 1024 bits.
+        *                                                      - 254 or 256 bits, when @c lInBits is @c 2048 bits.
+        *                                                      - 256 bits, when @c lInBits is @c 3072 bits.
+        *      @exception      E_SUCCESS                                       The method is successful.
+        *      @exception      E_OUT_OF_MEMORY                         The memory is insufficient.
+        *      @exception      E_SYSTEM                                        The method cannot proceed due to a severe system error. @n
+        *                                                                                      The method has failed to operate with the OpenSSL library, or the Tizen::Base::ByteBuffer operation has failed.
+        *      @remarks        The specific error code can be accessed using the GetLastResult() method.
+        */
        Tizen::Security::IKeyParameters* GenerateKeyParametersN(int lInBits = 1024, int nInBits = 160) const;
 
        /**
@@ -137,9 +135,8 @@ public:
         *      @param[in]   pKeyParams                         The domain parameters of the key exchange algorithm @n
         *                                                                              These parameters are instantiated.
         *      @exception      E_SUCCESS                               The method is successful.
-        *      @exception      E_UNSUPPORTED_ALGORITHM The requested algorithm is not supported.
         *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
-        *      @exception      E_SYSTEM                                A system error has occurred. @n
+        *      @exception      E_SYSTEM                                The method cannot proceed due to a severe system error.@n
         *                                                                              The method has failed to operate with the OpenSSL library, or the Tizen::Base::ByteBuffer operation has failed.
         *      @remarks        The specific error code can be accessed using the GetLastResult() method.
         */
@@ -151,18 +148,17 @@ public:
         *      @since          2.0
         *
         *      @return         A pointer to the KeyPair class, @n
-                       else @c null if the method fails to create the key pair
+                       else @c null if the method fails to create the key pair.
+        *                              Default key format will be pkcs1 for private key and x509 for public key.
         *      @exception      E_SUCCESS                                       The method is successful.
-        *      @exception      E_UNSUPPORTED_ALGORITHM         The requested algorithm is not supported.
         *      @exception      E_OUT_OF_MEMORY                         The memory is insufficient.
-        *      @exception      E_SYSTEM                                        A system error has occurred. @n
+        *      @exception      E_SYSTEM                                        The method cannot proceed due to a severe system error. @n
         *                                                                                      The method has failed to operate with the OpenSSL library, or the Tizen::Base::ByteBuffer operation has failed.
         * @remarks     The specific error code can be accessed using the GetLastResult() method.
         */
        virtual Tizen::Security::KeyPair* GenerateKeyPairN(void) const;
 
 private:
-
        //
        // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
        //
@@ -184,7 +180,7 @@ private:
        class _KeyPairGeneratorImpl* __pKeyPairGeneratorImpl;
        friend class _KeyPairGeneratorImpl;
 
-}; //KeyPairGenerator
+};     //KeyPairGenerator
 
 } } //Tizen::Security
 
diff --git a/inc/FSecPkcs.h b/inc/FSecPkcs.h
new file mode 100644 (file)
index 0000000..45b80ee
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs.h
+ * @brief              This is the header file for the %Pkcs namespace.
+ *
+ * This header file contains the declarations of the %Pkcs namespace.
+ *
+ */
+#ifndef _FSEC_PKCS_H_
+#define _FSEC_PKCS_H_
+
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsRc2CbcParameters.h>
+#include <FSecPkcsInitialVector.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs05Schemes.h>
+#include <FSecPkcsPkcs08PrivateKeyInfo.h>
+#include <FSecPkcsPkcs08EncryptedPrivateKeyInfo.h>
+#include <FSecPkcsPkcs08Attribute.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+/**
+ * @namespace  Tizen::Security::Pkcs
+ * @brief              This namespace contains classes and interfaces for managing the Pkcs 5 and 8 implementation.
+ * @since              2.1
+ *
+ * @remarks            @b Header @b %file: @b \#include @b <FSecurity.h> @n
+ *                             @b Library : @b osp-appfw
+ *
+ *
+ *     The %Pkcs namespace provides classes and interfaces for managing Pkcs 5 and 8 implementation.
+ *     It provides a mechanism for password based key derivation, encryption/decryption @n
+ *     mac genaration/verification.
+ *     It also provides a standard format to store private key and encrypted private key.
+ *
+ *      For more information on the %Pkcs namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/security/pkcs.htm">Pkcs Guide</a>. @n
+ *
+ *     The following diagram illustrates the relationships between the classes belonging to the %Pkcs namespace.
+ *     @image html security_pkcs_classdiagram.png
+ *
+ */
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+} } } //Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_H_
diff --git a/inc/FSecPkcsAlgorithmIdentifier.h b/inc/FSecPkcsAlgorithmIdentifier.h
new file mode 100644 (file)
index 0000000..aac47ab
--- /dev/null
@@ -0,0 +1,194 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsAlgorithmIdentifier.h
+ * @brief              This is the header file for the %AlgorithmIdentifier class.
+ *
+ * This header file contains the declarations of the %AlgorithmIdentifier class.
+ */
+
+#ifndef _FSEC_PKCS_ALGORITHM_IDENTIFIER_H_
+#define _FSEC_PKCS_ALGORITHM_IDENTIFIER_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              AlgorithmIdentifier
+ * @brief              This class implements the ASN.1 specified AlgorithmIdentifier, which is used for
+ *                             creating the standard AlgorithmIdentifier object.
+ *              AlgorithmIdentifier structure consist the OID value of the Algorithm
+ *              and the parameters of that algorithm.
+ *
+ *              It is defined in ASN.1 as
+ *
+ *              AlgorithmIdentifier { ALGORITHM-IDENTIFIER:InfoObjectSet }
+ *              ::=
+ *              SEQUENCE {
+ *              algorithm ALGORITHM-IDENTIFIER.&id({InfoObjectSet}),
+ *              parameters ALGORITHM-IDENTIFIER.&Type({InfoObjectSet}
+ *              {@algorithm}) OPTIONAL }
+ *              ALGORITHM-IDENTIFIER ::= TYPE-IDENTIFIER
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ AlgorithmIdentifier
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       AlgorithmIdentifier(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~AlgorithmIdentifier(void);
+
+       /**
+        * Initializes the %AlgorithmIdentifier with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   objectId                                                This parameter specifies object Identifier of particular algorithm. Object IDs
+        *                                                                                                                              are defined by standard bodies for algorithms and other crypto objects.Object ID of AlgorithmIdentifier can be described in string format like 1.2.3.4
+        * @param[in]   pParams                                                 This parameter specifies a pointer to AlgorithmParameters object. This is an
+        *                                                                                                                              optional parameter and contains a list of user supplied input parameters for the specified algorithm.
+        *                                                                                                                              For example, for Symmetric algorithms Initial vector (IV) is required as input.
+        *                                                                                                                              The default value of this parameter is NULL.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_UNSUPPORTED_ALGORITHM         The object id of the input algorithm is not supported.
+        */
+       result Construct(const Tizen::Base::String& objectId, const IAlgorithmParameters* pParams = null);
+
+       /**
+        * Initializes this instance of %AlgorithmIdentifier with the DER encoded Bytebuffer that conatins @n
+        * the ASN.1 specified AlgorithmIdentifier structure.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     An instance of DER encoded ByteBuffer
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Checks whether the specified instance of %AlgorithmIdentifier equals the current instance.
+        *
+        * @since                       2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *            else @c false
+        * @param[in]   rhs                                                                     An instance of %AlgorithmIdentifier
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %AlgorithmIdentifier.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %AlgorithmIdentifier
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Get the copy of AlgorithmIdentifier instance.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to AlgorithmIdentifier, containing the copy of this instance, @n
+        *                                              else @c null if an error occurs.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       AlgorithmIdentifier* CloneN(void) const;
+
+       /**
+        * Gets the parameters of algorithm.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to IAlgorithmParameters, containing the parameter list of algorithm, @n
+        *                                              else @c null if an no parameters exist.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       IAlgorithmParameters* GetParametersN(void) const;
+
+       /**
+        * Gets the object Id value of an algorithm in string format.
+        *
+        * @since                       2.1
+        *
+        * @return              Object ID of AlgorithmIdentifier in string format like 1.2.3.4.
+        *
+        */
+       Tizen::Base::String GetAlgorithmObjectId(void) const;
+
+       /**
+        * Gets the encoded form of the AlgorithmIdentifier. @n
+        * It is assumed that each AlgorithmIdentifier type will have only a single form of encoding that is DER encoding.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to the DER encoded ByteBuffer, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       AlgorithmIdentifier(const AlgorithmIdentifier& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       AlgorithmIdentifier& operator =(const AlgorithmIdentifier& rhs);
+
+private:
+       class _AlgorithmIdentifierImpl* __pAlgorithmIdentifierImpl;
+       friend class _AlgorithmIdentifierImpl;
+}; // AlgorithmIdentifier
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_ALGORITHM_IDENTIFIER_H_
diff --git a/inc/FSecPkcsIAlgorithmParameters.h b/inc/FSecPkcsIAlgorithmParameters.h
new file mode 100644 (file)
index 0000000..9fe225a
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsIAlgorithmParameters.h
+ * @brief              This is the header file for the %IAlgorithmParameters interface.
+ *
+ * This header file contains the declarations of the %IAlgorithmParameters interface.
+ */
+
+#ifndef _FSEC_PKCS_IALGORITHM_PARAMETERS_H_
+#define _FSEC_PKCS_IALGORITHM_PARAMETERS_H_
+
+#include <FSecPkcsTypes.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @interface  IAlgorithmParameters
+ * @brief              This is an interface class for cryptographic algorithm parameters like IV etc. It provides the generic
+ *                                     functionalities which must be supported by all derived algorithm parameters like PbKdf2Parameters, PbEs2Parameters.
+ *                                     This is an abstract class and hence object of this class cannot be instantiated.
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ IAlgorithmParameters
+{
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, @n
+        * the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since               2.1
+        */
+       virtual ~IAlgorithmParameters(void) {}
+
+       /**
+        * Get the copy of parameters of the specified algorithm type.
+        *
+        * @since                       2.1
+        *
+        * @return              Pointer to AlgorithmParameters, containing the instance of algorithm parameter , @n
+        *                                              else @c null if an error occurs.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual IAlgorithmParameters* CloneN(void) const = 0;
+
+       /**
+        * Get the pkcs algorithm parameter type enumerated value.
+        *
+        * @since                       2.1
+        *
+        * @return              PkcsAlgorithmParamterType, containing the enumerated value of PkcsAlgorithmParameterType.
+        *
+        */
+       virtual PkcsAlgorithmParameterType GetType(void) const = 0;
+
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAlgorithmParameters_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAlgorithmParameters_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAlgorithmParameters_Reserved3(void) {}
+
+}; // IAlgorithmParameters
+
+} } } // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_IAGORITHM_PARAMETERS_H_
diff --git a/inc/FSecPkcsInitialVector.h b/inc/FSecPkcsInitialVector.h
new file mode 100644 (file)
index 0000000..b863263
--- /dev/null
@@ -0,0 +1,168 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsInitialVector.h
+ * @brief              This is the header file for the %InitialVector class.
+ *
+ * This header file contains the declarations of the %InitialVector class.
+ */
+
+#ifndef _FSEC_PKCS_INITIAL_VECTOR_H_
+#define _FSEC_PKCS_INITIAL_VECTOR_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsTypes.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              InitialVector
+ * @brief              This class implements the functionalities specified by the InitialVector class.
+ *                                     This class represents the Initial Vector parameter for symmetric ciphers like DES, AES, DES_EDE.
+ *                                     This InitialVector Parameters will be used by both Pkcs05 and Pkcs08 related classes at the time of encryption.
+ * @since              2.1
+ *
+ *
+ */
+
+class _OSP_EXPORT_ InitialVector
+       : public virtual IAlgorithmParameters
+       , public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       InitialVector(void);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since                2.1
+       */
+
+       virtual ~InitialVector(void);
+
+       /**
+        * Initializes this instance of %InitialVector with the specified input buffer.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        *
+        * @param[in]   initialVector           An instance of ByteBuffer, holding the initial vector data.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& initialVector);
+
+       /**
+        * Get copy of this instance.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to IAlgorithmParameters, containing the copy of this instance.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual IAlgorithmParameters* CloneN(void) const;
+
+       /**
+        * Get the algorithm parameter type enum value for Initial Vector.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType              Enum value  containing the PKCS_ALGO_PARAM_TYPE_IV value for Initial vector parameter.
+        *
+        */
+       virtual PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %InitialVector equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                     An instance of %InitialVector
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %InitialVector.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %InitialVector
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Get the instance of byte buffer that contains the Initial vector value.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the ByteBuffer class that contains the output.
+        */
+       const Tizen::Base::ByteBuffer& GetInitialVector(void) const;
+
+       /**
+        * Gets the encoded form of the InitialVector. @n
+        * It is assumed that each InitialVector type will have only a single form of encoding that is DER encoding.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to the DER encoded ByteBuffer, @n
+        *                                                      else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       InitialVector(const InitialVector& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       InitialVector& operator =(const InitialVector& rhs);
+
+private:
+       class _InitialVectorImpl* __pInitialVectorImpl;
+       friend class _InitialVectorImpl;
+
+}; // InitialVector
+
+} } } //Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_INITIAL_VECTOR_H_
diff --git a/inc/FSecPkcsPkcs05PbEs2Parameters.h b/inc/FSecPkcsPkcs05PbEs2Parameters.h
new file mode 100644 (file)
index 0000000..d38e826
--- /dev/null
@@ -0,0 +1,204 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05PbEs2Parameters.h
+ * @brief              This is the header file for the %Pkcs05PbEs2Parameters class.
+ *
+ * This header file contains the declarations of the %Pkcs05PbEs2Parameters class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_
+#define _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_
+
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Pkcs05PbEs2Parameters
+ * @brief              This class implements the functionalities specified by the Pkcs05 encryption scheme 2.
+ *                                     PBES2 combines a password-based key derivation function, which shall be PBKDF2
+ *                                     for PKCS #5 version 2.1, with an underlying encryption scheme
+ *                                     The key length and any other parameters for the underlying encryption scheme depend on the scheme.
+ *
+ *              It is defined in ASN.1 as:
+ *
+ *              PBES2-params ::= SEQUENCE {
+ *              keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
+ *              encryptionScheme AlgorithmIdentifier {{PBES2-Encs}} }
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ Pkcs05PbEs2Parameters
+       : public virtual IAlgorithmParameters
+       , public Tizen::Base::Object
+{
+
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       Pkcs05PbEs2Parameters(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~Pkcs05PbEs2Parameters(void);
+
+       /**
+        * Initializes this instance of %Pkcs05PbEs2Parameters with the encoded Bytebuffer which contain Password based encryption @n
+        * parameters structure(PBES2) in ASN.1 DER format.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer contains Pkcs05PbEs2Parameters.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %Pkcs05PbEs2Parameters with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   keyDerivationFunction           An instance of AlgorithmIdentifier, holding key derivation function.
+        * @param[in]   encryptionScheme                An instance of AlgorithmIdentifier, holding encryption scheme.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& keyDerivationFunction, const AlgorithmIdentifier& encryptionScheme);
+
+       /**
+        * Gets the encoded form of the Pkcs05PbEs2Parameters.
+        * It is assumed that each Pkcs05PbEs2Parameters will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       /**
+        * Get the reference to the AlgorithmIdentifier instance  which identifies the underlying key derivation function.
+        * It shall be an algorithm ID with an OID in the set PBES2-KDFs, which for this version of PKCS #5 shall consist of id-PBKDF2.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying key derivation function.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
+
+       /**
+        * Get the reference to the AlgorithmIdentifier instance  which identifies the underlying encryption algorithm.
+        * It shall be an OID in the set PBES2-Encs, whose definition is left to the application.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying encryption algorithm.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetEncryptionScheme(void) const;
+
+       /**
+        * Get the AlgorithmParameters which identifies the underlying Parameters like PbKdf2,PbEs2,PbMac1.
+        * For this class AlgorithmParameters will be of Pbes2 type.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to IAlgorithmParameters containing the algorithm identifier of underlying pseudo random function, @n
+        *                              else @c null if an error occurs.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual IAlgorithmParameters* CloneN(void) const;
+
+       /**
+        *
+        * Get the PkcsAlgorithmParameterType value.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType holding enum value PKCS_ALGO_PARAM_TYPE_PKCS05_PBES02 for PBES2 Parameters.
+        *
+        */
+       virtual PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %Pkcs05PbEs2Parameters equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                                     An instance of %Pkcs05PbEs2Parameters
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %Pkcs05PbEs2Parameters.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbEs2Parameters
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs05PbEs2Parameters(const Pkcs05PbEs2Parameters& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       Pkcs05PbEs2Parameters& operator =(const Pkcs05PbEs2Parameters& rhs);
+
+private:
+       class _Pkcs05PbEs2ParametersImpl* __pPkcs05PbEs2ParametersImpl;
+       friend class _Pkcs05PbEs2ParametersImpl;
+};  //Pkcs05PbEs2Parameters
+
+} } } // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_PKCS_05_PBES2_PARAMETERS_H_
diff --git a/inc/FSecPkcsPkcs05PbKdf2Parameters.h b/inc/FSecPkcsPkcs05PbKdf2Parameters.h
new file mode 100644 (file)
index 0000000..6f7f9f6
--- /dev/null
@@ -0,0 +1,246 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05PbKdf2Parameters.h
+ * @brief              This is the header file for the %Pkcs05PbKdf2Parameters class.
+ *
+ * This header file contains the declarations of the %Pkcs05PbKdf2Parameters class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_05_PBKDF2_PARAMETERS_H_
+#define _FSEC_PKCS_PKCS_05_PBKDF2_PARAMETERS_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Pkcs05PbKdf2Parameters
+ * @brief              This class implements the functionalities specified by the Pkcs05 KDF2 scheme. PBKDF2 applies a pseudo random function to derive
+ *                                     keys. The length of the derived key is essentially unbounded. However, the maximum effective search space for the derived key may
+ *                                     be limited by the structure of the underlying pseudorandom function.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             PBKDF2-params ::= SEQUENCE {
+ *                             salt CHOICE {
+ *                             specified OCTET STRING,
+ *                             otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}
+ *                             },
+ *                             iterationCount INTEGER (1..MAX),
+ *                             keyLength INTEGER (1..MAX) OPTIONAL,
+ *                             prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT
+ *                             algid-hmacWithSHA1 }
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ Pkcs05PbKdf2Parameters
+       : public virtual IAlgorithmParameters
+       , public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       Pkcs05PbKdf2Parameters(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~Pkcs05PbKdf2Parameters(void);
+
+       /**
+        * Initializes this instance of %Pkcs05PbKdf2Parameters with the encoded Bytebuffer which contain password based @n
+        * key derivation function parameters structure(PBKDF2) in ASN.1 DER format.
+         *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     DER encoded ByteBuffer of Pkcs05PbKdf2Parameters.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %Pkcs05PbKdf2Parameters with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   saltBuffer                                      An instance of ByteBuffer, holding salt value.
+        * @param[in]   iterationCount                  Integer value holding the positive integer specifying iteration count
+        *                                                                                                                              for generation of password based key.
+        * @param[in]   derivedKeyLength                Positive integer specifying length of password based key to be generated.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remark              In this case when pseudo random function algorithm is not passed then default HMAC-SHA1 will be used.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, int derivedKeyLength = 0);
+
+       /**
+        * Initializes the %Pkcs05PbKdf2Parameters with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   saltBuffer                                      An instance of ByteBuffer, holding salt value.
+        * @param[in]   iterationCount                  Integer value holding the positive integer specifying iteration count
+        *                                                                                                                              for generation of password based key.
+        * @param[in]   prf                                                                     An instance of AlgorithIdentifier, holding the underlying pseudo-random function to use for
+        *                                                                                                                              generation of password based key.
+        * @param[in]   derivedKeyLength                Positive integer specifying length of password based key to be generated.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, const AlgorithmIdentifier& prf, int derivedKeyLength = 0);
+
+       /**
+        * Gets the encoded form of the Pkcs05PbKdf2Parameters.
+        * It is assumed that each Pkcs05PbKdf2Parameters  will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       /**
+        * Get the salt byte buffer.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to Salt ByteBuffer Containing the specified salt value.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const Tizen::Base::ByteBuffer& GetSaltValue(void) const;
+
+       /**
+        * Get the iteration count.
+        * The purpose of this count is to increase the cost of producing keys from a password, thereby also increasing the difficulty of attack.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value containing the iteration count for PBKDF2.
+        *
+        */
+       int GetIterationCount(void) const;
+
+       /**
+        * Get the derived key length.
+        * This API will return the length of the derived key that will be used for generating the password based key.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value containing the length of the derived key.
+        *
+        */
+       int GetDerivedKeyLength(void) const;
+
+       /**
+        * Get the reference to the Algorithm Identifier which identifies the underlying pseudo random function.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier Containing the algorithm identifier of underlying pseudo random function.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetPrf(void) const;
+
+       /**
+        *
+        * Get the pointer to the AlgorithmParameters which identifies the underlying Parameters like PbKdf2,PbEs2,PbMac1.
+        * For this class AlgorithmParameters will be of PbKdf2 type.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to IAlgorithmParameters Containing the algorithm identifier of underlying pseudo random function, @n
+        *                              else @c null if an error occurs.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual IAlgorithmParameters* CloneN(void) const;
+
+       /**
+        * Get the PkcsAlgorithmParameterType value.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType holding enum value PKCS_ALGO_PARAM_TYPE_PKCS05_KDF02 for KDF2 Parameters.
+        */
+       virtual PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %Pkcs05PbKdf2Parameters equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                                     An instance of %Pkcs05PbKdf2Parameters
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %Pkcs05PbKdf2Parameters.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbKdf2Parameters
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs05PbKdf2Parameters(const Pkcs05PbKdf2Parameters& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       Pkcs05PbKdf2Parameters& operator =(const Pkcs05PbKdf2Parameters& rhs);
+
+private:
+       class _Pkcs05PbKdf2ParametersImpl* __pPkcs05PbKdf2ParametersImpl;
+       friend class _Pkcs05PbKdf2ParametersImpl;
+};  // Pkcs05PbKdf2Parameters
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_PKCS_05_PBKDF2_PARAMETERS_H_
diff --git a/inc/FSecPkcsPkcs05PbMacParameters.h b/inc/FSecPkcsPkcs05PbMacParameters.h
new file mode 100644 (file)
index 0000000..069cf3d
--- /dev/null
@@ -0,0 +1,201 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05PbMacParameters.h
+ * @brief              This is the header file for the %Pkcs05PbMacParameters class.
+ *
+ * This header file contains the declarations of the %Pkcs05PbMacParameters class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_
+#define _FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Pkcs05PbMacParameters
+ * @brief              This class implements the functionalities specified by the Pkcs05 MAC scheme.
+ *                                     PBMAC1 combines a password-based key derivation function, which shall be PBKDF2
+ *                                     for this version of PKCS #5, with an underlying message authentication
+ *                                     scheme. The key length and any other parameters for
+ *                                     the underlying message authentication scheme depend on the scheme.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             PBMAC1-params ::= SEQUENCE {
+ *                             keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
+ *                             messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ Pkcs05PbMacParameters
+       : public virtual IAlgorithmParameters
+       , public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since                       2.1
+        */
+       Pkcs05PbMacParameters(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since                       2.1
+        */
+       virtual ~Pkcs05PbMacParameters(void);
+
+       /**
+        * Initializes this instance of %Pkcs05PbMacParameters with the Bytebuffer which contain Password based message  @n
+        * authentication parameters structure(PBMAC1) in ASN.1 DER format.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer contains Pkcs05PbMacParameters.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %Pkcs05PbMacParameters with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   keyDerivationFunc               An instance of AlgorithmIdentifier, holding key derivation function.
+        * @param[in]   messageAuthScheme               An instance of AlgorithmIdentifier, holding message authentication scheme.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& keyDerivationFunc, const AlgorithmIdentifier& messageAuthScheme);
+
+       /**
+        * Gets the encoded form of the Pkcs05PbMacParameters.
+        * It is assumed that each Pkcs05PbMacParameters will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       /**
+        * Get the reference to the AlgorithmIdentifier instance  which identifies the underlying key derivation function.
+        * It shall be an algorithm ID with an OID in the set PBES2-KDFs, which for this version of PKCS #5 shall consist of id-PBKDF2.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying key derivation function.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
+
+       /**
+        * This function implements GetMacAlgorithm API which returns the algorithm identifier which identifies the underlying
+        * MAC algorithm. It shall be an OID like OID_HMAC_SHA1 or OID_HMAC_SHA2_224 etc.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying MAC algorithm.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetMacAlgorithm(void) const;
+
+       /**
+        * Get the AlgorithmParameters which identifies the underlying Parameters like PbKdf2,PbEs2,PbMac1.
+        * For this class AlgorithmParameters will be of PbMac1 type.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to IAlgorithmParameters Containing the algorithm identifier of underlying pseudo random function.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual IAlgorithmParameters* CloneN(void) const;
+
+       /**
+        * Get the PkcsAlgorithmParameterType value.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType holding enum value PKCS_ALGO_PARAM_TYPE_PKCS05_MAC for PBMAC Parameters.
+        */
+       virtual PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %Pkcs05PbMacParameters equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                             An instance of %Pkcs05PbMacParameters
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+       */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %Pkcs05PbMacParameters.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbMacParameters
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs05PbMacParameters(const Pkcs05PbMacParameters& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       Pkcs05PbMacParameters& operator =(const Pkcs05PbMacParameters& rhs);
+
+private:
+       class _Pkcs05PbMacParametersImpl* __pPkcs05PbMacParametersImpl;
+       friend class _Pkcs05PbMacParametersImpl;
+
+};  // Pkcs05PbMacParameters
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_PKCS_05_PBMAC_PARAMETERS_H_
diff --git a/inc/FSecPkcsPkcs05Schemes.h b/inc/FSecPkcsPkcs05Schemes.h
new file mode 100644 (file)
index 0000000..14a9363
--- /dev/null
@@ -0,0 +1,196 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05Schemes.h
+ * @brief              This is the header file for the %Pkcs05Schemes class.
+ *
+ * This header file contains the declarations of the %Pkcs05Schemes class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_05_SCHEMES_H_
+#define _FSEC_PKCS_PKCS_05_SCHEMES_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+  * @class             Pkcs05Schemes
+  * @brief             This class implements the functionalities specified by the pkcs05 schemes like Key derivation function,
+  *                                            encryption and signature schemes.
+  * @since             2.1
+  *
+  */
+
+class _OSP_EXPORT_ Pkcs05Schemes
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        */
+       Pkcs05Schemes(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~Pkcs05Schemes(void);
+
+       /**
+        * Initializes the %Pkcs05Schemes with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code.
+        * @param[in]   password                                        An instance of ByteBuffer , holding the password.
+        * @param[in]   derivedKeyLength        A positive integer contains the length of derived key.@n
+        *                                                                                                                      It is a variable length in PbEs2 based on underlying encryption operation.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& password, int derivedKeyLength);
+
+       /**
+        * This API will generate the Password based derived key using PBKDF2 scheme.
+        * The length of the derived key is essentially unbounded. However, the maximum effective search space for
+        * the derived key may be limited by the structure of the underlying pseudo random function.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to ByteBuffer contains the derived key, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   params                                          An instance of PbKdf2Parameters, containing Kdf2 parameter.
+        *                                                                                                                      salt value, iteration count and key length.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GenerateKeyKdf2N(const Pkcs05PbKdf2Parameters& params);
+
+       /**
+        * This API implements EncryptionScheme2N API which combines the GenerateKeyKdf2N function and encrypts the
+        * message M under a password P to produce a ciphertext C, by applying selected key derivation function KDF
+        * (which is GenerateKeyKdf2N) and selected underlying encryption scheme (which can be any block chiper).
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer contains the encrypted message, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   params                                          An instance of PbEs2Parameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                         An instance of ByteBuffer, holding the plain text to encrypt.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* EncryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message);
+
+       /**
+        * This API implements DecryptionScheme2N API which combines the GenerateKeyKdf2N function and decrypts the ciphertext C,
+        * under a password P to recover message M , by applying selected key derivation function KDF(which is GenerateKeyKdf2N)
+        * and selected underlying decryption algorithm (which can be any block cipher).
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer contains the plain text message.
+        * @param[in]   params                                          An instance of PbEs2Parameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                         An instance of ByteBuffer, holding the cipher text to decrypt.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* DecryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message);
+
+       /**
+        * This API implements GetPbHMacN API process a message M under a password P to generate a message authentication code T,
+        * by applying selected key derivation function KDF(which is GenerateKeyKdf2N) and selected underlying message authentication scheme
+        * (which can be any HMAC algorithm). GenerateMacN combines a password-based key derivation function, which shall be
+        * GenerateKeyKdf2N for this version of PKCS #5, with an underlying message authentication scheme
+        * The key length and any other parameters for the underlying message authentication scheme
+        * depend on the scheme.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer containing the HMAC generated from message, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   params                                          An instance of bMacParameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                         An instance of ByteBuffer, holding the message for which MAC needs to be generated.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetPbHMacN(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message);
+
+       /**
+        * This API implements VerifyMac API which processes a message M under a password P to verify a message authentication code T,
+        * by applying a selected key derivation function KDF2 and a selected underlying message authentication scheme combines a
+        * password-based key derivation function, which shall be GenerateKeyKdf2N for this version of PKCS #5, with an underlying
+        * message authentication scheme (which can be any SHA-1 or any SHA-2 algorithm). The key length and any other parameters
+        * for the underlying message authentication scheme depend on the scheme.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   params                                                  An instance of PbMacParameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                              function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                                 An instance of ByteBuffer, holding the message M.
+        * @param[in]   mac                                                                     An instance of ByteBuffer, holding the HMAC mac that needs to be verified against message.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       result VerifyPbMac(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message, const Tizen::Base::ByteBuffer& mac);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs05Schemes(const Pkcs05Schemes& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       Pkcs05Schemes& operator =(const Pkcs05Schemes& rhs);
+
+private:
+       class _Pkcs05SchemesImpl* __pPkcs05SchemesImpl;
+       friend class _Pkcs05SchemesImpl;
+
+}; //Pkcs05Schemes
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_PKCS_05_SCHEMES_H_
diff --git a/inc/FSecPkcsPkcs08Attribute.h b/inc/FSecPkcsPkcs08Attribute.h
new file mode 100644 (file)
index 0000000..284da3a
--- /dev/null
@@ -0,0 +1,165 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08Attribute.h
+ * @brief              This is the header file for the %Pkcs08Attribute class.
+ *
+ * This header file contains the declarations of the %Pkcs08Attribute class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_08_ATTRIBUTE_H_
+#define _FSEC_PKCS_PKCS_08_ATTRIBUTE_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Pkcs08Attribute
+ * @brief              This class implements the functionalities specified by the Pkcs08Attribute class. An Attribute object consists
+ *                                     of an attribute type (specified by an object identifier) and one or more attribute values. It acts as a
+ *                                     container for adding, inserting, removing, encoding X.509 AttributeValue.
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ Pkcs08Attribute
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        */
+       Pkcs08Attribute(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~Pkcs08Attribute(void);
+
+       /**
+        * Intializes this instance of %Pkcs08Attribute with the Bytebuffer which contain X.509 Attribute @n
+        * structure in ASN.1 DER format. @n
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer of X.509 Attribute structure.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Intializes this instance of %Pkcs08Attribute with specified attribute type.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributeType                   This parameter specifies object Identifier of particular x.509 attribute type. Object IDs @n
+        *                                                                                                                      (e.g. oid for name is 2.5.4.41)are defined by standard bodies for attribute.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::String& attributeType);
+
+       /**
+        * Get the attribute type.
+        * This function implements GetAttributeType API which returns the Attribute type of this attribute instance.
+        *
+        * @since               2.1
+        *
+        * @return              Containing the Object ID of Attribute Type in string format like 2.5.4.41
+        *
+        */
+       Tizen::Base::String GetAttributeType(void) const;
+
+       /**
+        * This function adds attribute value in the attribute value list.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributeValue                  An instance of Pkcs08AttributeValue to add an attribute in the list.
+        */
+       result AddAttributeValue(const Pkcs08AttributeValue& attributeValue);
+
+       /**
+        * This function remove attribute value in the attribute value list.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributeValue                  An instance of Pkcs08AttributeValue to remove an attribute in the list.
+        */
+       result RemoveAttributeValue(const Pkcs08AttributeValue& attributeValue);
+
+       /**
+        * This function returns the array list containing the attribute values of type Pkcs08AttributeValue.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to an ArrayList containing the list of Attribute values.
+        */
+       const Tizen::Base::Collection::ArrayList& GetAttributeValues(void) const;
+
+       /**
+        * Gets the encoded form of the Pkcs08Attribute.
+        * It is assumed that each Pkcs08Attribute will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs
+        *
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs08Attribute(const Pkcs08Attribute& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       Pkcs08Attribute& operator =(const Pkcs08Attribute& rhs);
+
+private:
+       class _Pkcs08AttributeImpl* __pPkcs08AttributeImpl;
+       friend class _Pkcs08AttributeImpl;
+
+}; //Pkcs08Attribute
+
+}}} // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_PKCS_08_ATTRIBUTE_H_
diff --git a/inc/FSecPkcsPkcs08AttributeValue.h b/inc/FSecPkcsPkcs08AttributeValue.h
new file mode 100644 (file)
index 0000000..e70f729
--- /dev/null
@@ -0,0 +1,144 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08AttributeValue.h
+ * @brief              This is the header file for the %Pkcs08AttributeValue class.
+ *
+ * This header file contains the declarations of the %Pkcs08AttributeValue class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_08_ATTRIBUTE_VALUE_H_
+#define _FSEC_PKCS_PKCS_08_ATTRIBUTE_VALUE_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsTypes.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Pkcs08AttributeValue
+ * @brief              This class implements the functionalities specified by the Pkcs08AttributeValue class.
+ * @brief              Pkcs08AttributeValue object will consist of the value of an attribute and the tag value.
+ * @since              2.1
+ *
+ */
+class _OSP_EXPORT_ Pkcs08AttributeValue
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        */
+       Pkcs08AttributeValue(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~Pkcs08AttributeValue(void);
+
+       /**
+        * Intializes this instance of %Pkcs08AttributeValue with the Bytebuffer which contain  AttributeValue @n
+        * (contain tag i.e. Ans1_Type and the value)
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer of AttrributeValue.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Intializes this instance of %Pkcs08AttributeValue with specified parameters.
+        * This API implements the Construct API which initializes the attribute value instance based on passed byte buffer.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   value                                   An instance of ByteBuffer, holding raw value. @n
+        * @param[in]   tag                                             Tag holding the tag type. This tag number is assigned by ASN1 standards for @n
+        *                                                                                                      basic data types.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& value, const Pkcs08TagValue tag);
+
+       /**
+        * Get the reference to the ByteBuffer contains the attribute value.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to ByteBuffer,containing raw value.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const Tizen::Base::ByteBuffer& GetValue(void) const;
+
+       /**
+        * Get the tag value of an attribute.
+        * This tag number is assigned by ASN1 standards for basic data types..
+        *
+        * @since               2.1
+        *
+        * @return              Tag value that is assigned by ASN1 standards for basic data types.
+        */
+       Pkcs08TagValue GetTag(void) const;
+
+       /**
+        * Gets the pointer to the ByteBuffer that contains the attribute value in encoded format.
+        * It is assumed that each Pkcs08Attribute will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs08AttributeValue(const Pkcs08AttributeValue& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       Pkcs08AttributeValue& operator =(const Pkcs08AttributeValue& rhs);
+
+private:
+       class _Pkcs08AttributeValueImpl* __pPkcs08AttributeValueImpl;
+       friend class _Pkcs08AttributeValueImpl;
+
+}; //Pkcs08AttributeValue
+
+}}} //Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_PKCS_08_ATTRIBUTE_VALUE_H_
diff --git a/inc/FSecPkcsPkcs08EncryptedPrivateKeyInfo.h b/inc/FSecPkcsPkcs08EncryptedPrivateKeyInfo.h
new file mode 100644 (file)
index 0000000..f97453e
--- /dev/null
@@ -0,0 +1,182 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08EncryptedPrivateKeyInfo.h
+ * @brief              This is the header file for the %Pkcs08EncryptedPrivateKeyInfo class.
+ *
+ * This header file contains the declarations of the %Pkcs08EncryptedPrivateKeyInfo class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
+#define _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Pkcs08EncryptedPrivateKeyInfo
+ * @brief              This class implements to encrypt a private key.An Encrypted private key structure consist
+ *                                     of an encryption algorithm and the encrypted Pkcs08PrivateKeyInfo.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             EncryptedPrivateKeyInfo ::= SEQUENCE {
+ *                             encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
+ *                             encryptedData EncryptedData
+ *                             }
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ Pkcs08EncryptedPrivateKeyInfo
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       Pkcs08EncryptedPrivateKeyInfo(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~Pkcs08EncryptedPrivateKeyInfo(void);
+
+       /**
+        * Initializes this instance of %Pkcs08EncryptedPrivateKeyInfo with the encoded Bytebuffer which contain  @n
+        * EncryptedPrivateKeyInfo structure(EncryptedPrivateKeyInfo) in ASN.1 DER format.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     DER encoded Bytebuffer contains Pkcs08 EncryptedPrivateKeyInfo structure.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %Pkcs08EncryptedPrivateKeyInfo with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   algorithmId                                     An instance of AlgorithmIdentifier.
+        * @param[in]   encryptedData                           Encrypted private key.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData);
+
+       /**
+        * Initializes the %Pkcs08EncryptedPrivateKeyInfo with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   algorithmId                                             An instance of AlgorithmIdentifier which identifies secret key algorithm.
+        * @param[in]   key                                                                             Key for encrypting privateKeyInfo.
+        * @param[in]   encodedPrivateKeyInfo   An instance of encryptedPrivateKeyInfo.
+        * @exception   E_SUCCESS                                                       The method is successful.
+        * @exception   E_INVALID_ARG                                   The specified input parameter is invalid.
+        *
+        */
+       result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfo);
+
+       /**
+        * Gets the reference to AlgorithmIdentifier which identifies the  encryption algorithm under which private key is encrypted.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier Contains the algorithm identifier of Pkcs08EncryptedPrivateKeyInfo object.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetAlgorithm(void) const;
+
+       /**
+        * Gets the pointer to the ByteBuffer which contains encrypted private key.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to ByteBuffer class contains the private key of Pkcs08EncryptedPrivateKeyInfo object, @n
+        *                              else @c null if an error occurs.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncryptedDataN(void) const;
+
+       /**
+        * This API will provide the implementation of DecryptN to decrypt the Pkcs08EncryptedPrivateKeyInfo Object
+        * using the Key or Password.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to ByteBuffer Contains the decrypted private key of Pkcs08EncryptedPrivateKeyInfo object, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   key                             An instance of ByteBuffer, holding key to decrypt private key using particular @n
+        *                                                                                      secret key algorithm.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* DecryptN(const Tizen::Base::ByteBuffer& key);
+
+       /**
+        * Gets the ASN.1 DER encoded pkcs08 encrypted private key structure.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs08EncryptedPrivateKeyInfo(const Pkcs08EncryptedPrivateKeyInfo& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       Pkcs08EncryptedPrivateKeyInfo& operator =(const Pkcs08EncryptedPrivateKeyInfo& rhs);
+
+private:
+       class _Pkcs08EncryptedPrivateKeyInfoImpl* __pPkcs08EncryptedPrivateKeyInfoImpl;
+       friend class _Pkcs08EncryptedPrivateKeyInfoImpl;
+
+
+}; //Pkcs08EncryptedPrivateKeyInfo
+
+}}} // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
diff --git a/inc/FSecPkcsPkcs08PrivateKeyInfo.h b/inc/FSecPkcsPkcs08PrivateKeyInfo.h
new file mode 100644 (file)
index 0000000..c218c60
--- /dev/null
@@ -0,0 +1,195 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08PrivateKeyInfo.h
+ * @brief              This is the header file for the %Pkcs08PrivateKeyInfo class.
+ *
+ * This header file contains the declarations of the %Pkcs08PrivateKeyInfo class.
+ */
+
+#ifndef _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
+#define _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsPkcs08Attribute.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Pkcs08PrivateKeyInfo
+ * @brief              This class implements the functionalities specified by the Pkcs08 PrivateKeyInfo class.
+ *                             This class represents the structure of Pkcs08 Private Key Info.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             PrivateKeyInfo ::= SEQUENCE {
+ *                             version Version,
+ *                             privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
+ *                             privateKey PrivateKey,
+ *                             attributes [0] Attributes OPTIONAL }
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ Pkcs08PrivateKeyInfo
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       Pkcs08PrivateKeyInfo(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~Pkcs08PrivateKeyInfo(void);
+
+       /**
+        * Initializes this instance of %Pkcs08PrivateKeyInfo with the encoded byte buffer which contain  @n
+        * pkcs08 private key info structure(PrivateKeyInfo) in ASN.1 DER format. @n
+        * It parses this encoded buffer and extracts the appropiate values of private key, its algorithm id and attributes.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     The instance of Bytebuffer, containing DER encoded PrivateKeyInfo structure.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %Pkcs08PrivateKeyInfo with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code.
+        * @param[in]   keyAlgorithmId                  An instance of AlgorithIdentifier, holding algorithm identifier of private key algorithm.
+        * @param[in]   privateKey                                      An instance of ByteBuffer holding privatekey.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& keyAlgorithmId, const Tizen::Base::ByteBuffer& privateKey);
+
+       /**
+        * This function will provide the implementation of GetVersion API to get the private key syntax version number of PrivateKeyInfo object @n
+        * that is used for storing private key and its related information and default value of this version is 0.
+        *
+        * @since               2.1
+        *
+        * @return              An integer valuse contains the version.
+        *
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Gets the reference to AlgorithmIdentifier which identifies the secret key algorithm.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier Contains the algorithm identifier of Pkcs08PrivateKeyInfo object.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetPrivateKeyAlgorithm(void) const;
+
+       /**
+        * This function will provide the implementation of GetPrivateKeyN API to get the reference to ByteBuffer which contains
+        * the private key in binary format.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to ByteBuffer Contains the private key of Pkcs08PrivateKeyInfo object.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const Tizen::Base::ByteBuffer& GetPrivateKey(void) const;
+
+       /**
+        * This API will provide the implementation of GetAttributes API to get the Attributes of type Pkcs08Attribute which are extended @n
+        * information of private key in context.
+        *
+        * @since               2.1
+        *
+        * @return              Reference to array list, contains the list of attributes of type Pkcs08Attribute.
+        */
+       const Tizen::Base::Collection::ArrayList& GetAttributes(void) const;
+
+       /**
+        * This function adds Attributes in private key info i.e. extended information of private key in context.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributes                                      An instance of Pkcs08Attribute class..
+        */
+       result AddAttribute(const Pkcs08Attribute& attributes);
+
+       /**
+        * This function remove Attribute in private key info i.e. extended information of private key in context.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributes                                      An instance of Pkcs08Attribute class.
+        */
+       result RemoveAttribute(const Pkcs08Attribute& attributes);      
+       
+       /**
+        * Gets the DER encoded Pkcs08PrivateKeyInfo structure.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer Contains the DER encoded private key info.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Pkcs08PrivateKeyInfo(const Pkcs08PrivateKeyInfo& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       Pkcs08PrivateKeyInfo& operator =(const Pkcs08PrivateKeyInfo& rhs);
+
+private:
+       class _Pkcs08PrivateKeyInfoImpl* __pPkcs08PrivateKeyInfoImpl;
+       friend class _Pkcs08PrivateKeyInfoImpl;
+
+}; //Pkcs08PrivateKeyInfo
+
+}}} // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_PKCS_08_PRIVATE_KEY_INFO_H_
diff --git a/inc/FSecPkcsRc2CbcParameters.h b/inc/FSecPkcsRc2CbcParameters.h
new file mode 100644 (file)
index 0000000..925f30a
--- /dev/null
@@ -0,0 +1,182 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsRc2CbcParameters.h
+ * @brief              This is the header file for the %PkcsRc2CbcParametersr class.
+ *
+ * This header file contains the declarations of the %PkcsRc2CbcParameters class.
+ */
+
+#ifndef _FSEC_PKCS_RC2_CBC_PARAMETERS_H_
+#define _FSEC_PKCS_RC2_CBC_PARAMETERS_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsTypes.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              Rc2CbcParameters
+ * @brief              This class implements the functionalities specified by the Rc2 Cbc mode parameter.
+ * @brief              This class implements the functionalities specified by the Rc2 Cbc mode parameter.
+ *                                     This class represents the Rc2 cbc mode parameter for symmetric ciphers RC2.
+ *                                     ASN.1 format for RC2-CBC-Parameter ::= SEQUENCE {
+ *                                     rc2ParameterVersion INTEGER OPTIONAL,
+ *                                     iv OCTET STRING (SIZE(8)) }
+ *
+ * @since              2.1
+ *
+ */
+
+class _OSP_EXPORT_ Rc2CbcParameters
+       : public virtual IAlgorithmParameters
+       , public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       Rc2CbcParameters(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~Rc2CbcParameters(void);
+
+       /**
+        * Initializes this instance of %Rc2CbcParameters with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   initialVector                   An instance of ByteBuffer containing the initial vector.
+        * @param[in]   version                                         An integer value defines the rc2 cbc parameter version.
+        *                                                                                                                      As per Pkcs 5 standard, possible value can be 160,120,58 or any value
+        *                                                                                                                      greater than or equal to 256.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& initialVector, int version = 0);
+
+       /**
+        * Get the copy of this instance.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to IAlgorithmParameters, containing the copy of this instance.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual IAlgorithmParameters* CloneN(void) const;
+
+       /**
+        * Get the algorithm parameter type enum value for Rc2CbcParameters.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType      Enum value  containing the PKCS_ALGO_PARAM_TYPE_RC2 value for Rc2CbcParameters parameter.
+        *
+        */
+       virtual PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %Rc2CbcParameters equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                             An instance of %Rc2CbcParameters
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+       */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %Rc2CbcParameters.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %Rc2CbcParameters
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Get the rc2 cbc parameter version value.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value that contains the rc2 cbc parameter version.
+        *
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Get the instance of byte buffer that contains the Initial Vector value.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to ByteBuffer , containing the initial vector data.
+        *
+        */
+       const Tizen::Base::ByteBuffer& GetInitialVector(void) const;
+
+       /**
+        * Gets the encoded form of the Rc2CbcParameter. @n
+        * It is assumed that each Rc2CbcParameter type will have only a single form of encoding that is DER encoding.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to the DER encoded ByteBuffer, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       Rc2CbcParameters(const Rc2CbcParameters& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use GetCloneN() to get an exact copy of the instance.
+       //
+       // @since               2.1
+       Rc2CbcParameters& operator =(const Rc2CbcParameters& rhs);
+
+private:
+       class _Rc2CbcParametersImpl* __pRc2CbcParametersImpl;
+       friend class _Rc2CbcParametersImpl;
+
+}; // Rc2CbcParameters
+
+} } } // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_RC2_CBC_PARAMETERS_H_
diff --git a/inc/FSecPkcsTypes.h b/inc/FSecPkcsTypes.h
new file mode 100644 (file)
index 0000000..ca8a643
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsTypes.h
+ * @brief              This header file contains the declarations of AlgorithmIdentifier and AttributeType OID List.
+ * @brief              This header file also contains the enum declaration of AlgorithmParameterType and Pkcs08TagValue.
+ *
+ * This header file contains the declarations of the AlgorithmIdentifier and AttributeType OID List.
+ * It also contains the enum declaration of AlgorithmParameterType and Pkcs08TagValue.
+ */
+
+#ifndef _FSEC_PKCS_TYPES_H_
+#define _FSEC_PKCS_TYPES_H_
+
+#include <FBaseString.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @enum    PkcsAlgorithmParameterType
+ *
+ * Defines the type of parameters.
+ *
+ * @since              2.1
+ */
+enum PkcsAlgorithmParameterType
+{
+       PKCS_ALGO_PARAM_TYPE_IV,              /**< parameter type is initial vector */
+       PKCS_ALGO_PARAM_TYPE_PKCS05_PBES02,   /**< parameter type is pkcs5 password based encryption scheme2 */
+       PKCS_ALGO_PARAM_TYPE_PKCS05_KDF02,    /**< parameter type is pkcs5 password based key derivation scheme2 */
+       PKCS_ALGO_PARAM_TYPE_PKCS05_MAC,      /**< parameter type is pkcs5 message authentication scheme */
+       PKCS_ALGO_PARAM_TYPE_RC2,             /**< parameter type is rc2 cbc */
+       PKCS_ALGO_PARAM_TYPE_UNKOWN = 0xFFFFFFFF  /**< Unknown parameter type */
+}; //PkcsAlgorithmParameterType;
+
+/**
+ * @enum       Pkcs08TagValue
+ *
+ * Defines the Asn1 tag type.
+ *
+ * @since 2.1
+ */
+enum Pkcs08TagValue
+{
+       PKCS08_TAG_RESERVED = 0, /**< reserved for use by the encoding rules. */
+       PKCS08_TAG_BOOLEAN = 1, /**< an arbitrary bool value. */
+       PKCS08_TAG_INTEGER = 2, /**< an arbitrary integer value. */
+       PKCS08_TAG_BITSTRING = 3, /**< an arbitrary string of bits. */
+       PKCS08_TAG_OCTETSTRING = 4, /**< an arbitrary string of octets. */
+       PKCS08_TAG_NULL = 5, /**< a null value. */
+       PKCS08_TAG_OBJECT_ID = 6, /**< object identifier. */
+       PKCS08_TAG_OBJECT_DES = 7, /**< object descriptor providing a brief description of an object. */
+       PKCS08_TAG_EXTERNAL = 8, /**< an arbitrary external value. */
+       PKCS08_TAG_REAL = 9, /**< an arbitrary real value. */
+       PKCS08_TAG_ENUM = 10, /**< an enumerated value. */
+       PKCS08_TAG_EMBEDDED = 11, /**< an embedded value. */
+       PKCS08_TAG_UTF8STRING = 12, /**< an arbitrary utf8 string. */
+       PKCS08_TAG_REL_OBJ_ID = 13, /**< relative object id. */
+       PKCS08_TAG_SEQUENCE = 16, /**< an ordered collection of one or more types. */
+       PKCS08_TAG_SET = 17, /**< an unordered collection of one or more types. */
+       PKCS08_TAG_CHAR_STRING = 18, /**< numeric string. */
+       PKCS08_TAG_PRINTABLE_STRING = 19, /**< an arbitrary string of printable characters. */
+       PKCS08_TAG_TELETEXT_STRING = 20, /**< teletext string, T61 string. */
+       PKCS08_TAG_VIDEOTEXT_STRING = 21, /**< videotex string. */
+       PKCS08_TAG_IA5STRING = 22, /**< an arbitrary string of IA5 (ASCII) characters.*/
+       PKCS08_TAG_UTC_TIME = 23, /**< a coordinated universal time" or Greenwich Mean Time (GMT) value. */
+       PKCS08_TAG_GEN_TIME = 24, /**< generalized time. */
+       PKCS08_TAG_GRAPHICS_STRING = 25, /**< graphic string. */
+       PKCS08_TAG_VISIBLE_STRING = 26, /**< visible string, ISO64 string. */
+       PKCS08_TAG_GENERAL_STRING = 27, /**< general string. */
+       PKCS08_TAG_UNIVERSAL_STRING = 28, /**< universal string. */
+       PKCS08_TAG_CHARACTER_STRING = 29, /**< an arbitrary character string. */
+       PKCS08_TAG_BMP_STRING = 30, /**< bmp string. */
+       PKCS08_TAG_UNKNOWN = -1 /**< unknown tag type. */
+}; // Pkcs08TagValue;
+
+/*
+-- Basic object identifiers in Pkcs05 and Pkcs08
+*/
+
+_OSP_EXPORT_ extern const wchar_t OID_PKCS_05[];    /**< object identifier for pkcs05. */
+_OSP_EXPORT_ extern const wchar_t OID_PBKDF2[];  /**< object identifier for password based key derivation function scheme2. */
+_OSP_EXPORT_ extern const wchar_t OID_PBES2[];   /**< object identifier for password based encryption scheme2. */
+_OSP_EXPORT_ extern const wchar_t OID_PBMAC1[];  /**< object identifier for password based message authetication scheme1. */
+_OSP_EXPORT_ extern const wchar_t OID_HMAC_SHA1[];  /**< object identifier for hmac-sha1. */
+_OSP_EXPORT_ extern const wchar_t OID_HMAC_SHA2_224[];  /**< object identifier for hmac-sha224. */
+_OSP_EXPORT_ extern const wchar_t OID_HMAC_SHA2_256[];  /**< object identifier for hmac-sha256. */
+_OSP_EXPORT_ extern const wchar_t OID_HMAC_SHA2_384[]; /**< object identifier for hmac-sha384. */
+_OSP_EXPORT_ extern const wchar_t OID_HMAC_SHA2_512[]; /**< object identifier for hmac-sha512. */
+_OSP_EXPORT_ extern const wchar_t OID_DES_CBC[];  /**< object identifier for des-cbc mode. */
+_OSP_EXPORT_ extern const wchar_t OID_DES_CBC_EDE3[];   /**< object identifier for des-cbc-ede3 mode. */
+_OSP_EXPORT_ extern const wchar_t OID_AES_128_CBC[];    /**< object identifier for aes-128-cbc mode. */
+_OSP_EXPORT_ extern const wchar_t OID_AES_192_CBC[];   /**< object identifier for aes-192-cbc mode. */
+_OSP_EXPORT_ extern const wchar_t OID_AES_256_CBC[];   /**< object identifier for aes-256-cbc mode. */
+_OSP_EXPORT_ extern const wchar_t OID_RC2_CBC[];    /**< object identifier for rc2-cbc mode. */
+_OSP_EXPORT_ extern const wchar_t OID_PKCS_08[];    /**< object identifier for pkcs08. */
+_OSP_EXPORT_ extern const wchar_t OID_RSA_ENCRYPTION[];   /**< object identifier for rsa encryption scheme. */
+
+
+/*
+-- Basic object identifiers in Pkcs08 for AttributeType
+*/
+
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_NAME[];  /**< object identifier for attribute type name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_SURNAME[];    /**< object identifier for attribute type surname. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_GIVEN_NAME[]; /**< object identifier for attribute type of any given name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_INITIAL[];   /**< object identifier for attribute type initial. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_GEN_QUALIFIER[];  /**< object identifier for attribute type generation qualifier. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_COMMON_NAME[]; /**< object identifier for attribute type common name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_LOCALITY_NAME[];  /**< object identifier for attribute type locality name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_STATE_OR_PROV_NAME[];   /**< object identifier for attribute type state/province name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_ORG_NAME[]; /**< object identifier for attribute type of any orgnization name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_ORG_UNIT_NAME[];    /**< object identifier for any orgnization unit name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_TITLE[]; /**< object identifier for attribute type title. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_DN_QUALIFIER[];   /**< object identifier for distinguished name qualifier. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_COUNTRY_NAME[];    /**< object identifier for attribute type country name. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_SERIAL_NUMBER[];   /**< object identifier for attribute type serial number. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_PSEUDONYM[]; /**< object identifier for attribute type pseudonym. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_DOMAIN_COMPONENT[]; /**< object identifier for any domain component. */
+_OSP_EXPORT_ extern const wchar_t OID_ATTR_EMAIL_ADDRESS[];  /**< object identifier for any email address. */
+
+} } } // Tizen::Security::Pkcs
+
+
+
+
+#endif // _FSEC_PKCS_TYPES_H_
diff --git a/inc/FSecPrivacyInfo.h b/inc/FSecPrivacyInfo.h
new file mode 100755 (executable)
index 0000000..741eda0
--- /dev/null
@@ -0,0 +1,162 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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    FSecPrivacyInfo.h
+* @brief  This is the header file for the %PrivacyInfo class.
+*
+* This header file contains the declarations of the %PrivacyInfo class.
+*/
+#ifndef _FSEC_PRIVACY_INFO_H_
+#define _FSEC_PRIVACY_INFO_H_
+#include <FBaseObject.h>
+namespace Tizen { namespace Security
+{
+/**
+* @class       PrivacyInfo
+* @brief       This class represents the privacy information.
+*
+* @since       2.1
+*
+* @final This class is not intended for extension.
+*
+* The %PrivacyInfo class represents the privacy information.
+* %PrivacyInfo provides methods to retrieve the name and description of privilege.
+*/
+class _OSP_EXPORT_ PrivacyInfo
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       PrivacyInfo(void);
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.1
+        *
+        */
+       virtual ~PrivacyInfo(void);
+       /**
+        * Initializes this instance of %PrivacyInfo with the specified parameters.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   privacyId                       The privacy ID
+        * @param[in]   enable                          Set to @c true to enable the privacy setting, @n
+        *                                  else @c false
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c privacyId is invalid or the @c privacyId is not exist.
+        *
+        */
+       result Construct(const Tizen::Base::String& privacyId, bool enable = false);
+       /**
+        * Gets a privacy ID.
+        *
+        * @since               2.1
+        *
+        * @return              The privacy ID.
+        *
+        */
+       Tizen::Base::String GetId(void) const;
+       /**
+        * Checks whether the privacy setting is enabled.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the privacy setting is enabled, @n
+        *                              else @c false
+        * @see                 SetEnabled()
+        */
+       bool IsEnabled(void) const;
+       /**
+        * Enables or disables the privacy setting.
+        *
+        * @since               2.1
+        *
+        * @param[in]   enable                  A Boolean value indicating whether the privacy setting is enabled.
+        * @see                 IsEnabled()
+        *
+        */
+       void SetEnabled(bool enable);
+       /**
+        * Gets the localized display name of privacy.
+        *
+        * @since               2.1
+        *
+        * @return              The display name of privacy, else an empty string is returned if there is no value.
+        *
+        */
+       Tizen::Base::String GetDisplayName(void) const;
+       /**
+        * Gets the localized description of privacy.
+        *
+        * @since               2.1
+        *
+        * @return              The description of privacy, else an empty string is returned if there is no value.
+        *
+        */
+       Tizen::Base::String GetDescription(void) const;
+private:
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @param[in]   rhs         An instance of %PrivacyInfo
+       //
+       PrivacyInfo(const PrivacyInfo& rhs);
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @param[in]   rhs          An instance of %PrivacyInfo
+       //
+       PrivacyInfo& operator =(const PrivacyInfo& rhs);
+private:
+       class _PrivacyInfoImpl* __pImpl;
+       friend class _PrivacyInfoImpl;
+}; // PrivacyInfo
+} } // Tizen::Security
+#endif // _FSEC_PRIVACY_INFO_H_
diff --git a/inc/FSecPrivacyManager.h b/inc/FSecPrivacyManager.h
new file mode 100755 (executable)
index 0000000..6265248
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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                FSecPrivacyManager.h
+* @brief       This is the header file for the %PrivacyManager class.
+*
+* This header file contains the declarations of the %PrivacyManager class.
+*/
+#ifndef _FSEC_PRIVACY_MANAGER_H_
+#define _FSEC_PRIVACY_MANAGER_H_
+#include <FBaseObject.h>
+#include <FAppTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Security
+{
+class PrivacyInfo;
+/**
+ * @class        PrivacyManager
+ * @brief        This class gets the privacy information and manages an application's privacy settings.
+ *
+ * @since   2.1
+ *
+ * @final   This class is not intended for extension.
+ *
+ * The %PrivacyManager class lets an application to get or save application's privacy settings.
+ */
+class _OSP_EXPORT_ PrivacyManager
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Gets the privacy manager instance.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the %PrivacyManager instance, @n
+        *                              else @c null if it fails
+        *
+        * @exception   E_SUCCESS                 The method is successful.
+        * @exception   E_SYSTEM                   The method cannot proceed due to a severe system error.
+        *
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static PrivacyManager* GetInstance(void);
+       /**
+        * Gets a list of packages which access user's privacy information.
+        *
+        * @since               2.1
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/privacymanager.read
+        *
+        * @return              A pointer to the list of application packages (PackageId) which access user's privacy information, @n
+        *                              else @c null if an error occurs
+        *
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        *
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetPrivacyAppPackageListN(void) const;
+       /**
+        * Gets a list of privacy information of a package.
+        *
+        * @since               2.1
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/privacymanager.read
+        *
+        * @return              A pointer to the privacy information list (Privacyinfo), @n
+        *                              else @c null if an error occurs
+        * @param[in]   packageId                               The package ID
+        *
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        *
+        * @remarks              The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const;
+
+       /**
+        * Sets the specific privacy setting of a package
+        *
+        * @since               2.1
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/privacymanager.write
+        *
+        * @return              An error code
+        * @param[in]   packageId                               The package ID
+        * @param[in]   privacyInfo                             The privacy setting to be set
+        *
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c packageId is not found in privacy database or @n
+        *                                                                              the package did not be defined to access to the privacy information.
+        * @exception   E_INVALID_ARG                   The specified @c packageId length is invalid.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        *
+        */
+       result SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo);
+private:
+       //
+       // This default constructor is intentionally declared as private to implement the %Singleton semantic.
+       //
+       // @since                  2.1
+       //
+       PrivacyManager(void);
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since                  2.1
+       //
+       PrivacyManager(const PrivacyManager& rhs);
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since                  2.1
+       //
+       PrivacyManager& operator =(const PrivacyManager& rhs);
+       //
+       // This destructor is intentionally declared as private to implement the %Singleton semantic.
+       //
+       // @since                  2.1
+       //
+       virtual ~PrivacyManager(void);
+private:
+       class _PrivacyManagerImpl* __pPrivacyManagerImpl;
+       friend class _PrivacyManagerImpl;
+}; // PrivacyManager
+}} // Tizen::Security
+#endif // _FSEC_PRIVACY_MANAGER_H_
diff --git a/inc/FSecPrivilegeInfo.h b/inc/FSecPrivilegeInfo.h
new file mode 100755 (executable)
index 0000000..a7816b2
--- /dev/null
@@ -0,0 +1,167 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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       FSecPrivilegeInfo.h
+ * @brief      This is the header file for the %PrivilegeInfo class.
+ *
+ * This header file contains the declarations of the %PrivilegeInfo class.
+ */
+
+#ifndef _FSEC_PRIVILEGE_INFO_H_
+#define _FSEC_PRIVILEGE_INFO_H_
+#include <FBaseObject.h>
+namespace Tizen { namespace Security
+{
+
+class _PrivilegeInfoImpl;
+
+/**
+* @class       PrivilegeInfo
+* @brief       This class represents the privilege information.
+*
+* @since       2.1
+*
+* @final       This class is not intended for extension.
+*
+* The %PrivilegeInfo class represents the privilege information.
+* %PrivilegeInfo provides methods to retrieve the name and description of privilege.
+*
+*/
+
+class _OSP_EXPORT_ PrivilegeInfo
+       : public Tizen::Base::Object
+{
+public:
+
+       /**
+        * Gets the name of a privilege.
+        *
+        * @since       2.1
+        *
+        * @return              The name of a privilege, else an empty string is returned if there is no value.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        An unexpected system error occurred.
+        * @exception   E_INVALID_ARG           The specified input privilege string is invalid.
+        * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::String GetName(const Tizen::Base::String& privilege);
+
+       /**
+        * Gets the description of a privilege.
+        *
+        * @since               2.1
+        *
+        * @return              The description of a privilege, else an empty string is returned if there is no value.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        An unexpected system error occurred.
+        * @exception   E_INVALID_ARG           The specified input privilege string is invalid.
+        * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::String GetDescription(const Tizen::Base::String& privilege);
+
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        *
+        * @remarks  After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       PrivilegeInfo(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.1
+        *
+        */
+       virtual ~PrivilegeInfo(void);
+
+       /**
+        * Initializes this instance of %PrivilegeInfo with the specified parameters.
+        *
+        * @since         2.1
+        *
+        * @return       An error code
+        * @param[in]   privilegeId                The privilege ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG          The specified @c privilegeId is invalid.
+        *
+        */
+       result Construct(const Tizen::Base::String& privilegeId);
+
+       /**
+        * Gets a privilege ID.
+        *
+        * @since              2.1
+        *
+        * @return            The privilege ID.
+        *
+        */
+       Tizen::Base::String GetId(void) const;
+
+       /**
+        * Gets the localized display name of privilege.
+        *
+        * @since              2.1
+        *
+        * @return            The display name of privilege, else an empty string is returned if there is no value.
+        *
+        */
+       Tizen::Base::String GetDisplayName(void) const;
+
+       /**
+        * Gets the localized description of privilege.
+        *
+        * @since              2.1
+        *
+        * @return            The description of privilege, else an empty string is returned if there is no value.
+        *
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+private:
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @param[in]   rhs         An instance of %PrivilegeInfo
+       //
+       PrivilegeInfo(const PrivilegeInfo& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @param[in]   rhs An instance of %PrivilegeInfo
+       //
+       PrivilegeInfo& operator =(const PrivilegeInfo& rhs);
+
+private:
+       static class _PrivilegeInfoImpl* __pPrivilegeInfoImpl;
+       class _PrivilegeInfoImpl * __pImpl;
+       friend class _PrivilegeInfoImpl;
+
+}; // PrivilegeInfo
+
+} } // Tizen::Security::PrivilegeInfo
+
+#endif // _FSEC_PRIVILEGE_INFO_H_
diff --git a/inc/FSecRsaKeyConverter.h b/inc/FSecRsaKeyConverter.h
new file mode 100644 (file)
index 0000000..dda7168
--- /dev/null
@@ -0,0 +1,165 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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                       FSecRsaKeyConverter.h
+ * @brief              This is the header file for the %RsaKeyConverter class.
+ *
+ * This header file contains the declarations of the %RsaKeyConverter class.
+ */
+
+#ifndef _FSEC_RSA_KEY_CONVERTER_H_
+#define _FSEC_RSA_KEY_CONVERTER_H_
+
+#include <FSecIPublicKey.h>
+#include <FSecIPrivateKey.h>
+
+namespace Tizen { namespace Security
+{
+
+/**
+ * @enum    RsaKeyFormat
+ *
+ * Defines the type of rsa key format.
+ *
+ * @since              2.1
+ */
+enum RsaKeyFormat
+{
+       RSA_KEY_FORMAT_PKCS01_PRIVATE_KEY = 0,     /**< % rsa key format is pkcs1 private key. */
+       RSA_KEY_FORMAT_PKCS01_PUBLIC_KEY = 1,      /**< % rsa key format is pkcs1 public key. */
+       RSA_KEY_FORMAT_PKCS08_PRIVATE_KEY = 2,     /**< % rsa key format is pkcs8 private key. */
+       RSA_KEY_FORMAT_X509_PUBLIC_KEY = 3,      /**< % rsa key format is X509 public key. */
+       RSA_KEY_FORMAT_UNKNOWN = 0xffffffff       /**< % rsa key format is unknown. */
+}; //RsaKeyFormat;
+
+/**
+ *  @class             RsaKeyConverter
+ *  @brief             This class provides support for converting the RSA public/private key in multiple key formats and multiple encoding formats.
+ *                             Supported RSA key formats are PKCS1/PKCS8/X509.
+ *                             Supported encoding formats are DER/PEM.
+ *  @since      2.1
+ */
+
+class _OSP_EXPORT_ RsaKeyConverter
+{
+
+public:
+       /**
+        *      Generates a RSA encoded private key in the passed input RSA key format.
+        *      If the input private key is in PEM encoded format then the output RSA private key will be PEM encoded and if it is in DER encoded format
+        *      then the output RSA private key will be DER encoded.
+        *
+        *      @since          2.1
+        *
+        *      @return         A pointer to the encoded %ByteBuffer instance, @n
+        *                          else @c null if the method fails to convert the private key in the passed input format.
+        *      @param[in]      format                          An enum value contains the RSA private key format.
+        *                                                                      Valid values for the supported output RSA private key formats are only RSA_KEY_FORMAT_PKCS01_PRIVATE_KEY, RSA_KEY_FORMAT_PKCS08_PRIVATE_KEY.
+        *      @param[in]      key                                     An instance of IPrivateKey.
+        *      @exception      E_SUCCESS                                       The method is successful.
+        *      @exception      E_INVALID_ARG           The specified input parameter is invalid.
+        *  @remarks    The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::ByteBuffer* ConvertPrivateKeyFormatN(RsaKeyFormat format, const IPrivateKey& key);
+
+       /**
+        *      Generates a RSA encoded public key in the passed input RSA key format.
+        *      If the input public key is in PEM encoded format then the output RSA public key will be PEM encoded and if it is in DER encoded format
+        *      then the output RSA public key will be DER encoded.
+        *
+        *      @since          2.1
+        *
+        *      @return         A pointer to the encoded %ByteBuffer instance, @n
+        *                              else @c null if the method fails to convert the public key in the passed input format.
+        *      @param[in]      format                          An enum value contains the RSA public key format.
+        *                                                                      Valid values for the supported output RSA public key formats are only RSA_KEY_FORMAT_PKCS01_PUBLIC_KEY, RSA_KEY_FORMAT_X509_PUBLIC_KEY.
+        *      @param[in]      key                                     An instance of IPublicKey.
+        *      @exception      E_SUCCESS                                       The method is successful.
+        *      @exception      E_INVALID_ARG           The specified input parameter is invalid.
+        *      @remarks    The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::ByteBuffer* ConvertPublicKeyFormatN(RsaKeyFormat format, const IPublicKey& key);
+
+       /**
+        *      Converts a DER encoded RSA key to the PEM encoded format.
+        *
+        *      @since          2.1
+        *
+        *      @return         A pointer to the PEM encoded %ByteBuffer instance, @n
+                                       else @c null if the method fails to convert the key in the pem encoded format.
+        *      @param[in]      format                          An enum value contains the RSA key format of the input key.
+        *      @param[in]      key                                     An instance of IKey.
+        *      @exception      E_SUCCESS                                       The method is successful.
+        *      @exception      E_INVALID_ARG           The specified input parameter is invalid.
+        *      @remarks    The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::ByteBuffer* ConvertDerToPemN(RsaKeyFormat format, const IKey& key);
+
+       /**
+        *      Converts a PEM encoded RSA key to the DER encoded format.
+        *
+        *      @since          2.1
+        *
+        *      @return         A pointer to the DER encoded %ByteBuffer instance, @n
+                                           else @c null if the method fails to convert the key in the der encoded format.
+        *      @param[in]      format                          An enum value contains the RSA key format of the input key.
+        *      @param[in]      key                                     An instance of IKey,
+        *      @exception      E_SUCCESS                                       The method is successful.
+        *      @exception      E_INVALID_ARG           The specified input parameter is invalid.
+        *  @remarks    The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::ByteBuffer* ConvertPemToDerN(RsaKeyFormat format, const IKey& key);
+
+private:
+       //
+       // This default constructor is intentionally declared as private because this class cannot be constructed.
+       //
+       // @since       2.1
+       //
+       RsaKeyConverter(void);
+
+       //
+       // This destructor is intentionally declared as private because this class cannot be constructed.
+       //
+       // @since       2.1
+       //
+       ~RsaKeyConverter(void);
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since 2.1
+       //
+       RsaKeyConverter(const RsaKeyConverter& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since 2.1
+       //
+       RsaKeyConverter& operator =(const RsaKeyConverter& rhs);
+
+private:
+       class _RsaKeyConverterImpl* __pRsaKeyConverterImpl;
+       friend class _RsaKeyConverterImpl;
+
+};     //RsaKeyConverter
+
+} } //Tizen::Security
+
+#endif // _FSEC_RSA_KEY_CONVERTER_H_
old mode 100644 (file)
new mode 100755 (executable)
index a587a64..d67f259
 #include "FSecCryptoDhKeyExchange.h"
 #include "FSecKeaKeyParameters.h"
 #include "FSecDhKeyParameters.h"
+#include "FSecRsaKeyConverter.h"
 #include "FSecCrypto.h"
 #include "FSecCert.h"
+#include "FSecPkcs.h"
+#include "FSecPrivacyManager.h"
+#include "FSecPrivacyInfo.h"
+#include "FSecPrivilegeInfo.h"
+#include "FSecAccessController.h"
 
 
 /**
old mode 100755 (executable)
new mode 100644 (file)
index 475dc0b..f59dafd
@@ -83,7 +83,7 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/alarm
+        * @privilege   http://tizen.org/privilege/alarm
         *
         * @return      An error code
         * @param[in]   duetime                 The time for the alarm to ring
@@ -100,7 +100,7 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/alarm
+        * @privilege   http://tizen.org/privilege/alarm
         *
         * @return      An error code
         * @param[in]   start                   The time for the alarm to ring first
@@ -119,7 +119,7 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/alarm
+        * @privilege   http://tizen.org/privilege/alarm
         *
         * @return      An error code
         * @exception   E_SUCCESS               The method is successful.
@@ -134,7 +134,7 @@ public:
         * @since       2.0
         *
         * @return      An instance of Tizen::Base::DateTime indicating the start time for the alarm
-        * @remarks     If this Alarm instance is not registered by %Set method, return value is default value of %DateTime class.
+        * @remarks     If this Alarm instance is not registered by Set() methods, return value is default value of %DateTime class.
         */
        const Tizen::Base::DateTime GetStartTime(void) const;
 
@@ -144,7 +144,7 @@ public:
         * @since       2.0
         *
         * @return      The period of the current instance of %Alarm in minutes
-        * @remarks     If this Alarm instance is not registered by %Set method, return value is 0.
+        * @remarks     If this Alarm instance is not registered by Set() methods, return value is @c 0.
         */
        int GetPeriod(void) const;
 
index d4d14c7..d567f89 100644 (file)
@@ -59,7 +59,7 @@ enum DeviceType
        DEVICE_TYPE_WIRED_HEADPHONE = WiredHeadphone,           /**< Wired headphone */
        DEVICE_TYPE_STORAGE_CARD = StorageCard,                 /**< Storage card */
        DEVICE_TYPE_KEYBOARD = Keyboard,                        /**< Hardware Built-in keyboard */
-       DEVICE_TYPE_HDMI,                                       /**< HDMI @if OSPCOMPAT @b Since @  2.0 @endif */
+       DEVICE_TYPE_HDMI,                                       /**< HDMI */
 };
 
 /**
@@ -111,10 +111,10 @@ public:
         * @if OSPCOMPAT
         * @page DeviceManagerGetStatePage Compatibility for GetState()
         * @section DeviceManagerGetStatePageIssueSection Issues
-        * Implementation of this method in %Tizen API version prior to 2.0 has the following issue: @n
+        * Implementation of this method in OSP compatible applications has the following issue: @n
         * The GetState() method does not return E_DEVICE_UNAVAILABLE anymore. The E_DEVICE_UNAVAILABLE exception is removed.
         * @section DeviceManagerGetStatePageIssueSection Resolutions
-        * The E_UNSUPPORTED_OPERATION exception is added since 2.0. So, use E_UNSUPPORTED_OPERATION instead of E_DEVICE_UNAVAILABLE.
+        * The E_UNSUPPORTED_OPERATION exception is added since Tizen. So, use E_UNSUPPORTED_OPERATION instead of E_DEVICE_UNAVAILABLE.
         * @endif
         */
 
@@ -145,10 +145,10 @@ public:
         * @if OSPCOMPAT
         * @page DeviceManagerAddDeviceEventListenerPage Compatibility for AddDeviceEventListener()
         * @section DeviceManagerAddDeviceEventListenerPageIssueSection Issues
-        * Implementation of this method in %Tizen API version prior to 2.0 has the following issue: @n
+        * Implementation of this method in OSP compatible applications has the following issue: @n
         * This AddDeviceEventListener() method does not return E_DEVICE_UNAVAILABLE anymore. The E_DEVICE_UNAVAILABLE exception is removed.
         * @section DeviceManagerAddDeviceEventListenerPageIssueSection Resolutions
-        * The E_UNSUPPORTED_OPERATION exception is added since 2.0. So, use E_UNSUPPORTED_OPERATION instead of E_DEVICE_UNAVAILABLE exception.
+        * The E_UNSUPPORTED_OPERATION exception is added since Tizen. So, use E_UNSUPPORTED_OPERATION instead of E_DEVICE_UNAVAILABLE exception.
         * @endif
         */
 
@@ -172,10 +172,10 @@ public:
         * @if OSPCOMPAT
         * @page DeviceManagerRemoveDeviceEventListenerPage Compatibility for RemoveDeviceEventListener()
         * @section DeviceManagerRemoveDeviceEventListenerPageIssueSection Issues
-        * Implementation of this method in %Tizen API version prior to 2.0 has the following issue: @n
+        * Implementation of this method in OSP compatible applications has the following issue: @n
         * This RemoveDeviceEventListener() method does not return E_DEVICE_UNAVAILABLE anymore. The E_DEVICE_UNAVAILABLE exception is removed.
         * @section DeviceManagerRemoveDeviceEventListenerPageIssueSection Resolutions
-        * The E_UNSUPPORTED_OPERATION exception is added since 2.0. So, use E_UNSUPPORTED_OPERATION instead of E_DEVICE_UNAVAILABLE exception.
+        * The E_UNSUPPORTED_OPERATION exception is added since Tizen. So, use E_UNSUPPORTED_OPERATION instead of E_DEVICE_UNAVAILABLE exception.
         * @endif
         */
 
index 28544ee..6885963 100644 (file)
@@ -108,7 +108,6 @@ public:
        * @param[in]    dirType The pre-defined directory type
        * @remarks      The directory path for some directory types such as IMAGES, SOUNDS, VIDEOS, CAMERA, DOWNLOADS, and OTHERS may not yet exist,
        *               so you must make sure that it exists before using it.
-       * @see          PredefinedDirectoryType
        * @see          Tizen::Io::Directory::Create()
        */
        static Tizen::Base::String GetPredefinedPath(PredefinedDirectoryType dirType);
diff --git a/inc/FSysIBootEventListener.h b/inc/FSysIBootEventListener.h
new file mode 100644 (file)
index 0000000..7dbf040
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// 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       FSysIBootEventListener.h
+ * @brief      This is the header file of the %IBootEventListener interface.
+ *
+ * This header file contains the declarations of the %IBootEventListener interface.
+ */
+
+#ifndef _FSYS_IBOOT_EVENT_LISTENER_H_
+#define _FSYS_IBOOT_EVENT_LISTENER_H_
+
+#include <FBaseResult.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace System
+{
+
+/**
+ * @interface  IBootEventListener
+ * @brief      This interface is the listener of the boot event.
+ *
+ * @since 2.1
+ *
+ * The %IBootEventListener interface must be registered and implemented by an application to receive boot events from the system.
+ *
+ */
+class _OSP_EXPORT_ IBootEventListener
+       : public virtual Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This is the destructor for this class. This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since 2.1
+        */
+       virtual ~IBootEventListener(void) {}
+       /**
+        * Called when a certain setting value has been changed.
+        *
+        * @since       2.1
+        */
+       virtual void OnBootCompleted(void) = 0;
+
+protected:
+       //
+       // This method is for internal use only.
+       // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // @since 2.1
+       virtual void OnIBootEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only.
+       // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // @since 2.1
+       virtual void OnIBootEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only.
+       // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // @since 2.1
+       virtual void OnIBootEventListener_Reserved3(void) {}
+
+}; // IBootEventListener
+
+} } // Tizen::System
+
+#endif // _FSYS_IBOOT_EVENT_LISTENER_H_
index c260dea..ff9ae4c 100644 (file)
@@ -62,6 +62,16 @@ public:
         */
        virtual void OnScreenOff(void) = 0;
 
+       /**
+        * Called when the screen brightness is changed.
+        *
+        * @since 2.1
+        *
+        * @param[in]   brightness         Screen brightness between @c 0 to  @c 10.
+        */
+       virtual void OnScreenBrightnessChanged(int brightness) {}
+
+
 protected:
        //
        // This method is for internal use only.
@@ -77,13 +87,6 @@ protected:
        // @since 2.0
        virtual void OnIScreenEventListener_Reserved2(void) {}
 
-       //
-       // This method is for internal use only.
-       // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
-       //
-       // @since 2.0
-       virtual void OnIScreenEventListener_Reserved3(void) {}
-
 }; // IScreenEventListener
 
 } } // Tizen::System
old mode 100755 (executable)
new mode 100644 (file)
index 6f3a329..c971051
@@ -34,6 +34,7 @@ namespace Tizen { namespace System
 class IScreenEventListener;
 class IChargingEventListener;
 class IBatteryEventListener;
+class IBootEventListener;
 
 /**
  * @enum       BatteryLevel
@@ -95,17 +96,18 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/power
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/power
         *
         * @return      An error code
-        * @param[in]   keepOn  Set to @c true if the screen remains in the 'ON' state until the application goes to the background, @n
+        * @param[in]   keepOn  Set to @c true if the screen remains in the 'ON' state until the application goes to the background(inactivated), @n
         *                      else @c false if the state of the screen is controlled by the default power control policy of the system
         * @param[in]   dimming Set to @c true if the screen is dimmed when there is no user input for a certain amount of time, @n
         *                      else @c false if the screen is not dimmed
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                A system error has occurred.
-        * @remarks     The application should explicitly call this method again, if the screen is to be kept 'ON' after coming back from the background state.
+        * @remarks     The application should explicitly call this method again on foreground(activated) state, if the screen is to be kept 'ON' after coming back from the background(inactivated) state.
         */
        static result KeepScreenOnState(bool keepOn, bool dimming = true);
 
@@ -126,17 +128,19 @@ public:
         * Sets the screen brightness level for an application.
         *
         * @since       2.0
-        * @privilege   %http://tizen.org/privilege/power
+        *
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/power
         *
         * @return      An error code
-        * @param[in]   brightness      The brightness level to set @n
-        *                              The parameter value can range between @c 1 (minimum) and @c 10 (maximum).
-        * @exception   E_SUCCESS       The method is successful.
+        * @param[in]   brightness              The brightness level to set @n
+               *                               The parameter value can range between @c 1 (minimum) and @c 10 (maximum).
+        * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @exception   E_OUT_OF_RANGE          The specified @c brightness is out of range.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @remarks     This brightness level is only available when an application is running on the foreground. Even if the brightness is set to level 1, a black screen is not displayed. Level 1 is the minimum brightness level that can be set for an application.
-        * @see         RestoreScreenBrightness()
+        * @remarks     This brightness level is only available when an application is running on the foreground(activated). Even if the brightness is set to level 1, a black screen is not displayed. Level 1 is the minimum brightness level that can be set for an application. For screen off, Please refer TurnScreenOff method.
+        * @see         RestoreScreenBrightness(), TurnScreenOff()
         */
 
        static result SetScreenBrightness(int brightness);
@@ -173,7 +177,9 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/power
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/power
+        *
         * @return      An error code
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
@@ -186,7 +192,9 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/power
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/power
+        *
         * @return      An error code
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
@@ -199,7 +207,8 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/power
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/power
         *
         * @return      An error code
         * @param[in]   enable  Set to @c true to prevent the CPU from going into sleep mode, @n
@@ -207,6 +216,7 @@ public:
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                A system error has occurred.
+        * @remark      This method keeps CPU power state only. Screen state or lock screen is not managed by this method.
         */
        static result KeepCpuAwake(bool enable);
 
@@ -215,21 +225,86 @@ public:
         *
         * @since       2.0
         *
+        * @deprecated This method is deprecated. @n 
+         *             Instead of using this method, please use AddScreenEventListener and RemoveScreenEventListener.
+        *
         * @param[in]   listener                The screen event listener
-        * @see         IScreenEventListener
+        * @remarks     This method always overwrites the first element of internal IScreenEventListener list.
+        *              The first element added by AddScreentEventListener may be overwritten by this method,
+        *              which may not be an expected behavior by API users. So, it is not recommended to use this method.
         */
        static void SetScreenEventListener(IScreenEventListener& listener);
 
+
+       /**
+        * Adds the screen event listener.
+        *
+        * @since       2.1
+        *
+        * @param[in]   listener                The screen event listener
+        * @exception E_SUCCESS               The method is successful.
+        * @exception E_OBJ_ALREADY_EXIST   The listener has already been added.
+        * @exception E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @see         IScreenEventListener, RemoveScreenEventListener
+        */
+       static result AddScreenEventListener(IScreenEventListener& listener);
+
+       /**
+        * Removes the screen event listener.
+        *
+        * @since       2.1
+        *
+        * @param[in]   listener                The screen event listener
+        * @exception E_SUCCESS               The method is successful.
+        * @exception E_OBJ_NOT_FOUND     The specified listener cannot be found.
+        * @exception E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @see         IScreenEventListener, AddScreenEventListener
+        */
+       static result RemoveScreenEventListener(IScreenEventListener& listener);
+
+
        /**
         * Sets the charging event listener.
         *
         * @since       2.0
         *
+        * @deprecated This method is deprecated. @n
+        *               Instead of using this method, please use AddChargingEventListener and RemoveChargingEventListener.
+        *
         * @param[in]   listener        The charging event listener
+        * @remarks     This method always overwrites the first element of internal IChargingEventListener list.
+        *              The first element added by AddChargingEventListener may be overwritten by this method,
+        *              which may not be an expected behavior by API users. So, it is not recommended to use this method.
         */
        static void SetChargingEventListener(IChargingEventListener& listener);
 
        /**
+        * Adds the charging event listener.
+        *
+        * @since       2.1
+        *
+        * @param[in]   listener                The charging event listener
+        * @exception E_SUCCESS               The method is successful.
+        * @exception E_OBJ_ALREADY_EXIST   The listener has already been added.
+        * @exception E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @see IChargingEventListener, RemoveChargingEventListener
+        */
+       static result AddChargingEventListener(IChargingEventListener& listener);
+
+       /**
+        * Removes the charging event listener.
+        *
+        * @since       2.1
+        *
+        * @param[in]   listener                The charging event listener
+        * @exception E_SUCCESS               The method is successful.
+        * @exception E_OBJ_NOT_FOUND     The specified listener cannot be found.
+        * @exception E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @see IChargingEventListener, AddChargingEventListener
+        */
+       static result RemoveChargingEventListener(IChargingEventListener& listener);
+
+       /**
         * Sets the battery event listener.
         *
         * @since       2.0
@@ -251,7 +326,7 @@ public:
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_UNSUPPORTED_OPERATION The method is not supported by this device.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @remakrs     The specific error code can be accessed using the GetLastResult() method.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
         * @remarks     The resolution of the level is @c 1 percentage. The range of the level is minimum @c 0 to maximum @c 100. 
         */
        static int GetCurrentBatteryLevelInPercentage(void);
@@ -283,6 +358,32 @@ public:
         */
        static bool IsCharging(void);
 
+       /**
+        * Adds the boot event listener.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   listener        The boot event listener
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_OBJ_ALREADY_EXIST     The listener is already added.
+        * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
+        */
+       static result AddBootEventListener(IBootEventListener& listener);
+
+       /**
+        * Removes the boot event listener.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   listener        The boot event listener
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_OBJ_ALREADY_EXIST     The listener is not added.
+        * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
+        */
+       static result RemoveBootEventListener(IBootEventListener& listener);
+
 private:
        /**
         * This is the default constructor for this class. This default constructor is intentionally declared as private so that only the platform can create an instance.
old mode 100755 (executable)
new mode 100644 (file)
index 67b36a0..bf25996
@@ -61,7 +61,7 @@ class IRuntimeInfoGetLonglongAsyncResultListener;
  *      result r = E_SUCCESS;
  *
  *      String key(L"http://tizen.org/runtime/memory.allocated");
- *      int allocatedMemory = 0;
+ *      long long allocatedMemory = 0;
  *
  *      r = RuntimeInfo::GetValue(key, allocatedMemory);
  *      TryCatch(r == E_SUCCESS, , "MyRuntimeInfo: Failed to get value");
@@ -105,9 +105,8 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">key name</a> of the runtime information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">here</a>.
-        *                        @xmlonly <pcheck kind="value" since="2.0"> memory.allocated, memory.available </pcheck> @endxmlonly
-        *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">here</a>.
+        *                      - @b Deprecated All the key values provided prior to %Tizen are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info_deprecated.htm">here</a>.
         * @endif
         * @param[out]  value                   The integer type runtime information
@@ -127,9 +126,8 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">key name</a> of the runtime information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">here</a>.
-        *                        @xmlonly <pcheck kind="value" since="2.0"> storage.external.available, storage.internal.available, storage.media.available </pcheck> @endxmlonly
-        *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">here</a>.
+        *                      - @b Deprecated All the key values provided prior to %Tizen are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info_deprecated.htm">here</a>.
         *                       @xmlonly <pcheck kind="value" since="1.0" deprecated="yes"> @endxmlonly MaxAllocatableMemory, AvailableVideoMemory @xmlonly </pcheck> @endxmlonly
         * @endif
@@ -162,7 +160,7 @@ public:
         * @since       2.0
         *
         * @return      An error code
-        * @param[in]   key                     The key name of the runtime information
+        * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">key name</a> of the runtime information
         * @param[out]  value                   The @c bool type runtime information
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
@@ -191,12 +189,11 @@ public:
         * @since       2.0
         *
         * @return      An error code
-        * @param[in]   key             The key of the runtime information
+        * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">key name</a> of the runtime information
         * @param[in]   listener        The result listener
         * @exception   E_SUCCESS       The method is successful.
         * @exception   E_OBJ_NOT_FOUND The specified @c key is not found.
         * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
-        * @remarks     The listener instance ownership is transferred to platform. After notifying result, listener instance is removed automatically. A reuse of the listener instance is not allowed.
         */
        static result GetValueAsync(const Tizen::Base::String& key, IRuntimeInfoGetLonglongAsyncResultListener* listener);
 
@@ -206,12 +203,11 @@ public:
         * @since       2.0
         *
         * @return      An error code
-        * @param[in]   key             The key of the runtime information
+        * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/runtime_info.htm">key name</a> of the runtime information
         * @param[in]   listener        The result listener
         * @exception   E_SUCCESS       The method is successful.
         * @exception   E_OBJ_NOT_FOUND The specified @c key is not found.
         * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
-        * @remarks     The listener instance ownership is transferred to platform. After notifying result, listener instance is removed automatically. A reuse of the listener instance is not allowed.
         */
        static result GetValueAsync(const Tizen::Base::String& key, IRuntimeInfoGetIntAsyncResultListener* listener);
 
old mode 100755 (executable)
new mode 100644 (file)
index 21c3c00..43d57e4
@@ -90,8 +90,7 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">here</a>.
-        *                        @xmlonly <pcheck kind="value" since="2.0">locale.country, locale.time.format, locale.date.format, locale.datetime.format, font.type, locale.language, theme, sound.ringtone, screen.wallpaper, screen.wallpaper.lock, usbmode</pcheck> @endxmlonly
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">here</a>.
         *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info_deprecated.htm">here</a>.
         * @endif
@@ -113,8 +112,7 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">here</a>.
-        *                        @xmlonly <pcheck kind="value" since="2.0">font.size, sound.media.volume, sound.notification.volume, sound.ringtone.volume, sound.system.volume, vibrator.level </pcheck> @endxmlonly
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">here</a>.
         *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info_deprecated.htm">here</a>.
         * @endif
@@ -168,8 +166,7 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">here</a>.
-        *                        @xmlonly <pcheck kind="value" since="2.0">network.roaming, network.flightmode, network.packetservice, locale.time.format.24hour, location.gps, location.wps, sound.silentmode, motion </pcheck> @endxmlonly
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">here</a>.
         *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info_deprecated.htm">here</a>.
         * @endif
@@ -214,7 +211,8 @@ public:
         *
         * @since 2.0
         *
-        * @privilege   %http://tizen.org/privilege/setting
+        * @privilege   public
+        * @privilege   http://tizen.org/privilege/setting
         *
         * @return      An error code
         * @param[in]   key                     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
@@ -225,7 +223,7 @@ public:
         * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
         * @exception   E_UNSUPPORTED_OPERATION The specified @c key exists. However, it is not supported by this device.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        */     
+        */
        static result SetValue(const Tizen::Base::String& key, bool value);
 
        /**
@@ -233,7 +231,8 @@ public:
         *
         * @since 2.0
         *
-        * @privilege   %http://tizen.org/privilege/setting
+        * @privilege   public
+        * @privilege   http://tizen.org/privilege/setting
         *
         * @return      An error code
         * @param[in]   key                     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
@@ -252,7 +251,8 @@ public:
         *
         * @since 2.0
         *
-        * @privilege   %http://tizen.org/privilege/setting
+        * @privilege   public
+        * @privilege   http://tizen.org/privilege/setting
         *
         * @return      An error code
         * @param[in]   key                     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
@@ -271,7 +271,8 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/setting
+        * @privilege   public
+        * @privilege   http://tizen.org/privilege/setting
         *
         * @return      An error code
         * @param[in]   filePath                The file path of the wallpaper
@@ -279,7 +280,6 @@ public:
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @exception   E_FILE_NOT_FOUND        The entry for the specified wallpaper file or the file path cannot be found.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @remarks     The specified wallpaper file is copied to the managed folder by the system, while the previously set wallpaper is removed. <br> This parameter is compatible with "Wallpaper".
         */
 
        static result SetWallpaper(const Tizen::Base::String& filePath);
@@ -289,7 +289,8 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/setting
+        * @privilege   public
+        * @privilege   http://tizen.org/privilege/setting
         *
         * @return      An error code
         * @param[in]   filePath                The file path of the ringtone
@@ -297,7 +298,6 @@ public:
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @exception   E_FILE_NOT_FOUND        The entry for the specified wallpaper file or the file path cannot be found.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @remarks     The specified ringtone file has to exist in the media directory.
         */
        static result SetRingtone(const Tizen::Base::String& filePath);
 
@@ -306,7 +306,8 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/setting
+        * @privilege   public
+        * @privilege   http://tizen.org/privilege/setting
         *
         * @return      An error code
         * @param[in]   soundCategory           The sound volume category
@@ -349,13 +350,12 @@ public:
        static result RemoveSettingEventListener(ISettingEventListener& listener);
 
        /**
-        * @if  VISPARTNER-MANUFACTURER
         * Gets the specific @c bool type setting information based on the specified designators (key).
         *
         * @since 2.0
         *
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/systemsetting.read
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/systemsetting.read
         *
         * @return      An error code
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
@@ -365,18 +365,16 @@ public:
         * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
         * @exception   E_UNSUPPORTED_OPERATION The specified @c key exists. However, it is not supported by this device.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @endif
         */
        static result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
 
        /**
-        * @if  VISPARTNER-MANUFACTURER
         * Sets the specific @c bool type setting information based on the specified designators (key).
         *
         * @since 2.0
         *
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/systemsetting.write
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/systemsetting.write
         *
         * @return      An error code
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
@@ -387,17 +385,15 @@ public:
         * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
         * @exception   E_UNSUPPORTED_OPERATION The specified @c key exists. However, it is not supported by this device.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @endif
         */
        static result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
 
        /**
-        * @if  VISPARTNER-MANUFACTURER
         * Sets the specific @c bool type setting information based on the specified designators (key) asynchronously.
         *
         * @since 2.0
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/systemsetting.write
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/systemsetting.write
         *
         * @return      An error code
         * @param[in]   key                     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
@@ -409,19 +405,16 @@ public:
         * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
         * @exception   E_UNSUPPORTED_OPERATION The specified @c key is existed, However it is not supported by this device.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @remarks The listener instance ownership is transferred to platform. After notifying result, listener instance is removed automatically. A reuse of the listener instance is not allowed.
-        * @endif
         */
        static result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
 
        /**
-        * @if  VISPARTNER-MANUFACTURER
         * Sets the specific Tizen::Base::String type setting information based on the specified designators (key).
         *
         * @since 2.0
         *
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/systemsetting.write
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/systemsetting.write
         *
         * @return      An error code
         * @param[in]   key                     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
@@ -432,25 +425,22 @@ public:
         * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
         * @exception   E_UNSUPPORTED_OPERATION The specified @c key exists. However, it is not supported by this device.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @endif
         */
        static result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
 
        /**
-        * @if  VISPARTNER-MANUFACTURER
         * Resets current device. @n
         * All data is removed and device is initialized.
         *
         * @since 2.0
         *
-        * @visibility  partner-manufacturer
-        * @privilege   %http://tizen.org/privilege/systemsetting.write
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/systemsetting.write
         *
         * @return      An error code
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGED_DENIED     The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @endif
         */
        static result ResetToFactoryDefault(void);
 
@@ -485,8 +475,8 @@ private:
         */
        virtual ~SettingInfo(void);
 
-       /**             
-        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.           
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
         */
        SettingInfo(const SettingInfo& value);
 
old mode 100755 (executable)
new mode 100644 (file)
index 55cf971..8f0d05e
@@ -107,8 +107,7 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">key name</a> of the system information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">here</a>.
-        *                              @xmlonly <pcheck kind="value" since="2.0">telephony, input.keyboard.layout, screen.size, screen.coordinatesystem.physical, screen.coordinatesystem.logical, platform.core.cpu.arch, platform.core.fpu.arch, platform.name, modelname, duid, map.provider</pcheck> @endxmlonly
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">here</a>.
         *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo_deprecated.htm">here</a>.
         * @endif
@@ -128,8 +127,7 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">key name</a> of the system information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">here</a>.
-        *                              @xmlonly <pcheck kind="value" since="2.0">multipointtouch.pointcount, sound.media.volume.max, sound.notification.volume.max, sound.ringtone.volume.max, sound.system.volume.max, screen.bpp, screen.height, screen.width, screen.dpi</pcheck> @endxmlonly 
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">here</a>.
         *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo_deprecated.htm">here</a>.
         * @endif
@@ -197,8 +195,7 @@ public:
         * @param[in]   key     The <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">key name</a> of the system information @n
         * @if OSPCOMPAT
         *                      The following key values are updated: @n
-        *                      - @b Since: @b 2.0 Refer <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">here</a>.
-        *                              @xmlonly <pcheck kind="value" since="2.0">bluetooth, camera, camera.front, camera.front.flash, camera.back, camera.back.flash, location, location.wps, location.gps, microphone, nfc, sensor.barometer, sensor.barometer.wakeup, sensor.accelerometer, sensor.accelerometer.wakeup, sensor.magnetometer, sensor.magnetometer.wakeup, sensor.gyroscope, sensor.gyroscope.wakeup, sensor.photometer, sensor.photometer.wakeup, sensor.tiltmeter, sensor.tiltmeter.wakeup, sensor.proximity, sensor.proximity.wakeup, usb.host, usb.accessory, input.keyboard, wifi, wifi.direct, opengles.version.1_1, opengles.version.2_0, screen.desktopmode, screen.output.rca, screen.output.hdmi, fmradio, speech.recognition, sip.voip</pcheck> @endxmlonly 
+        *                      - Since Tizen, refer <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo.htm">here</a>.
         *                      - @b Deprecated All the key values provided prior to %Tizen 2.0 are deprecated. For more detailed information, refer 
         *                       <a href="../org.tizen.native.appprogramming/html/guide/system/sysinfo_deprecated.htm">here</a>.
         * @endif
@@ -210,11 +207,12 @@ public:
        static result GetValue(const Tizen::Base::String& key, bool& value);
 
        /**
-        * Gets the platform version in the "[Major].[Minor].[Build Version]" format.
+        * Gets the platform version in the "[Major].[Minor].[Patch Version]" format.
         *
         * @since 2.0
         *
-        * @privilege   %http://tizen.org/privilege/platforminfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/platforminfo
         *
         * @return      An error code
         * @param[out]  platformVersion         The platform version
@@ -229,7 +227,8 @@ public:
         *
         * @since 2.0
         *
-        * @privilege   %http://tizen.org/privilege/platforminfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/platforminfo
         *
         * @return      An error code
         * @param[out]  nativeApiVersion        The Native API version
@@ -244,7 +243,8 @@ public:
         *
         * @since 2.0
         *
-        * @privilege   %http://tizen.org/privilege/platforminfo
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/platforminfo
         *
         * @return      An error code
         * @param[out]  webApiVersion           The %Tizen API version
@@ -254,21 +254,35 @@ public:
         */
        static result GetWebApiVersion(Tizen::Base::String& webApiVersion);
 
+       /*
+        * Gets the platform build information.
+        *
+        * @since 2.1
+        *
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/platforminfo
+        *
+        * @return      An error code
+        * @param[out]  buildInfo               The %Tizen build information
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       static result GetBuildInfo(Tizen::Base::String& buildInfo);
+
        /**
-        * @if VISPARTNER
         * Gets the International Mobile Equipment Identity (IMEI) of the device.
         *
         * @since       2.0
         *
-        * @visibility  partner
-        * @privilege   %http://tizen.org/privilege/useridentity
+        * @privlevel   partner
+        * @privilege   http://tizen.org/privilege/useridentity
         *
         * @return      An error code
         * @param[out]  imei                    The IMEI of the device
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @endif
         */
        static result GetImei(Tizen::Base::String& imei);
 
index e916054..4d6318a 100644 (file)
@@ -95,7 +95,7 @@ public:
         * @since       2.0
         *
         * @return      An error code
-        * @param[in]   timeMode        The time mode @c TIME_MODE_UTC, TIME_MODE_STANDARD, or @c TIME_MODE_WALL
+        * @param[in]   timeMode        The time mode @c TIME_MODE_UTC, @c TIME_MODE_STANDARD, or @c TIME_MODE_WALL
         * @param[out]  currentTime     The current system time
         * @exception   E_SUCCESS       The method is successful.
         */
@@ -112,18 +112,19 @@ public:
         */
        static result GetTicks(long long& ticks);
 
-       /*
-        * @if VISPARTNER
+       /**
         * Sets the current system time.
         *
         * @since 2.0
         *
+        * @privlevel   platform
+        * @privilege   http://tizen.org/privilege/systemsetting.write
+        *
         * @return      An error code
         * @param[in]   currentTime             The current system time in UTC
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
-        * @endif
         */
        static result SetCurrentTime(const Tizen::Base::DateTime& currentTime);
 private:
old mode 100755 (executable)
new mode 100644 (file)
index 0d0c88a..a1d7a04
@@ -67,8 +67,12 @@ namespace Tizen { namespace System
  *             goto CATCH;
  *     }
  *
- *     // Vibrate with a given pattern and level
- *     vibrator.Start(2000, 1000, 1, 50);
+ *     // Initialize vibration pattern
+ *     IntensityDurationVibrationPattern patterns[4] = {{2000, 50}, {1000, 0}, {500, -1}, {1000, 80}};
+ *     int length = sizeof(patterns);
+
+ *     // Vibrate with a given pattern and repeat count
+ *     vibrator.Start(patterns, length, 3);
  *
  *     return E_SUCCESS;
  *
@@ -79,6 +83,28 @@ namespace Tizen { namespace System
  * @endcode
  */
 
+/**
+ * @struct      IntensityDurationVibrationPattern
+ * @brief       This struct has the specified duration and a vibration intensity level.
+ *
+ * This can be used with Vibrator::Start(IntensityDurationVibrationPattern[] patterns, int length, int count) as a custom pattern.
+ *
+ * @since 2.1
+ */
+struct IntensityDurationVibrationPattern
+{
+       int duration; /**< The duration in milliseconds when the vibrator is on. @n
+                       *       The @c duration is not allowed a negative value.
+                       */
+       int intensity; /**< The vibration intensity [@c -1~ @c 100]: @n
+                       *       @li The system default vibration intensity (-1)
+                       *       @li The silent vibration intensity (0)
+                       *       @li The minimum vibration intensity (1)
+                       *       @li The maximum vibration intensity (100)
+                       */
+};
+
+
 class _OSP_EXPORT_ Vibrator
        : public Tizen::Base::Object
 {
@@ -115,6 +141,33 @@ public:
         */
        result Construct(void);
 
+
+        /**
+         * Vibrates the device with the specified array pattern which has vibration intensity and duration. @n
+         * This method returns the result immediately so that the vibration occurs simultaneously as the device runs. @n
+         * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately. @n
+         * If a new vibrator instance triggers the vibration, the vibrator merges the previous vibration pattern with the new one in the overlapped time. @n
+         * If the system alert occurs such as ring vibration and a system event notification, the vibration can be interrupted. @n
+         * If the application is terminated, the vibration is canceled.
+         *
+         * @since 2.1
+         *
+         * @privilege     http://tizen.org/privilege/vibrator
+         *
+         * @return      An error code
+         *
+         * @param[in]   patterns                        An array of @c IntensityDurationVibrationPattern.
+        * @param[in]   length                          The length of @c patterns.
+         * @param[in]   repeatCount                           The number of repeat for pattern. This value has to be between 1 to 100.
+         * @exception   E_SUCCESS           The method is successful.
+         * @exception    E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+         * @exception   E_INVALID_ARG       A specified input parameter is invalid.
+         * @exception E_OPERATION_FAILED The device operation has failed.
+         * @remarks The vibration intensity does not apply the change, even if the system default vibration intensity is changed after starting vibration.
+         * @see  IntensityDurationVibrationPattern
+         */
+        result Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount = 1);
+
        /**
         * Vibrates the device with the specified pattern and level. @n
         * This method returns the result immediately so that the vibration occurs simultaneously as the device runs.
@@ -122,7 +175,10 @@ public:
         *
         * @since 2.0
         *
-        * @privilege   %http://tizen.org/privilege/vibrator
+        * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern[] patterns, int length, int repeatCount).
+        *
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/vibrator
         *
         * @return      An error code
         * @param[in]   onPeriod    The period in milliseconds when the vibrator is on @n
@@ -153,7 +209,10 @@ public:
         *
         * @since       2.0
         *
-        * @privilege   %http://tizen.org/privilege/vibrator
+        * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern[] patterns, int length, int repeatCount).
+        *
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/vibrator
         *
         * @return      An error code
         * @param[in]   milliseconds    The duration for the vibration in milliseconds @n
@@ -178,7 +237,8 @@ public:
         *
         * @since   2.0
         *
-        * @privilege   %http://tizen.org/privilege/vibrator
+        * @privlevel   public
+        * @privilege   http://tizen.org/privilege/vibrator
         *
         * @return      An error code
         * @exception   E_SUCCESS           The method is successful.
index b3914fe..fcd052c 100644 (file)
@@ -54,6 +54,7 @@
 #include <FSysIScreenEventListener.h>
 #include <FSysIChargingEventListener.h>
 #include <FSysPowerManager.h>
+#include <FSysIBootEventListener.h>
 
 // Device State
 #include <FSysDeviceManager.h>
index 66bf303..a9241be 100644 (file)
@@ -47,6 +47,8 @@ namespace Tizen { namespace Text
  * The %Encoding class is the base class for all classes that implement character encoding.
  *
  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/text/converting_all_text_data.htm">Converting All Text Data at Once</a>.
+ * 
+ * For more information on the supported encoding types, see <a href="../org.tizen.native.appprogramming/html/guide/text/text.htm>Encoding standards in Tizen</a>.
  *
  * The following example demonstrates how to use the %Encoding class.
  *
@@ -506,7 +508,8 @@ public:
         * @remarks             The specific error code can be accessed using the GetLastResult() method. @n
         *                      The supported encoding types are ASCII, GSM, UCS-2, UCS-2LE, UCS-2BE, UCS-4, UCS-4LE, UCS-4BE, UTF-8, UTF-16, UTF-16LE, UTF-16BE, @n
         *                              UTF-32, UTF-32LE, UTF-32BE, ISO-8859-1~16 (except ISO-8859-12), Windows-874, Windows-1250 ~ Windows-1258, @n
-        *                              KSC5601, BIG5, GB2312, Shift_JIS and ISO-2022-jp.
+        *                              KSC5601, BIG5, GB2312, Shift-JIS and ISO-2022-jp. @n
+        *                              For more information on the supported encoding types, see <a href="../org.tizen.native.appprogramming/html/guide/text/text.htm>Encoding standards in Tizen</a>.
         * @see                 Tizen::Text::Encoding::GetAvailableEncodingsN()
         */
        static Encoding* GetEncodingN(const Tizen::Base::String& encodingType);
index b21bcfd..fd2c4ae 100644 (file)
@@ -24,7 +24,7 @@
 #define _FRAMEWORK_H_
 /**
  * @namespace  Tizen
- * @brief              This namespace is the root namespace of the %Tizen native framework.
+ * @brief              This namespace is the root namespace of the Tizen native framework.
  *
  * The %Tizen namespace is the top-level namespace that encompasses all other
  * C++ namespaces in Tizen.
index c064287..185cb63 100755 (executable)
@@ -3,7 +3,9 @@
 prefix=@PREFIX@
 exec_prefix=/usr
 libdir=/usr/lib/osp
+libserverdir=/usr/lib/osp-server
 includedir=/usr/include/osp
+includeserverdir=/usr/include/osp/server
 
 Name: @PC_NAME@
 Description: @PACKAGE_DESCRIPTION@
index c72b0b3..39b8495 100755 (executable)
@@ -3,7 +3,7 @@
 
 Name:       osp-appfw
 Summary:    The App Framework library of OSP 
-Version:    1.2.0.0
+Version:    1.2.1.0
 Release:    1
 Group:      TO_BE/FILLED_IN
 License:    Apache License, Version 2.0 or Flora
@@ -13,21 +13,11 @@ BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  pkgconfig(capi-appfw-package-manager)
 BuildRequires:  pkgconfig(capi-content-mime-type)
-BuildRequires:  pkgconfig(capi-location-manager)
-BuildRequires:  pkgconfig(capi-media-sound-manager)
-BuildRequires:  pkgconfig(capi-network-connection)
 BuildRequires:  pkgconfig(capi-network-serial)
-BuildRequires:  pkgconfig(capi-network-tethering)
-BuildRequires:  pkgconfig(capi-network-wifi)
-BuildRequires:  pkgconfig(capi-network-bluetooth)
 BuildRequires:  pkgconfig(capi-system-device)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(capi-system-power)
-BuildRequires:  pkgconfig(capi-system-sensor)
-BuildRequires:  pkgconfig(capi-system-system-settings)
 BuildRequires:  pkgconfig(capi-system-runtime-info)
-BuildRequires:  pkgconfig(capi-telephony-network-info)
-BuildRequires:  pkgconfig(capi-telephony-sim)
 BuildRequires:  pkgconfig(alarm-service)
 BuildRequires:  pkgconfig(appsvc)
 BuildRequires:  pkgconfig(aul)
@@ -46,6 +36,7 @@ BuildRequires:  pkgconfig(libpcre)
 BuildRequires:  pkgconfig(libssl)
 BuildRequires:  pkgconfig(libsoup-2.4)
 BuildRequires:  pkgconfig(libwbxml2)
+BuildRequires:  pkgconfig(message-port)
 BuildRequires:  pkgconfig(minizip)
 BuildRequires:  pkgconfig(notification)
 BuildRequires:  pkgconfig(openssl)
@@ -53,46 +44,27 @@ BuildRequires:  pkgconfig(pkgmgr)
 BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(pmapi)
 BuildRequires:  pkgconfig(libprivilege-control)
-BuildRequires:  pkgconfig(sensor)
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(uuid)
 BuildRequires:  pkgconfig(vconf)
-BuildRequires:  pkgconfig(wifi-direct)
 BuildRequires:  pkgconfig(zlib)
 BuildRequires:  pkgconfig(drm-service-core-intel)
-#BuildRequires:  drm-service-core-intel-devel
-BuildRequires:  pkgconfig(tapi)
 BuildRequires:  pkgconfig(haptic)
-BuildRequires:  pkgconfig(sysman)
 BuildRequires:  pkgconfig(x11)
 BuildRequires:  boost-devel
 BuildRequires:  gettext-tools
-BuildRequires:  libcryptsvc-devel
-BuildRequires:  dukgenerator
 
 # runtime requires
 Requires: capi-appfw-app-manager  
 Requires: capi-appfw-application  
 Requires: capi-appfw-package-manager
-Requires: capi-content-mime-type  
-Requires: capi-location-manager 
-Requires: capi-media-sound-manager  
-Requires: capi-network-connection  
-Requires: capi-network-serial  
-Requires: capi-network-tethering
-Requires: capi-network-wifi  
-Requires: capi-system-device  
-Requires: capi-system-info  
-Requires: capi-system-power  
-Requires: capi-system-sensor  
-Requires: capi-system-system-settings  
-Requires: capi-system-runtime-info  
-Requires: capi-telephony-sim
+Requires: capi-content-mime-type
+Requires: capi-network-serial
+Requires: capi-system-runtime-info
 Requires: chromium
+Requires: message-port
 Requires: osp-env-config
-#Requires: drm-service-core-intel
 Requires: sqlite
-Requires:  libcryptsvc-devel
 
 Provides:   libosp-appfw.so.1
 
@@ -109,6 +81,7 @@ Group:      TO_BE/FILLED_IN
 Requires:   %{name} = %{version}-%{release}
 Requires: boost-devel
 Requires: pkgconfig(pkgmgr-info)
+Requires: pkgconfig(capi-appfw-app-manager)
 
 %description devel
 The  App Framework library of OSP (DEV)
@@ -117,6 +90,7 @@ The  App Framework library of OSP (DEV)
 Summary:    osp app framework internel (Internal)
 Group:      TO_BE/FILLED_IN
 Requires:   %{name} = %{version}-%{release}
+Requires: pkgconfig(capi-appfw-app-manager)
 
 %description internal-devel
 The App Framework library of OSP (Internal-DEV)
@@ -203,9 +177,11 @@ chown -R 5000:5000 /opt/usr/media
 /etc/*
 /opt/usr/share/.osp-compat/share/*
 /opt/usr/etc/*
+/usr/share/osp/.*
 /usr/share/locale/*
 /usr/etc/*
 %{_libdir}/osp/libosp-appfw.so*
+%{_libdir}/osp-server/libosp-appfw-server.so*
 
 %files devel
 %{_includedir}/osp/*.h
@@ -220,7 +196,9 @@ chown -R 5000:5000 /opt/usr/media
 %{_includedir}/osp/security/*
 %{_includedir}/osp/system/*
 %{_includedir}/osp/text/*
+%{_includedir}/osp/server/*
 
 %files debug
 %{_libdir}/osp/debug/libosp-appfw.so*
+%{_libdir}/osp-server/debug/libosp-appfw-server.so*
 
diff --git a/res/arm/usr/etc/system-info.ini b/res/arm/usr/etc/system-info.ini
deleted file mode 100644 (file)
index c129e9d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#SystemInfo
-WACVersion=
-OverlayRegionHeightUnit=2
-OverlayRegionWidthUnit=2
-MaxOverlayRegionCount=8
-http://tizen.org/feature/screen.size.normal=true
-http://tizen.org/feature/screen.size.large=false
-http://tizen.org/feature/screen.coordinate_system.size.normal=true
-http://tizen.org/feature/screen.coordinate_system.size.large=false
-http://tizen.org/feature/screen.coordinate_system.physical.normal_480x800=false
-http://tizen.org/feature/screen.coordinate_system.physical.normal_720x1280=true
-http://tizen.org/feature/screen.coordinate_system.physical.large_480x800=false
-http://tizen.org/feature/screen.coordinate_system.physical.large_720x1280=false
-http://tizen.org/feature/screen.coordinate_system.logical.normal=true
-http://tizen.org/feature/screen.coordinate_system.logical.large=false
-http://tizen.org/feature/platform.native.api.version=2.0
-http://tizen.org/feature/platform.web.api.version=2.0
-#UiControlInfo
-OverlayRegionHeightUnit=2
-OverlayRegionWidthUnit=2
-MaxOverlayRegionCount=8
-OverlayRegionBufferPixelFormat=ARGB8888/RGB565/YCbCr420P/NV12/UYVY
-OverlayDstMinWidth=16
-OverlayDstMinHeight=8
-OverlaySrcMinWidth=16
-OverlaySrcMinHeight=8
diff --git a/res/common/usr/share/osp/.external-privilege.ini b/res/common/usr/share/osp/.external-privilege.ini
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/res/common/usr/share/osp/.privilege-description.db b/res/common/usr/share/osp/.privilege-description.db
new file mode 100644 (file)
index 0000000..b2d2552
Binary files /dev/null and b/res/common/usr/share/osp/.privilege-description.db differ
diff --git a/res/x86/usr/etc/system-info.ini b/res/x86/usr/etc/system-info.ini
deleted file mode 100644 (file)
index 024441d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#SystemInfo
-WACVersion=
-OverlayRegionHeightUnit=1
-OverlayRegionWidthUnit=1
-MaxOverlayRegionCount=8
-http://tizen.org/feature/screen.size.normal=true
-http://tizen.org/feature/screen.size.large=false
-http://tizen.org/feature/screen.coordinate_system.size.normal=true
-http://tizen.org/feature/screen.coordinate_system.size.large=false
-http://tizen.org/feature/screen.coordinate_system.physical.normal_480x800=false
-http://tizen.org/feature/screen.coordinate_system.physical.normal_720x1280=true
-http://tizen.org/feature/screen.coordinate_system.physical.large_480x800=false
-http://tizen.org/feature/screen.coordinate_system.physical.large_720x1280=false
-http://tizen.org/feature/screen.coordinate_system.logical.normal=true
-http://tizen.org/feature/screen.coordinate_system.logical.large=false
-http://tizen.org/feature/platform.native.api.version=2.0
-http://tizen.org/feature/platform.web.api.version=2.0
-#UiControlInfo
-OverlayRegionHeightUnit=1
-OverlayRegionWidthUnit=1
-MaxOverlayRegionCount=8
-OverlayRegionBufferPixelFormat=ARGB8888/RGB565/YCbCr420P/NV12/UYVY
-OverlayDstMinWidth=16
-OverlayDstMinHeight=8
-OverlaySrcMinWidth=16
-OverlaySrcMinHeight=8
old mode 100644 (file)
new mode 100755 (executable)
index 60e1855..9d06cf4
@@ -1,40 +1,32 @@
 SET(SLP_INCLUDE_DIRS
-     /usr/include 
-     /usr/include/vconf 
-     /usr/include/glib-2.0 
-     /usr/lib/glib-2.0/include 
-     /usr/include/dbus-1.0 
-     /usr/lib/dbus-1.0/include 
-     /usr/include/dlog 
-     /usr/include/appfw 
-     /usr/include/aul 
-     /usr/include/notification
-     /usr/include/heynoti 
-     /usr/include/sensor 
-     /usr/include/media 
-     /usr/include/devman 
-     /usr/include/network 
-     /usr/include/libxml2 
-     /usr/include/content 
-     /usr/include/system 
-     /usr/include/location 
-     /usr/include/libsoup-2.4 
-     /usr/include/pkgmgr 
-     /usr/include/telephony 
-     /usr/include/curl
-     /usr/include/minizip
-     /usr/include/chromium
-     /usr/include/wifi-direct   
-        /usr/include/drm-intel
-     /usr/include/telephony-client
-     /usr/include/haptic
-        /usr/include/sysman
-     /usr/include/ecore-1
-     /usr/include/eina-1
-     /usr/include/eina-1/eina
+       /usr/include 
+       /usr/include/vconf 
+       /usr/include/glib-2.0 
+       /usr/lib/glib-2.0/include 
+       /usr/include/dbus-1.0 
+       /usr/lib/dbus-1.0/include 
+       /usr/include/dlog 
+       /usr/include/appfw 
+       /usr/include/aul 
+       /usr/include/notification
+       /usr/include/heynoti 
+       /usr/include/devman 
+       /usr/include/network 
+       /usr/include/libxml2 
+       /usr/include/content 
+       /usr/include/system 
+       /usr/include/libsoup-2.4 
+       /usr/include/pkgmgr 
+       /usr/include/curl
+       /usr/include/minizip
+       /usr/include/chromium
+       /usr/include/drm-intel
+       /usr/include/haptic
+       /usr/include/ecore-1
+       /usr/include/eina-1
+       /usr/include/eina-1/eina
 )
 
-
 ## Add SubModules
 ADD_SUBDIRECTORY(osp-string)
 ADD_SUBDIRECTORY(newlib-compat)
@@ -46,6 +38,4 @@ ADD_SUBDIRECTORY(security)
 ADD_SUBDIRECTORY(system)
 ADD_SUBDIRECTORY(text)
 ADD_SUBDIRECTORY(appfw)
-
-
-
+ADD_SUBDIRECTORY(server osp-appfw-server)
index dc33998..844963d 100644 (file)
@@ -17,6 +17,8 @@ SET (${this_target}_SOURCE_FILES
        package/FAppPkg_PackageAppInfoImpl.cpp
        package/FAppPkg_PackageInfoImpl.cpp
        package/FAppPkg_PackageManagerImpl.cpp
+       package/FAppPkgPackageLicenseManager.cpp
+       package/FAppPkg_PackageParser.cpp
        FAppApp.cpp
        FApp_AppImpl.cpp
        FAppServiceApp.cpp
@@ -27,7 +29,6 @@ SET (${this_target}_SOURCE_FILES
        FApp_AppManagerProxy.cpp
        FApp_ConditionManagerProxy.cpp
        FApp_PackageManagerProxy.cpp
-       FApp_NotificationManagerProxy.cpp
        FAppAppRegistry.cpp
        FApp_AppRegistryImpl.cpp
        FAppAppResource.cpp
@@ -43,12 +44,9 @@ SET (${this_target}_SOURCE_FILES
        FApp_AppArg.cpp
        FAppNotificationManager.cpp
        FApp_NotificationManagerImpl.cpp
-       FAppNotificationMessage.cpp
-       FApp_NotificationMessageImpl.cpp
        FApp_AppManagerIpcMessage.cpp
        FApp_ConditionManagerIpcMessages.cpp
        FApp_PackageManagerIpcMessages.cpp
-       FApp_NotificationManagerIpcMessages.cpp
        FApp_AppLaunchCondition.cpp
        FApp_AppLaunchConditionHandlerBase.cpp
        FAppSqlDataControl.cpp
index 49d080a..3ced2b0 100644 (file)
@@ -125,6 +125,13 @@ App::GetAppResourcePath(void) const
        return appResPath;
 }
 
+String
+App::GetAppSharedPath(void) const
+{
+       static String appSharedPath(_AppInfo::GetAppRootPath() + L"shared/");
+       return appSharedPath;
+}
+
 result
 App::Terminate(void)
 {
index e9cd615..f578e32 100644 (file)
@@ -222,13 +222,7 @@ AppManager::TerminateApplication(const AppId& appId)
        SysTryReturnResult(NID_APP, appId.GetLength() <= WIDGET_APP_MAX_APPID_LENGTH, E_MAX_EXCEEDED,
                                                  "The length of appid exceeded the limit(%d).", WIDGET_APP_MAX_APPID_LENGTH);
 
-       String tmpAppId = appId;
-       String executableName = L"";
-
-       result r = _AppManagerImpl::ExtractValues(appId, tmpAppId, executableName );
-       bool hasExecutableName = (r == E_SUCCESS);
-
-       return __pAppManagerImpl->TerminateApplication(tmpAppId, (hasExecutableName) ? &executableName : null);
+       return __pAppManagerImpl->TerminateApplication(appId);
 }
 
 bool
@@ -236,13 +230,7 @@ AppManager::IsRunning(const AppId& appId) const
 {
        SysAssertf(__pAppManagerImpl != null, "Not constructed properly by platform.");
 
-       String tmpAppId = appId;
-       String executableName = L"";
-
-       result r = _AppManagerImpl::ExtractValues(appId, tmpAppId, executableName );
-       bool hasExecutableName = (r == E_SUCCESS);
-
-       return __pAppManagerImpl->IsRunning(tmpAppId, (hasExecutableName) ? &executableName : null);
+       return __pAppManagerImpl->IsRunning(appId);
 }
 
 IList*
@@ -261,7 +249,7 @@ AppManager::RegisterAppLaunch(const String& condition, const IList* pArguments,
        result r = _AccessController::CheckUserPrivilege(_PRV_APPLICATION_LAUNCH);
        SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
-       return __pAppManagerImpl->RegisterAppLaunch(L"", _AppInfo::GetAppExecutableName(), condition, pArguments, option);
+       return __pAppManagerImpl->RegisterAppLaunch(L"", condition, pArguments, option);
 }
 
 result
@@ -272,7 +260,7 @@ AppManager::UnregisterAppLaunch(void)
        result r = _AccessController::CheckUserPrivilege(_PRV_APPLICATION_LAUNCH);
        SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
-       return __pAppManagerImpl->UnregisterAppLaunch(L"", _AppInfo::GetAppExecutableName(), null);
+       return __pAppManagerImpl->UnregisterAppLaunch(L"", null);
 }
 
 result
@@ -283,7 +271,7 @@ AppManager::UnregisterAppLaunch(const String& condition)
        result r = _AccessController::CheckUserPrivilege(_PRV_APPLICATION_LAUNCH);
        SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
-       return __pAppManagerImpl->UnregisterAppLaunch(L"", _AppInfo::GetAppExecutableName(), &condition);
+       return __pAppManagerImpl->UnregisterAppLaunch(L"", &condition);
 }
 
 bool
@@ -291,21 +279,16 @@ AppManager::IsAppLaunchRegistered(void) const
 {
        SysAssertf(__pAppManagerImpl != null, "Not constructed properly by platform.");
 
-       return __pAppManagerImpl->IsAppLaunchRegistered(L"", _AppInfo::GetAppExecutableName(), null);
+       return __pAppManagerImpl->IsAppLaunchRegistered(L"", null);
 }
 
 result
 AppManager::RegisterAppLaunch(const AppId& appId, const String& condition, const IList* pArguments, LaunchOption option)
 {
        SysAssertf(__pAppManagerImpl != null, "Not constructed properly by platform.");
+       SysTryReturnResult(NID_APP, _Aul::IsInstalled(appId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
 
-       String tmpAppId = appId;
-       String executableName = L"";
-
-       _AppManagerImpl::ExtractValues(appId, tmpAppId, executableName );
-       SysTryReturnResult(NID_APP, _PackageManagerImpl::GetInstance()->IsPackageInstalled(tmpAppId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
-
-       return __pAppManagerImpl->RegisterAppLaunch(tmpAppId, executableName, condition, pArguments, option);
+       return __pAppManagerImpl->RegisterAppLaunch(appId, condition, pArguments, option);
 }
 
 
@@ -313,14 +296,9 @@ result
 AppManager::UnregisterAppLaunch(const AppId& appId, const String* pCondition)
 {
        SysAssertf(__pAppManagerImpl != null, "Not constructed properly by platform.");
+       SysTryReturnResult(NID_APP, _Aul::IsInstalled(appId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
 
-       String tmpAppId = appId;
-       String executableName = L"";
-
-       _AppManagerImpl::ExtractValues(appId, tmpAppId, executableName );
-       SysTryReturnResult(NID_APP, _PackageManagerImpl::GetInstance()->IsPackageInstalled(tmpAppId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
-
-       return __pAppManagerImpl->UnregisterAppLaunch(tmpAppId, executableName, pCondition);
+       return __pAppManagerImpl->UnregisterAppLaunch(appId, pCondition);
 }
 
 
@@ -329,13 +307,7 @@ AppManager::IsAppLaunchRegistered(const AppId& appId, const String* pCondition)
 {
        SysAssertf(__pAppManagerImpl != null, "Not constructed properly by platform.");
 
-       String tmpAppId = appId;
-       String executableName = L"";
-
-       _AppManagerImpl::ExtractValues(appId, tmpAppId, executableName );
-       SysTryReturn(NID_APP, _PackageManagerImpl::GetInstance()->IsPackageInstalled(tmpAppId) == true, false, E_APP_NOT_INSTALLED, "[E_APP_NOT_INSTALLED] The application(%ls) is not installed.", appId.GetPointer());
-
-       return __pAppManagerImpl->IsAppLaunchRegistered(tmpAppId, executableName, pCondition);
+       return __pAppManagerImpl->IsAppLaunchRegistered(appId, pCondition);
 }
 
 result
index 833d2f4..4ce6e22 100644 (file)
  * @brief      This is the implementation for the AppResource class.
  */
 
-#include <unique_ptr.h>
-
 #include <FBaseResult.h>
+#include <FBaseSysLog.h>
 #include <FAppAppResource.h>
 
-#include <FBaseSysLog.h>
-#include "FApp_Aul.h"
 #include <FSec_AccessController.h>
 #include "FApp_AppResourceImpl.h"
+#include "FApp_AppInfo.h"
 
 using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
 using namespace Tizen::Security;
 
 namespace Tizen { namespace App
 {
 
-Tizen::Base::Collection::HashMap* AppResource::pContainer = null;
-
 AppResource::AppResource(void)
        : __pAppResourceImpl(null)
 {
@@ -51,29 +46,10 @@ AppResource::~AppResource(void)
        delete __pAppResourceImpl;
 }
 
-
-result
-AppResource::Construct(void)
-{
-       SysAssertf(__pAppResourceImpl == null,
-                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
-
-       __pAppResourceImpl = new (std::nothrow) _AppResourceImpl();
-       SysTryReturnResult(NID_APP, __pAppResourceImpl != null, E_OUT_OF_MEMORY, "Allocation failed.");
-
-       result r = __pAppResourceImpl->Construct();
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return E_SUCCESS;
-
-}
-
-
 result
 AppResource::GetString(const String& resourceId, String& loadedString) const
 {
        SysAssertf(__pAppResourceImpl != null, "Not yet constructed. Construct() should be called before use.");
-
        return __pAppResourceImpl->GetString(resourceId, loadedString);
 }
 
@@ -82,7 +58,6 @@ Bitmap*
 AppResource::GetBitmapN(const String& imgFilePath, BitmapPixelFormat pixelFormat) const
 {
        SysAssertf(__pAppResourceImpl != null, "Not yet constructed. Construct() should be called before use.");
-
        return __pAppResourceImpl->GetBitmapN(imgFilePath, pixelFormat);
 }
 
@@ -91,7 +66,6 @@ Bitmap*
 AppResource::GetBitmapN(const String& imgFilePath) const
 {
        SysAssertf(__pAppResourceImpl != null, "Not yet constructed. Construct() should be called before use.");
-
        return __pAppResourceImpl->GetBitmapN(imgFilePath);
 }
 
@@ -99,26 +73,27 @@ AppResource::GetBitmapN(const String& imgFilePath) const
 AppResource*
 AppResource::GetInstance(void)
 {
-       result r = E_SUCCESS;
-       static AppResource* pAppResource = null;
-
-       if (pAppResource == null)
+       static AppResource* pSelfAppResource = null;
+       if (pSelfAppResource == null)
        {
-               pAppResource = new (std::nothrow) AppResource();
-               SysTryCatch(NID_APP, pAppResource != null, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] app resource allocation failed.");
-
-               r = pAppResource->Construct();
-               SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Initialization of app resource failed.", GetErrorMessage(r));
+               pSelfAppResource = _AppResourceImpl::GetInstanceN(APP_RESOURCE_DEFAULT);
        }
 
-       SetLastResult(r);
-       return pAppResource;
+//     ClearLastResult();      // as this method does not register any exception.
+       return pSelfAppResource;
+}
 
-CATCH:
-       delete pAppResource;
-       pAppResource = null;
+AppResource*
+AppResource::LoadAppResource(const Tizen::Base::String& resourcePath)
+{
+       SysTryReturn(NID_APP, !resourcePath.IsEmpty(), null, E_INVALID_ARG, "Resource path is empty");
+
+       AppResource* pAppResource = _AppResourceImpl::GetInstanceN(APP_RESOURCE_BY_LIBRARY_NAME, resourcePath);
+       if (GetLastResult() == E_DATA_NOT_FOUND)
+       {
+               SetLastResult(E_FILE_NOT_FOUND);
+       }
 
-       SetLastResult(r);
        return pAppResource;
 }
 
@@ -126,125 +101,38 @@ AppResource*
 AppResource::GetInstanceByAppId(const AppId& appId)
 {
        result r = E_SUCCESS;
-       
+
        r = _AccessController::CheckUserPrivilege(_PRV_APPSETTING);
        SysTryReturn(NID_APP, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
 
-       SysTryReturn(NID_APP, _Aul::IsInstalled(appId) == true, null, E_APP_NOT_INSTALLED, "Application is not installed.", GetErrorMessage(E_APP_NOT_INSTALLED));
-
-       if (pContainer == null)
-       {
-               std::unique_ptr< HashMap > pContainerMap(new (std::nothrow) HashMap());
-               SysTryReturn(NID_APP, pContainerMap != null,
-                               null, E_OUT_OF_MEMORY, "[%s] Creating the container is failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-               r = pContainerMap->Construct();
-               SysTryReturn(NID_APP, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] Creating the container is failed [%s].", GetErrorMessage(r));
-
-               pContainer = pContainerMap.release();
-       }
+       SysTryReturn(NID_APP, !appId.IsEmpty(), null, E_APP_NOT_INSTALLED, "Invalid app id");
 
        String packageId;
        r = appId.SubString(0, 10, packageId);
        SysTryReturn(NID_APP, !IsFailed(r), null,
-                       E_APP_NOT_INSTALLED, "[%s] Failed to get package info", GetErrorMessage(E_APP_NOT_INSTALLED));
-
-       bool hasAppResource = false;
-       r = pContainer->ContainsKey(packageId, hasAppResource);
-       SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Checking to contain is failed.", GetErrorMessage(r));
-
-       if(hasAppResource == true)
-       {
-               SetLastResult(r);
-               return static_cast<AppResource*> (pContainer->GetValue(packageId));
-       }
-       else
-       {
-               std::unique_ptr< String > pStr(new (std::nothrow) String(packageId));
-               SysTryReturn(NID_APP, pStr != null, null,
-                               E_OUT_OF_MEMORY, "[%s] Creating a key is failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-               AppResource* pAppResource = new (std::nothrow) AppResource;
-               SysTryReturn(NID_APP, pAppResource != null, null,
-                               E_OUT_OF_MEMORY, "[%s] Unable to allocate memory for AppResource", GetErrorMessage(E_OUT_OF_MEMORY));
-
-               r = pAppResource->Construct(packageId);
-               SysTryCatch(NID_APP, !IsFailed(r), ,
-                               E_SYSTEM, "[E_SYSTEM] Adding an element to the container is failed [%s].", GetErrorMessage(r));
-
-               r = pContainer->Add(*pStr, *pAppResource);
-               SysTryCatch(NID_APP, !IsFailed(r), ,
-                               E_SYSTEM, "[E_SYSTEM] Adding an element to the container is failed [%s].", GetErrorMessage(r));
-
-               SetLastResult(r);
-               pStr.release();
-               return pAppResource;
-CATCH:
-               delete pAppResource;
-               return null;
-       }
+                       E_APP_NOT_INSTALLED, "[%s] Failed to get the package info", GetErrorMessage(E_APP_NOT_INSTALLED));
+       return _AppResourceImpl::GetInstanceN(APP_RESOURCE_BY_APP_ID, packageId);
 }
 
 result
 AppResource::ReleaseInstanceByAppId(const AppId& appId)
 {
        result r = E_SUCCESS;
-       AppResource* pAppResource = null;
 
        r = _AccessController::CheckUserPrivilege(_PRV_APPSETTING);
-       SysTryReturn(NID_APP, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+       SysTryReturnResult(NID_APP, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
 
-       SysTryReturnResult(NID_APP, _Aul::IsInstalled(appId) == true, E_OBJ_NOT_FOUND, "Applicationis not installed.");
-
-       if (pContainer != null)
+       if (appId == _AppInfo::GetApplicationId() || appId == _AppInfo::GetPackageId())
        {
-               String packageId;
-               r = appId.SubString(0, 10, packageId);
-               SysTryReturn(NID_APP, !IsFailed(r), E_OBJ_NOT_FOUND,
-                               E_OBJ_NOT_FOUND, "[%s] Failed to get package info", GetErrorMessage(E_OBJ_NOT_FOUND));
-
-               pAppResource = static_cast<AppResource*> (pContainer->GetValue(packageId));
-               delete pAppResource;
-               r = pContainer->Remove(packageId);
+               SysLog(NID_APP, "Ignoring key[%ls] with current instance", appId.GetPointer());
+               return E_SUCCESS;
        }
 
-       return r;
-}
-
-result
-AppResource::Construct(const AppId& appId)
-{
-       SysAssertf(__pAppResourceImpl == null,
-                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
-
-       __pAppResourceImpl = new (std::nothrow) _AppResourceImpl();
-       SysTryReturnResult(NID_APP, __pAppResourceImpl != null, E_OUT_OF_MEMORY, "Allocation failed.");
-
-       result r = __pAppResourceImpl->Construct(appId);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return E_SUCCESS;
-
-}
-
-void
-AppResource::Reinitialize(void)
-{
-       if (pContainer != null)
-       {
-               IMapEnumerator* pMapEnum = pContainer->GetMapEnumeratorN();
-               while(pMapEnum->MoveNext() == E_SUCCESS)
-               {
-                       AppResource* pAppResource = static_cast<AppResource*> (pMapEnum->GetValue());
-                       String* pStr = static_cast<String*> (pMapEnum->GetKey());
-                       pAppResource->Reinitialize(*pStr);
-               }
-       }
+       String packageId;
+       r = appId.SubString(0, 10, packageId);
+       SysTryReturn(NID_APP, !IsFailed(r), null,
+                       E_OBJ_NOT_FOUND, "[%s] Failed to get the package info", GetErrorMessage(E_OBJ_NOT_FOUND));
+       return _AppResourceImpl::ReleaseInstance(packageId);
 }
 
-void
-AppResource::Reinitialize(const AppId& appId)
-{
-       __pAppResourceImpl->Reinitialize(appId);
-}
 } } // Tizen::App
index a24746e..fae9ba5 100644 (file)
@@ -129,7 +129,7 @@ NotificationManager::NotifyOnBehalf(const AppId& appId, int badgeNumber)
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
        return __pNotificationManagerImpl->NotifyOnBehalf(appId, badgeNumber);
@@ -140,7 +140,7 @@ NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageTex
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
        return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText);
@@ -151,7 +151,7 @@ NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageTex
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
        return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText, badgeNumber);
@@ -162,7 +162,7 @@ NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageTex
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
        return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText, launchArguments);
@@ -196,7 +196,7 @@ NotificationManager::NotifyOngoingActivityOnBehalf(const AppId& appId, const Str
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
 
@@ -208,7 +208,7 @@ NotificationManager::NotifyOngoingActivityOnBehalf(const AppId& appId, const Str
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
        return __pNotificationManagerImpl->NotifyOngoingActivityOnBehalf(appId, messageText, launchArguments);
@@ -230,7 +230,7 @@ NotificationManager::RemoveOngoingActivityNotificationOnBehalf(const AppId& appI
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
        return __pNotificationManagerImpl->RemoveOngoingActivityNotificationOnBehalf(appId);
@@ -252,7 +252,7 @@ NotificationManager::RemoveNotificationOnBehalf(const AppId& appId)
 {
        SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
 
-       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATIONMANAGER);
+       result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
        SysTryReturnResult(NID_APP,  !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
 
        return __pNotificationManagerImpl->RemoveNotificationOnBehalf(appId);
old mode 100644 (file)
new mode 100755 (executable)
index 83824ad..2d5a38e
@@ -195,6 +195,16 @@ _AppArg::ConstructForAppLaunchCondition(const String& condition, const IList* pL
        return CreateAppLaunchConditionArg(__pBundle, condition, pList);
 }
 
+result
+_AppArg::ConstructForAppLaunchCondition(const String& condition, const IList* pList, const IMap* pMap)
+{
+       __pBundle = bundle_create();
+       SysTryReturnResult(NID_APP, __pBundle != null, E_OUT_OF_MEMORY, "Bundle creation failure.");
+
+       CreateAppLaunchConditionArg(__pBundle, condition, pList);
+
+       return CreateResultArg(__pBundle, pMap);
+}
 
 ArrayList*
 _AppArg::GetArgListN(int num) const
@@ -314,23 +324,8 @@ _AppArg::GetArgMapN(void) const
 
        if (pHashMap->GetCount() == 0)
        {
-               // [FIXME] temporary resolution for PolarisOffice
-               const char* p = appsvc_get_uri(__pBundle);
-               if (p == null)
-               {
-                       delete pHashMap;
-                       return null;
-               }
-               else
-               {
-                       pHashMap->Add(new (std::nothrow) String(L"reqId"), new (std::nothrow) String(L"-1"));
-                       pHashMap->Add(new (std::nothrow) String(L"path1"), new (std::nothrow) String(L""));
-                       pHashMap->Add(new (std::nothrow) String(L"path2"), new (std::nothrow) String(L""));
-                       pHashMap->Add(new (std::nothrow) String(L"path3"), new (std::nothrow) String(L""));
-                       pHashMap->Add(new (std::nothrow) String(L"path"), new (std::nothrow) String(p));
-
-                       return pHashMap;
-               }
+               delete pHashMap;
+               return null;
        }
 
        ArrayList* pList = _AppMessageImpl::GetValueArray(__pBundle, OSP_K_ARG);
@@ -383,7 +378,6 @@ BundleIterFnCb(const char* pKey, const int type, const bundle_keyval_t* pVal, vo
                        bundle_keyval_get_basic_val(const_cast<bundle_keyval_t*>(pVal), reinterpret_cast<void**>(&pStr), &size);
                        if (pStr)
                        {
-                               SysLog(NID_APP, "(%s, %s)", pKey, pStr);
                                pMap->Add(new (std::nothrow) String(pKey), new (std::nothrow) String(pStr));
                        }
                        break;
@@ -606,6 +600,17 @@ _AppArg::GetCalleeAppId(void) const
 
 
 void
+_AppArg::SaveCalleeAppId(void)
+{
+       const AppId& appId = GetCalleeAppId();
+
+       std::unique_ptr<char[]> pVal(_StringConverter::CopyToCharArrayN(appId));
+
+       appsvc_add_data(__pBundle, OSP_K_CALLEE_APPID, pVal.get());
+}
+
+
+void
 _AppArg::AddListFromBundle(ArrayList* pList, bundle* bk, const char* key)
 {
        bundle* pBundle = bk;
index a7287c2..1a3a28a 100755 (executable)
@@ -258,39 +258,31 @@ _AppControlImpl::StartOsp(const IList* pDataList, IAppControlEventListener* pLis
                req = reqObj.GetRequestNumber();
 
                _processId = pImpl->Launch(_path, pArg, req);
-               SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
+
+               if (_processId < 0)
+               {
+                       reqObj.Invalidate();
+                       r = GetLastResult();
+                       SysLog(NID_APP, "[%s]Launching(%ls) is failed" , GetErrorMessage(r), _path.GetPointer());
+                       return r;
+               }
        }
        else
        {
                _processId = pImpl->Launch(_path, pArg);
                delete pArg;
+               SysTryReturnResult(NID_APP, _processId >= 0, GetLastResult(), "Launching(%ls) is failed", _path.GetPointer());
        }
 
-       {
-               // registers to server
-               _IAppManager* pMgr = _AppManagerProxy::GetService();
+       // registers to server
+       _IAppManager* pMgr = _AppManagerProxy::GetService();
 
-               // actually register, not launch
-               if (pMgr)
-               {
-                       const int MAX_PACKAGE_ID = 10;
-
-                       String appId;
-                       String execName;
-                       r = _path.SubString(0, MAX_PACKAGE_ID, appId);
-                       if (r == E_SUCCESS)
-                       {
-                               r = _path.SubString(MAX_PACKAGE_ID + 1, execName);
-                               if (r == E_SUCCESS)
-                               {
-                                       pMgr->LaunchApplication(appId, execName, req);
-                               }
-                       }
-               }
+       // actually register, not launch
+       if (pMgr)
+       {
+               pMgr->LaunchApplication(_path, req);
        }
 
-CATCH:
-
        return r;
 }
 
@@ -312,40 +304,31 @@ _AppControlImpl::StartOsp(const String* pUriData, const String* pMimeType, const
                _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCb, pListener, _property);
                req = reqObj.GetRequestNumber();
 
-               _processId = pImpl->Launch(_path, pArg, req);
-               SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
+               _processId = pImpl->Launch(_path, pArg, req);           
+               if (_processId < 0)
+               {
+                       reqObj.Invalidate();
+                       r = GetLastResult();
+                       SysLog(NID_APP, "[%s]Launching(%ls) is failed" , GetErrorMessage(r), _path.GetPointer());
+                       return r;
+               }
        }
        else
        {
                _processId = pImpl->Launch(_path, pArg);
                delete pArg;
+               SysTryReturnResult(NID_APP, _processId >= 0, GetLastResult(), "Launching(%ls) is failed", _path.GetPointer());
        }
 
-       {
-               // registers to server
-               _IAppManager* pMgr = _AppManagerProxy::GetService();
-
-               // actually register, not launch
-               if (pMgr)
-               {
-                       const int MAX_PACKAGE_ID = 10;
+       // registers to server
+       _IAppManager* pMgr = _AppManagerProxy::GetService();
 
-                       String appId;
-                       String execName;
-                       r = _path.SubString(0, MAX_PACKAGE_ID, appId);
-                       if (r == E_SUCCESS)
-                       {
-                               r = _path.SubString(MAX_PACKAGE_ID + 1, execName);
-                               if (r == E_SUCCESS)
-                               {
-                                       pMgr->LaunchApplication(appId, execName, req);
-                               }
-                       }
-               }
+       // actually register, not launch
+       if (pMgr)
+       {
+               pMgr->LaunchApplication(_path, req);
        }
 
-CATCH:
-
        return r;
 }
 
@@ -381,7 +364,6 @@ _AppControlImpl::StartImplicit(bundle* pBundle, const IList* pDataList, IAppCont
        // [FIXME] launch registration is not working correctly
 
 CATCH:
-
        return r;
 }
 
@@ -441,7 +423,7 @@ _AppControlImpl::AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg,
 
        String oId;
 
-       AppId provider = pResArg->GetCalleeAppId();
+       AppId provider = pResArg->GetValue(OSP_K_CALLEE_APPID);
 
        const char* p = appsvc_get_operation(inb);
        if (p)
@@ -506,7 +488,7 @@ _AppControlImpl::AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, servi
 
        String oId;
 
-       AppId provider = pResArg->GetCalleeAppId();
+       AppId provider = pResArg->GetValue(OSP_K_CALLEE_APPID);
 
        const char* p = appsvc_get_operation(inb);
        if (p)
@@ -587,7 +569,10 @@ _AppControlImpl::StartNative(const IList* pDataList, IAppControlEventListener* p
        pLib = new (std::nothrow) _LibraryImpl;
        SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
 
-       result r = pLib->Construct(_path);
+       unsigned long option = _LIBRARY_LOAD_OPTION_LAZY;
+       option |= _LIBRARY_LOAD_OPTION_NODELETE;
+
+       result r = pLib->Construct(_path, option);
        SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (pListener)
@@ -647,7 +632,11 @@ _AppControlImpl::StartNative(const String* pUriData, const String* pMimeType, co
        pLib = new (std::nothrow) _LibraryImpl;
        SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
 
-       result r = pLib->Construct(_path);
+       unsigned long option = _LIBRARY_LOAD_OPTION_LAZY;
+       option |= _LIBRARY_LOAD_OPTION_NODELETE;
+
+       result r = pLib->Construct(_path, option);
+
        SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (pListener)
@@ -880,6 +869,7 @@ _AppControlImpl::GetCategoryListN(void) const
 void
 _AppControlImpl::StopAppControlResponseListener(IAppControlResponseListener* pListener)
 {
+       _AppControlManager::GetInstance()->__listenerList.Add(pListener);
 }
 
 }}    //Tizen::App
index a109998..c47a88a 100755 (executable)
@@ -83,6 +83,7 @@ namespace Tizen { namespace App
 const wchar_t TIZEN_OPERATION_PICK[] = L"http://tizen.org/appcontrol/operation/pick";
 const wchar_t SELECTOR_NOTI_KEY[] = L"__APP_SVC_CALLER_NOTI__";
 const int _MAX_PACKAGE_ID_LENGTH = 10;
+const int _MAX_DATA_ARGUMENT_LENGTH = 32768; // 32KB
 
 _InProcessInfo::~_InProcessInfo(void)
 {
@@ -102,6 +103,7 @@ _AppControlManager::_AppControlManager(void)
        // AppControl event handling is expected to be performed in the main thread.
        __appControlEvent.Construct();
        __appControlEvent.AddListener(*dynamic_cast<_IAppControlSysEventListener*>(this));
+       __listenerList.Construct();
 }
 
 _AppControlManager::~_AppControlManager(void)
@@ -152,8 +154,12 @@ _AppControlManager::OnAppControlEventReceivedN(int reqId, _AppArg* pAppArg, int
                if (pInfo->magic == LAUNCH_INFO_MAGIC)
                {
                        SysLog(NID_APP, "Invoking callback 0x%x", pInfo->launchCb);
+                       //pAppArg->Print();
 
-                       (*pInfo->launchCb)(pInfo->pUserData, pInfo->pArg, pAppArg, static_cast<service_result_e>(res), pInfo->property);
+                       if (pInfo->pUserData && (!__listenerList.Contains(pInfo->pUserData)))
+                       {
+                               (*pInfo->launchCb)(pInfo->pUserData, pInfo->pArg, pAppArg, static_cast<service_result_e>(res), pInfo->property);
+                       }
                }
                else
                {
@@ -248,8 +254,9 @@ _AppControlManager::OnAppControlEventReceivedN(int reqId, int res, const IMap* p
                else
                {
                        IAppControlResponseListener* pListener = dynamic_cast<IAppControlResponseListener*>(pInfo->pListener);
-                       if (pListener)
+                       if (pListener && (!__listenerList.Contains(pInfo->pListener)))
                        {
+                               SysLog(NID_APP, "OSP_AC OnAppControlCompleteResponseReceived");
                                pListener->OnAppControlCompleteResponseReceived(aId, oId, static_cast<AppCtrlResult>(res), pArgs);
                        }
                        else
@@ -305,6 +312,9 @@ LaunchResultCb(bundle* b, int request_code, appsvc_result_val res, void* data)
        result r = pAppArg->Construct(b);
        SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] AppControl event argument creation failure.", GetErrorMessage(r));
 
+       // save callee appId ASAP
+       pAppArg->SaveCalleeAppId();
+
        pArg = new (std::nothrow) _AppControlEventArg(request_code, pAppArg, res);
        SysTryCatch(NID_APP, pArg != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] AppControl event argument creation failure.");
 
@@ -353,15 +363,31 @@ _AppControlManager::LaunchPkg(_AppMessageImpl& msg, const char* pkg_name, const
                appsvc_set_uri(kb, uri);
        }
 
-       const long handle = _AppImpl::GetInstance()->GetWindowHandle();
-       _AppArg::UpdateWindowHandle(kb, handle);
+       if (_AppImpl::GetInstance() != null)
+       {
+               const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+               _AppArg::UpdateWindowHandle(kb, handle);
+       }
 
        SysLog(NID_APP, "MIME(%s), URI(%s).", appsvc_get_mime(kb), appsvc_get_uri(kb));
        int pid = appsvc_run_service(kb, 0, reinterpret_cast<appsvc_res_fn>(pCb), this);
 
-       SysTryReturnResult(NID_APP, pid >= 0, E_SYSTEM, "Launching service %s failure with %d", pkg_name, pid);
+       result r = E_SUCCESS;
+       if (pid < 0)
+       {
+               switch (pid)
+               {
+               case APPSVC_RET_EILLACC:
+                       r = E_ILLEGAL_ACCESS;
+                       break;
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+               SysLog(NID_APP, "[%s]Launching service %s failure", GetErrorMessage(r), pkg_name);
+       }
 
-       return E_SUCCESS;
+       return r;
 }
 int
 _AppControlManager::Launch(_AppMessageImpl& msg, const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data)
@@ -386,13 +412,30 @@ _AppControlManager::Launch(_AppMessageImpl& msg, const char* pkg_name, const cha
                appsvc_set_uri(kb, uri);
        }
 
-       const long handle = _AppImpl::GetInstance()->GetWindowHandle();
-       _AppArg::UpdateWindowHandle(kb, handle);
+       if (_AppImpl::GetInstance() != null)
+       {
+               const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+               _AppArg::UpdateWindowHandle(kb, handle);
+       }
 
        SysLog(NID_APP, "MIME(%s), URI(%s).", appsvc_get_mime(kb), appsvc_get_uri(kb));
        int pid = appsvc_run_service(kb, 0, reinterpret_cast<appsvc_res_fn>(pCb), this);
 
-       SysTryReturn(NID_APP, pid >= 0, -1, E_SYSTEM, "Launching service %s failure with %d", pkg_name, pid);
+       result r = E_SUCCESS;
+       if (pid < 0)
+       {
+               switch (pid)
+               {
+               case APPSVC_RET_EILLACC:
+                       r = E_ILLEGAL_ACCESS;
+                       break;
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+               SysLog(NID_APP, "[%s]Launching service %s failure", GetErrorMessage(r), pkg_name);
+       }
+       SetLastResult(r);
 
        return pid;
 }
@@ -407,18 +450,16 @@ _AppControlManager::LaunchPkg(const char* pkg_name, const char* op, const char*
 }
 
 result
-_AppControlManager::LaunchAppWithCondition(const AppId& appId, const String& executableName, const String& condition, IList* pArrayArgs)
+_AppControlManager::LaunchAppWithCondition(const AppId& appId, const String& condition, IList* pArrayArgs)
 {
        result r = E_SUCCESS;
-       const String& actualAppId = appId + L'.' + executableName;
        _AppArg * pArg = new (std::nothrow) _AppArg();
        SysTryCatch(NID_APP, pArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
 
        r = pArg->ConstructForAppLaunchCondition(condition, pArrayArgs);
        SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] ConstructForAppLaunchCondition(%ls, .. ) fails", GetErrorMessage(r), condition.GetPointer());
 
-       r = _AppControlManager::LaunchApp(actualAppId, pArg);
-
+       r = _AppControlManager::LaunchApp(appId, pArg);
 CATCH:
        delete pArg;
        return r;
@@ -444,8 +485,11 @@ _AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
 
        pArg->UpdateRequestId(req);
 
-       const long handle = _AppImpl::GetInstance()->GetWindowHandle();
-       pArg->UpdateWindowHandle(handle);
+       if (_AppImpl::GetInstance() != null)
+       {
+               const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+               pArg->UpdateWindowHandle(handle);
+       }
 
        int pid = -1;
        bundle* kb = NULL;
@@ -457,6 +501,14 @@ _AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
        // [INFO] Ugly solution for submode support
        pArg->UpdateAppId(tempId);
        kb = pArg->GetBundle();
+
+       bundle_raw* dataBuf = null;
+       int dataLen = 0;
+       int res = bundle_encode(kb, &dataBuf, &dataLen);
+       bundle_free_encoded_rawdata(&dataBuf);
+       SysTryReturnResult(NID_APP, res == 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+       SysTryReturnResult(NID_APP, dataLen <= _MAX_DATA_ARGUMENT_LENGTH, E_MAX_EXCEEDED,
+                       "The data length (%d) exceeds the maximum limit.", dataLen);
        
        pid = appsvc_run_service(kb, req, LaunchResultCb, this);
        if (pid > 0)
@@ -486,9 +538,20 @@ _AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
        }
        while (count < TRY_COUNT);
 
-       SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Launching service failure for %ls with %d", appId.GetPointer(), pid);
+       result r = E_SUCCESS;
+       switch (pid)
+       {
+       case APPSVC_RET_EILLACC:
+               r = E_ILLEGAL_ACCESS;
+               break;
+       default:
+               r = E_SYSTEM;
+               break;
+       }
+
+       SysLogException(NID_APP, r, "[%s] Launching service failure for %ls", GetErrorMessage(r), appId.GetPointer());
 
-       return E_SYSTEM;
+       return r;
 }
 
 int
@@ -511,8 +574,11 @@ _AppControlManager::Launch(const AppId& appId, _AppArg* pArg, int req)
 
        pArg->UpdateRequestId(req);
 
-       const long handle = _AppImpl::GetInstance()->GetWindowHandle();
-       pArg->UpdateWindowHandle(handle);
+       if (_AppImpl::GetInstance() != null)
+       {
+               const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+               pArg->UpdateWindowHandle(handle);
+       }
 
        int pid = -1;
        bundle* kb = NULL;
@@ -553,7 +619,20 @@ _AppControlManager::Launch(const AppId& appId, _AppArg* pArg, int req)
        }
        while (count < TRY_COUNT);
 
-       SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Launching service failure for %ls with %d", appId.GetPointer(), pid);
+       result r = E_SUCCESS;
+       switch (pid)
+       {
+       case APPSVC_RET_EILLACC:
+               r = E_ILLEGAL_ACCESS;
+               break;
+       default:
+               r = E_SYSTEM;
+               break;
+       }
+
+       SysLogException(NID_APP, r, "[%s] Launching service failure for %ls", GetErrorMessage(r), appId.GetPointer());
+
+       SetLastResult(r);
 
        return pid;
 }
@@ -586,6 +665,9 @@ _AppControlManager::LaunchAppImplicit(_AppArg* pArg, int req)
        case APPSVC_RET_ELAUNCH:
                r = E_SYSTEM;
                break;
+       case APPSVC_RET_EILLACC:
+               r = E_ILLEGAL_ACCESS;
+               break;
        default:
                break;
        }
index c14c87a..e929d9d 100644 (file)
@@ -47,7 +47,6 @@ class IAppControlProviderEventListener;
 /**
  * @class      _AppControlProviderManagerImpl
  * @brief      This class manages all the application controls.
- * @since 2.1
  *
  * The %_AppControlProviderManagerImpl class manages all the application controls.
  */
@@ -64,12 +63,12 @@ public:
 
        AppId GetClientAppId(RequestId reqId) const;
 
-       /** 
+       /**
         * Internal GetImpl() method.
         */
        static const _AppControlProviderManagerImpl* GetInstance(const AppControlProviderManager& ac);
 
-       /** 
+       /**
         * Internal GetImpl() method.
         */
        static _AppControlProviderManagerImpl* GetInstance(AppControlProviderManager& ac);
@@ -91,8 +90,8 @@ private:
        _AppControlProviderManagerImpl(const _AppControlProviderManagerImpl& rhs);
 
        /**
-        * This is the assignment operator for this class.
-        */
+       * This is the assignment operator for this class.
+       */
        _AppControlProviderManagerImpl& operator =(const _AppControlProviderManagerImpl& rhs);
 
        friend class AppControlProviderManager;
index 34725d1..5413239 100644 (file)
@@ -54,19 +54,15 @@ using namespace Tizen::Io;
 namespace
 {
 
-const wchar_t ACTL_PRIVATE_FILE[] = L"/usr/etc/app-control-system.ini";
 const wchar_t ACTL_DEFAULT_FILE[] = L"/usr/etc/app-control-info.ini";
 const wchar_t ACTL_LEGACY_FILE[] = L"/usr/etc/app-control-alias.ini";
 const wchar_t ACTL_ALIAS_FILE[] = L"/usr/etc/app-control-appid.ini";
-const wchar_t ACTL_PRIVATE_ALIAS_FILE[] = L"/usr/etc/app-control-private-appid.ini";
 
 const wchar_t TIZEN_ALIAS_APPID_PREFIX[] = L"tizen.";
 
 const String ACTL_REGISTRY_OP_NUM = L"OPID_Count";
 const String ACTL_REGISTRY_PUBLIC = L"Public";
-const String ACTL_REGISTRY_LAUNCH_TYPE = L"LaunchType";
 const String ACTL_REGISTRY_PATH = L"Path";
-const String ACTL_REGISTRY_CATEGORY = L"Category";
 const String ACTL_REGISTRY_TITLE = L"Title";
 const String ACTL_REGISTRY_ALIAS_PROVIDER = L"PROVIDER_ALIAS";
 
@@ -129,13 +125,7 @@ _AppControlRegistry::LoadRegistry(void)
 {
        _RegistryImpl reg;
 
-       String regPath = ACTL_PRIVATE_FILE;
-
-       // if ACTL_SYSTEM does not exist, then use default name
-       if (!File::IsFileExist(regPath))
-       {
-               regPath = ACTL_DEFAULT_FILE;
-       }
+       const String regPath = ACTL_DEFAULT_FILE;
 
        result r = reg.Construct(regPath, REG_OPEN_READ_ONLY, null);
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -166,7 +156,6 @@ _AppControlRegistry::LoadRegistry(void)
                }
 
                int public_open = 0;
-               int launch_type = 0;
 
                ///////////////////////////////////////////////////////////////////////
                // Plubic
@@ -185,32 +174,12 @@ _AppControlRegistry::LoadRegistry(void)
                }
 
                ///////////////////////////////////////////////////////////////////////
-               // Launch type
-               index = reg.GetEntryIndex(i, ACTL_REGISTRY_LAUNCH_TYPE);
-               if (index >= 0)
-               {
-                       size = sizeof(size);
-
-                       reg.GetEntryValue(i, index, REG_VALUE_TYPE_INT, &launch_type, &size);
-               }
-
-               ///////////////////////////////////////////////////////////////////////
                // Path
                index = reg.GetEntryIndex(i, ACTL_REGISTRY_PATH);
                if (index >= 0)
                {
                        size = REG_VALUE_BUFFER_LEN;
                        reg.GetEntryValue(i, index, REG_VALUE_TYPE_STRING, &actl_path, &size);
-
-                       if (launch_type == _APPCONTROL_TYPE_OSP)
-                       {
-                               if (!_Aul::IsInstalled(actl_path))
-                               {
-                                       SysLog(NID_APP, "Osp app %ls not installed.", actl_path.GetPointer());
-                                       continue;
-                               }
-                               // [FIXME] retrieve from package info here
-                       }
                }
 
                ///////////////////////////////////////////////////////////////////////
@@ -263,18 +232,7 @@ _AppControlRegistry::LoadRegistry(void)
                                        prop |= _APPCONTROL_PROPERTY_PUBLIC;
                                }
 
-                               switch (launch_type)
-                               {
-                               case _APPCONTROL_TYPE_NATIVE:
-                                       prop |= _APPCONTROL_PROPERTY_SLP;
-                                       break;
-                               case _APPCONTROL_TYPE_OSP:
-                                       prop |= _APPCONTROL_PROPERTY_OSP;
-                                       break;
-                               default:
-                                       SysLog(NID_APP, "Invalid launch type %d", launch_type);
-                                       break;
-                               }
+                               prop |= _APPCONTROL_PROPERTY_SLP;
 
                                //SysLog(NID_APP, "(%ls, %ls)", sec_name.GetPointer(), actl_opId.GetPointer());
                                AppControl* pAc = _AppControlImpl::CreateN(actl_path, sec_name, actl_opId, actl_name, prop);
@@ -285,8 +243,8 @@ _AppControlRegistry::LoadRegistry(void)
                                }
                                else
                                {
-                                       SysLog(NID_APP, "Failed to create AppControl instance (%ls, %ls, %d, %d)",
-                                                               sec_name.GetPointer(), actl_opId.GetPointer(), public_open, launch_type);
+                                       SysLog(NID_APP, "Failed to create AppControl instance (%ls, %ls, %d)",
+                                                               sec_name.GetPointer(), actl_opId.GetPointer(), public_open);
                                }
                        }
                }
@@ -395,13 +353,7 @@ _AppControlRegistry::LoadAliasList(void)
 {
        _RegistryImpl reg;
 
-       String regPath = ACTL_PRIVATE_ALIAS_FILE;
-
-       // if ACTL_SYSTEM does not exist, then use default name
-       if (!File::IsFileExist(regPath))
-       {
-               regPath = ACTL_ALIAS_FILE;
-       }
+       const String regPath = ACTL_ALIAS_FILE;
 
        result r = reg.Construct(regPath, REG_OPEN_READ_ONLY, null);
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
old mode 100644 (file)
new mode 100755 (executable)
index bc07e0e..8e7f45d
@@ -24,6 +24,7 @@
 
 #include <notification/notification.h>
 #include <appsvc/appsvc.h>
+#include <vconf.h>
 
 #include <FBaseInteger.h>
 #include <FBaseColArrayList.h>
@@ -63,10 +64,12 @@ using namespace Tizen::System;
 namespace
 {
 
-const int HEARTBEAT_WAIT_COUNT = 20;
-const char HEARBEAT_PATH[] = "/tmp/osp-initialized";
+const int HEARTBEAT_WAIT_COUNT = 3;
 const wchar_t SERVICE_APPID[] = L"aospd00043.osp-app-service";
 const char SELECTOR_RESPONSE_KEY[] = "__APP_SVC_START_INFO__";
+#ifndef VCONFKEY_APPSERVICE_STATUS
+#define VCONFKEY_APPSERVICE_STATUS  "memory/appservice/status"
+#endif
 
 }
 
@@ -97,6 +100,7 @@ _AppImpl::_AppImpl(App* pApp)
        , __pIAppImpl(null)
        , __pRequestHandler(&_AppImpl::HandleAppRequest)
        , __pLegacyRequestHandler(&_AppImpl::HandleDummyAppRequest)
+       , __forcedTermination(false)
 {
        __pAppImpl = this;
 }
@@ -122,6 +126,7 @@ _AppImpl::Construct(const IList* pArgs)
 result
 _AppImpl::Execute(_IAppImpl* pIAppImpl)
 {
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
        result r = E_SUCCESS;
        int eflResult = APP_ERROR_NONE;
        int argc = _AppInfo::GetArgc();
@@ -188,8 +193,43 @@ _AppImpl::OnCreate(void* user_data)
 {
        SysLog(NID_APP, "Platform creation event.");
 
+       _AppImpl* pAppImpl = static_cast<_AppImpl*>(user_data);
+       if (pAppImpl == null)
+       {
+               _AppInfo::SetAppState(TERMINATED);
+               SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Invalid platform state.");
+               return false;
+       }
+
        _AppInfo::SetAppState(INITIALIZING);
 
+       if (!ConfirmAppService())
+       {
+               _AppInfo::SetAppState(TERMINATED);
+               SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
+               return false;
+       }
+
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:start]", _AppInfo::GetAppExecutableName().GetPointer());
+       if (!pAppImpl->__pIAppImpl->OnAppInitializing())
+       {
+               _AppInfo::SetAppState(TERMINATED);
+               SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
+               return false;
+       }
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:done]", _AppInfo::GetAppExecutableName().GetPointer());
+
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:start]", _AppInfo::GetAppExecutableName().GetPointer());
+       _IAppManager* pAppManager = _AppManagerProxy::GetService();
+
+       if (pAppManager != null)
+       {
+               result r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
+               SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
+       }
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
+       // hide splash window
+
        _PowerManagerImpl::InitBatteryEvent();
 
        return true;
@@ -222,6 +262,7 @@ _AppImpl::OnService(service_s* service, void* user_data)
                }
        }
 
+       //_AppArg::Print(pBundle);
        int req = -1;
        _AppHandler handler = _APP_HANDLER_NONE;
        pAppImpl->RegisterAppRequest(service, req, handler);
@@ -229,11 +270,10 @@ _AppImpl::OnService(service_s* service, void* user_data)
        bool initialLaunch = false;
 
        // initial launch
-       // (1) OnAppInitializing()
+       // (1) AppControl / DataControl provider listener
        // (2) OnAppInitialized()
-       // (3) AppControl / DataControl provider listener
-       // (4) OnResume() (OnForeground()) (UiApp only)
-       // (5) OnUserEventReceivedN()
+       // (3) OnResume() (OnForeground()) (UiApp only)
+       // (4) OnUserEventReceivedN()
 
        // already launched
        // (1) AppControl / DataControl provider listener
@@ -251,35 +291,9 @@ _AppImpl::OnService(service_s* service, void* user_data)
                        _AppInfo::GetAppInfo()->SetParentWindowHandle(winId);
                        SysLog(NID_APP, "Saving window handle 0x%x.", winId);
                }
-
-               if (!ConfirmAppService())
-               {
-                       _AppInfo::SetAppState(TERMINATED);
-                       SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
-                       app_efl_exit();
-                       return;
-               }
-
-               if (!pAppImpl->__pIAppImpl->OnAppInitializing())
-               {
-                       _AppInfo::SetAppState(TERMINATED);
-                       SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
-                       app_efl_exit();
-                       return;
-               }
-
-               _IAppManager* pAppManager = _AppManagerProxy::GetService();
-
-               if (pAppManager != null)
-               {
-                       result r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), _AppInfo::GetAppType() , _AppInfo::GetProcessId());
-                       SysTryReturnVoidResult(NID_APP, !IsFailed(r), r, "[%s] Application registration failed.", GetErrorMessage(r));
-               }
-
-               // hide splash window
-
                // call for callbacks
                // ptr to member function
+               SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:start]", _AppInfo::GetAppExecutableName().GetPointer());
                (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
 
                if (!pAppImpl->__pIAppImpl->OnAppInitialized())
@@ -289,8 +303,11 @@ _AppImpl::OnService(service_s* service, void* user_data)
                        app_efl_exit();
                        return;
                }
+               SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:done]", _AppInfo::GetAppExecutableName().GetPointer());
 
                _AppInfo::SetAppState(RUNNING);
+
+               SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:done]", _AppInfo::GetAppExecutableName().GetPointer());
        }
        else
        {
@@ -326,11 +343,13 @@ void
 _AppImpl::OnResume(void* user_data)
 {
        SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:start]", _AppInfo::GetAppExecutableName().GetPointer());
 
        _AppImpl* pAppImpl = _AppImpl::GetInstance();
        SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
        SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
        pAppImpl->__pIAppImpl->OnResume();
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:done]", _AppInfo::GetAppExecutableName().GetPointer());
 }
 
 
@@ -338,12 +357,14 @@ void
 _AppImpl::OnPause(void* user_data)
 {
        SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:start]", _AppInfo::GetAppExecutableName().GetPointer());
 
        _AppImpl* pAppImpl = _AppImpl::GetInstance();
        SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
        SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
        pAppImpl->__pIAppImpl->OnPause();
        pAppImpl->OnAppCheckpoint();
+       SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:done]", _AppInfo::GetAppExecutableName().GetPointer());
 }
 
 
@@ -581,7 +602,9 @@ _AppImpl::OnLanguageChanged(void* user_data)
 {
        SysLog(NID_APP, "");
        _AppInfo::UpdatePackageInfo(true);
-       _AppResourceImpl::GetInstance()->Reinitialize();
+
+       _AppResourceImpl::Reinitialize();
+       SysLog(NID_APP, "Language change done.");
 }
 
 void
@@ -615,10 +638,20 @@ _AppImpl::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
 void
 _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
 {
-       const String& internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
-       bool isInternalOperation = ( __pAppControlProviderInternalEventListener != null && internalOperation.IsEmpty() == false);
+       IAppControlProviderEventListener* pAppControlProviderEventListener = null;
 
-       if (__pAppControlProviderEventListener == null && isInternalOperation == false)
+       const String internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
+       if( !internalOperation.IsEmpty() )
+       {
+               SysLog(NID_APP, "internalOperation:%ls", internalOperation.GetPointer() );
+               pAppControlProviderEventListener = __pAppControlProviderInternalEventListener;
+       }
+       else
+       {
+               pAppControlProviderEventListener = __pAppControlProviderEventListener;
+       }
+
+       if( pAppControlProviderEventListener == null)
        {
                SysLog(NID_APP, "No AppControl provider event listener set for request %d.", reqId);
                return;
@@ -657,14 +690,7 @@ _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
 
        std::unique_ptr<HashMap> pMap(arg.GetArgMapN());
 
-       if( isInternalOperation )
-       {
-               __pAppControlProviderInternalEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
-       }
-       else
-       {
-               __pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
-       }
+       pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
 
        SysLog(NID_APP, "AppControl (%ls, %ls) invocation finished.", appId.GetPointer(), operationId.GetPointer());
 }
@@ -1058,7 +1084,8 @@ _AppImpl::OnConditionRequestReceived(const _AppArg& arg, RequestId reqId)
        }
 
        String condition = arg.GetValue(OSP_K_COND);
-       Object* pExtraData = null;//TODO: retrieve NFC extra data.
+       //Object* pExtraData = null;//TODO: retrieve NFC extra data.
+    HashMap* pExtraData = arg.GetArgMapN();
        ArrayList* pList = arg.GetArgListN();
 
        __pAppLaunchConditionEventListener->OnAppLaunchConditionMetN(condition, pExtraData, pList);
@@ -1087,18 +1114,19 @@ _AppImpl::OnAppCheckpoint(void)
 bool
 _AppImpl::ConfirmAppService(void)
 {
-       int count = 0;
-       long interval = 100;
-       const String tmpFile = HEARBEAT_PATH;
-
        if (_AppInfo::GetApplicationId() == SERVICE_APPID)
        {
                return true;
        }
 
+       int value = -1;
+       int count = 0;
+       long interval = 100;
+
        while (true)
        {
-               if (File::IsFileExist(tmpFile))
+               int res = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &value);
+               if (value > 0)
                {
                        return true;
                }
@@ -1111,6 +1139,7 @@ _AppImpl::ConfirmAppService(void)
                SysLog(NID_APP, "Waiting for app service %dth time(%d msec).", count, interval);
                count++;
                Thread::Sleep(interval);
+               interval += 100;
        }
 
        return false;
@@ -1202,9 +1231,21 @@ void
 _AppImpl::OnPowerOffNotiReceived(void* user_data)
 {
        SysLog(NID_APP, "Application is being terminated by power off.");
+
+       _AppImpl* pAppImpl = _AppImpl::GetInstance();
+       if (pAppImpl != null)
+       {
+               pAppImpl->__forcedTermination = true;
+       }
        
        app_efl_exit();
 }
 
+bool 
+_AppImpl::IsForcedTermination(void)
+{
+       return __forcedTermination;
+}
+
 }} //Tizen::App
 
index 719f3e8..69c3740 100644 (file)
@@ -79,10 +79,11 @@ namespace Tizen { namespace App
 
 const int MAX_APIVERSION = 8;
 const int MAX_APPID = 10;
-const char APPINFO_FILE_PATH[] = "info/version.info";
 const char PACKAGE_PATH_FORMAT2[] = "/opt/apps/0000000000/";
 const char PATH_ROOT[] = "/opt/apps/";
+const char APPINFO_FILE_PATH[] = "info/version.info";
 const char COMPAT_FILE_PATH[] = "info/compat.info";
+const char TYPE_FILE_PATH[] = "info/type.info";
 
 
 _AppInfo::_AppInfo(void)
@@ -188,6 +189,24 @@ _AppInfo::Construct(const char* appId, const char* exeName, int argc, char* argv
                        __isOspCompat = true;
                }
 
+               // type file may does not exist
+               fd = openat(__appRootDirFd, TYPE_FILE_PATH, O_RDONLY);
+               if (fd > 0)
+               {
+                       pFile = fdopen(fd, "r");
+                       if (pFile)
+                       {
+                               int i;
+                               int line = fscanf(pFile, "%d", &i);
+
+                               fclose(pFile);
+                               // fd is closed when the stream is closed by fclose();
+
+                               __appType = _APP_TYPE_UI_APP | i;
+                               SysLog(NID_APP, "Reading app type %d -> %d", i, __appType);
+                       }
+               }
+
                SysLog(NID_APP, "AppInfo initialization finished [%ls][%ls.%ls][%d].",
                                __appId.GetPointer(), __packageId.GetPointer(), __appExecutableName.GetPointer(), __apiVersion);
        }
@@ -370,18 +389,7 @@ _AppInfo::GetAppRootDirFd(void)
 }
 
 
-const AppId&
-_AppInfo::GetAppId(void)
-{
-       const String& packageId = GetAppInfo()->__packageId;
-
-       SysAssertf(!packageId.IsEmpty(), "PackageId is not initialized properly.");
-
-       return packageId;
-}
-
-
-const AppId&
+AppId
 _AppInfo::GetApplicationId(void)
 {
        const String& appId = GetAppInfo()->__appId;
@@ -392,7 +400,7 @@ _AppInfo::GetApplicationId(void)
 }
 
 
-const PackageId&
+PackageId
 _AppInfo::GetPackageId(void)
 {
        const String& packageId = GetAppInfo()->__packageId;
@@ -403,7 +411,7 @@ _AppInfo::GetPackageId(void)
 }
 
 
-const String&
+String
 _AppInfo::GetAppExecutableName(void)
 {
        return GetAppInfo()->__appExecutableName;
@@ -471,7 +479,7 @@ _AppInfo::SetAppState(AppState appState)
 }
 
 
-_AppType
+int
 _AppInfo::GetAppType(void)
 {
        return GetAppInfo()->__appType;
@@ -481,7 +489,7 @@ _AppInfo::GetAppType(void)
 void
 _AppInfo::SetAppType(_AppType appType)
 {
-       GetAppInfo()->__appType = appType;
+       GetAppInfo()->__appType |= appType;
 }
 
 
index 2fbfc60..16fc79c 100644 (file)
@@ -29,7 +29,7 @@ using namespace Tizen::Base::Collection;
 
 
 _AppLaunchCondition::_AppLaunchCondition(void)
-: __appId(L""), __executableName(L""), __pArguments(null), __option(AppManager::LAUNCH_OPTION_DEFAULT), __conditionString(L""), __pUserData(null), __regSectionName(L"")
+: __appId(L""), __pArguments(null), __option(AppManager::LAUNCH_OPTION_DEFAULT), __conditionString(L""), __pUserData(null), __regSectionName(L"")
 {
 }
 
@@ -43,10 +43,9 @@ _AppLaunchCondition::~_AppLaunchCondition(void)
 }
 
 result
-_AppLaunchCondition::Construct(const AppId& appId, const String& executableName, const String& conditionString, const IList* pArgs, AppManager::LaunchOption option, const String* pRegSectionName)
+_AppLaunchCondition::Construct(const AppId& appId, const String& conditionString, const IList* pArgs, AppManager::LaunchOption option, const String* pRegSectionName)
 {
        __appId = appId;
-       __executableName = executableName;
        __option = option;
        __conditionString = conditionString;
        __pUserData = null;
@@ -73,12 +72,6 @@ _AppLaunchCondition::GetUserData(void) const
        return const_cast<Object*>(__pUserData);
 }
 
-String
-_AppLaunchCondition::GetExecutableName(void) const
-{
-       return __executableName;
-}
-
 result
 _AppLaunchCondition::SetUserData(const Object* pUserData)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 787e509..0c2e7f5
@@ -42,10 +42,10 @@ _AppLaunchConditionHandlerBase::SetEventListener(_IAppLaunchConditionEventListen
 }
 
 result
-_AppLaunchConditionHandlerBase::Fire(const _AppLaunchCondition& operation)
+_AppLaunchConditionHandlerBase::Fire(const _AppLaunchCondition& operation, Tizen::Base::Collection::IMap* pExtraData)
 {
        SysTryReturnResult(NID_APP, __pEventListener != null, E_INVALID_STATE, "__pEventListener shoule not be null!");
-       __pEventListener->OnAppLaunchConditionMet(operation);
+       __pEventListener->OnAppLaunchConditionMet(operation, pExtraData);
        return E_SUCCESS;
 }
 
index b13b58d..76b13f4 100755 (executable)
@@ -27,6 +27,7 @@
 
 #include <aul/aul.h>
 #include <bundle.h>
+#include <app_manager.h>
 #include <Ecore.h>
 #include <Ecore_X.h>
 #include <X11/Xlib.h>
@@ -59,6 +60,7 @@
 #include "FApp_AppControlImpl.h"
 #include "FApp_ConditionManagerProxy.h"
 #include "FApp_IAppManagerEventListener.h"
+#include "FApp_IAppEventListener.h"
 #include "FApp_MapDataControlImpl.h"
 #include "FApp_SqlDataControlImpl.h"
 #include "FAppPkg_PackageManagerImpl.h"
@@ -96,9 +98,20 @@ static void* (* p_ecore_event_handler_del)(Ecore_Event_Handler* event_handler) =
 // libX11.so
 static int (* p_XSelectInput)(Display* display, Window w, long event_mask) = null;
 static Display* (* p_XOpenDisplay)(_Xconst char* display_name) = null;
+static int (* p_XCloseDisplay)(Display* display) = null;
 
 Ecore_Event_Handler* pWindowPropertyChanged = null;
 
+struct _DisplayDeleter
+{
+       void operator()(Display* pDisplay)
+       {
+               if (p_XOpenDisplay)
+               {
+                       p_XCloseDisplay(pDisplay);
+               }
+       }
+};
 
 int
 GetTotalSize(const Tizen::Base::Collection::ICollection& col)
@@ -219,6 +232,7 @@ _AppManagerImpl::_AppManagerImpl(void)
        , __eventListenerCount(0)
        , __pUiLibrary(null)
        , __pX11Library(null)
+       , __pAppEventList(null)
 {
        SysLog(NID_APP, "");
 }
@@ -646,18 +660,12 @@ _AppManagerImpl::LaunchApplication(const String& appId, AppManager::LaunchOption
 
 
 result
-_AppManagerImpl::TerminateApplication(const AppId& appId, const String* pExecutableName)
+_AppManagerImpl::TerminateApplication(const AppId& appId)
 {
-       result r = E_SUCCESS;
-
        _IAppManager* pMgr = _AppManagerProxy::GetService();
-       if (pMgr)
-       {
-               const String& name = (pExecutableName) ? *pExecutableName : _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(appId);
-               r = pMgr->TerminateApplication(appId, name);
-       }
+       SysTryReturnResult(NID_APP, pMgr, E_SYSTEM, "Failed to _AppManagerProxy::GetService().");
 
-       return r;
+       return pMgr->TerminateApplication(appId);
 }
 
 
@@ -666,7 +674,7 @@ TerminateIterFnCb(const aul_app_info* pAppInfo, void* pData)
 {
        const char* pStr = static_cast<const char*>(pData);
 
-       if (pStr && strncmp(pStr, pAppInfo->pkg_name, 10) == 0)
+       if (pStr && strncmp(pStr, pAppInfo->pkg_name, _MAX_PACKAGE_ID_LENGTH) == 0)
        {
                aul_terminate_pid(pAppInfo->pid);
                SysLog(NID_APP, "%s(%d) is terminated.", pAppInfo->pkg_name, pAppInfo->pid);
@@ -677,8 +685,6 @@ TerminateIterFnCb(const aul_app_info* pAppInfo, void* pData)
 result
 _AppManagerImpl::TerminateApplications(const PackageId& packageId)
 {
-       result r = E_SUCCESS;
-
        std::unique_ptr<char[]> pPackage(_StringConverter::CopyToCharArrayN(packageId));
        aul_app_get_running_app_info(TerminateIterFnCb, static_cast<void*>(pPackage.get()));
 
@@ -687,18 +693,12 @@ _AppManagerImpl::TerminateApplications(const PackageId& packageId)
 }
 
 bool
-_AppManagerImpl::IsRunning(const AppId& appId, const String* pExecutableName) const
+_AppManagerImpl::IsRunning(const AppId& appId) const
 {
-       bool b = false;
-
        _IAppManager* pMgr = _AppManagerProxy::GetService();
-       if (pMgr)
-       {
-               const String& name = (pExecutableName) ? *pExecutableName : _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(appId);
-               b = pMgr->IsRunning(appId, name);
-       }
+       SysTryReturnResult(NID_APP, pMgr, E_SYSTEM, "Failed to _AppManagerProxy::GetService().");
 
-       return b;
+       return pMgr->IsRunning(appId);
 }
 
 static int
@@ -730,17 +730,17 @@ _AppManagerImpl::GetRunningAppListN(void) const
 
 
 result
-_AppManagerImpl::RegisterAppLaunch(const AppId& appId, const String& executableName, const String& condition, const IList* pArguments,
+_AppManagerImpl::RegisterAppLaunch(const AppId& appId, const String& condition, const IList* pArguments,
                                                                   AppManager::LaunchOption option)
 {
        _ConditionManagerProxy* pProxy = GetConditionManagerProxy();
        SysTryReturnResult(NID_APP, null != pProxy, E_INVALID_STATE, "ConditionManager instance must not be null.");
 
-       return pProxy->RegisterAppLaunch(appId, executableName, condition, pArguments, option);
+       return pProxy->RegisterAppLaunch(appId, condition, pArguments, option);
 }
 
 result
-_AppManagerImpl::UnregisterAppLaunch(const AppId& appId, const String& executableName, const String* pCondition)
+_AppManagerImpl::UnregisterAppLaunch(const AppId& appId, const String* pCondition)
 {
        _ConditionManagerProxy* pProxy = GetConditionManagerProxy();
        SysTryReturnResult(NID_APP, null != pProxy, E_INVALID_STATE, "ConditionManager instance must not be null.");
@@ -752,18 +752,18 @@ _AppManagerImpl::UnregisterAppLaunch(const AppId& appId, const String& executabl
                                                  "No such a condition.");
        }
 
-       return pProxy->UnregisterAppLaunch(appId, executableName, pCondition);
+       return pProxy->UnregisterAppLaunch(appId, pCondition);
 }
 
 bool
-_AppManagerImpl::IsAppLaunchRegistered(const AppId& appId, const String &executableName, const String* pCondition)
+_AppManagerImpl::IsAppLaunchRegistered(const AppId& appId, const String* pCondition)
 {
        _ConditionManagerProxy* pProxy = GetConditionManagerProxy();
        SysTryReturn(NID_APP, null != pProxy, false, E_INVALID_STATE, "[%s] ConditionManager instance must not be null.",
                                 GetErrorMessage(E_INVALID_STATE));
 
        ClearLastResult();
-       return pProxy->IsAppLaunchRegistered(appId, executableName, pCondition);
+       return pProxy->IsAppLaunchRegistered(appId, pCondition);
 }
 
 result
@@ -778,8 +778,7 @@ _AppManagerImpl::OnServiceEventReceived(int clientId, const _AppManagerEventArg&
        SysLog(NID_APP, "appId:%ls, appType:0x%x", arg.GetAppId().GetPointer(), arg.GetAppType());
 
        _AppManagerEventArg* pArg = new (std::nothrow)_AppManagerEventArg(arg);
-       SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
-                                          GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
        __appManagerEvent.FireAsync(*pArg);
        return E_SUCCESS;
 }
@@ -832,26 +831,97 @@ _AppManagerImpl::RemoveEventListener(_IAppManagerEventListener& listener)
        return E_SUCCESS;
 }
 
-// input ("qik37po9ck.BasicApp") => output {"qik37po9ck", "BasicApp"}
-result
-_AppManagerImpl::ExtractValues(AppId inAppId, AppId& outAppId, String& outExecutableName)
+
+void
+_AppManagerImpl::AppEventCallback(app_context_h app_context, app_context_event_e event, void* pData)
 {
-       const int APP_ID_LEN = 10;
+       _AppManagerImpl* pImpl = static_cast<_AppManagerImpl*>(pData);
+       if (pImpl == null || pImpl->__pAppEventList == null)
+       {
+               SysLogException(NID_APP, E_SYSTEM, "Wrong _AppManagerImpl state.");
+               return;
+       }
+
+       std::unique_ptr< IEnumeratorT<_IAppEventListener*> > pEnum(pImpl->__pAppEventList->GetEnumeratorN());
 
-       if (inAppId.GetLength() > APP_ID_LEN)
+       if (pEnum.get())
        {
-               result r = inAppId.SubString(APP_ID_LEN + 1, inAppId.GetLength() - (APP_ID_LEN + 1), outExecutableName);
-               SysTryReturnResult(NID_APP, !IsFailed(r), E_INVALID_ARG, "invalid AppId(%ls)", inAppId.GetPointer());
+               char* pAppId = NULL;
+               app_context_get_app_id(app_context, &pAppId);
+               if (pAppId == NULL)
+               {
+                       SysLogException(NID_APP, E_SYSTEM, "Cannot acquire appId.");
+                       return;
+               }
 
-               r = inAppId.SubString(0, APP_ID_LEN, outAppId);
-               SysTryReturnResult(NID_APP, !IsFailed(r), E_INVALID_ARG, "invalid AppId(%ls)", inAppId.GetPointer());
+               const String appId = pAppId;
 
-               SysLog(NID_APP, "appId(%ls), executableName(%ls)", outAppId.GetPointer(), outExecutableName.GetPointer());
-               return E_SUCCESS;
+               free(pAppId);
+
+               // ugly comparson inside loop
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       _IAppEventListener* pListener = null;
+                       pEnum->GetCurrent(pListener);
+
+                       const int val = event;
+                       switch (val)
+                       {
+                       case APP_CONTEXT_EVENT_LAUNCHED:
+                               pListener->OnApplicationLaunched(appId, 0);
+                               break;
+                       case APP_CONTEXT_EVENT_TERMINATED:
+                               pListener->OnApplicationTerminated(appId, 0);
+                               break;
+                       default:
+                               SysLog(NID_APP, "Invalid state.");
+                               break;
+                       }
+               }
+       }
+
+       SysLog(NID_APP, "Finished invoking application event listener.");
+}
+
+result
+_AppManagerImpl::AddAppEventListener(_IAppEventListener& listener)
+{
+       if (__pAppEventList == null)
+       {
+               std::unique_ptr< LinkedListT<_IAppEventListener*> > pAppEventList(new LinkedListT<_IAppEventListener*>);
+               SysTryReturnResult(NID_APP, pAppEventList, E_SYSTEM, "Memory allocation failed.");
+
+               const int ret = app_manager_set_app_context_event_cb(_AppManagerImpl::AppEventCallback, this);
+               SysTryReturnResult(NID_APP, ret == APP_MANAGER_ERROR_NONE, E_SYSTEM, "Context registration failed.");
+
+               __pAppEventList = pAppEventList.release();
+               SysLog(NID_APP, "Registered app event listener.");
+       }
+
+       return __pAppEventList->Add(&listener);
+}
+
+result
+_AppManagerImpl::RemoveAppEventListener(_IAppEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_APP,__pAppEventList != null, E_OBJ_NOT_FOUND, "_IAppEventListener list is empty.");
+
+       r = __pAppEventList->Remove(&listener);
+
+       if (__pAppEventList->GetCount() == 0)
+       {
+               app_manager_unset_app_context_event_cb();
+
+               delete __pAppEventList;
+               __pAppEventList = null;
        }
-       return E_SYSTEM;
+
+       return E_SUCCESS;
 }
 
+
 _LibraryImpl&
 _AppManagerImpl::GetUiLibraryImpl(void)
 {
@@ -960,14 +1030,16 @@ _AppManagerImpl::GetActiveWindow(void)
                                                   "A system error has been occurred. Failed to get ecore_x_window_prop_window_get.");
        }
 
-       Ecore_X_Window* pRoots = null;
        int num = 0;
-
-       pRoots = p_ecore_x_window_root_list(&num);
-       Ecore_X_Atom activeAtom = p_ecore_x_atom_get("_NET_ACTIVE_WINDOW");
+       Ecore_X_Window* pRoots = p_ecore_x_window_root_list(&num);
 
        Ecore_X_Window activeWin = 0;
-       p_ecore_x_window_prop_window_get(pRoots[0], activeAtom, &activeWin, 1);
+       if (pRoots)
+       {
+               Ecore_X_Atom activeAtom = p_ecore_x_atom_get("_NET_ACTIVE_WINDOW");
+               p_ecore_x_window_prop_window_get(pRoots[0], activeAtom, &activeWin, 1);
+               free(pRoots);
+       }
 
        return activeWin;
 }
@@ -996,35 +1068,42 @@ _AppManagerImpl::AddActiveAppEventListener(IActiveAppEventListener& listener)
        {
                _LibraryImpl& lib = _AppManagerImpl::GetEcoreXLibraryImpl();
                p_ecore_x_window_root_list = reinterpret_cast<Ecore_X_Window*(*)(int* num_ret)>(lib.GetProcAddress(L"ecore_x_window_root_list"));
-               SysTryReturnResult(NID_APP, p_ecore_x_window_root_list != null, EINA_FALSE,
+               SysTryReturnResult(NID_APP, p_ecore_x_window_root_list != null, E_SYSTEM,
                                                   "A system error has been occurred. Failed to get p_ecore_x_window_root_list.");
        }
        if (p_ECORE_X_EVENT_WINDOW_PROPERTY == null)
        {
                _LibraryImpl& lib = _AppManagerImpl::GetEcoreXLibraryImpl();
                p_ECORE_X_EVENT_WINDOW_PROPERTY = reinterpret_cast<int*>(lib.GetProcAddress(L"ECORE_X_EVENT_WINDOW_PROPERTY"));
-               SysTryReturnResult(NID_APP, p_ECORE_X_EVENT_WINDOW_PROPERTY != null, EINA_FALSE,
+               SysTryReturnResult(NID_APP, p_ECORE_X_EVENT_WINDOW_PROPERTY != null, E_SYSTEM,
                                                   "A system error has been occurred. Failed to get p_ECORE_X_EVENT_WINDOW_PROPERTY.");
        }
        if (p_XOpenDisplay == null)
        {
                _LibraryImpl& lib = GetX11LibraryImpl();
                p_XOpenDisplay = reinterpret_cast<Display*(*)(_Xconst char* display_name)>(lib.GetProcAddress(L"XOpenDisplay"));
-               SysTryReturnResult(NID_APP, p_XOpenDisplay != null, EINA_FALSE,
+               SysTryReturnResult(NID_APP, p_XOpenDisplay != null, E_SYSTEM,
                                                   "A system error has been occurred. Failed to get p_XOpenDisplay.");
        }
+       if (p_XCloseDisplay == null)
+       {
+               _LibraryImpl& lib = GetX11LibraryImpl();
+               p_XCloseDisplay = reinterpret_cast<int(*)(Display* display)>(lib.GetProcAddress(L"XCloseDisplay"));
+               SysTryReturnResult(NID_APP, p_XCloseDisplay != null, E_SYSTEM,
+                                                  "A system error has been occurred. Failed to get p_XCloseDisplay.");
+       }
        if (p_XSelectInput == null)
        {
                _LibraryImpl& lib = GetX11LibraryImpl();
                p_XSelectInput = reinterpret_cast<int(*)(Display* display, Window w, long event_mask)>(lib.GetProcAddress(L"XSelectInput"));
-               SysTryReturnResult(NID_APP, p_XSelectInput != null, EINA_FALSE,
+               SysTryReturnResult(NID_APP, p_XSelectInput != null, E_SYSTEM,
                                                   "A system error has been occurred. Failed to get p_XSelectInput.");
        }
        if (p_ecore_event_handler_add == null)
        {
                _LibraryImpl& lib = GetEcoreLibraryImpl();
                p_ecore_event_handler_add = reinterpret_cast<Ecore_Event_Handler*(*)(int type, Ecore_Event_Handler_Cb func, const void* data)>(lib.GetProcAddress(L"ecore_event_handler_add"));
-               SysTryReturnResult(NID_APP, p_ecore_event_handler_add != null, EINA_FALSE,
+               SysTryReturnResult(NID_APP, p_ecore_event_handler_add != null, E_SYSTEM,
                                                   "A system error has been occurred. Failed to get p_ecore_event_handler_add.");
        }
 
@@ -1033,19 +1112,22 @@ _AppManagerImpl::AddActiveAppEventListener(IActiveAppEventListener& listener)
        result r = __activeAppEventListenerList.Add(&listener);
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       Ecore_X_Window* pRoots = null;
-       int num = 0;
-       pRoots = p_ecore_x_window_root_list(&num);
-
-       for (int i = 0; i < num; i++)
-       {
-               Display* pDisplay = p_XOpenDisplay(NULL);
-               p_XSelectInput(pDisplay, pRoots[i], PropertyChangeMask);
-       }
-
        if (!pWindowPropertyChanged)
        {
+               std::unique_ptr<Display, _DisplayDeleter> pDisplay(p_XOpenDisplay(NULL));
+               SysTryReturnResult(NID_APP, pDisplay != null, E_SYSTEM, "A system error has been occurred. Failed to XOpenDisplay.");
+
+               int num = 0;
+               Ecore_X_Window* pRoots = p_ecore_x_window_root_list(&num);
+               SysTryReturnResult(NID_APP, pRoots != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               for (int i = 0; i < num; i++)
+               {
+                       p_XSelectInput(pDisplay.get(), pRoots[i], PropertyChangeMask);
+               }
+
                pWindowPropertyChanged = p_ecore_event_handler_add(*p_ECORE_X_EVENT_WINDOW_PROPERTY, OnPropertyChanged, (void*) this);
+               free(pRoots);
                SysTryReturnResult(NID_APP, pWindowPropertyChanged, E_SYSTEM, "A system error has been occurred.");
        }
 
index 23d1249..2e1983f 100644 (file)
@@ -112,12 +112,12 @@ _AppManagerProxy::SetService(_IAppManager* pAppManager)
 
 
 result
-_AppManagerProxy::LaunchApplication(const AppId& appId, const String& executableName, int req)
+_AppManagerProxy::LaunchApplication(const AppId& appId, int req)
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
        SysLog(NID_APP, "");
 
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_LaunchApplication(appId, executableName, req));
+       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_LaunchApplication(appId, req));
        result r = __pIpcClient->SendRequest(*pMsg.get());
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed.");
 
@@ -125,13 +125,13 @@ _AppManagerProxy::LaunchApplication(const AppId& appId, const String& executable
 }
 
 result
-_AppManagerProxy::TerminateApplication(const AppId& appId, const String& executableName)
+_AppManagerProxy::TerminateApplication(const AppId& appId)
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
        SysLog(NID_APP, "");
 
        result response = E_SUCCESS;
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_TerminateApplication(appId, executableName, &response));
+       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_TerminateApplication(appId, &response));
        result r = __pIpcClient->SendRequest(*pMsg.get());
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed.");
 
@@ -139,11 +139,11 @@ _AppManagerProxy::TerminateApplication(const AppId& appId, const String& executa
 }
 
 bool
-_AppManagerProxy::IsRunning(const AppId& appId, const String& executableName)
+_AppManagerProxy::IsRunning(const AppId& appId)
 {
        bool isRunning = false;
 
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_IsRunning(appId, executableName, &isRunning));
+       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_IsRunning(appId, &isRunning));
        result r = __pIpcClient->SendRequest(*pMsg.get());
        SysTryReturn(NID_APP, !IsFailed(r), false, r, "SendRequest is failed.");
 
@@ -165,12 +165,12 @@ _AppManagerProxy::GetRunningAppList(Collection::ArrayList* pArray)
 }
 
 result
-_AppManagerProxy::RegisterApplication(const AppId& appId, const String& executableName, _AppType appType, int pId)
+_AppManagerProxy::RegisterApplication(const String& packageId, const String& executableName, _AppType appType, int pId)
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
        SysLog(NID_APP, "");
 
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_RegisterApplication(appId, executableName, static_cast<int>(appType), pId));
+       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_RegisterApplication(packageId, executableName, static_cast<int>(appType), pId));
        result r = __pIpcClient->SendRequest(*pMsg.get());
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed.");
 
index b2acafb..52a2efc 100644 (file)
@@ -46,8 +46,6 @@ _AppRegistryImpl::~_AppRegistryImpl(void)
 {
        if (__pRegistry != null)
        {
-               __pRegistry->Flush();
-
                delete __pRegistry;
                __pRegistry = null;
        }
index 33ad248..856a00b 100644 (file)
  * @brief      This is the implementation for the _AppResourceImpl class.
  */
 
-#include <FBaseObject.h>
-#include <FBaseString.h>
+#include <unique_ptr.h>
+
 #include <FBaseResult.h>
 #include <FBaseSysLog.h>
-#include <FAppAppResource.h>
-
+#include <FBaseColHashMap.h>
 #include <FBaseRt_LibraryImpl.h>
 
-#include "FApp_AppResourceImpl.h"
-#include "FApp_AppResourceString.h"
+#include <FAppAppResource.h>
 #include "FApp_AppManagerImpl.h"
+#include "FApp_AppResourceString.h"
 #include "FApp_IAppResourceBitmap.h"
 
+#include "FApp_AppResourceImpl.h"
+
+
 using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Runtime;
+using namespace Tizen::Graphics;
 using namespace Tizen::Io;
-using namespace Tizen::Locales;
-using namespace Tizen::System;
 
-using namespace Tizen::Graphics;
 
 namespace Tizen { namespace App
 {
 
 #define BITMAP_PIXEL_FORMAT_INVALID (BITMAP_PIXEL_FORMAT_MIN)
 
-static _IAppResourceBitmap*(* p_Create_AppResourceBitmapInstanceN)(void) = null;
-static _IAppResourceBitmap*(* p_Create_AppResourceBitmapInstanceByAppIdN)(const String& appId) = null;
+
+static _IAppResourceBitmap*(* p_Create_IAppResourceBitmapInstanceN)(int type, const String& value) = null;
+
+Tizen::Base::Collection::HashMap* _AppResourceImpl::__pContainer = null;
 
 _AppResourceImpl::_AppResourceImpl(void)
-       : __pAppResource(null)
-       , __p_AppResourceString(null)
+       : __p_AppResourceString(null)
        , __p_IAppResourceBitmap(null)
-       , __isByAppId(false)
+       , __type(APP_RESOURCE_DEFAULT)
+       , __value()
 {
 }
 
-
 result
-_AppResourceImpl::Construct(const Locale& locale)
+_AppResourceImpl::ReleaseInstance(const Tizen::Base::String& key)
 {
-       return Construct();
-}
+       if (__pContainer != null)
+       {
+               AppResource* pAppResource = static_cast<AppResource*> (__pContainer->GetValue(key));
+               delete pAppResource;
 
+               return __pContainer->Remove(key);
+       }
 
-result
-_AppResourceImpl::Construct(void)
-{
        return E_SUCCESS;
 }
 
-result
-_AppResourceImpl::Construct(const AppId& appId)
+// Exception: E_OUT_OF_MEMORY, E_SYSTEM, E_INVALID_ARG, E_OBJ_NOT_FOUND, E_APP_NOT_INSTALLED [Get_AppResourceStringN], Get_IAppResourceBitmapN
+AppResource*
+_AppResourceImpl::GetInstanceN(AppResourceBy type, const Tizen::Base::String& value)
 {
        result r = E_SUCCESS;
-       if (__p_AppResourceString == null)
+       if (__pContainer == null)
        {
-               __p_AppResourceString = new (std::nothrow) _AppResourceString();
-               SysTryReturnResult(NID_APP, __p_AppResourceString != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]Failed to create String resource");
+               std::unique_ptr< HashMap > pContainer(new (std::nothrow) HashMap());
+               SysTryReturn(NID_APP, pContainer != null,
+                               null, E_OUT_OF_MEMORY, "[%s] Creating the container is failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-               r = __p_AppResourceString->Construct(appId);
-               SysTryCatch(NID_APP, !IsFailed(r),  , r, "[%s] Failed to construct String resource", GetErrorMessage(r));
+               r = pContainer->Construct();
+               SysTryReturn(NID_APP, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] Creating the container is failed [%s].", GetErrorMessage(r));
+
+               __pContainer = pContainer.release();
        }
 
-       if (p_Create_AppResourceBitmapInstanceByAppIdN == null)
+       bool hasAppResource = false;
+       r = __pContainer->ContainsKey(value, hasAppResource);
+       SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Checking to contain is failed.", GetErrorMessage(r));
+
+       if(hasAppResource == true)
        {
-               _LibraryImpl& lib = _AppManagerImpl::GetInstance()->GetUiLibraryImpl();
-               p_Create_AppResourceBitmapInstanceByAppIdN = reinterpret_cast<_IAppResourceBitmap*(*)(const String& appId)>(lib.GetProcAddress(L"_Create_IAppResourceBitmapInstanceByAppIdN"));
-               SysTryCatch(NID_APP, p_Create_AppResourceBitmapInstanceByAppIdN != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get Bitmap resource [%s].", GetErrorMessage(GetLastResult()));
+               return static_cast<AppResource*> (__pContainer->GetValue(value));
        }
-
-       if (__p_IAppResourceBitmap == null)
+       else
        {
-               __p_IAppResourceBitmap = p_Create_AppResourceBitmapInstanceByAppIdN(appId);
-               SysTryCatch(NID_APP, __p_IAppResourceBitmap != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get Bitmap resource.");
+               std::unique_ptr< _AppResourceImpl > pAppResourceImpl(new (std::nothrow) _AppResourceImpl());
+               SysTryReturn(NID_APP, pAppResourceImpl != null,
+                               null, E_OUT_OF_MEMORY, "[%s] Unable to allocate memory for AppResourceImpl.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               std::unique_ptr< _AppResourceString > pAppResourceString(_AppResourceString::Get_AppResourceStringN(type, value));
+               r = GetLastResult();
+               SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Unable to get _AppResourceString.", GetErrorMessage(r));
+
+               std::unique_ptr< _IAppResourceBitmap > pAppResourceBitmap(Get_IAppResourceBitmapN(type, value));
+               r = GetLastResult();
+               SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Unable to get _IAppResourceBitmap.", GetErrorMessage(r));
+
+               pAppResourceImpl->__p_AppResourceString = pAppResourceString.release();
+               pAppResourceImpl->__p_IAppResourceBitmap = pAppResourceBitmap.release();
+               pAppResourceImpl->__type = type;
+               pAppResourceImpl->__value = value;
+
+               std::unique_ptr< String > pStr(new (std::nothrow) String(value));
+               SysTryReturn(NID_APP, pStr != null, null,
+                               E_OUT_OF_MEMORY, "[%s] Creating a key is failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               AppResource* pAppResource = new (std::nothrow) AppResource;
+               SysTryReturn(NID_APP, pAppResource != null, null,
+                               E_OUT_OF_MEMORY, "[%s] Unable to allocate memory for AppResource", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pAppResource->__pAppResourceImpl = pAppResourceImpl.release();
+               r = __pContainer->Add(*pStr, *pAppResource);
+               if (IsFailed(r))
+               {
+                       delete pAppResource;
+                       SysTryReturn(NID_APP, false, null,
+                               E_SYSTEM, "[E_SYSTEM] Adding an element to the container is failed [%s].", GetErrorMessage(r));
+               }
+
+               pStr.release();
+               return pAppResource;
        }
+       return null;
+}
 
-       __isByAppId = true;
-       return E_SUCCESS;
+_IAppResourceBitmap*
+_AppResourceImpl::Get_IAppResourceBitmapN(AppResourceBy type, const Tizen::Base::String& value)
+{
+       if (p_Create_IAppResourceBitmapInstanceN == null)
+       {
+               _LibraryImpl& lib = _AppManagerImpl::GetInstance()->GetUiLibraryImpl();
+               p_Create_IAppResourceBitmapInstanceN =
+                               reinterpret_cast<_IAppResourceBitmap*(*)(int, const String&)>(lib.GetProcAddress(L"_Create_IAppResourceBitmapInstanceN"));
+               SysTryReturn(NID_APP, p_Create_IAppResourceBitmapInstanceN != null,
+                               null, E_SYSTEM, "[E_SYSTEM] Failed to get Bitmap resource [%s].", GetErrorMessage(E_SYSTEM));
+       }
 
-CATCH:
-       delete __p_AppResourceString;
-       __p_AppResourceString = null;
+       std::unique_ptr< _IAppResourceBitmap > pAppResourceBitmap(p_Create_IAppResourceBitmapInstanceN(type, value));
+       SysTryReturn(NID_APP, pAppResourceBitmap != null, null,
+                       E_SYSTEM, "[%s] Unable to get IAppResourceBitmap.", GetErrorMessage(E_SYSTEM));
 
-       return r;
+       return pAppResourceBitmap.release();
 }
 
 _AppResourceImpl::~_AppResourceImpl(void)
@@ -113,54 +166,31 @@ _AppResourceImpl::~_AppResourceImpl(void)
        delete __p_IAppResourceBitmap;
 }
 
-
 result
 _AppResourceImpl::GetString(const String& resourceId, String& loadedString)
 {
-       result r = E_SUCCESS;
-
-       if ((__isByAppId == false) && (__p_AppResourceString == null))
+       if (__p_AppResourceString == null)
        {
-               __p_AppResourceString = new (std::nothrow) _AppResourceString();
-               SysTryReturnResult(NID_APP, __p_AppResourceString != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]Not enough memory.");
-
-               r = __p_AppResourceString->Construct();
-               SysTryCatch(NID_APP, !IsFailed(r), , r = E_SYSTEM, "[E_SYSTEM] Failed to get String resource.");
+               __p_AppResourceString = _AppResourceString::Get_AppResourceStringN(__type, __value);
+               SysTryReturnResult(NID_APP, __p_AppResourceString == null, E_FAILURE, "Failed to get String resource.");
        }
 
-       r = __p_AppResourceString->GetString(resourceId, loadedString);
-
-CATCH:
-       return r;
+       return __p_AppResourceString->GetString(resourceId, loadedString);
 }
 
-
 Bitmap*
 _AppResourceImpl::GetBitmapN(const String& imgFilePath, BitmapPixelFormat pixelFormat)
 {
-       if (__isByAppId == false)
+       if (__p_IAppResourceBitmap == null)
        {
-               if (p_Create_AppResourceBitmapInstanceN == null)
-               {
-                       _LibraryImpl& lib = _AppManagerImpl::GetInstance()->GetUiLibraryImpl();
-                       p_Create_AppResourceBitmapInstanceN = reinterpret_cast<_IAppResourceBitmap*(*)(void)>(lib.GetProcAddress(L"_Create_IAppResourceBitmapInstanceN"));
-                       SysTryCatch(NID_APP, p_Create_AppResourceBitmapInstanceN != null, , E_SYSTEM, "[E_SYSTEM] Failed to get Bitmap resource [%s].", GetErrorMessage(GetLastResult()));
-               }
-
-               if (__p_IAppResourceBitmap == null)
-               {
-                       __p_IAppResourceBitmap = p_Create_AppResourceBitmapInstanceN();
-                       SysTryCatch(NID_APP, __p_IAppResourceBitmap != null, , E_SYSTEM, "[E_SYSTEM] Failed to get Bitmap resource.");
-               }
+               __p_IAppResourceBitmap = Get_IAppResourceBitmapN(__type, __value);
+               SysTryReturn(NID_APP, __p_IAppResourceBitmap == null,
+                               null, E_SYSTEM, "[%s] Failed to get Bitmap resource.", GetErrorMessage(E_SYSTEM));
        }
 
        return __p_IAppResourceBitmap->GetBitmapN(imgFilePath, pixelFormat);
-
-CATCH:
-       return null;
 }
 
-
 Bitmap*
 _AppResourceImpl::GetBitmapN(const String& imgFilePath)
 {
@@ -168,33 +198,58 @@ _AppResourceImpl::GetBitmapN(const String& imgFilePath)
 }
 
 
-AppResource*
-_AppResourceImpl::GetAppResource(void)
-{
-       return __pAppResource;
-}
+static bool g_init = false;
 
 _AppResourceImpl*
 _AppResourceImpl::GetInstance(void)
 {
-//     return __pAppResource->__pAppResourceImpl;
-       return AppResource::GetInstance()->__pAppResourceImpl;
+       AppResource* pAppResource = AppResource::GetInstance();
+       if (pAppResource)
+       {
+               g_init = true;
+               return pAppResource->__pAppResourceImpl;
+       }
+       return null;
 }
 
 void
 _AppResourceImpl::Reinitialize(void)
 {
-       if (__p_AppResourceString != null)
+       if (!g_init)
+       {
+               SysLog(NID_APP, "AppResource not initialized yet.");
+               return;
+       }
+
+       _AppResourceImpl* pThis = _AppResourceImpl::GetInstance();
+       if (pThis == null)
        {
+               SysLog(NID_APP, "No _AppResourceImpl instance.");
+               return;
+       }
 
-               __p_AppResourceString->Initialize();
+       if (pThis->__pContainer != null)
+       {
+               std::unique_ptr< IMapEnumerator > pMapEnum(pThis->__pContainer->GetMapEnumeratorN());
+               if (pMapEnum)
+               {
+                       while(pMapEnum->MoveNext() == E_SUCCESS)
+                       {
+                               AppResource* pAppResource = static_cast<AppResource*> (pMapEnum->GetValue());
+                               if (pAppResource && pAppResource->__pAppResourceImpl)
+                               {
+                                       _AppResourceImpl* pAppResourceImpl = pAppResource->__pAppResourceImpl;
+                                       delete pAppResourceImpl->__p_AppResourceString;
+                                       pAppResourceImpl->__p_AppResourceString =
+                                                       _AppResourceString::Get_AppResourceStringN(pAppResourceImpl->__type, pAppResourceImpl->__value);
+
+                                       // This function will be called on Language change event
+                                       // Need not to re-initialize Bitmap resource as language change does not affect bitmap resource path
+                               }
+                       }
+               }
        }
-       AppResource::Reinitialize();
 }
 
-void
-_AppResourceImpl::Reinitialize(const AppId& appId)
-{
-               __p_AppResourceString->Initialize(appId);
-}
+
 } } // Tizen::App
index eb475ed..f633981 100644 (file)
 
 #include <FBaseObject.h>
 #include <FBaseString.h>
-#include <FOspConfig.h>
+
 #include <FGrpBitmapCommon.h>
 
-namespace Tizen { namespace Locales { class Locale; } }
+namespace Tizen { namespace Base { namespace Collection { class HashMap; } } }
 namespace Tizen { namespace Graphics { class Bitmap; } }
 
 namespace Tizen { namespace App
@@ -38,6 +38,13 @@ class AppResource;
 class _AppResourceString;
 class _IAppResourceBitmap;
 
+enum AppResourceBy
+{
+       APP_RESOURCE_DEFAULT,
+       APP_RESOURCE_BY_APP_ID,
+       APP_RESOURCE_BY_LIBRARY_NAME
+};
+
 class _AppResourceImpl
        : public Tizen::Base::Object
 {
@@ -117,6 +124,8 @@ public:
        */
        Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath);
 
+       static void Reinitialize(void);
+
        /**
        * Gets the AppResoruce instance pointer.
        *
@@ -126,11 +135,11 @@ public:
        */
        static _AppResourceImpl* GetInstance(void);
 
-       AppResource* GetAppResource(void);
-
-       void Reinitialize(void);
+       static AppResource* GetInstanceN(AppResourceBy type, const Tizen::Base::String& value = L"");
+       static _IAppResourceBitmap* Get_IAppResourceBitmapN(AppResourceBy type, const Tizen::Base::String& value = L"");
 
-       void Reinitialize(const AppId& appId);
+       static void ReinitializeAll(void);
+       static result ReleaseInstance(const Tizen::Base::String& key);
 
 private:
        /**
@@ -148,34 +157,18 @@ private:
        _AppResourceImpl(const _AppResourceImpl& source);
 
        /**
-       * Initializes this instance.
-       *
-       */
-       result Construct(void);
-
-       /**
-       * Initializes this instance.
-       *
-       */
-       result Construct(const AppId& appId);
-
-       /**
-       * Initializes this instance with the specified locale.
-       *
-       */
-       result Construct(const Tizen::Locales::Locale& locale);
-
-       /**
         * This is the assignment operator for this class.
         */
        _AppResourceImpl& operator =(const _AppResourceImpl& source);
 
 private:
-       friend class AppResource;
-       AppResource* __pAppResource;
        _AppResourceString* __p_AppResourceString;
        _IAppResourceBitmap* __p_IAppResourceBitmap;
-       bool __isByAppId;
+
+       AppResourceBy __type;
+       Tizen::Base::String __value;
+
+       static Tizen::Base::Collection::HashMap* __pContainer;
 
 }; // _AppResourceImpl
 
index 9bfc349..26cb559 100644 (file)
 #include <libxml/parser.h>
 #include <libxml/xpath.h>
 #include <libxml/tree.h>
+#include <unicode/locid.h>
+
 #include <unique_ptr.h>
 #include <runtime_info.h>
-#include <unicode/locid.h>
 
-#include <FBaseObject.h>
-#include <FBaseString.h>
 #include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FBaseColHashMap.h>
+
 #include <FIoFile.h>
 #include <FIoDirectory.h>
-#include <FSysSystemInfo.h>
-#include <FSys_SettingInfoImpl.h>
 
-#include <FBaseSysLog.h>
-#include <FAppPkgPackageManager.h>
-#include <FAppPkgPackageInfo.h>
-#include <FBase_StringConverter.h>
 #include <FApp_AppInfo.h>
-
-#include "FApp_AppResourceString.h"
+#include <FAppPkgPackageInfo.h>
 #include "FAppPkg_PackageManagerImpl.h"
 #include "FAppPkg_PackageInfoImpl.h"
 
+#include "FApp_AppResourceImpl.h"
+#include "FApp_AppResourceString.h"
+
 using namespace Tizen::App::Package;
 using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
-using namespace Tizen::Locales;
-using namespace Tizen::System;
 
 static const char* AR_ROOT_NODE_NAME = "string_table";
 static const char* AR_CHILD_NODE_1 = "text";
 static const char* AR_ATTRIBUTE = "id";
 
-static xmlNodePtr gCur = 0;
+struct FreeXmlDoc
+{
+       void operator ()(_xmlDoc* p)
+       {
+               if (p != null)
+               {
+                       xmlFreeDoc(p);
+               }
+       }
+};
 
 namespace Tizen { namespace App
 {
@@ -63,61 +70,68 @@ namespace Tizen { namespace App
 _AppResourceString::_AppResourceString(void)
        : __pDoc(null)
        , __pLockOfParser(null)
+       , __pXmlNodeMap(null)
 {
 }
 
-
-result
-_AppResourceString::Construct(const Tizen::Locales::Locale& locale)
-{
-       return Construct();
-}
-
-
-result
-_AppResourceString::Construct(void)
+_AppResourceString::~_AppResourceString(void)
 {
-       return Initialize();
+       if (__pDoc != null)
+       {
+               xmlFreeDoc(__pDoc);
+       }
+       if (__pXmlNodeMap)
+       {
+               __pXmlNodeMap->RemoveAll(true);
+               delete __pXmlNodeMap;
+       }
+       delete __pLockOfParser;
 }
 
-result
-_AppResourceString::Construct(const AppId& appId)
+// Exception: E_OUT_OF_MEMORY, E_APP_NOT_INSTALLED, E_SYSTEM
+_AppResourceString*
+_AppResourceString::Get_AppResourceStringN(int type, const Tizen::Base::String& value)
 {
-       return Initialize(appId);
-}
+       std::unique_ptr< _AppResourceString > pAppResourceString(new (std::nothrow) _AppResourceString);
+       SysTryReturn(NID_APP, pAppResourceString != null, null,
+                       E_OUT_OF_MEMORY, "[%s] Unable to allocate memory for _AppResourceString", GetErrorMessage(E_OUT_OF_MEMORY));
 
-result
-_AppResourceString::Initialize(void)
-{
-       result r = E_SUCCESS;
-       if (__pLockOfParser == null)
+       String resourceFolder;
+       switch(type)
        {
-               __pLockOfParser = new (std::nothrow) Tizen::Base::Runtime::Mutex();
-               SysTryReturnResult(NID_APP, __pLockOfParser != null, E_OUT_OF_MEMORY, "Failed to initialize resource parser.");
-
-               r = __pLockOfParser->Create();
-               SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to Create Mutex.", GetErrorMessage(r));
+       case APP_RESOURCE_DEFAULT:
+       case APP_RESOURCE_BY_LIBRARY_NAME:
+       default:
+               resourceFolder = _AppInfo::GetAppRootPath();
+               resourceFolder.Append(L"res/");
+               resourceFolder.Append(value);
+               resourceFolder.Append(L"/");
+               break;
+
+       case APP_RESOURCE_BY_APP_ID:
+               std::unique_ptr< PackageInfo> pPkgInfo(_PackageManagerImpl::GetInstance()->GetPackageInfoN(value));
+               SysTryReturn(NID_APP, pPkgInfo != null, null,
+                               E_APP_NOT_INSTALLED, "[%s] Failed to get the package info", GetErrorMessage(E_APP_NOT_INSTALLED));
+
+               _PackageInfoImpl* pPkgInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo.get());
+               SysTryReturn(NID_APP, pPkgInfoImpl != null, null,
+                               E_APP_NOT_INSTALLED, "[%s] Failed to get the package info impl", GetErrorMessage(E_APP_NOT_INSTALLED));
+
+               resourceFolder = pPkgInfoImpl->GetAppRootPath();
+               resourceFolder.Append(L"/res/");
+               break;
        }
 
+       result r = pAppResourceString->Initialize(resourceFolder);
+       SysTryReturn(NID_APP, !IsFailed(r), null,
+                               r, "[%s] Failed to initialize AppResourceString", GetErrorMessage(r));
 
-       r = __pLockOfParser->Acquire();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to Acquire Mutex.", GetErrorMessage(r));
-
-       r = InitializeStringInfo();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to InitializeStringInfo.", GetErrorMessage(r));
-
-       __pLockOfParser->Release();
-       return E_SUCCESS;
-
-CATCH:
-       delete __pLockOfParser;
-       __pLockOfParser = null;
-
-       return r;
+       ClearLastResult();
+       return pAppResourceString.release();
 }
 
 result
-_AppResourceString::Initialize(const AppId& appId)
+_AppResourceString::Initialize(String& resourceFolder)
 {
        result r = E_SUCCESS;
        if (__pLockOfParser == null)
@@ -130,12 +144,12 @@ _AppResourceString::Initialize(const AppId& appId)
        }
 
        r = __pLockOfParser->Acquire();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to Acquire Mutex.", GetErrorMessage(r));
-
-       r = InitializeStringInfo(appId);
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to InitializeStringInfo.", GetErrorMessage(r));
+       SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Acquire Mutex [%s].", GetErrorMessage(r));
 
+       r = InitializeStringInfo(resourceFolder);
        __pLockOfParser->Release();
+
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to InitializeStringInfo.", GetErrorMessage(r));
        return E_SUCCESS;
 
 CATCH:
@@ -145,53 +159,36 @@ CATCH:
        return r;
 }
 
-
-
 result
-_AppResourceString::InitializeStringInfo(void)
+_AppResourceString::InitializeStringInfo(String& resourceFolder)
 {
-       if (__pDoc != null)
-       {
-               SysLog(NID_APP, "__pDoc is freed to reinitialize.");
-               xmlFreeDoc(__pDoc);
-               __pDoc = null;
-       }
-
        char* pValue = null;
        int ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &pValue);
-       SysTryReturnResult(NID_APP, ret == 0, E_FAILURE, "[E_SYSTEM] runtime_info_get_value_string returns %d.", ret);
+       SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "runtime_info_get_value_string returns %d.", ret);
 
        U_ICU_NAMESPACE::Locale icuLcl(pValue);
-
        String language(icuLcl.getISO3Language());
        String country(icuLcl.getCountry());
 
-//     SysLog(NID_APP, "res/%ls-%ls.xml", language.GetPointer(), country.GetPointer());
-
        String resFilename;
-       result r = resFilename.Format(256 * 2 + 10, L"res/%ls-%ls.xml", language.GetPointer(), country.GetPointer());
-       SysTryReturn(NID_APP, !IsFailed(r), E_FAILURE, r, "[%s] Failed to format path string", GetErrorMessage(r));
-
-       const String& homePath = _AppInfo::GetAppRootPath();
-       __pDoc = ParseXmlFile( homePath + resFilename);
+       result r = resFilename.Format(256 * 2 + 10, L"%ls-%ls.xml", language.GetPointer(), country.GetPointer());
+       SysTryReturn(NID_APP, !IsFailed(r), E_SYSTEM, r, "[E_SYSTEM] Failed to format path string [%s]", GetErrorMessage(r));
 
-       // Fall-back
-       if (__pDoc == null)
+       if (!resourceFolder.EndsWith(L'/'))
        {
-               String dirName(L"res/");
-               Directory dir;
-               DirEnumerator* pDirEnum = null;
-               String name;
-
-               r = dirName.Insert(homePath, 0);
-               SysTryReturn(NID_APP, !IsFailed(r), E_FAILURE, r, "[%s] Failed to insert string.", GetErrorMessage(r));
+               resourceFolder.Append(L'/');
+       }
 
+       std::unique_ptr< _xmlDoc, FreeXmlDoc > pDoc(ParseXmlFile(resourceFolder + resFilename));
+       if (pDoc == null)
+       {
                // open directory
-               r = dir.Construct(dirName);
+               Directory dir;
+               r = dir.Construct(resourceFolder);
                if (r == E_SUCCESS)
                {
                        // read all directory entries
-                       pDirEnum = dir.ReadN();
+                       DirEnumerator* pDirEnum = dir.ReadN();
                        if (pDirEnum != null)
                        {
                                const String starts = language + L"-";
@@ -201,12 +198,10 @@ _AppResourceString::InitializeStringInfo(void)
                                while (pDirEnum->MoveNext() == E_SUCCESS)
                                {
                                        // get several properties of each directory entry.
-                                       name = pDirEnum->GetCurrentDirEntry().GetName();
-
-                                       if (name.StartsWith(starts, 0) && name.EndsWith(ends))
+                                       resFilename = pDirEnum->GetCurrentDirEntry().GetName();
+                                       if (resFilename.StartsWith(starts, 0) && resFilename.EndsWith(ends))
                                        {
-                                               resFilename = L"res/" + name;
-                                               __pDoc = ParseXmlFile(homePath + resFilename);
+                                               pDoc.reset(ParseXmlFile(resourceFolder + resFilename));
                                                break;
                                        }
                                }
@@ -216,194 +211,99 @@ _AppResourceString::InitializeStringInfo(void)
                }
        }
 
-       if (__pDoc == null)
+       if (pDoc == null)
        {
-               __pDoc = ParseXmlFile(homePath + L"res/eng-GB.xml");
+               pDoc.reset(ParseXmlFile(resourceFolder + L"eng-GB.xml"));
        }
 
-       if (__pDoc == null)
+       if (pDoc == null)
        {
-               __pDoc = ParseXmlFile(homePath + L"res/eng-US.xml");
+               pDoc.reset(ParseXmlFile(resourceFolder + L"eng-US.xml"));
        }
 
-       if (__pDoc == null)
+       if (pDoc == null)
        {
-               __pDoc = ParseXmlFile(homePath + L"res/English.xml");
+               pDoc.reset(ParseXmlFile(resourceFolder + L"English.xml"));
        }
 
-       if (__pDoc == null)
-       {
-               SysLog(NID_APP, "Can't find xml resource file.");
-               return E_SUCCESS; //E_FILE_NOT_FOUND;
-       }
+       SysTryLogReturn(NID_APP, pDoc != null, E_SUCCESS, "Can't find xml resource file.");
 
-       xmlNodePtr cur = xmlDocGetRootElement(__pDoc);
-       SysTryReturnResult(NID_APP, cur != null, E_FAILURE, "Empty document.");
+       xmlNodePtr cur = xmlDocGetRootElement(pDoc.get());
+       SysTryReturnResult(NID_APP, cur != null, E_SYSTEM, "Empty document.");
 
-       if (xmlStrcmp(cur->name, (const xmlChar*) AR_ROOT_NODE_NAME))
-       {
-               SysLogException(NID_APP, E_FAILURE, "[E_FAILURE] Document root node is not <string_table>.");
-               return E_FAILURE;
-       }
+       ret = xmlStrcmp(cur->name, (const xmlChar*) AR_ROOT_NODE_NAME);
+       SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "Document root node is not <string_table>.");
 
-       gCur = cur;
+       std::unique_ptr< HashMap, AllElementsDeleter > pXmlNodeMap (new (std::nothrow) HashMap());
+       SysTryReturnResult(NID_APP, pXmlNodeMap != null, E_OUT_OF_MEMORY, " Memory allocation failed.");
 
-       return E_SUCCESS;
-}
-
-result
-_AppResourceString::InitializeStringInfo(const AppId& appId)
-{
-       if (__pDoc != null)
-       {
-               SysLog(NID_APP, "__pDoc is freed to reinitialize.");
-               xmlFreeDoc(__pDoc);
-               __pDoc = null;
-       }
-
-       char* pValue = null;
-       int ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &pValue);
-       SysTryReturnResult(NID_APP, ret == 0, E_FAILURE, "[E_SYSTEM] runtime_info_get_value_string returns %d.", ret);
-
-
-       U_ICU_NAMESPACE::Locale icuLcl(pValue);
-
-       String language(icuLcl.getISO3Language());
-       String country(icuLcl.getCountry());
+       r = pXmlNodeMap->Construct();
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "Unable to construct xml node map [%s]", GetErrorMessage(r));
 
-//     SysLog(NID_APP, "res/%ls-%ls.xml", language.GetPointer(), country.GetPointer());
-
-       String resFilename;
-       result r = resFilename.Format(256 * 2 + 10, L"/res/%ls-%ls.xml", language.GetPointer(), country.GetPointer());
-       SysTryReturn(NID_APP, !IsFailed(r), E_FAILURE, r, "[%s] Failed to format path string", GetErrorMessage(r));
-
-       PackageInfo* pPkgInfo = null;
-       pPkgInfo = _PackageManagerImpl::GetInstance()->GetPackageInfoN(appId);
-       SysTryReturnResult(NID_APP, pPkgInfo != null, E_APP_NOT_INSTALLED, "Failed to get the package info");
-
-       _PackageInfoImpl* pPkgInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
-       SysTryReturnResult(NID_APP, pPkgInfoImpl != null, E_APP_NOT_INSTALLED, "Failed to get the package info impl");
-
-       const Tizen::Base::String& homePath = pPkgInfoImpl->GetAppRootPath();
-
-       __pDoc = ParseXmlFile( homePath + resFilename);
-
-       // Fall-back
-       if (__pDoc == null)
+       xmlChar* pxmlValue = null;
+       cur = cur->xmlChildrenNode;
+       while (cur != null)
        {
-               String dirName(L"/res/");
-               Directory dir;
-               DirEnumerator* pDirEnum = null;
-               String name;
-
-               r = dirName.Insert(homePath, 0);
-               SysTryReturn(NID_APP, !IsFailed(r), E_FAILURE, r, "[%s] Failed to insert string.", GetErrorMessage(r));
-
-               // open directory
-               r = dir.Construct(dirName);
-               if (r == E_SUCCESS)
+               if ((!xmlStrcmp(cur->name, (const xmlChar*) AR_CHILD_NODE_1)))
                {
-                       // read all directory entries
-                       pDirEnum = dir.ReadN();
-                       if (pDirEnum != null)
+                       pxmlValue = xmlGetProp(cur, (const xmlChar*) AR_ATTRIBUTE);
+                       if (cur->type == (xmlElementType)  XML_ELEMENT_NODE)
                        {
-                               const String starts = language + L"-";
-                               const String ends = L".xml";
+                               xmlChar* pContent = xmlNodeListGetString( pDoc.get(), cur->xmlChildrenNode, 1);
 
-                               // loop through all directory entries
-                               while (pDirEnum->MoveNext() == E_SUCCESS)
-                               {
-                                       // get several properties of each directory entry.
-                                       name = pDirEnum->GetCurrentDirEntry().GetName();
-
-                                       if (name.StartsWith(starts, 0) && name.EndsWith(ends))
-                                       {
-                                               resFilename = L"/res/" + name;
-                                               __pDoc = ParseXmlFile(homePath + resFilename);
-                                               break;
-                                       }
-                               }
-                               // Delete enumerator
-                               delete pDirEnum;
-                       }
-               }
-       }
+                               std::unique_ptr< String > pKey(new (std::nothrow) String);
+                               SysTryReturnResult(NID_APP, pKey != null, E_OUT_OF_MEMORY, " Memory allocation failed.");
+                               Tizen::Base::Utility::StringUtil::Utf8ToString((char*) pxmlValue, *pKey);
 
-       if (__pDoc == null)
-       {
-               __pDoc = ParseXmlFile(homePath + L"/res/eng-GB.xml");
-       }
+                               std::unique_ptr< String > pValue(new (std::nothrow) String);
+                               SysTryReturnResult(NID_APP, pValue != null, E_OUT_OF_MEMORY, " Memory allocation failed.");
+                               Tizen::Base::Utility::StringUtil::Utf8ToString((char*) pContent, *pValue);
 
-       if (__pDoc == null)
-       {
-               __pDoc = ParseXmlFile(homePath + L"/res/eng-US.xml");
-       }
+                               pXmlNodeMap->Add(*pKey, *pValue);
+                               pKey.release();
+                               pValue.release();
+                       }
 
-       if (__pDoc == null)
-       {
-               __pDoc = ParseXmlFile(homePath + L"/res/English.xml");
+               }
+               cur =  cur->next;
        }
 
-       if (__pDoc == null)
+       if (__pDoc != null)
        {
-               SysLog(NID_APP, "Can't find xml resource file.");
-               return E_DATA_NOT_FOUND;
+               xmlFreeDoc(__pDoc);
+               __pDoc = null;
        }
 
-       xmlNodePtr cur = xmlDocGetRootElement(__pDoc);
-       SysTryReturnResult(NID_APP, cur != null, E_FAILURE, "Empty document.");
-
-       if (xmlStrcmp(cur->name, (const xmlChar*) AR_ROOT_NODE_NAME))
+       if (__pXmlNodeMap)
        {
-               SysLogException(NID_APP, E_FAILURE, "[E_FAILURE] Document root node is not <string_table>.");
-               return E_FAILURE;
+               __pXmlNodeMap->RemoveAll(true);
+               delete __pXmlNodeMap;
        }
 
-       gCur = cur;
-
-       delete pPkgInfo;
+       __pDoc = pDoc.release();
+       __pXmlNodeMap = pXmlNodeMap.release();
        return E_SUCCESS;
 }
 
 xmlDocPtr
 _AppResourceString::ParseXmlFile(const String& path)
 {
-       if (File::IsFileExist(path) == false )
-       {
-               SysLog(NID_APP, "'%ls' isn't exist.", path.GetPointer());
-               return null;
-       }
-
-       std::unique_ptr<char[]> pBuf(_StringConverter::CopyToCharArrayN(path));
-       xmlDocPtr docPtr = xmlParseFile(pBuf.get());
-
-       if (docPtr == null)
-       {
-               SysLog(NID_APP, "failed to parse resource file(%ls)", path.GetPointer());
-               return null;
-       }
-
-       SysLog(NID_APP, "'%ls' is parsed successfully.", path.GetPointer());
-       return docPtr;
-}
-
-
-_AppResourceString::~_AppResourceString(void)
-{
-       if (__pDoc != null)
+       xmlDocPtr pDoc = null;
+       if (File::IsFileExist(path))
        {
-               xmlFreeDoc(__pDoc);
+               std::unique_ptr<char[]> pBuf(_StringConverter::CopyToCharArrayN(path));
+               pDoc = xmlParseFile(pBuf.get());
        }
-       delete __pLockOfParser;
+       return pDoc;
 }
 
 
 result
 _AppResourceString::GetString(const String resourceId, String& loadedString)
 {
-       SysTryReturnResult(NID_APP, __pDoc != null, E_INVALID_STATE, "Can't find xml resource file.");
-
 #if defined(ENABLE_XPATH)
+       SysTryReturnResult(NID_APP, __pDoc != null, E_FAILURE, "Can't find xml resource file.");
+
        xmlXPathContextPtr __pXpathCtx = null;
        xmlXPathObjectPtr __pXpathObj = null;
 
@@ -456,72 +356,28 @@ _AppResourceString::GetString(const String resourceId, String& loadedString)
        return E_SUCCESS;
 
 #else
-       xmlNodePtr cur = null;
-       xmlChar* pValue = null;
-       xmlChar* pId = null;
-
        SysTryReturnResult(NID_APP, !resourceId.IsEmpty(), E_INVALID_ARG, "Wrong resource Id.");
-       SysTryReturnResult(NID_APP, gCur != null && __pDoc != null, E_INVALID_STATE,
-                               "Application string resource was not initialized.");
-       SysTryReturnResult(NID_APP, __pLockOfParser != null, E_INVALID_STATE, "__pLockOfParser was not initialized.");
+       SysTryReturnResult(NID_APP, __pDoc != null, E_FAILURE, "Application string resource was not initialized.");
+       SysTryReturnResult(NID_APP, __pLockOfParser != null, E_FAILURE, "__pLockOfParser was not initialized.");
 
        result r = __pLockOfParser->Acquire();
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Failed to Acquire Mutex.", GetErrorMessage(r));
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_FAILURE, "Failed to Acquire Mutex [%s].", GetErrorMessage(r));
 
-       pId = (xmlChar*) (_StringConverter::CopyToCharArrayN(resourceId));
-       cur = gCur;
-       cur = cur->xmlChildrenNode;
-       while (cur != null)
+       String* pkeyValue = static_cast< String* > (__pXmlNodeMap->GetValue(resourceId));
+       r = E_FAILURE; //GetLastResult();
+       if (pkeyValue)
        {
-               if ((!xmlStrcmp(cur->name, (const xmlChar*) AR_CHILD_NODE_1)))
+               loadedString = *pkeyValue;
+               if (HasSpecialString(loadedString))
                {
-                       pValue = xmlGetProp(cur, (const xmlChar*) AR_ATTRIBUTE);
-                       if (!xmlStrcmp(pValue, (const xmlChar*) pId))
-                       {
-                               xmlChar* pContent = xmlNodeListGetString( __pDoc, cur->xmlChildrenNode, 1);
-                               SysLog(NID_APP, "xml content=%s", pContent);
-                               loadedString = (char*) (pContent);
-
-                               if (HasSpecialString(loadedString))
-                               {
-                                       String rawString(loadedString);
-                                       ConvertToCstyleString(rawString, loadedString);
-                               }
-
-                               if (pContent)
-                               {
-                                       xmlFree(pContent);
-                               }
-
-                               if (pValue)
-                               {
-                                       xmlFree(pValue);
-                               }
-
-                               if (pId)
-                               {
-                                       delete[] (char*) pId;
-                               }
-
-                               __pLockOfParser->Release();
-                               return E_SUCCESS;
-                       }
-                       if (pValue)
-                       {
-                               xmlFree(pValue);
-                       }
+                       String rawString(loadedString);
+                       ConvertToCstyleString(rawString, loadedString);
                }
-               cur = cur->next;
-       }
-
-       if (pId)
-       {
-               delete[] (char*) pId;
+               r = E_SUCCESS;
        }
 
        __pLockOfParser->Release();
-
-       return E_FAILURE;
+       return r;
 #endif
 }
 
@@ -530,7 +386,6 @@ bool
 _AppResourceString::HasSpecialString(const String& resourceStr)
 {
        int foundIndex = 0;
-
        return((resourceStr.IndexOf("&lt;", 0, foundIndex) == E_SUCCESS)
                || (resourceStr.IndexOf("&amp;", 0, foundIndex) == E_SUCCESS)
                || (resourceStr.IndexOf("&gt;", 0, foundIndex) == E_SUCCESS)
@@ -544,20 +399,14 @@ _AppResourceString::HasSpecialString(const String& resourceStr)
 result
 _AppResourceString::ConvertToCstyleString(const String& resourceStr, String& convertedStr)
 {
-       result r = E_SUCCESS;
-
-       int i = 0;
-       int j = 0;
-       int len = 0;
-
        SysTryReturnResult(NID_APP, resourceStr.GetLength() > 0, E_INVALID_ARG, "resource string must be greater than 0.");
 
        std::unique_ptr<char[]> pBuffer(_StringConverter::CopyToCharArrayN(resourceStr));
-       // len = resourceStr.GetLength(); comment out because GetLength() returns UTF8 length.
        SysTryReturnResult(NID_APP, pBuffer != null, E_OUT_OF_MEMORY, "Memory allocation failure.");
 
-       len = strlen(pBuffer.get());//  len = String_length((MString)pBuffer);
-
+       int i = 0;
+       int j = 0;
+       int len = strlen(pBuffer.get());//      len = String_length((MString)pBuffer);
        while (i < len)
        {
                if (pBuffer[i] == '\\')
@@ -636,8 +485,7 @@ _AppResourceString::ConvertToCstyleString(const String& resourceStr, String& con
        }
 
        convertedStr = pBuffer.get();
-
-       return r;
+       return E_SUCCESS;
 }
 
 
index 58a0a3b..623d886 100644 (file)
@@ -26,7 +26,7 @@
 #include <FBaseObject.h>
 #include <FBaseString.h>
 
-namespace Tizen { namespace Locales { class Locale; } }
+namespace Tizen { namespace Base { namespace Collection { class HashMap; } } }
 
 struct _xmlDoc;
 typedef _xmlDoc* xmlDocPtr;
@@ -59,28 +59,14 @@ public:
        */
        result GetString(const Tizen::Base::String resourceId, Tizen::Base::String& loadedString);
 
-       /**
-       * Initializes this instance.
-       *
-       */
-       result Construct(void);
-
-       /**
-       * Initializes this instance with the specified locale.
-       *
-       */
-       result Construct(const Tizen::Locales::Locale& locale);
-
 
-       result Initialize(void);
+       result Initialize(Tizen::Base::String& resourceFolder);
+       result InitializeStringInfo(Tizen::Base::String& resourceFolder);
 
-       result Construct(const AppId& appId);
+       static _AppResourceString* Get_AppResourceStringN(int type, const Tizen::Base::String& value = L"");
 
-       result Initialize(const AppId& appId);
 
 private:
-       result InitializeStringInfo(void);
-       result InitializeStringInfo(const AppId& appId);
        static bool HasSpecialString(const Tizen::Base::String& resourceStr);
        static result ConvertToCstyleString(const Tizen::Base::String& resourceStr, Tizen::Base::String& convertedStr);
        static xmlDocPtr ParseXmlFile(const Tizen::Base::String& path);
@@ -109,8 +95,8 @@ private:
 
        xmlDocPtr __pDoc;
        Tizen::Base::Runtime::Mutex* __pLockOfParser;
+       Tizen::Base::Collection::HashMap* __pXmlNodeMap;
 
-       friend class _AppResourceImpl;
 }; // _AppResourceString
 
 } } // Tizen::App
old mode 100644 (file)
new mode 100755 (executable)
index e869903..171a22d
@@ -72,6 +72,7 @@ const int _MAX_TIZEN_SVC_DESC_LEN = 1024;
 
 const int _MAX_CATEGORY = 12;
 const int _MAX_PACKAGE_ID_LENGTH = 10;
+const int _MAX_DATA_ARGUMENT_LENGTH = 32768; // 32KB
 
 // borrowed from app-svc/include/pri_key.h
 #define APP_SVC_K_RES_VAL      "__APP_SVC_K_RES_VAL__"
@@ -96,46 +97,59 @@ static const _CategoryList _CATEGORY_LIST[] =
 
 static const int _NUM_CATEGORY = sizeof(_CATEGORY_LIST) / sizeof(_CategoryList);
 
-
 result
-_Aul::SendResult(bundle* b, appsvc_result_val res)
+_Aul::GetConvertedResult(const int aul_ret, const char* pFunctionName)
 {
        result r = E_SUCCESS;
 
-       // to skip error handling, of appsvc_send_result, use aul_send_service_result() directly.
-       //int ret = appsvc_send_result(b, res);
-
-       char tmp[32] = {0, };
-       snprintf(tmp, 32, "%d", static_cast<int>(res));
-       appsvc_add_data(b, APP_SVC_K_RES_VAL, tmp);
-
-       int ret = aul_send_service_result(b);
-
-       switch (ret)
+       switch (aul_ret)
        {
        case AUL_R_EINVAL:
                r = E_INVALID_ARG;
-               SysLogException(NID_APP, r, "Invalid result bundle.");
+               SysLogException(NID_APP, r, "%s : Invalid argument.", pFunctionName);
                break;
 
        case AUL_R_ECOMM:
                r = E_SYSTEM;
-               SysLogException(NID_APP, r, "Internal IPC error.");
+               SysLogException(NID_APP, r, "%s : Internal IPC error.", pFunctionName);
                break;
 
        case AUL_R_ERROR:
                r = E_SYSTEM;
-               SysLogException(NID_APP, r, "General error.");
+               SysLogException(NID_APP, r, "%s : General error.", pFunctionName);
                break;
 
        default:
-               SysLog(NID_APP, "SendResult() ok");
+               SysLog(NID_APP, "%s : successed.", pFunctionName);
                break;
        }
 
        return r;
 }
 
+result
+_Aul::SendResult(bundle* b, appsvc_result_val res)
+{
+       // to skip error handling, of appsvc_send_result, use aul_send_service_result() directly.
+       //int ret = appsvc_send_result(b, res);
+
+       char tmp[32] = {0, };
+       snprintf(tmp, 32, "%d", static_cast<int>(res));
+       appsvc_add_data(b, APP_SVC_K_RES_VAL, tmp);
+
+       bundle_raw* dataBuf = null;
+       int dataLen = 0;
+       int ret = bundle_encode(b, &dataBuf, &dataLen);
+       bundle_free_encoded_rawdata(&dataBuf);
+       SysTryReturnResult(NID_APP, ret == 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+       SysTryReturnResult(NID_APP, dataLen <= _MAX_DATA_ARGUMENT_LENGTH, E_MAX_EXCEEDED,
+                       "The data length (%d) exceeds the maximum limit.", dataLen);
+
+       int aul_ret = aul_send_service_result(b);
+
+       return GetConvertedResult(aul_ret, "SendResult");
+}
+
 
 bool
 _Aul::IsRunning(const AppId& appId, const String& exeName)
@@ -180,31 +194,33 @@ result
 _Aul::TerminateApplicationByPid(int pid)
 {
        int ret_aul = aul_terminate_pid(pid);
-       result r = E_SUCCESS;
-
-       switch (ret_aul)
-       {
-       case AUL_R_EINVAL:
-               r = E_INVALID_ARG;
-               SysLogException(NID_APP, r, "invaild pid.\n");
-               break;
 
-       case AUL_R_ECOMM:
-               r = E_SYSTEM;
-               SysLogException(NID_APP, r, "internal AUL IPC error.\n");
-               break;
+       return GetConvertedResult(ret_aul, "TerminateApplicationByPid");
+}
 
-       case AUL_R_ERROR:
-               r = E_SYSTEM;
-               SysLogException(NID_APP, r, "general error.\n");
-               break;
+static int
+TerminateApplicationIterFnCb(const aul_app_info* pAppInfo, void* pData)
+{
+       const char* pStr = static_cast<const char*>(pData);
 
-       default:
-               SysLog(NID_APP, "'%d' is terminated.", pid);
-               break;
+       if (pStr && strncmp(pStr, pAppInfo->pkg_name, NATIVE_APP_MAX_APPID_LENGTH) == 0)
+       {
+               SysLog(NID_APP, "%s(%d) is terminated.", pAppInfo->pkg_name, pAppInfo->pid);
+               int ret_aul = aul_terminate_pid( pAppInfo->pid );
+               SetLastResult(_Aul::GetConvertedResult(ret_aul, "TerminateApplication"));
        }
+       return 0;
+}
 
-       return r;
+result
+_Aul::TerminateApplication(const AppId& appId)
+{
+       SetLastResult(E_OBJ_NOT_FOUND);
+       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+       aul_app_get_running_app_info(TerminateApplicationIterFnCb, static_cast<void*>(pAppId.get()));
+
+       SysLog(NID_APP, "%ls terminated.", appId.GetPointer());
+       return GetLastResult();
 }
 
 result
@@ -287,28 +303,23 @@ bool _Aul::IsInstalled(const AppId& appId)
 }
 
 result
-_Aul::_DesktopFile::MakePath(const AppId& appId, const String* pExeName, char* path, int size)
+_Aul::_DesktopFile::MakePath(const AppId& appId, char* path, int size)
 {
        SysTryReturnResult(NID_APP, path != null, E_INVALID_ARG, "");
 
-       char packageName[MAX_SLP_PACKAGE_ID] = {0, };
-       result r = E_SUCCESS;
-       _PackageManagerImpl* pPackageManagerImpl = _PackageManagerImpl::GetInstance();
-       SysTryReturnResult(NID_APP, pPackageManagerImpl, E_INVALID_STATE, "Invalid package manager instance.");
-
-       r = pPackageManagerImpl->GetPackageName(appId, pExeName, packageName, MAX_SLP_PACKAGE_ID);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "%s", GetErrorMessage(r));
+       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+       SysTryReturnResult(NID_APP, pAppId != null, E_OUT_OF_MEMORY, "Failed to allocate memory for 'pAppId'");
 
-       snprintf(path, size, _DESKTOP_FILE_PATH_FORMAT, _DESKTOP_FILE_PATH, packageName);
+       snprintf(path, size, _DESKTOP_FILE_PATH_FORMAT, _DESKTOP_FILE_PATH, pAppId.get());
 
-       return r;
+       return E_SUCCESS;
 }
 
 result
 _Aul::_DesktopFile::UpdateService(const AppId& appId, const char* value)
 {
        char path[FILENAME_MAX] = {0, };
-       MakePath(appId, null, path, FILENAME_MAX);
+       MakePath(appId, path, FILENAME_MAX);
 
        return UpdateField(path, _X_TIZEN_SVC, value);
 }
@@ -318,12 +329,11 @@ result
 _Aul::_DesktopFile::RemoveService(const AppId& appId, const char* operationOnlyValue)
 {
        char path[FILENAME_MAX] = {0, };
-       MakePath(appId, null, path, FILENAME_MAX);
+       MakePath(appId, path, FILENAME_MAX);
 
        return UpdateField(path, _X_TIZEN_SVC, operationOnlyValue, true);
 }
 
-
 //
 // Update value of specified field.
 // currently only "x-slp-svc" field is supported.
index bef8692..cecb603 100644 (file)
@@ -62,7 +62,7 @@ _ConditionManagerProxy::Construct()
 }
 
 result
-_ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const String& condition,
+_ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const String& condition,
                                                                                  const IList* pArguments, AppManager::LaunchOption option)
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
@@ -74,7 +74,7 @@ _ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const Tizen::Base:
        dummy.Construct();
 
        std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_RegisterAppLaunch(
-                                               appId, executableName, condition, (pArrayList != null) ? *pArrayList : dummy,
+                                               appId, condition, (pArrayList != null) ? *pArrayList : dummy,
                                                (int) AppManager::LAUNCH_OPTION_DEFAULT, &response));
        result r = __pIpcClient->SendRequest(*pMsg.get());
 
@@ -85,7 +85,7 @@ _ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const Tizen::Base:
 
 
 result
-_ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const String* pCondition)
+_ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, /*const Tizen::Base::String& executableName,*/ const String* pCondition)
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
        SysLog(NID_APP, "");
@@ -93,7 +93,7 @@ _ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const Tizen::Bas
 
        result response = E_SUCCESS;
        std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_UnregisterAppLaunch(
-                                                                                                       appId, executableName, (pCondition != null) ? *pCondition : L"", &response));
+                                                                                                       appId, (pCondition != null) ? *pCondition : L"", &response));
        result r = __pIpcClient->SendRequest(*pMsg.get());
 
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
@@ -102,7 +102,7 @@ _ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const Tizen::Bas
 }
 
 bool
-_ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String& executableName, const String* pCondition) const
+_ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const String* pCondition) const
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
        SysLog(NID_APP, "");
@@ -110,7 +110,7 @@ _ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const Tizen::B
        bool isAppLaunchRegistered = false;
        result exception = E_SYSTEM;
        std::auto_ptr<IPC::Message> pMsg(new (std::nothrow) ConditionManager_IsAppLaunchRegistered(
-                       appId, executableName, (pCondition != null) ? *pCondition : L"", &isAppLaunchRegistered, &exception));
+                       appId, (pCondition != null) ? *pCondition : L"", &isAppLaunchRegistered, &exception));
        result r = __pIpcClient->SendRequest(*pMsg.get());
 
        SysTryReturn(NID_APP, !IsFailed(r), false, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
index bb61179..9b68cda 100644 (file)
@@ -49,11 +49,11 @@ public:
 
        result Construct(void);
 
-       result RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pArguments, AppManager::LaunchOption option);
+       result RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pArguments, AppManager::LaunchOption option);
 
-       result UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String* pCondition);
+       result UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String* pCondition);
 
-       bool IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String* pCondition = null) const;
+       bool IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String* pCondition = null) const;
 
 private:
        _ConditionManagerProxy(const _ConditionManagerProxy& rhs);
index 55c6020..e3eecb6 100644 (file)
@@ -264,7 +264,7 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon
 
        //resultArg.Print();
        r = _Aul::SendResult(resultArg.GetBundle(), static_cast< appsvc_result_val >(0));
-       SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, r, "[%s] _Aul::SendResult() was failed.", GetErrorMessage(r));
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to send result.", GetErrorMessage(r));
 
        // Erases _AppArg after sending the result back to the caller
        pAppMgr->__resultManager.RemoveItem(static_cast< int >(reqId));
old mode 100644 (file)
new mode 100755 (executable)
index 46e7da8..8fd840f
@@ -213,7 +213,7 @@ _ImeAppImpl::OnImeAppImplTerminating(void)
 
        if (_AppInfo::GetAppState() != TERMINATED)
        {
-               result = __pUiApp->OnAppTerminating(*(AppRegistry::GetInstance()), false);
+               result = __pUiApp->OnAppTerminating(*(AppRegistry::GetInstance()), __pAppImpl->IsForcedTermination());
                _AppInfo::SetAppState(TERMINATED);
        }
 
index 49b447a..b34a680 100644 (file)
 
 #include <typeinfo>
 #include <new>
+#include <unique_ptr.h>
 
 #include <appsvc/appsvc.h>
 
 #include <FBaseInteger.h>
 #include <FBaseString.h>
+#include <FBaseRtIEventArg.h>
 #include <FAppMapDataControl.h>
 #include <FAppIMapDataControlResponseListener.h>
 
 #include "FApp_MapDataControlImpl.h"
 #include "FApp_AppArg.h"
 
+using namespace std;
+
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
 using namespace Tizen::App;
 using namespace Tizen::Io;
 
 namespace Tizen { namespace App
 {
 
+class _MapDataControlEventArg
+       : public IEventArg
+{
+public:
+               _MapDataControlEventArg(_DataControlRequestType requestType, RequestId reqId, String providerId, String dataId,
+                               IList* pResultValueList, bool providerResult, String* pErrorMsg)
+                       : __requestType(requestType)
+                       , __reqId(reqId)
+                       , __providerId(providerId)
+                       , __dataId(dataId)
+                       , __pResultValueList(pResultValueList)
+                       , __providerResult(providerResult)
+                       , __pErrorMsg(pErrorMsg)
+               {
+               }
+               ~_MapDataControlEventArg(void)
+               {
+                       if (__pResultValueList)
+                       {
+                               __pResultValueList->RemoveAll(true);
+                               delete __pResultValueList;
+                       }
+                       delete __pErrorMsg;
+               }
+
+               _DataControlRequestType __requestType;
+               RequestId __reqId;
+               String __providerId;
+               String __dataId;
+               IList* __pResultValueList;
+               bool __providerResult;
+               String* __pErrorMsg;
+};
+
+class _MapDataControlEvent
+       : public Event
+{
+protected:
+               virtual void FireImpl(IEventListener& listener, const IEventArg& arg);
+};
+
+void
+_MapDataControlEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       const _MapDataControlEventArg* pArg = dynamic_cast<const _MapDataControlEventArg*>(&arg);
+       if (pArg != null)
+       {
+               IMapDataControlResponseListener* pListener = dynamic_cast<IMapDataControlResponseListener*> (&listener);
+               if (pListener != null)
+               {
+                       switch (pArg->__requestType)
+                       {
+                       case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
+                               pListener->OnMapDataControlGetValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                               *(pArg->__pResultValueList), pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
+                               pListener->OnMapDataControlAddValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                                pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
+                               pListener->OnMapDataControlSetValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                               pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
+                               pListener->OnMapDataControlRemoveValueResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                               pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
+}
+
 // private
 _MapDataControlImpl::_MapDataControlImpl(void)
        : __appId(L"")
        , __providerId(L"")
        , __access(_DATACONTROL_ACCESS_UNDEFINED)
-       , __pListener(null)
+       , __pPreviousListener(null)
+       , __pMapDataControlEvent(null)
 {
 }
 
 _MapDataControlImpl::~_MapDataControlImpl(void)
 {
+       delete __pMapDataControlEvent;
 }
 
 _MapDataControlImpl*
@@ -71,8 +153,7 @@ _MapDataControlImpl::GetInstance(const MapDataControl& dc)
 }
 
 result
-_MapDataControlImpl::StartMapDataControl(int type, const IList* pDataList, IMapDataControlResponseListener* pListener,
-                                                                                int* pReq)
+_MapDataControlImpl::StartMapDataControl(int type, const IList* pDataList, int* pReq)
 {
        result r = E_SUCCESS;
 
@@ -84,12 +165,10 @@ _MapDataControlImpl::StartMapDataControl(int type, const IList* pDataList, IMapD
        _AppControlManager* pAppManagerImpl = _AppControlManager::GetInstance();
        int req = -1;
 
-       if (__pListener)
+       if (__pMapDataControlEvent)
        {
-               SysLog(NID_APP, "listener address: 0x%x", (void*) __pListener);
-
                // reqId is system-wide id because the bundle is system-wide.
-               _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, MapDataControlCallback, __pListener, -1);
+               _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, MapDataControlCallback, __pMapDataControlEvent, -1);
                req = reqObj.GetRequestNumber();
 
                r = pAppManagerImpl->LaunchApp(__appId, pArg, req);
@@ -106,19 +185,7 @@ _MapDataControlImpl::StartMapDataControl(int type, const IList* pDataList, IMapD
                delete pArg;
        }
 
-       {
-               // registers to server
-               _IAppManager* pAppManager = _AppManagerProxy::GetService();
-
-               // actually register, not launch
-               if (pAppManager)
-               {
-                       pAppManager->LaunchApplication(__appId, null, req);
-               }
-       }
-
 CATCH:
-
        return r;
 }
 
@@ -149,13 +216,16 @@ _MapDataControlImpl::GetValue(const String& dataId, const String& key,
        pCountPerPage->Append(countPerPage);
        pArgList->Add(*pCountPerPage);
 
-       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, pArgList, __pListener, &id);
+       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
        SysLog(NID_APP, "dataId: %ls, key: %ls, reqId: %d, pageNo: %d, countPerPage: %d",
                        dataId.GetPointer(), key.GetPointer(), reqId, pageNo, countPerPage);
 
+       // fall through
+CATCH:
        pArgList->RemoveAll(true);
        delete pArgList;
 
@@ -172,6 +242,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
        String* pReqId = null;
        String* pProviderId = null;
        String* pDataId = null;
+       String* pErrorMessage = null;
        String* pErrorMsg = null;
        String* pResultCount = null;
        String* pValue = null;
@@ -183,6 +254,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
        bool providerResult = true;
        bundle* origBundle = null;
        bundle* resBundle = null;
+       _MapDataControlEventArg* pEventArg = null;
        result r = E_SUCCESS;
 
        SysTryReturnResult(NID_APP, pResArg != null, E_INVALID_ARG, "Empty result callback.");
@@ -191,9 +263,9 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
        resBundle = pResArg->GetBundle();
        if (resBundle)
        {
-               IMapDataControlResponseListener* pListener = static_cast< IMapDataControlResponseListener* >(data);
+               _MapDataControlEvent* pMapDataControlEvent = static_cast< _MapDataControlEvent* >(data);
 
-               if (pListener != null && typeid(pListener) == typeid(IMapDataControlResponseListener*))
+               if (pMapDataControlEvent != null && typeid(pMapDataControlEvent) == typeid(_MapDataControlEvent*))
                {
                        const char* p = null;
 
@@ -206,8 +278,11 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                        Integer::Parse(*pResult, providerRes);
                        providerResult = static_cast< bool >(providerRes);
 
-                       pErrorMsg = dynamic_cast< String* >(pResultList->GetAt(1));
-                       SysTryCatch(NID_APP, pErrorMsg, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
+                       pErrorMessage = dynamic_cast< String* >(pResultList->GetAt(1));
+                       SysTryCatch(NID_APP, pErrorMessage, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
+                       pErrorMsg = new (std::nothrow) String(*pErrorMessage);
+                       SysTryCatch(NID_APP, pErrorMsg, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                        // request info
                        origBundle = pArg->GetBundle();
@@ -216,21 +291,21 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                        SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
                        pRequestType = new (std::nothrow) String(p);
                        SysTryCatch(NID_APP, pRequestType, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                       "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
                        Integer::Parse(*pRequestType, requestType);
 
                        p = appsvc_get_data(origBundle, OSP_K_REQUEST_ID);
                        SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
                        pReqId = new (std::nothrow) String(p);
                        SysTryCatch(NID_APP, pReqId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                       "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
                        Integer::Parse(*pReqId, reqId);
 
                        p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_PROVIDER);
                        SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
                        pProviderId = new (std::nothrow) String(p);
                        SysTryCatch(NID_APP, pProviderId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                       "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                        pOrigList = _AppArg::GetListN(origBundle, OSP_K_ARG);
                        SysTryCatch(NID_APP, pOrigList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
@@ -246,19 +321,31 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                        {
                                pResultValueList = new (std::nothrow) ArrayList();
                                SysTryCatch(NID_APP, pResultValueList, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                               "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                               "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                                if (providerResult == true)
                                {
-                                       pResultCount = dynamic_cast <String*>(pResultList->GetAt(2));
-                                       SysTryCatch(NID_APP, pResultCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
+                                       pResultCount = dynamic_cast< String* >(pResultList->GetAt(2));
+                                       if (pResultCount == null)
+                                       {
+                                               SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
+                                               pResultValueList->RemoveAll(true);
+                                               delete pResultValueList;
+                                               goto CATCH;
+                                       }
                                        Integer::Parse(*pResultCount, resultCount);
 
                                        int index = 3;
                                        while (resultCount)
                                        {
-                                               pValue = dynamic_cast <String*>(pResultList->GetAt(index));
-                                               SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
+                                               pValue = dynamic_cast< String* >(pResultList->GetAt(index));
+                                               if (pValue == null)
+                                               {
+                                                       SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
+                                                       pResultValueList->RemoveAll(true);
+                                                       delete pResultValueList;
+                                                       goto CATCH;
+                                               }
 
                                                pResultValueList->Add(*(new (std::nothrow) String(*pValue)));
                                                resultCount--;
@@ -266,25 +353,37 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                                        }
                                }
 
-                               pListener->OnMapDataControlGetValueResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, *pResultValueList, providerResult, pErrorMsg);
+                               pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, pResultValueList, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pMapDataControlEvent->Fire(*pEventArg);
 
-                               pResultValueList->RemoveAll(true);
-                               delete pResultValueList;
                                break;
                        }
                        case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
-                               pListener->OnMapDataControlAddValueResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, providerResult, pErrorMsg);
+                       {
+                               pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, null, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pMapDataControlEvent->Fire(*pEventArg);
                                break;
+                       }
                        case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
-                               pListener->OnMapDataControlSetValueResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, providerResult, pErrorMsg);
+                       {
+                               pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, null, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pMapDataControlEvent->Fire(*pEventArg);
                                break;
+                       }
                        case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
-                               pListener->OnMapDataControlRemoveValueResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, providerResult, pErrorMsg);
+                       {
+                               pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, null, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pMapDataControlEvent->Fire(*pEventArg);
                                break;
+                       }
                        default:
                                break;
                        }
@@ -310,12 +409,6 @@ CATCH:
                delete pResultList;
        }
 
-       if (pResultValueList)
-       {
-               pResultValueList->RemoveAll(true);
-               delete pResultValueList;
-       }
-
        if (pOrigList)
        {
                pOrigList->RemoveAll(true);
@@ -347,13 +440,16 @@ _MapDataControlImpl::AddValue(const String& dataId, const String& key,
        pArgList->Add(*(new String(key)));
        pArgList->Add(*(new String(value)));
 
-       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, pArgList, __pListener, &id);
+       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
        SysLog(NID_APP, "dataId: %ls, key: %ls, value: %ls, reqId: %d",
                        dataId.GetPointer(), key.GetPointer(), value.GetPointer(), reqId);
 
+       // fall through
+CATCH:
        pArgList->RemoveAll(true);
        delete pArgList;
 
@@ -379,13 +475,16 @@ _MapDataControlImpl::SetValue(const String& dataId, const String& key,
        pArgList->Add(*(new String(oldValue)));
        pArgList->Add(*(new String(newValue)));
 
-       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, pArgList, __pListener, &id);
+       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
        SysLog(NID_APP, "dataId: %ls, key: %ls, oldValue: %ls, newValue: %ls, reqId: %d",
                        dataId.GetPointer(), key.GetPointer(), oldValue.GetPointer(), newValue.GetPointer(), reqId);
 
+       // fall through
+CATCH:
        pArgList->RemoveAll(true);
        delete pArgList;
 
@@ -410,13 +509,16 @@ _MapDataControlImpl::RemoveValue(const String& dataId, const String& key,
        pArgList->Add(*(new String(key)));
        pArgList->Add(*(new String(value)));
 
-       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, pArgList, __pListener, &id);
+       r = StartMapDataControl(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
        SysLog(NID_APP, "dataId: %ls, key: %ls, value: %ls, reqId: %d",
                        dataId.GetPointer(), key.GetPointer(), value.GetPointer(), reqId);
 
+       // fall through
+CATCH:
        pArgList->RemoveAll(true);
        delete pArgList;
 
@@ -426,7 +528,35 @@ _MapDataControlImpl::RemoveValue(const String& dataId, const String& key,
 result
 _MapDataControlImpl::SetMapDataControlResponseListener(IMapDataControlResponseListener* pListener)
 {
-       __pListener = pListener;
+       result r = E_SUCCESS;
+
+       if (__pPreviousListener != null)
+       {
+               r =  __pMapDataControlEvent->RemoveListener(*__pPreviousListener);
+               SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "Remove listener failed.");
+                __pPreviousListener = null;
+       }
+
+       if (pListener != null)
+       {
+               r =  __pMapDataControlEvent->AddListener(*pListener);
+               if (IsFailed(r))
+               {
+                       switch (r)
+                       {
+                       case E_OBJ_ALREADY_EXIST:
+                               return E_SUCCESS;
+                       case E_INVALID_OPERATION:
+                               SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] The thread setting the listener is worker thread.");
+                               return E_SYSTEM;
+                       default:
+                               SysLogException(NID_APP, r, "[%s] Propagating to caller...", GetErrorMessage(r));
+                               return r;
+                       }
+               }
+       }
+
+       __pPreviousListener = pListener;
 
        return E_SUCCESS;
 }
@@ -435,13 +565,14 @@ _MapDataControlImpl::SetMapDataControlResponseListener(IMapDataControlResponseLi
 MapDataControl*
 _MapDataControlImpl::CreateMapDataControl(const AppId& appId, const String& providerId, const String& access)
 {
-       MapDataControl* pDc = null;
-       _MapDataControlImpl* pDcImpl = null;
+       unique_ptr<MapDataControl> pDc(new (std::nothrow) MapDataControl);
+       SysTryReturn(NID_APP, pDc != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient");
 
-       pDc = new (std::nothrow) MapDataControl;
-       SysTryReturn(NID_APP, pDc != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient");
+       _MapDataControlImpl* pDcImpl = _MapDataControlImpl::GetInstance(*pDc);
+       unique_ptr<_MapDataControlEvent> pMapDataControlEvent(new (std::nothrow) _MapDataControlEvent);
+       SysTryReturn(NID_IO, pMapDataControlEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-       pDcImpl = _MapDataControlImpl::GetInstance(*pDc);
+       pDcImpl->__pMapDataControlEvent = pMapDataControlEvent.release();
        pDcImpl->__appId = appId;
        pDcImpl->__providerId = providerId;
 
@@ -463,7 +594,7 @@ _MapDataControlImpl::CreateMapDataControl(const AppId& appId, const String& prov
                SysLog(NID_IO, "The accessibility of DataControl provider is invalid.");
        }
 
-       return pDc;
+       return pDc.release();
 }
 
 }} // Tizen::App
index c080ff6..fa34f57 100644 (file)
@@ -29,6 +29,7 @@
 #include <FBaseDataType.h>
 #include <FBaseObject.h>
 #include <FBaseString.h>
+#include <FBaseRtEvent.h>
 
 #include "FApp_AppControlManager.h"
 
@@ -78,13 +79,13 @@ private:
        static MapDataControl* CreateMapDataControl(const AppId& appId, const Tizen::Base::String& providerId,
             const Tizen::Base::String& access);
 
-       result StartMapDataControl(int type, const Tizen::Base::Collection::IList* pDataList,
-            IMapDataControlResponseListener* pListener, int* pReq);
+       result StartMapDataControl(int type, const Tizen::Base::Collection::IList* pDataList, int* pReq);
 
        Tizen::Base::String __appId;
        Tizen::Base::String __providerId;
        int __access;
-       IMapDataControlResponseListener* __pListener;
+       IMapDataControlResponseListener* __pPreviousListener;
+       Tizen::Base::Runtime::Event* __pMapDataControlEvent;
 
        friend class MapDataControl;
        friend class _AppManagerImpl;
index 0b69e45..456e436 100644 (file)
 #include <FBaseInternalTypes.h>
 #include <FBase_StringConverter.h>
 #include "FApp_NotificationManagerImpl.h"
-#include "FApp_NotificationManagerProxy.h"
 #include "FApp_AppInfo.h"
+#include "FIoFile.h"
 #include "FAppPkg_PackageManagerImpl.h"
 #include "FApp_Aul.h"
 #include "FApp_AppArg.h"
+#include "FAppPkgPackageAppInfo.h"
+#include "FAppPkg_PackageAppInfoImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::App;
 using namespace Tizen::App::Package;
+using namespace Tizen::Io;
 
 extern "C" int service_create_request(bundle *data, service_h *service);
 
@@ -71,22 +74,6 @@ ConvertNotificationResult(int error)
        }
 }
 
-ui_notification_progress_type_e
-ConvertToNotificationProgressType(int progressType)
-{
-       switch (progressType)
-       {
-       case ONGOING_ACTIVITY_TYPE_TEXT:
-               return UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE;
-       case ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE:
-               return UI_NOTIFICATION_PROGRESS_TYPE_SIZE;
-       case ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE:
-               return UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE;
-       default:
-               return UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE;
-       }
-}
-
 bool
 IsPosted(ui_notification_h handle)
 {
@@ -121,7 +108,6 @@ namespace Tizen { namespace App
 {
 
 _NotificationManagerImpl::_NotificationManagerImpl(void)
-: __pNotificationManager(null)
 {
 }
 
@@ -132,21 +118,7 @@ _NotificationManagerImpl::~_NotificationManagerImpl(void)
 result
 _NotificationManagerImpl::Construct(void)
 {
-       result r = E_SUCCESS;
-
-       __pNotificationManager = new (std::nothrow) _NotificationManagerProxy;
-       SysTryReturnResult(NID_APP, __pNotificationManager != null, E_OUT_OF_MEMORY, "__pNotificationManagerProxy creation failed.");
-
-       r = __pNotificationManager->Construct();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "__pNotificationManager->Construct() failed [%s].", GetErrorMessage(r));
-
        return E_SUCCESS;
-
-CATCH:
-       delete __pNotificationManager;
-       __pNotificationManager = null;
-
-       return r;
 }
 
 const _NotificationManagerImpl*
@@ -190,11 +162,14 @@ _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
        result r = E_SUCCESS;
        int retcode = 0;
        char* pMsg = null;
-       ui_notification_h core = NULL;
        char* pkgname = NULL;
+       char* pIcon = NULL;
        bundle* pKb = NULL;
        service_h svc = NULL;
        _AppArg arg;
+       String iconPath;
+       ui_notification_h core = NULL;
+       PackageAppInfo* pPackageAppInfo = NULL;
 
        if (!messageText.IsEmpty())
        {
@@ -210,6 +185,18 @@ _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
                int ret = ui_notification_set_content(core, pMsg);
                SysTryLog(NID_APP, ret == UI_NOTIFICATION_ERROR_NONE, "Setting notification content failure : %d.", ret);
 
+               const String& currappId = _AppInfo::GetApplicationId();
+
+               pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(currappId);
+               iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
+
+               if (!iconPath.IsEmpty() && File::IsFileExist(iconPath))
+               {
+                       pIcon = _StringConverter::CopyToCharArrayN(iconPath);
+                       r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon));
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+               }
+
                app_get_package(&pkgname);
                SysTryCatch(NID_APP, pkgname != NULL, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Cannot acquire package name for current application.");
 
@@ -236,12 +223,14 @@ _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
        }
 
 CATCH:
+       delete pPackageAppInfo;
        delete[] pMsg;
+       delete[] pIcon;
+
        if (pkgname)
        {
                free(pkgname);
        }
-
        if (core)
        {
                ui_notification_destroy(core);
@@ -257,20 +246,22 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe
 {
        result r = E_SUCCESS;
        int retcode = 0;
+       String iconPath;
        char* pMsg = null;
-       char* pIcon = NULL;
+       char* pIcon = null;
+       char* pDefaultIconPath = NULL;
        char* pName = NULL;
        ui_notification_h core = NULL;
        char buffer[256];
        bundle* pKb = NULL;
        service_h svc = NULL;
        _AppArg arg;
+       PackageAppInfo* pPackageAppInfo = null;
 
        memset(buffer, 0, 256);
 
-       bool b = _Aul::IsInstalled(appId);
-
-       SysTryReturnResult(NID_APP, b == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
+       bool inInstalled = _Aul::IsInstalled(appId);
+       SysTryReturnResult(NID_APP, inInstalled == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
 
        if (!isOngoing || !messageText.IsEmpty())
        {
@@ -288,9 +279,21 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe
 
                snprintf(buffer, 256, "%ls", appId.GetPointer());
 
-               app_manager_get_app_icon_path(buffer, &pIcon);
-               r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon));
-               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+               pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId);
+               iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
+
+               if (!iconPath.IsEmpty() && File::IsFileExist(iconPath))
+               {
+                       pIcon = _StringConverter::CopyToCharArrayN(iconPath);
+                       r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon));
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+               }
+               else
+               {
+                       app_manager_get_app_icon_path(buffer, &pDefaultIconPath);
+                       r = ConvertNotificationResult(ui_notification_set_icon(core, pDefaultIconPath));
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path  failed.", GetErrorMessage(r));
+               }
 
                app_manager_get_app_name(buffer, &pName);
                r = ConvertNotificationResult(ui_notification_set_title(core, pName));
@@ -319,18 +322,17 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe
        }
 
 CATCH:
+       delete pPackageAppInfo;
        delete[] pMsg;
-
-       if (core)
+       delete[] pIcon;
+       if (pDefaultIconPath)
        {
-               ui_notification_destroy(core);
+               free(pDefaultIconPath);
        }
-
-       if (pIcon)
+       if (core)
        {
-               free(pIcon);
+               ui_notification_destroy(core);
        }
-
        if (pName)
        {
                free(pName);
@@ -341,6 +343,45 @@ CATCH:
 
 
 result
+_NotificationManagerImpl::RemoveImpl(const char* pAppId, notification_type_e type)
+{
+       result r = E_SUCCESS;
+
+       notification_error_e err = notification_delete_all_by_type(pAppId, type);
+       switch (err)
+       {
+       case NOTIFICATION_ERROR_NONE:
+               r = E_SUCCESS;
+               break;
+
+       case NOTIFICATION_ERROR_INVALID_DATA:
+               r = E_INVALID_ARG;
+               break;
+
+       default:
+               r = E_SYSTEM;
+               break;
+       }
+
+       return r;
+}
+
+
+result
+_NotificationManagerImpl::RemoveImpl(const AppId& appId, bool isOngoing)
+{
+       const bool isValidAppId = _Aul::IsInstalled(appId);
+       SysTryReturnResult(NID_APP, isValidAppId, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
+
+       result r = E_SUCCESS;
+       notification_error_e err = NOTIFICATION_ERROR_NONE;
+       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+       const notification_type_e notiType = (isOngoing) ? NOTIFICATION_TYPE_ONGOING : NOTIFICATION_TYPE_NOTI;
+
+       return RemoveImpl(pAppId.get(), notiType);
+}
+
+result
 _NotificationManagerImpl::Notify(int badgeNumber) const
 {
        SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
@@ -521,61 +562,25 @@ _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, cons
 result
 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
 {
-       result r = E_SUCCESS;
-
-       notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
-       switch (err)
-       {
-       case NOTIFICATION_ERROR_NONE:
-               r = E_SUCCESS;
-               break;
-
-       case NOTIFICATION_ERROR_INVALID_DATA:
-               r = E_INVALID_ARG;
-               break;
-
-       default:
-               r = E_SYSTEM;
-               break;
-       }
-
-       return r;
+       return RemoveImpl(NULL, NOTIFICATION_TYPE_ONGOING);
 }
 
 result
 _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
 {
-       return __pNotificationManager->RemoveNotification(appId, true);
+       return RemoveImpl(appId, true);
 }
 
 result
 _NotificationManagerImpl::RemoveNotification(void)
 {
-       result r = E_SUCCESS;
-
-       notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
-       switch (err)
-       {
-       case NOTIFICATION_ERROR_NONE:
-               r = E_SUCCESS;
-               break;
-
-       case NOTIFICATION_ERROR_INVALID_DATA:
-               r = E_INVALID_ARG;
-               break;
-
-       default:
-               r = E_SYSTEM;
-               break;
-       }
-
-       return r;
+       return RemoveImpl(NULL, NOTIFICATION_TYPE_NOTI);
 }
 
 result
 _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId)
 {
-       return __pNotificationManager->RemoveNotification(appId,false);
+       return RemoveImpl(appId, false);
 }
 
 };
diff --git a/src/app/FApp_NotificationManagerProxy.cpp b/src/app/FApp_NotificationManagerProxy.cpp
deleted file mode 100644 (file)
index 2491d26..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// 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        FApp_NotificationManagerProxy.cpp
- * @brief      This is the implementation for the _NotificationManagerProxy.cpp class.
- */
-
-#include <new>
-#include <memory>
-
-#include <FBaseErrors.h>
-#include <FBaseSysLog.h>
-#include <FIo_IpcClient.h>
-
-#include "FApp_NotificationManagerIpcMessages.h"
-#include "FApp_NotificationManagerProxy.h"
-#include "FApp_NotificationManagerEventParamTraits.h"
-
-using namespace Tizen::Base;
-
-namespace Tizen { namespace App
-{
-
-_NotificationManagerProxy::_NotificationManagerProxy(void)
-       : __pIpcClient(null)
-{
-}
-
-_NotificationManagerProxy::~_NotificationManagerProxy(void)
-{
-}
-
-result
-_NotificationManagerProxy::Construct()
-{
-       __pIpcClient = new (std::nothrow) Tizen::Io::_IpcClient();
-       SysTryReturnResult(NID_APP, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
-
-       result r = __pIpcClient->Construct("osp.app.ipcserver.notificationmanager");
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "_IpcClient constructing failed [%s].", GetErrorMessage(r));
-
-       return E_SUCCESS;
-}
-
-result
-_NotificationManagerProxy::NotifyMessage(const AppId& appId, const NotificationMessage& notiMessage, bool Ongoing)
-{
-       SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
-
-       result response = E_SUCCESS;
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) NotificationManager_NotifyMessage(appId, notiMessage, Ongoing, &response));
-       result r = __pIpcClient->SendRequest(*pMsg.get());
-
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
-
-       return response;
-}
-
-result
-_NotificationManagerProxy::RemoveNotification(const AppId& appId, bool Ongoing)
-{
-       SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
-
-       result response = E_SUCCESS;
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) NotificationManager_RemoveNotification(appId, Ongoing, &response));
-       result r = __pIpcClient->SendRequest(*pMsg.get());
-
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
-
-       return response;
-}
-
-} } // Tizen::App
diff --git a/src/app/FApp_NotificationManagerProxy.h b/src/app/FApp_NotificationManagerProxy.h
deleted file mode 100644 (file)
index 76ce27a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// 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       FApp_NotificationManagerProxy.h
- * @brief      This is the header file of the _NotificationManagerProxy class.
- */
-
-#ifndef _FAPP_INTERNAL_NOTIFICATION_MANAGER_PROXY_H_
-#define _FAPP_INTERNAL_NOTIFICATION_MANAGER_PROXY_H_
-
-#include <FBaseObject.h>
-#include <FBaseString.h>
-#include <FAppTypes.h>
-#include <FAppNotificationManager.h>
-
-#include "FApp_Types.h"
-
-namespace Tizen { namespace Io { class _IpcClient; } }
-
-namespace Tizen { namespace App
-{
-
-class NotificationMessage;
-
-/**
- * @class       _NotificationManagerProxy
- * @brief
- * @since 2.1
- */
-class _NotificationManagerProxy
-       : public Tizen::Base::Object
-{
-public:
-       _NotificationManagerProxy(void);
-       virtual ~_NotificationManagerProxy(void);
-
-       result Construct(void);
-
-       result NotifyMessage(const AppId& appId, const NotificationMessage& message, bool Ongoing);
-       result RemoveNotification(const AppId& appId, bool Ongoing);
-
-
-private:
-       _NotificationManagerProxy(const _NotificationManagerProxy& rhs);
-
-       _NotificationManagerProxy& operator =(const _NotificationManagerProxy& rhs);
-
-private:
-       Tizen::Io::_IpcClient* __pIpcClient;
-
-}; // _NotificationManagerProxy
-
-} } // Tizen::App
-
-#endif // _FAPP_INTERNAL_NOTIFICATION_MANAGER_PROXY_H_
old mode 100644 (file)
new mode 100755 (executable)
index 0eb07de..29fd2c2
@@ -82,7 +82,7 @@ void
 _ServiceAppImpl::OnService(service_s* service, bool initial)
 {
        SysLog(NID_APP, "Service requested.");
-       char* pOperation = null;
+       char* pOperation = NULL;
        int errVal = service_get_operation(service, &pOperation);
 
        if ( (errVal == SERVICE_ERROR_NONE) && (!strcmp(pOperation, "osp.appsvc.operation.ALARM")) )
@@ -93,7 +93,7 @@ _ServiceAppImpl::OnService(service_s* service, bool initial)
                errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pAlarmId);
                if (errVal == SERVICE_ERROR_NONE)
                {
-                       int alarmId = atoi(pAlarmId);
+                       //int alarmId = atoi(pAlarmId);
 
                        String* pAlarmStr = new (std::nothrow) String(pAlarmId);
                        ArrayList alarmArg;
@@ -101,11 +101,16 @@ _ServiceAppImpl::OnService(service_s* service, bool initial)
                        __pServiceApp->OnUserEventReceivedN(HANDLER_REQUEST_ALARMID, &alarmArg);
                }
 
-               if (pAlarmId != NULL)
+               if (pAlarmId)
                {
                        free(pAlarmId);
                }
        }
+
+       if (pOperation)
+       {
+               free(pOperation);
+       }
 }
 
 void
@@ -120,7 +125,7 @@ _ServiceAppImpl::OnTerminate(void)
 
        _AppInfo::SetAppState(TERMINATING);
 
-       if (OnServiceAppImplTerminating(false) != true)
+       if (OnServiceAppImplTerminating(__pAppImpl->IsForcedTermination()) != true)
        {
                SysLog(NID_APP, "[E_SYSTEM] The Termination of application failed.");
        }
index 35d0e38..98e6208 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <typeinfo>
 #include <new>
+#include <unique_ptr.h>
 
 #include <appsvc/appsvc.h>
 
@@ -31,6 +32,7 @@
 #include <FBaseColIList.h>
 #include <FBaseColIMap.h>
 #include <FBaseColIMapEnumerator.h>
+#include <FBaseRtIEventArg.h>
 #include <FIoFile.h>
 #include <FAppSqlDataControl.h>
 #include <FAppISqlDataControlResponseListener.h>
 #include "FApp_SqlDataControlImpl.h"
 #include "FApp_AppArg.h"
 
+using namespace std;
+
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
 using namespace Tizen::App;
 using namespace Tizen::Io;
 
 namespace Tizen { namespace App
 {
 
+class _SqlDataControlEventArg
+       : public IEventArg
+{
+public:
+               _SqlDataControlEventArg(_DataControlRequestType requestType, RequestId reqId, String providerId, String dataId,
+                               _DataControlResultSetEnumerator* pResultSetEnum, long long insertRowId, bool providerResult, String* pErrorMsg)
+                       : __requestType(requestType)
+                       , __reqId(reqId)
+                       , __providerId(providerId)
+                       , __dataId(dataId)
+                       , __pResultSetEnum(pResultSetEnum)
+                       , __insertRowId(insertRowId)
+                       , __providerResult(providerResult)
+                       , __pErrorMsg(pErrorMsg)
+               {
+               }
+               ~_SqlDataControlEventArg(void)
+               {
+                       delete __pResultSetEnum;
+                       delete __pErrorMsg;
+               }
+
+               _DataControlRequestType __requestType;
+               RequestId __reqId;
+               String __providerId;
+               String __dataId;
+               _DataControlResultSetEnumerator* __pResultSetEnum;
+               long long __insertRowId;
+               bool __providerResult;
+               String* __pErrorMsg;
+};
+
+class _SqlDataControlEvent
+       : public Event
+{
+protected:
+               virtual void FireImpl(IEventListener& listener, const IEventArg& arg);
+};
+
+void
+_SqlDataControlEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       const _SqlDataControlEventArg* pArg = dynamic_cast<const _SqlDataControlEventArg*>(&arg);
+       if (pArg != null)
+       {
+               ISqlDataControlResponseListener* pListener = dynamic_cast<ISqlDataControlResponseListener*> (&listener);
+               if (pListener != null)
+               {
+                       switch (pArg->__requestType)
+                       {
+                       case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
+                               pListener->OnSqlDataControlSelectResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                               *(pArg->__pResultSetEnum), pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
+                               pListener->OnSqlDataControlInsertResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                                pArg->__insertRowId, pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
+                               pListener->OnSqlDataControlUpdateResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                               pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
+                               pListener->OnSqlDataControlDeleteResponseReceived(pArg->__reqId, pArg->__providerId, pArg->__dataId,
+                                               pArg->__providerResult, pArg->__pErrorMsg);
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
+}
+
 // private
 _SqlDataControlImpl::_SqlDataControlImpl(void)
        : __appId(L"")
        , __providerId(L"")
        , __access(_DATACONTROL_ACCESS_UNDEFINED)
-       , __pListener(null)
+       , __pPreviousListener(null)
+       , __pSqlDataControlEvent(null)
 {
 }
 
 _SqlDataControlImpl::~_SqlDataControlImpl(void)
 {
+       delete __pSqlDataControlEvent;
 }
 
 _SqlDataControlImpl*
@@ -77,8 +157,7 @@ _SqlDataControlImpl::GetInstance(const SqlDataControl& dc)
 }
 
 result
-_SqlDataControlImpl::StartSqlDataControl(int type, const IList* pDataList, ISqlDataControlResponseListener* pListener,
-                                                                                int* pReq)
+_SqlDataControlImpl::StartSqlDataControl(int type, const IList* pDataList, int* pReq)
 {
        result r = E_SUCCESS;
 
@@ -90,12 +169,10 @@ _SqlDataControlImpl::StartSqlDataControl(int type, const IList* pDataList, ISqlD
        _AppControlManager* pAppManagerImpl = _AppControlManager::GetInstance();
        int req = -1;
 
-       if (__pListener)
+       if (__pSqlDataControlEvent)
        {
-               SysLog(NID_APP, "listener address: 0x%x", (void*) __pListener);
-
                // reqId is system-wide id because the bundle is system-wide.
-               _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, SqlDataControlCallback, __pListener, -1);
+               _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, SqlDataControlCallback, __pSqlDataControlEvent, -1);
                req = reqObj.GetRequestNumber();
 
                r = pAppManagerImpl->LaunchApp(__appId, pArg, req);
@@ -109,21 +186,10 @@ _SqlDataControlImpl::StartSqlDataControl(int type, const IList* pDataList, ISqlD
        else
        {
                r = pAppManagerImpl->LaunchApp(__appId, pArg);
-       }
-
-       {
-               // registers to server
-               _IAppManager* pMgr = _AppManagerProxy::GetService();
-
-               // actually register, not launch
-               if (pMgr)
-               {
-                       pMgr->LaunchApplication(__appId, null, req);
-               }
+               delete pArg;
        }
 
 CATCH:
-
        return r;
 }
 
@@ -196,7 +262,8 @@ _SqlDataControlImpl::Select(const String& dataId, const IList* pColumnList, cons
 
        pArgList->Add(*(new String(Integer::ToString(countPerPage)))); // list(6): count per page
 
-       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_QUERY, pArgList, __pListener, &id);
+       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_QUERY, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
@@ -221,6 +288,7 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
        String* pReqId = null;
        String* pProviderId = null;
        String* pDataId = null;
+       String* pErrorMessage = null;
        String* pErrorMsg = null;
        String* pTmpPath = null;
        String* pInsertRowId = null;
@@ -231,6 +299,7 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
        bool providerResult = true;
        bundle* origBundle = null;
        bundle* resBundle = null;
+       _SqlDataControlEventArg* pEventArg = null;
        result r = E_SUCCESS;
 
        SysTryReturnResult(NID_APP, pResArg != null, E_INVALID_ARG, "Empty result callback.");
@@ -239,9 +308,10 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
        resBundle = pResArg->GetBundle();
        if (resBundle)
        {
-               ISqlDataControlResponseListener* pListener = static_cast< ISqlDataControlResponseListener* >(data);
+               //ISqlDataControlResponseListener* pListener = static_cast< ISqlDataControlResponseListener* >(data);
+       _SqlDataControlEvent* pSqlDataControlEvent = static_cast< _SqlDataControlEvent* >(data);
 
-               if (pListener != null && typeid(pListener) == typeid(ISqlDataControlResponseListener*))
+               if (pSqlDataControlEvent != null && typeid(pSqlDataControlEvent) == typeid(_SqlDataControlEvent*))
                {
                        const char* p = null;
 
@@ -254,8 +324,11 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                        Integer::Parse(*pResult, providerRes);
                        providerResult = static_cast< bool >(providerRes);
 
-                       pErrorMsg = dynamic_cast< String* >(pResultList->GetAt(1));
-                       SysTryCatch(NID_APP, pErrorMsg, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
+                       pErrorMessage = dynamic_cast< String* >(pResultList->GetAt(1));
+                       SysTryCatch(NID_APP, pErrorMessage, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
+                       pErrorMsg = new (std::nothrow) String(*pErrorMessage);
+                       SysTryCatch(NID_APP, pErrorMsg, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                        origBundle = pArg->GetBundle();
 
@@ -264,21 +337,21 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                        SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
                        pRequestType = new (std::nothrow) String(p);
                        SysTryCatch(NID_APP, pRequestType, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                       "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
                        Integer::Parse(*pRequestType, requestType);
 
                        p = appsvc_get_data(origBundle, OSP_K_REQUEST_ID);
                        SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
                        pReqId = new (std::nothrow) String(p);
                        SysTryCatch(NID_APP, pReqId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                       "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
                        Integer::Parse(*pReqId, reqId);
 
                        p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_PROVIDER);
                        SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
                        pProviderId = new (std::nothrow) String(p);
                        SysTryCatch(NID_APP, pProviderId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                       "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                       "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                        pOrigList = _AppArg::GetListN(origBundle, OSP_K_ARG);
                        SysTryCatch(NID_APP, pOrigList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle");
@@ -294,12 +367,17 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                        {
                                pResultSetEnum = new (std::nothrow) _DataControlResultSetEnumerator;
                                SysTryCatch(NID_APP, pResultSetEnum, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                               "[E_OUT_OF_MEMORY] The memory was insufficient.");
+                                               "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                                if (providerResult == true)
                                {
                                        pTmpPath = dynamic_cast< String* >(pResultList->GetAt(2)); // result list[2]
-                                       SysTryCatch(NID_APP, pTmpPath, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result");
+                                       if (pTmpPath == null)
+                                       {
+                                               SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
+                                               delete pResultSetEnum;
+                                               goto CATCH;
+                                       }
 
                                        SysLog(NID_APP, "tempPath: %ls", pTmpPath->GetPointer());
                                        if (pTmpPath->Equals(L"NoResultSet", true) == false) // Result set exists
@@ -308,8 +386,10 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                                        }
                                }
 
-                               pListener->OnSqlDataControlSelectResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, *pResultSetEnum, providerResult, pErrorMsg);
+                               pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_QUERY, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, pResultSetEnum, -1, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pSqlDataControlEvent->Fire(*pEventArg);
 
                                if (pTmpPath)
                                {
@@ -317,7 +397,6 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                                        SysTryLog(NID_APP, !IsFailed(r), "Failed to remove temp file for result set: %ls", pTmpPath->GetPointer());
                                }
 
-                               delete pResultSetEnum;
                                break;
                        }
                        case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
@@ -331,18 +410,28 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
                                        LongLong::Parse(*pInsertRowId, insertRowId);
                                }
 
-                               pListener->OnSqlDataControlInsertResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, insertRowId, providerResult, pErrorMsg);
+                               pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_INSERT, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, null, insertRowId, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pSqlDataControlEvent->Fire(*pEventArg);
                                break;
                        }
                        case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
-                               pListener->OnSqlDataControlUpdateResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, providerResult, pErrorMsg);
+                       {
+                               pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, null, -1, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pSqlDataControlEvent->Fire(*pEventArg);
                                break;
+                       }
                        case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
-                               pListener->OnSqlDataControlDeleteResponseReceived(static_cast <RequestId>(reqId), *pProviderId,
-                                               *pDataId, providerResult, pErrorMsg);
+                       {
+                               pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_DELETE, static_cast <RequestId>(reqId),
+                                               *pProviderId, *pDataId, null, -1, providerResult, pErrorMsg);
+                               SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                               pSqlDataControlEvent->Fire(*pEventArg);
                                break;
+                       }
                        default:
                                break;
                        }
@@ -362,8 +451,6 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg*
        return E_SUCCESS;
 
 CATCH:
-       delete pResultSetEnum;
-
        if (pResultList)
        {
                pResultList->RemoveAll(true);
@@ -427,7 +514,8 @@ _SqlDataControlImpl::Insert(const Tizen::Base::String& dataId, const Tizen::Base
                i++;
        }
 
-       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_INSERT, pArgList, __pListener, &id);
+       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_INSERT, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
@@ -497,7 +585,8 @@ _SqlDataControlImpl::Update(const Tizen::Base::String& dataId, const Tizen::Base
                pArgList->Add(*(new String(L"NULL")));
        }
 
-       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE, pArgList, __pListener, &id);
+       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
@@ -539,12 +628,15 @@ _SqlDataControlImpl::Delete(const Tizen::Base::String& dataId, const Tizen::Base
                pArgList->Add(*(new String(L"NULL")));
        }
 
-       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_DELETE, pArgList, __pListener, &id);
+       r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_DELETE, pArgList, &id);
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
        reqId = static_cast< RequestId >(id);
 
        SysLog(NID_APP, "[DC_CALLER] dataId: %ls, pWhere: 0x%x, reqId: %d", dataId.GetPointer(), pWhere, reqId);
 
+       // fall through
+CATCH:
        pArgList->RemoveAll(true);
        delete pArgList;
 
@@ -554,7 +646,35 @@ _SqlDataControlImpl::Delete(const Tizen::Base::String& dataId, const Tizen::Base
 result
 _SqlDataControlImpl::SetSqlDataControlResponseListener(ISqlDataControlResponseListener* pListener)
 {
-       __pListener = pListener;
+       result r = E_SUCCESS;
+
+       if (__pPreviousListener != null)
+       {
+               r =  __pSqlDataControlEvent->RemoveListener(*__pPreviousListener);
+               SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "Remove listener failed.");
+                __pPreviousListener = null;
+       }
+
+       if (pListener != null)
+       {
+               r =  __pSqlDataControlEvent->AddListener(*pListener);
+               if (IsFailed(r))
+               {
+                       switch (r)
+                       {
+                       case E_OBJ_ALREADY_EXIST:
+                               return E_SUCCESS;
+                       case E_INVALID_OPERATION:
+                               SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] The thread setting the listener is worker thread.");
+                               return E_SYSTEM;
+                       default:
+                               SysLogException(NID_APP, r, "[%s] Propagating to caller...", GetErrorMessage(r));
+                               return r;
+                       }
+               }
+       }
+
+       __pPreviousListener = pListener;
 
        return E_SUCCESS;
 }
@@ -563,15 +683,16 @@ _SqlDataControlImpl::SetSqlDataControlResponseListener(ISqlDataControlResponseLi
 SqlDataControl*
 _SqlDataControlImpl::CreateSqlDataControl(const String& appId, const String& providerId, const String& access)
 {
-       SqlDataControl* pDc = null;
-       _SqlDataControlImpl* pDcImpl = null;
-
-       pDc = new (std::nothrow) SqlDataControl;
-       SysTryReturn(NID_APP, pDc != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient");
+       unique_ptr<SqlDataControl> pDc(new (std::nothrow) SqlDataControl);
+       SysTryReturn(NID_APP, pDc != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient");
 
-       pDcImpl = _SqlDataControlImpl::GetInstance(*pDc);
+       _SqlDataControlImpl* pDcImpl = _SqlDataControlImpl::GetInstance(*pDc);
        pDcImpl->__appId = appId;
        pDcImpl->__providerId = providerId;
+       unique_ptr<_SqlDataControlEvent> pSqlDataControlEvent(new (std::nothrow) _SqlDataControlEvent);
+       SysTryReturn(NID_IO, pSqlDataControlEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pDcImpl->__pSqlDataControlEvent = pSqlDataControlEvent.release();
 
        if (access == L"readonly")
        {
@@ -591,7 +712,7 @@ _SqlDataControlImpl::CreateSqlDataControl(const String& appId, const String& pro
                SysLog(NID_IO, "The accessibility of DataControl provider is invalid.");
        }
 
-       return pDc;
+       return pDc.release();
 }
 
 }} // Tizen::App
index 4134208..6439fa7 100644 (file)
@@ -28,6 +28,7 @@
 #include <FBaseDataType.h>
 #include <FBaseObject.h>
 #include <FBaseString.h>
+#include <FBaseRtEvent.h>
 
 #include "FApp_AppManagerImpl.h"
 
@@ -78,14 +79,14 @@ private:
        static SqlDataControl* CreateSqlDataControl(const Tizen::Base::String& appId, const Tizen::Base::String& providerId,
             const Tizen::Base::String& access);
 
-       result StartSqlDataControl(int type, const Tizen::Base::Collection::IList* pDataList,
-            ISqlDataControlResponseListener* pListener, int* pReq);
+       result StartSqlDataControl(int type, const Tizen::Base::Collection::IList* pDataList, int* pReq);
 
 private:
        Tizen::Base::String __appId;
        Tizen::Base::String __providerId;
        int __access;
-       ISqlDataControlResponseListener* __pListener;
+       ISqlDataControlResponseListener* __pPreviousListener;
+       Tizen::Base::Runtime::Event* __pSqlDataControlEvent;
 
        friend class SqlDataControl;
        friend class _AppManagerImpl;
diff --git a/src/app/inc/FAppNotificationMessage.h b/src/app/inc/FAppNotificationMessage.h
deleted file mode 100644 (file)
index 1406802..0000000
+++ /dev/null
@@ -1,340 +0,0 @@
-//
-// 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               FAppNotificationMessage.h
- * @brief              This is the header file for the %NotificationMessage class.
- *
- * This header file contains the declarations of the %NotificationMessage class.
- */
-
-#ifndef _FAPP_NOTIFICATION_MESSAGE_H_
-#define _FAPP_NOTIFICATION_MESSAGE_H_
-
-#include <FBase.h>
-#include <FAppTypes.h>
-#include <FAppNotificationManager.h>
-
-namespace Tizen { namespace App
-{
-
-/*
- * @class              NotificationMessage
- * @brief              This class provides methods for handling a notification message.
- *
- * @since 2.1
- *
- * @final      This class is not intended for extension.
- *
- * The %NotificationMessage class provides methods for handling a notification message. The %NotificationMessage instance corresponds to each notification item
- * in the notification area after it is posted. %NotificationMessage is either bound to the application or not and the associated
- * application is launched by selecting the bound %NotificationMessage in the notification area.
- *
- * For more information about the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/notifications.htm">Notifications</a>.
- *
- * @see        Tizen::App::NotificationManager
- */
-class _OSP_EXPORT_ NotificationMessage
-       : public Tizen::Base::Object
-{
-
-public:
-       /**
-        * Initializes this instance of %NotificationMessage with the specified appBinding.
-        *
-        * @since 2.1
-        *
-        * @param[in]   appBinding      Set to @c true to bind %NotificationMessage to the destination application, @n
-        *                                                      else @c false
-        * @remarks     Selecting the posted notification in the notification area leads to launch of the associated application
-        *                      if %NotificationMessage is bound to the destination application.
-        */
-       NotificationMessage(bool appBinding = true);
-
-       /**
-        * Copying of objects using this copy constructor is allowed.
-        *
-        * @since 2.1
-        *
-        * @param[in]   rhs     An instance of %NotificationMessage
-        */
-       NotificationMessage(const NotificationMessage& rhs);
-
-       /**
-        * Copying of objects using this copy assignment operator is allowed.
-        *
-        * @since 2.1
-        *
-        * @param[in]   rhs     An instance of %NotificationMessage
-        */
-       NotificationMessage& operator =(const NotificationMessage& rhs);
-
-       /**
-        * This destructor overrides Tizen::Base::Object::~Object().
-        *
-        * @since 2.1
-        */
-       virtual ~NotificationMessage(void);
-
-       /**
-        * Checks whether the specified instance of %NotificationMessage equals the current instance.
-        *
-        * @since 2.1
-        *
-        * @return      @c true if the specified instance equals the current instance, @n
-        *              else @c false
-        * @param[in]   rhs     An instance of %NotificationMessage
-        * @remarks     The method returns @c false if the specified object is not %NotificationMessage.
-        */
-       virtual bool Equals(const Object& rhs) const;
-
-       /**
-        * Gets the hash value of the current instance.
-        *
-        * @since 2.1
-        *
-        * @return      The hash value of the current instance
-        */
-       virtual int GetHashCode(void) const;
-
-       /**
-        * Gets the badge number of the notification message.
-        *
-        * @since 2.1
-        *
-        * @return              The badge number value
-        * @remarks     If the badge number is not set, then this method returns @c -1.
-        */
-       int GetBadgeNumber(void) const;
-
-       /**
-        * Sets the badge number of the notification message. @n
-        * %NotificationMessage has either badge number or badge number offset.
-        * If the badge number is set using %SetBadgeNumber(), then previous badge offset value is set to @c 0.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   value   The badge number value
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The specified @c value is less than @c 0 or greater than App::MAX_NOTIFICATION_BADGE_NUMBER.
-        */
-       result SetBadgeNumber(int value);
-
-       /**
-        * Gets the badge number offset of the notification message.
-        *
-        * @since 2.1
-        *
-        * @return              The badge offset value
-        */
-       int GetBadgeOffset(void) const;
-
-       /**
-        * Sets the badge number offset of the notification message. @n
-        * %NotificationMessage has either badge number or badge number offset.
-        * If the badge number offset is set using %SetBadgeOffset(), then previous badge number value is set to @c -1 and ignored. @n
-        *
-        * When posting the notification message, badge offset value is added to the current badge number,
-        * which can be acquired by NotificationManager::GetBadgeNumber(). Setting badge offset to @c 0
-        * means explicitly specifying not to change the current badge value with the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   value   The badge number value
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The absolute value of the specified @c value is greater than App::MAX_NOTIFICATION_BADGE_NUMBER.
-        * @remarks     Even though this method does not return E_INVALID_ARG, it does not guarantee the success of NotificationManager::Notify().
-        * @see SetBadgeNumber(), NotificationManager::GetBadgeNumber(), NotificationManager::Notify()
-        */
-       result SetBadgeOffset(int value);
-
-       /**
-        * Gets the alert text of the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      The alert text
-        */
-       Tizen::Base::String GetAlertText(void) const;
-
-       /**
-        * Sets an alert text of the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   text    The alert text
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The specified @c text is empty or the length of @c text is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH.
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        */
-       result SetAlertText(const Tizen::Base::String& text);
-
-       /**
-        * Gets the application message of the notification message. @n
-        * This message is delivered to the application as launch arguments.
-        *
-        * @since 2.1
-        *
-        * @return The message for application
-        */
-       Tizen::Base::String GetAppMessage(void) const;
-
-       /**
-        * Sets the application message of the notification message. @n
-        * This message is delivered to the application as launch arguments.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   appMessage              The message for the application
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The length of @c appMessage is greater than App::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
-        * @exception   E_INVALID_OPERATION     This instance is not bound to the application.
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        * @remarks     This method returns E_INVALID_OPERATION if %NotificationMessage instance is not bound to the application.
-        */
-       result SetAppMessage(const Tizen::Base::String& appMessage);
-
-       /**
-        * Gets the title text of the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      The title text
-        */
-       Tizen::Base::String GetTitleText(void) const;
-
-       /**
-        * Sets the title text of the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   title   The title text
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The length of @c title is greater than App::MAX_NOTIFICATION_TITLE_LENGTH.
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        */
-       result SetTitleText(const Tizen::Base::String& title);
-
-       /**
-        * Gets the file path of the icon image for the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      The file path of the icon image
-        */
-       Tizen::Base::String GetIconFilePath(void) const;
-
-       /**
-        * Sets the file path of the icon image for the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   iconPath        The file path of the icon image
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The specified path is invalid.
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        */
-       result SetIconFilePath(const Tizen::Base::String& iconPath);
-
-       /**
-        * Gets the file path of the sound file to be played for the notification message.
-        *
-        * @since 2.1
-        *
-        * @return      The file path of the sound file
-        */
-       Tizen::Base::String GetSoundFilePath(void) const;
-
-       /**
-        * Sets the file path of the sound file to be played for the notification message. @n
-        * The sound file should be wave file format.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   soundPath       The file path of the sound file
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The specified path is invalid.
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
-        * @remarks     If the format of the sound file is not valid, then the sound file is not played properly when the notification message is shown.
-        */
-       result SetSoundFilePath(const Tizen::Base::String& soundPath);
-
-       /**
-        * Gets the notification type for the ongoing activity notification.
-        *
-        * @since 2.1
-        *
-        * @return      The ongoing activity notification type
-        * @remarks     This information is only meaningful when the %NotificationMessage instance is delivered to the NotificationManager::NotifyOngoingActivity() method.
-        * @see NotificationManager::NotifyOngoingActivity(), SetOngoingActivityType()
-        */
-       OngoingActivityType GetOngoingActivityType(void) const;
-
-       /**
-        * Sets the notification type for the ongoing activity notification.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   type    The ongoing activity notification type
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_STATE The current progress value is not compatible to the specified @c type.
-        * @remarks     This information is only meaningful when the %NotificationMessage instance is delivered to the NotificationManager::NotifyOngoingActivity() method.
-        * @see NotificationManager::NotifyOngoingActivity(), SetOngoingActivityProgressValue()
-        */
-       result SetOngoingActivityType(OngoingActivityType type = ONGOING_ACTIVITY_TYPE_TEXT);
-
-       /**
-        * Gets the progress value for the ongoing activity notification.
-        *
-        * @since 2.1
-        *
-        * @return      The progress value
-        */
-       int GetOngoingActivityProgressValue(void) const;
-
-       /**
-        * Sets the progress value with the specified value.
-        *
-        * @since 2.1
-        *
-        * @return      An error code
-        * @param[in]   value   The progress value
-        * @exception   E_SUCCESS       The method is successful.
-        * @exception   E_INVALID_ARG   The specified @c value is less than @c 0, or
-     *                                                                 the specified @c value does not lie between @c 0 and @c 100 for App::ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE.
-        * @exception   E_INVALID_STATE This instance is in an invalid state. @n
-        *                                                              OngoingActivityType must be either App::ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE or App::ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE.
-        */
-       result SetOngoingActivityProgressValue(int value);
-
-private:
-       class _NotificationMessageImpl * __pNotificationMessageImpl;
-
-       friend class _NotificationMessageImpl;
-}; // NotificationMessage
-
-} } // Tizen::App
-
-#endif // _FAPP_NOTIFICATION_MESSAGE_H_
index 0da0521..1163337 100755 (executable)
 #include <FBaseInternalTypes.h>
 #include <FBaseColHashMapT.h>
 
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+} }
+
 namespace Tizen { namespace App { namespace Package
 {
 
@@ -64,6 +69,9 @@ public:
        const Tizen::Base::String& GetAppNotificationIconPath(void) const;
        result SetAppNotificationIconPath(const Tizen::Base::String& notificationIconPath);
 
+       Tizen::Graphics::Bitmap* GetAppMenuIconN(void) const;
+
+       Tizen::Base::Collection::IMap* GetAppMetadataListN(void) const;
        Tizen::Base::Collection::ArrayList* GetAppCategoryListN(void) const;
 
        bool IsMenuIconVisible(void) const;
@@ -72,6 +80,8 @@ public:
        bool IsMainApp(void) const;
        result SetMainApp(bool mainApp);
 
+       result AddCategory(Tizen::Base::String* pCategory);
+
        static _PackageAppInfoImpl* GetInstance(PackageAppInfo* pPackageAppInfo);
 
        result Construct(const AppId& appId);
@@ -91,24 +101,24 @@ public:
 
        Tizen::Base::Collection::ArrayList* GetLaunchConditionListN(void) const;
        Tizen::Base::Collection::ArrayList* GetLaunchConditionList(void) const;
-       result AddLaunchCondition(const Tizen::App::Package::_LaunchConditionInfoImpl& launchCondition);
+       result AddLaunchCondition(const _LaunchConditionInfoImpl& launchCondition);
 
        Tizen::Base::Collection::ArrayList* GetNotificationListN(void) const;
        Tizen::Base::Collection::ArrayList* GetNotificationList(void) const;
-       result AddNotification(const Tizen::App::Package::_NotificationInfoImpl& notification);
+       result AddNotification(const _NotificationInfoImpl& notification);
 
        Tizen::Base::Collection::ArrayList* GetAppFeatureListN(void) const;
        Tizen::Base::Collection::ArrayList* GetAppFeatureList(void) const;
        Tizen::Base::Collection::HashMapT<Tizen::Base::String, _AppFeatureInfoImpl*>* GetAppFeatureMapN(void) const;
-       result AddAppFeature(const Tizen::App::Package::_AppFeatureInfoImpl& appFeature);
+       result AddAppFeature(const _AppFeatureInfoImpl& appFeature);
 
        Tizen::Base::Collection::ArrayList* GetDataControlListN(void) const;
        Tizen::Base::Collection::ArrayList* GetDataControlList(void) const;
-       result AddDataControl(Tizen::App::Package::_DataControlInfoImpl* pDataControl);
+       result AddDataControl(_DataControlInfoImpl* pDataControl);
 
        Tizen::Base::Collection::ArrayList* GetAppControlListN(void) const;
        Tizen::Base::Collection::ArrayList* GetAppControlList(void) const;
-       result AddAppControl(Tizen::App::Package::_AppControlInfoImpl* pAppControl);
+       result AddAppControl(_AppControlInfoImpl* pAppControl);
 
        const Tizen::Base::String& GetPackageName(void) const;
        result SetPackageName(const Tizen::Base::String& packageName);
@@ -156,6 +166,7 @@ private:
 
        bool __launchingIconVisible;
        bool __mainApp;
+       bool __fromDatabase;
 
        Tizen::Base::String __name;
        Tizen::Base::String __type;
@@ -166,6 +177,7 @@ private:
        Tizen::Base::Collection::ArrayList* __pAppFeatureImplList;
        Tizen::Base::Collection::ArrayList* __pDataControlImplList;
        Tizen::Base::Collection::ArrayList* __pAppControlImplList;
+       Tizen::Base::Collection::ArrayList* __pAppCategoryList;
 
        Tizen::Base::String __mainmenuIcon;
        Tizen::Base::String __settingIcon;
index ef9c287..d9c703e 100755 (executable)
@@ -92,11 +92,16 @@ public:
        const PackageId& GetStoreClientId(void) const;
        result SetStoreClientId(const PackageId& packageId);
 
-       Tizen::Base::Collection::ArrayList* GetPackageAppInfoListN(void) const;
-       Tizen::App::Package::PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
+       Tizen::Base::Collection::ArrayList* GetPackageAppInfoListN(void);
+       PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
 
        static int PackageAppInfoListHandler(const pkgmgrinfo_appinfo_h handle, void* pUser_data);
 
+       Tizen::Base::Collection::ArrayList* GetPrivilegeListN(void) const;
+       result AddPrivilege(const Tizen::Base::String& privilege);
+
+       result AddPackageAppInfo(const PackageAppInfo& appInfo);
+
        // to be reviewed
        _PackageInfoImpl(void);
        virtual ~_PackageInfoImpl(void);
@@ -142,9 +147,9 @@ public:
 
        Tizen::Base::Collection::ArrayList* GetAppInfoListN(void) const;
        Tizen::Base::Collection::ArrayList* GetAppInfoList(void);
-       result AddAppInfo(const Tizen::App::Package::_PackageAppInfoImpl& appInfoImpl);
+       result AddAppInfo(const _PackageAppInfoImpl& appInfoImpl);
 
-       result GetPrivileges(Tizen::Base::String& privileges, Tizen::Base::String& hmacPrivileges);
+       result GetPrivileges(Tizen::Base::String& privileges, Tizen::Base::String& hmacPrivileges, Tizen::Base::Collection::ArrayList& privilegeList);
        result GetPrivilegesValue(Tizen::Base::String& privileges, Tizen::Base::String& hmacPrivileges) const;
        result SetPrivilegesValue(const Tizen::Base::String& privileges, const Tizen::Base::String& hmacPrivileges);
 
@@ -202,7 +207,9 @@ private:
        AppId __mainAppId;
        PackageId __storeClientId;
 
+       Tizen::Base::Collection::ArrayList* __pPrivilegeList;
        Tizen::Base::Collection::ArrayList* __pAppInfoImplList;
+       Tizen::Base::Collection::ArrayList* __pPackageAppInfoList;
        Tizen::Base::String __privileges;
        Tizen::Base::String __hmacPrivileges;
 
@@ -215,6 +222,7 @@ private:
        bool __downloaded;
        bool __iconAvailable;
        bool __externalStorage;
+       bool __fromDatabase;
 
        PackageType __packageType;
 
index 9c2c830..4870977 100755 (executable)
@@ -57,7 +57,7 @@ class IPackageInstallationResponseListener;
 class IPackageUninstallationResponseListener;
 
 static const int MAX_DATABASE_RETRY_COUNT = 30;
-extern const wchar_t PACKAGE_DATABASE_FILE_NAME[];
+static const wchar_t PACKAGE_DATABASE_FILE_NAME[] = L"/opt/usr/dbspace/.app-package.db";
 
 enum PackageStorageType
 {
@@ -110,28 +110,33 @@ public:
        result AddEventListener(IPackageInstallationEventListener* pListener, int priority = 2);
        result RemoveEventListener(IPackageInstallationEventListener* pListener);
 
-       Tizen::App::Package::PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
-       Tizen::App::Package::PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
+       PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
+       PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
        Tizen::Base::Collection::IList* GetPackageInfoListN(void) const;
 
        bool IsPackageInstalled(const PackageId& packageId) const;
 
-       result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, Tizen::App::Package::IPackageInstallationResponseListener* pListener);
-       result UninstallPackage(const PackageId& packageId, Tizen::App::Package::IPackageUninstallationResponseListener* pListener);
+       result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
+       result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
 
        result MoveToExternalStorage(const PackageId& packageId);
        result MoveToInternalStorage(const PackageId& packageId);
        
        static _PackageManagerImpl* GetInstance(void);
 
+       PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const;
+       Tizen::Base::Collection::IList* GetPackageInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap) const;
+       Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
+       Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
+
        void SendPackageEvent(PackageType type, const PackageId& packageId, const char* eventKey, const char* eventValue);
 
        Tizen::Base::String* GetAppIdOfDataControlN(const Tizen::Base::String& providerId);
 
        result CreatePackageTables(void);
 
-       Tizen::App::Package::PackageInfo* GetPackageInfoN(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId) const;
-       Tizen::App::Package::PackageInfo* GetPackageInfoN(PackageType packageType, const Tizen::Base::String& packageName) const;
+       PackageInfo* GetPackageInfoN(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId) const;
+       PackageInfo* GetPackageInfoN(PackageType packageType, const Tizen::Base::String& packageName) const;
 
        static int PackageInfoEventHandler(const pkgmgrinfo_pkginfo_h handle, void* pUser_data);
 
@@ -139,7 +144,7 @@ public:
        Tizen::Base::Collection::IList* GetDataControlInfoN(const Tizen::Base::String& providerId, const Tizen::Base::String& type) const;
        Tizen::Base::Collection::IMap* GetUiThemeListN(const PackageId& packageId) const;
 
-       result RegisterPackageInfo(Tizen::App::Package::_PackageInfoImpl& pkgInfoImpl);
+       result RegisterPackageInfo(_PackageInfoImpl& pkgInfoImpl);
        result UnregisterPackageInfo(const PackageId& packageId);
        Tizen::Base::Collection::ArrayList* GetPackageAppInfoImplListN(const PackageId& packageId) const;
        Tizen::Base::Collection::ArrayList* GetPackageAppFeatureListN(const PackageId& packageId, const Tizen::Base::String& executableName) const;
@@ -160,7 +165,7 @@ private:
        _PackageManagerImpl(void);
        virtual ~_PackageManagerImpl(void);
 
-       result GetAppInfo(int uniqueId, Tizen::App::Package::_PackageAppInfoImpl& appInfo) const;
+       result GetAppInfo(int uniqueId, _PackageAppInfoImpl& appInfo) const;
 
        result RegisterAppInfoList(int id, Tizen::Base::Collection::ArrayList* pList);
        result RegisterLaunchConditionList(int id, Tizen::Base::Collection::ArrayList* pList);
diff --git a/src/app/inc/FAppPkg_PackageParser.h b/src/app/inc/FAppPkg_PackageParser.h
new file mode 100755 (executable)
index 0000000..62a2cd5
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// 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       FAppPkg_PackageParser.h
+ * @brief      This is the header file for the _PackageParser class.
+*/
+
+#ifndef _FAPP_PKG_INTERNAL_PACKAGE_PARSER_H_
+#define _FAPP_PKG_INTERNAL_PACKAGE_PARSER_H_
+
+#include <libxml/xmlstring.h>
+
+namespace Tizen { namespace App { namespace Package
+{
+
+class _PackageInfoImpl;
+class _PackageAppInfoImpl;
+
+class _PackageXmlAttribute
+{
+public:
+       _PackageXmlAttribute(void);
+       virtual ~_PackageXmlAttribute(void);
+
+       bool Construct(const char* pName, const char* pValue);
+
+       char* Find(const char* pName);
+       bool Add(const char* pName, const char* pValue);
+
+private:
+       _PackageXmlAttribute(const _PackageXmlAttribute& value);
+       _PackageXmlAttribute& operator =(const _PackageXmlAttribute& source);
+
+       char* __pName;
+       char* __pValue;
+       _PackageXmlAttribute* __pNext;
+
+}; // _PackageXmlAttribute
+
+
+class _PackageXmlHandler
+{
+public:
+       _PackageXmlHandler(void);
+       virtual ~_PackageXmlHandler(void);
+
+       virtual bool OnStartDocument(void);
+       virtual bool OnEndDocument(void);
+       virtual bool OnStartElement(const char* pName);
+       virtual bool OnEndElement(const char* pName);
+       virtual bool OnCharacters(const char* pCharacters);
+
+       void SetError(void);
+       bool GetError(void);
+
+       char* GetElementName(void);
+       _PackageXmlAttribute* GetAttribute(void);
+       Tizen::Base::Collection::IEnumerator* GetElementEnumeratorN(void);
+       int GetElementCount(void);
+
+protected:
+       bool ParseNormalizedDocument(const char* pFilepath);
+       int Normalize(const char* pBuf, int size, char* pNormalizedBuf);
+
+       bool SetElementName(const char* pElementName);
+       void DeleteElement(void);
+
+       bool SetCharacters(const char* pCharacter);
+       char* GetCharacters(void);
+       void DeleteCharacters(void);
+
+       void SetAttribute(_PackageXmlAttribute* pAttr);
+       void DeleteAttribute(void);
+
+private:
+       _PackageXmlHandler(const _PackageXmlHandler& value);
+       _PackageXmlHandler& operator =(const _PackageXmlHandler& source);
+
+       static void StartDocument(void* pCtx);
+       static void EndDocument(void* pCtx);
+
+       static void StartElement(void* pCtx, const xmlChar* pName, const xmlChar** ppAtts);
+       static void EndElement(void* pCtx, const xmlChar* pName);
+       static void Characters(void* pCtx, const xmlChar* pCh, int len);
+
+       _PackageXmlAttribute* __pAttr;
+       char* __pElementName;
+       char* __pCharacters;
+       bool __error;
+
+       Tizen::Base::Collection::Stack __elementStack;
+
+}; // _PackageXmlHandler
+
+
+class _PackageParser
+       : public _PackageXmlHandler
+{
+public:
+       _PackageParser(void);
+       virtual ~_PackageParser(void);
+
+       bool Construct(PackageInfo* pPackageInfo);
+       bool Parse(const Tizen::Base::String& packagepath);
+
+private:
+       _PackageParser(const _PackageParser& value);
+       _PackageParser& operator =(const _PackageParser& source);
+
+       virtual bool OnStartElement(const char* pName);
+       virtual bool OnEndElement(const char* pName);
+       virtual bool OnCharacters(const char* pCharacters);
+
+       bool OnUiAppStartElement(void);
+       bool OnServiceAppStartElement(void);
+       bool OnIconsStartElement(void);
+
+       bool OnUiAppEndElement(void);
+       bool OnServiceAppEndElement(void);
+       bool OnDisplayNamesEndElement(void);
+
+       bool OnIdValue(const char* pCharacters);
+       bool OnVersionValue(const char* pCharacters);
+       bool OnAuthorValue(const char* pCharacters);
+       bool OnUrlValue(const char* pCharacters);
+       bool OnPrivilegeValue(const char* pCharacters);
+       bool OnIconValue(const char* pCharacters);
+       bool OnDisplayNameValue(const char* pCharacters);
+       bool OnDescriptionValue(const char* pCharacters);
+       bool OnCategoryValue(const char* pCharacters);
+
+       bool ParseAppAttribute(_PackageXmlAttribute* pAttr, bool isUiApp);
+
+private:
+       _PackageInfoImpl* __pPackageInfoImpl;
+       PackageAppInfo* __pAppInfo;
+
+       char* __pDefaultIconType;
+       bool __isDefaultName;
+}; // _PackageParser
+
+} } } // Tizen::App::Package
+
+#endif // _FAPP_PKG_INTERNAL_PACKAGE_PARSER_H_
old mode 100644 (file)
new mode 100755 (executable)
index 2340fdd..f834edd
@@ -67,6 +67,7 @@ enum _DataControlRequestType
 #define OSP_K_APPCONTROL_INTERNAL_OPERATION "__OSP_APPCONTROL_INTERNAL_INTERNAL_OPERATION__"
 #define OSP_K_DATACONTROL_PROVIDER      "__OSP_DATACONTROL_PROVIDER__"
 #define OSP_K_DATACONTROL_REQUEST_TYPE  "__OSP_DATACONTROL_REQUEST_TYPE__"
+#define OSP_K_CALLEE_APPID     "__OSP_CALLEE_APPID__"
 
 /**
  * @class       _AppArg
@@ -101,6 +102,7 @@ public:
        result Construct(bundle* b);
 
        result ConstructForAppLaunchCondition(const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pList);
+       result ConstructForAppLaunchCondition(const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pList, const Tizen::Base::Collection::IMap* pMap);
 
        Tizen::Base::Collection::ArrayList* GetArgListN(int num) const;
 
@@ -129,6 +131,8 @@ public:
 
        AppId GetCalleeAppId(void) const;
 
+       void SaveCalleeAppId(void);
+
        void Print() const
        {
                Print(__pBundle);
index fc51ce9..b7d7dd3 100755 (executable)
@@ -44,13 +44,6 @@ class IAppControlEventListener;
 class IAppControlResponseListener;
 class _AppArg;
 
-enum _AppControlType
-{
-       _APPCONTROL_TYPE_NONE = 0,
-       _APPCONTROL_TYPE_NATIVE = 2,
-       _APPCONTROL_TYPE_OSP = 3,
-};
-
 enum _AppControlProperty
 {
        _APPCONTROL_PROPERTY_NONE = 0x0,
index adce2a7..c53627a 100755 (executable)
@@ -254,7 +254,7 @@ public:
        result LaunchPkg(_AppMessageImpl& msg, const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data);
 
        int Launch(_AppMessageImpl& msg, const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data);
-       result LaunchAppWithCondition(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String& condition, Tizen::Base::Collection::IList* pArgs);
+       result LaunchAppWithCondition(const AppId& appId, const Tizen::Base::String& condition, Tizen::Base::Collection::IList* pArgs);
 
        result SendAppControlStartResponse(int req, const char* pValue, const char* pOp);
 
@@ -280,6 +280,7 @@ private:
        _RequestManagerT<_LaunchInfo> __launchManager;
        _RequestManagerT<_InProcessInfo> __inAppManager;
        _RequestManagerT<_ResultInfo> __resultManager;
+       Tizen::Base::Collection::ArrayListT<void*> __listenerList;
 
        //friend class AppManager;
        friend class _AppControlImpl;
old mode 100644 (file)
new mode 100755 (executable)
index 2797212..d21f076
@@ -276,6 +276,8 @@ public:
 
        void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
 
+       bool IsForcedTermination(void);
+
        static void OnPowerOffNotiReceived(void* pData);
 
 private:
@@ -456,6 +458,8 @@ private:
 
        AppRequestHandlerType __pLegacyRequestHandler;
 
+       bool __forcedTermination;
+
        static bool __isTerminationRequested;
 
        friend class App;
index 8efffdc..7f32f30 100644 (file)
@@ -94,27 +94,20 @@ public:
         *
         * @return      The application Id
         */
-       static const AppId& GetAppId(void);
+       static AppId GetApplicationId(void);
 
        /**
         * Gets the application's Id.
         *
         * @return      The application Id
         */
-       static const AppId& GetApplicationId(void);
-
-       /**
-        * Gets the application's Id.
-        *
-        * @return      The application Id
-        */
-       static const AppId& GetPackageId(void);
+       static AppId GetPackageId(void);
 
        /**
         * Gets the application executable name.
         *
         */
-       static const Tizen::Base::String& GetAppExecutableName(void);
+       static Tizen::Base::String GetAppExecutableName(void);
 
        /**
         * Checkes whether the application is submode or not.
@@ -166,7 +159,7 @@ public:
         *
         * @return      The current type of the application
         */
-       static _AppType GetAppType(void);
+       static int GetAppType(void);
 
        /**
         * Sets the current type of the application.
@@ -239,7 +232,7 @@ private:
 
 private:
        AppState __appState;
-       _AppType __appType;
+       int __appType;
        int __appRootDirFd;
        int __appHandlerType;
        int __parentWindowHandle;
index 724dfd2..6d74e1f 100644 (file)
@@ -116,18 +116,15 @@ private:
 
         * @see Tizen::App::AppManager::RegisterAppLaunch()
         */
-       result Construct(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String& conditionString, const Base::Collection::IList* pArgs, AppManager::LaunchOption option , const Tizen::Base::String* pRegSectionName = null);
+       result Construct(const AppId& appId, const Tizen::Base::String& conditionString, const Base::Collection::IList* pArgs, AppManager::LaunchOption option , const Tizen::Base::String* pRegSectionName = null);
 
 private:
        _AppLaunchCondition(const _AppLaunchCondition& operation);
        _AppLaunchCondition& operator =(const _AppLaunchCondition& operation);
 
-       Tizen::Base::String GetExecutableName(void) const;
-
 private:
        // app launch info
        AppId __appId;
-       Tizen::Base::String __executableName;
        Tizen::Base::Collection::ArrayList *__pArguments;
        AppManager::LaunchOption __option;
 
old mode 100644 (file)
new mode 100755 (executable)
index 89795aa..9e9b68b
@@ -120,9 +120,10 @@ protected:
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_INVALID_STATE         The event handler isn't initialized yet.
         * @param[in]   operation               The conditional operation registered.
+        * @param[in]   pExtraData              The extra data being delivered in which elements are a pair of key and value of Tizen::Base::String.
         * @see _IAppLaunchConditionEventListener::OnAppLaunchConditionMet
         */
-       result Fire(const _AppLaunchCondition& condition);
+       result Fire(const _AppLaunchCondition& condition, Tizen::Base::Collection::IMap* pExtraData = null);
 
 private:
        _IAppLaunchConditionEventListener* __pEventListener;
index 3e12526..865a775 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef _FAPP_INTERNAL_APP_MANAGER_IMPL_H_
 #define _FAPP_INTERNAL_APP_MANAGER_IMPL_H_
 
+#include <appfw/app_context.h>
+
 #include <FOspConfig.h>
 #include <FBaseColIListT.h>
 #include <FBaseColIList.h>
@@ -56,6 +58,7 @@ namespace Tizen { namespace App
 class _IAppManager;
 class _ConditionManagerProxy;
 class _IAppManagerEventListener;
+class _IAppEventListener;
 class _AppManagerEventArg;
 
 class _OSP_EXPORT_ _AppManagerImpl
@@ -190,12 +193,11 @@ public:
         *
         * @return      An error code
         * @param[in]   appId                           The application's ID to be executed
-        * @param[in]   pExecutableName         The executable name
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_SYSTEM                        A system error has occurred.
         * @exception   E_OBJ_NOT_FOUND         The application is not installed or not running.
         */
-       result TerminateApplication(const AppId& appId, const Tizen::Base::String* pExecutableName);
+       result TerminateApplication(const AppId& appId);
 
        /**
         * Terminates all the applications in a package.
@@ -214,9 +216,8 @@ public:
         * @return      @c true if the application is running, @n
         *          else @c false
         * @param[in]   appId               The installed application ID
-        * @param[in]   pExecutableName         The executable name
         */
-       bool IsRunning(const AppId& appId, const Tizen::Base::String* pExecutableName) const;
+       bool IsRunning(const AppId& appId) const;
 
        /**
         * Returns a list of running applications at the time of invocation.
@@ -253,7 +254,7 @@ public:
         * @exception  E_MAX_EXCEEDED           The size of @c pArguments has exceeded the maximum limit.
         * @exception  E_SYSTEM                         A system error has occurred.
         */
-       result RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pArguments, AppManager::LaunchOption option);
+       result RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pArguments, AppManager::LaunchOption option);
 
        /**
         * Unregisters the launch condition.
@@ -268,7 +269,7 @@ public:
         * @exception  E_SYSTEM                         A system error has occurred.
         * @exception  E_OUT_OF_MEMORY          The memory is insufficient.
         */
-       result UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String* pCondition);
+       result UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String* pCondition);
 
        /**
         * Checks whether a previously registered launch condition is present for the specified application.
@@ -283,7 +284,7 @@ public:
         * @exception  E_SYSTEM                         A system error has occurred.
         * @exception  E_OUT_OF_MEMORY          The memory is insufficient.
         */
-       bool IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String& executableName, const Tizen::Base::String* pCondition = null);
+       bool IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String* pCondition = null);
 
        /**
         * Sets a checkpoint event listener. @n
@@ -321,14 +322,16 @@ public:
      */
        result RemoveEventListener(_IAppManagerEventListener& listener);
 
+       result AddAppEventListener(_IAppEventListener& listener);
+
+       result RemoveAppEventListener(_IAppEventListener& listener);
+
        virtual result OnServiceEventReceived(const int clientId, const _AppManagerEventArg& arg);
 
        virtual result OnTerminateApplicationRequested(int clientId);
 
        static void SetAppManagerService(_IAppManager* pAppManager );
 
-       static result ExtractValues(AppId inAppId, AppId& outAppId, Tizen::Base::String& outExecutableName);
-
        _OSP_LOCAL_ Tizen::Base::Runtime::_LibraryImpl& GetUiLibraryImpl(void);
 
        static Tizen::Base::Runtime::_LibraryImpl& GetEcoreXLibraryImpl(void);
@@ -362,6 +365,8 @@ private:
 
        int GetProcessId(unsigned int window);
 
+       static void AppEventCallback(app_context_h app_context, app_context_event_e event, void* pData);
+
 private:
        _ConditionManagerProxy* __pConditionManager;
        int     __eventListenerCount;
@@ -369,6 +374,7 @@ private:
        Tizen::Base::Runtime::_LibraryImpl* __pX11Library;
        static Tizen::Base::Runtime::_LibraryImpl* __pEcoreXLibrary;
        static Tizen::Base::Runtime::_LibraryImpl* __pEcoreLibrary;
+       Tizen::Base::Collection::LinkedListT<_IAppEventListener*>* __pAppEventList;
        _AppManagerEvent __appManagerEvent;
        Tizen::Base::Collection::LinkedListT<IActiveAppEventListener*> __activeAppEventListenerList;
 
index b14817a..25442a6 100644 (file)
@@ -32,9 +32,9 @@
 
 #define IPC_MESSAGE_START AppManagerServiceStart
 
-IPC_MESSAGE_CONTROL3(AppManager_LaunchApplication, Tizen::App::AppId, Tizen::Base::String, int)
-IPC_SYNC_MESSAGE_CONTROL2_1(AppManager_TerminateApplication, Tizen::App::AppId, Tizen::Base::String, result)
-IPC_SYNC_MESSAGE_CONTROL2_1(AppManager_IsRunning, Tizen::App::AppId, Tizen::Base::String, bool)
+IPC_MESSAGE_CONTROL2(AppManager_LaunchApplication, Tizen::App::AppId, int)
+IPC_SYNC_MESSAGE_CONTROL1_1(AppManager_TerminateApplication, Tizen::App::AppId, result)
+IPC_SYNC_MESSAGE_CONTROL1_1(AppManager_IsRunning, Tizen::App::AppId, bool)
 IPC_SYNC_MESSAGE_CONTROL0_2(AppManager_GetRunningAppList, Tizen::Base::Collection::ArrayList, result)
 IPC_MESSAGE_CONTROL4(AppManager_RegisterApplication, Tizen::App::AppId, Tizen::Base::String, int, int)
 IPC_MESSAGE_CONTROL1(AppManager_UnregisterApplication, int)
index 72ffa22..9d36165 100644 (file)
@@ -49,22 +49,22 @@ class _OSP_EXPORT_ _AppManagerProxy
 public:
        virtual ~_AppManagerProxy(void);
 
-       virtual result LaunchApplication(const AppId& appId, const Tizen::Base::String& executableName, int req);
+       virtual result LaunchApplication(const AppId& appId, int req);
 
-       virtual result TerminateApplication(const AppId& appId, const Tizen::Base::String& executableName);
+       virtual result TerminateApplication(const AppId& appId);
 
-       virtual bool IsRunning(const AppId& appId, const Tizen::Base::String& executableName);
+       virtual bool IsRunning(const AppId& appId);
 
        virtual result GetRunningAppList(Tizen::Base::Collection::ArrayList* pList);
 
        // for platform
        virtual result InitEventListener(_IAppManagerServiceEventListener* pListener);
 
-       virtual result AddEventListener(int clientId );//, _IAppManagerServiceEventListener* pListener);
+       virtual result AddEventListener(int clientId );
 
-       virtual result RemoveEventListener(int clientId );//, _IAppManagerServiceEventListener* pListener);
+       virtual result RemoveEventListener(int clientId );
 
-       virtual result RegisterApplication(const AppId& appId, const Tizen::Base::String& executableName, _AppType appType, int pid);
+       virtual result RegisterApplication(const Tizen::Base::String& packageId, const Tizen::Base::String& executableName, _AppType appType, int pid);
 
        virtual result UnregisterApplication(int pid);
 
index 42f7a54..f44f4b9 100644 (file)
@@ -42,6 +42,10 @@ namespace Tizen { namespace App
 class _OSP_EXPORT_ _Aul
 {
 public:
+       static result GetConvertedResult(const int aul_ret, const char* pFunctionName);
+
+       static result TerminateApplication(const AppId& appId);
+
        static result TerminateApplicationByPid(int pid);
 
        static result SendResult(bundle* b, appsvc_result_val res);
@@ -93,7 +97,7 @@ public:
                /**
                 * Makes desktop file path from appId (retrives appName using _PackageMamagerImpl)
                 */
-               static result MakePath(const AppId& appId, const Tizen::Base::String* pExeName, char* path, int size);
+               static result MakePath(const AppId& appId, char* path, int size);
 
                /**
                 * Update service value of input buffer with specified value
index 7431c87..aec287b 100644 (file)
@@ -28,6 +28,6 @@
 
 #define IPC_MESSAGE_START ConditionManagerServiceStart
 
-IPC_SYNC_MESSAGE_CONTROL5_1(ConditionManager_RegisterAppLaunch, Tizen::App::AppId, Tizen::Base::String, Tizen::Base::String, Tizen::Base::Collection::ArrayList, int, result)
-IPC_SYNC_MESSAGE_CONTROL3_1(ConditionManager_UnregisterAppLaunch, Tizen::App::AppId, Tizen::Base::String, Tizen::Base::String, result)
-IPC_SYNC_MESSAGE_CONTROL3_2(ConditionManager_IsAppLaunchRegistered, Tizen::App::AppId, Tizen::Base::String, Tizen::Base::String, bool, result)
+IPC_SYNC_MESSAGE_CONTROL4_1(ConditionManager_RegisterAppLaunch, Tizen::App::AppId, Tizen::Base::String, Tizen::Base::Collection::ArrayList, int, result)
+IPC_SYNC_MESSAGE_CONTROL2_1(ConditionManager_UnregisterAppLaunch, Tizen::App::AppId, Tizen::Base::String, result)
+IPC_SYNC_MESSAGE_CONTROL2_2(ConditionManager_IsAppLaunchRegistered, Tizen::App::AppId, Tizen::Base::String, bool, result)
diff --git a/src/app/inc/FApp_IAppEventListener.h b/src/app/inc/FApp_IAppEventListener.h
new file mode 100644 (file)
index 0000000..c60d996
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// 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       FApp_IAppEventListener.h
+ * @brief      This is the header file for _IAppEventListener class.
+ */
+
+#ifndef _FAPP_INTERNAL_IAPP_EVENT_LISTENER_H_
+#define _FAPP_INTERNAL_IAPP_EVENT_LISTENER_H_
+
+#include <FAppTypes.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace App {
+
+/**
+* @interface _IAppEventListener
+* @brief This is a tagging interface that all event listeners must implement.
+*
+* The event listener can listen when the specific event is fired. The event listener
+* has several methods, and each method will be called when the specific event is fired.
+*
+*/
+class _IAppEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_IAppEventListener() {}
+
+       /**
+        * This method will be called when the application is launched.
+        */
+       virtual void OnApplicationLaunched(const AppId& appId, int reserved) = 0;
+
+       /**
+        * This method will be called when the application is terminated.
+        */
+       virtual void OnApplicationTerminated(const AppId& appId, int reserved) = 0;
+
+}; // _IAppEventListener
+
+}} //Tizen::App
+
+#endif // _FAPP_INTERNAL_IAPP_EVENT_LISTENER_H_
old mode 100644 (file)
new mode 100755 (executable)
index c556181..077fe55
@@ -48,10 +48,12 @@ public:
         * Called when an app launch condition meets.
         *
         * @since 2.1
-        * @param[in]   The operation   related conditional operation, which contains current context.
-        * @see                 _AppLaunchConditionHandlerBase::Fire
+        * @param[in]   operation       The operation related conditional operation, which contains current context.
+        * @param[in]   pExtraData      The extra data being delivered in which elements are a pair of key and value of Tizen::Base::String.
+        * @see                 _AppLaunchConditionHandlerBase::Fire(const _AppLaunchCondition& operation)
         */
-       virtual void OnAppLaunchConditionMet(const _AppLaunchCondition& operation) = 0 ;
+       virtual void OnAppLaunchConditionMet(const _AppLaunchCondition& operation, Tizen::Base::Collection::IMap* pExtraData = null) = 0 ;
+
 }; //_IAppLaunchConditionEventListener
 
 
index 5ada042..f1c6504 100644 (file)
@@ -40,11 +40,11 @@ class _IAppManager
 public:
        virtual ~_IAppManager() {}
 
-       virtual result LaunchApplication(const AppId& appId, const Tizen::Base::String& executableName, int req) = 0;
-       virtual result TerminateApplication(const AppId& appId, const Tizen::Base::String& executableName) = 0;
-       virtual bool IsRunning(const AppId& appId, const Tizen::Base::String& executableName) = 0;
+       virtual result LaunchApplication(const AppId& appId, int req) = 0;
+       virtual result TerminateApplication(const AppId& appId) = 0;
+       virtual bool IsRunning(const AppId& appId) = 0;
        virtual result GetRunningAppList(Tizen::Base::Collection::ArrayList* pArray) = 0;
-       virtual result RegisterApplication(const AppId& appId, const Tizen::Base::String& executableName, _AppType appType, int pid) = 0;
+       virtual result RegisterApplication(const Tizen::Base::String& packageId, const Tizen::Base::String& executableName, _AppType appType, int pid) = 0;
        virtual result UnregisterApplication(int pid) = 0;
 
        virtual result InitEventListener(_IAppManagerServiceEventListener* pListener) = 0;
index 8a7d6c8..8aa7612 100644 (file)
@@ -1,52 +1,51 @@
-//\r
-// Open Service Platform\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//     http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-/**\r
- * @file       FApp_IAppResourceBitmap.h\r
- * @brief      This is the header file of the _IAppResourceBitmap class.\r
- */\r
-\r
-#ifndef _FAPP_INTERNAL_IAPP_RESOURCE_BITMAP_H_\r
-#define _FAPP_INTERNAL_IAPP_RESOURCE_BITMAP_H_\r
-\r
-#include <FGrpBitmapCommon.h>\r
-\r
-namespace Tizen { namespace Graphics { class Bitmap; } }\r
-\r
-namespace Tizen { namespace Base\r
-{\r
-class String;\r
-}}//Tizen::Base\r
-\r
-namespace Tizen { namespace App\r
-{\r
-\r
-class _IAppResourceBitmap\r
-{\r
-public:\r
-       /**\r
-       * This is the destructor for this class.\r
-       */\r
-       virtual ~_IAppResourceBitmap(void) {};\r
-\r
-       virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const = 0;\r
-\r
-}; // _IAppResourceBitmap\r
-\r
-}} // Tizen::App\r
-\r
-#endif // _FAPP_INTERNAL_IAPP_RESOURCE_BITMAP_H_\r
+//
+// 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       FApp_IAppResourceBitmap.h
+ * @brief      This is the header file of the _IAppResourceBitmap class.
+ */
+
+#ifndef _FAPP_INTERNAL_IAPP_RESOURCE_BITMAP_H_
+#define _FAPP_INTERNAL_IAPP_RESOURCE_BITMAP_H_
+
+#include <FGrpBitmapCommon.h>
+
+namespace Tizen { namespace Graphics { class Bitmap; } }
+
+namespace Tizen { namespace Base
+{
+class String;
+}}//Tizen::Base
+
+namespace Tizen { namespace App
+{
+
+class _IAppResourceBitmap
+{
+public:
+       /**
+       * This is the destructor for this class.
+       */
+       virtual ~_IAppResourceBitmap(void) {};
+
+       virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const = 0;
+}; // _IAppResourceBitmap
+
+}} // Tizen::App
+
+#endif // _FAPP_INTERNAL_IAPP_RESOURCE_BITMAP_H_
diff --git a/src/app/inc/FApp_NotificationManagerEventParamTraits.h b/src/app/inc/FApp_NotificationManagerEventParamTraits.h
deleted file mode 100644 (file)
index 557c465..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// 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               FApp_NotificationManagerEventParamTraits.h
- * @brief              This is the header file for NotificationManagerEvent param traits.
- */
-
-#ifndef _FAPP_INTERNAL_NOTIFICATIONMANAGER_EVENT_ARG_PARAM_TRAITS_H_
-#define _FAPP_INTERNAL_NOTIFICATIONMANAGER_EVENT_ARG_PARAM_TRAITS_H_
-
-#include "FBaseString.h"
-#include "FBaseColIList.h"
-#include "FBaseColArrayList.h"
-#include "FIo_IpcCommonDataTypes.h"
-
-#include "base/tuple.h"
-#include "ipc/ipc_param_traits.h"
-
-#include "FAppNotificationMessage.h"
-
-
-namespace IPC
-{
-template <>
-struct ParamTraits<Tizen::App::NotificationMessage>
-{
-       typedef Tizen::App::NotificationMessage param_type;
-
-       static void Write(Message* m, const param_type& p)
-       {
-               WriteParam(m, p.GetAlertText());
-               WriteParam(m, p.GetAppMessage());
-               WriteParam(m, p.GetTitleText());
-               WriteParam(m, p.GetIconFilePath());
-               WriteParam(m, p.GetSoundFilePath());
-
-               m->WriteInt(p.GetBadgeNumber());
-               m->WriteInt(p.GetBadgeOffset());
-               m->WriteInt((int)p.GetOngoingActivityType());
-               m->WriteInt(p.GetOngoingActivityProgressValue());
-       }
-
-       static bool Read(const Message* m, void** iter, param_type* r)
-       {
-               Tizen::Base::String alertText;
-               Tizen::Base::String appMessage;
-               Tizen::Base::String titleText;
-               Tizen::Base::String iconFilePath;
-               Tizen::Base::String soundFilePath;
-
-               int badgeNo = -1;
-               int badgeOffset = 0;
-               int progressValue = -1;
-               int activityType = Tizen::App::ONGOING_ACTIVITY_TYPE_TEXT;
-
-               if (!ReadParam(m, iter, &alertText))
-               {
-                       return false;
-               }
-               if (!ReadParam(m, iter, &appMessage))
-               {
-                       return false;
-               }
-               if (!ReadParam(m, iter, &titleText))
-               {
-                       return false;
-               }
-               if (!ReadParam(m, iter, &iconFilePath))
-               {
-                       return false;
-               }
-               if (!ReadParam(m, iter, &soundFilePath))
-               {
-                       return false;
-               }
-               m->ReadInt(iter, &badgeNo);
-               m->ReadInt(iter, &badgeOffset);
-               m->ReadInt(iter, &progressValue);
-               m->ReadInt(iter, &activityType);
-
-               Tizen::App::NotificationMessage notimessage;
-               notimessage.SetAlertText(alertText);
-               notimessage.SetAppMessage(appMessage);
-               notimessage.SetTitleText(titleText);
-               notimessage.SetIconFilePath(iconFilePath);
-               notimessage.SetSoundFilePath(soundFilePath);
-
-               notimessage.SetBadgeNumber(badgeNo);
-               notimessage.SetBadgeOffset(badgeOffset);
-               notimessage.SetOngoingActivityProgressValue(progressValue);
-               notimessage.SetOngoingActivityType((Tizen::App::OngoingActivityType)activityType);
-
-               *r = notimessage;
-
-               return true;
-       }
-       static void Log(const param_type& p, std::string* l)
-       {
-       }
-
-};
-}
-
-#endif //_FAPP_INTERNAL_NOTIFICATIONMANAGER_EVENT_ARG_PARAM_TRAITS_H_
index 00c2312..1de7264 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef _FAPP_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_
 #define _FAPP_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_
 
+#include <notification/notification_type.h>
+
 #include <FBaseObject.h>
 #include <FAppTypes.h>
 #include <FOspConfig.h>
@@ -31,10 +33,8 @@ namespace Tizen { namespace App
 {
 
 class NotificationManager;
-class _NotificationManagerProxy;
 
 class _OSP_EXPORT_ _NotificationManagerImpl
-       : public Tizen::Base::Object
 {
 
 public:
@@ -436,12 +436,15 @@ private:
 
        inline result OngoingImpl(const AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const;
 
+       result RemoveImpl(const AppId& appId, bool isOngoing);
+
+       result RemoveImpl(const char* pAppId, notification_type_e type);
+
        _NotificationManagerImpl(const _NotificationManagerImpl& rhs);
 
        _NotificationManagerImpl& operator =(const _NotificationManagerImpl& rhs);
 
 private:
-       _NotificationManagerProxy* __pNotificationManager;
 };     //_NotificationManagerImpl
 
 } } // Tizen::App
diff --git a/src/app/inc/FApp_NotificationManagerIpcMessages.h b/src/app/inc/FApp_NotificationManagerIpcMessages.h
deleted file mode 100644 (file)
index 96cedef..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// 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        FApp_NotificationManagerIpcMessages.h
- * @brief      This is the header file for the NotificationManager Ipc message types.
- */
-
-#include <FAppTypes.h>
-#include <FAppNotificationMessage.h>
-
-#include "ipc/ipc_message_macros.h"
-#include "FIo_IpcCommonParamTraits.h"
-#include "FIo_IpcMessageStart.h"
-#include "FApp_NotificationManagerEventParamTraits.h"
-
-#define IPC_MESSAGE_START NotificationManagerServiceStart
-
-IPC_SYNC_MESSAGE_CONTROL3_1(NotificationManager_NotifyMessage, Tizen::App::AppId, Tizen::App::NotificationMessage, bool, result)
-IPC_SYNC_MESSAGE_CONTROL2_1(NotificationManager_RemoveNotification, Tizen::App::AppId, bool, result)
-
old mode 100755 (executable)
new mode 100644 (file)
index 7f91010..cf9f2f2
@@ -92,28 +92,6 @@ _DeleteCollectionMapValue(Tizen::Base::Collection::IMultiMapT<KeyType, ValueType
 namespace Tizen { namespace Base
 {
 
-template<>
-class ComparerT<String>
-: public virtual Tizen::Base::Collection::IComparerT<String>
-, public Object
-{
-public:
-       ComparerT(void) {}
-
-       virtual ~ComparerT(void) {}
-
-       virtual result Compare(const String& obj1, const String& obj2, int& cmp) const
-       {
-               cmp = String::Compare(obj1, obj2);
-               return E_SUCCESS;
-       }
-
-private:
-       ComparerT(const ComparerT& rhs);
-
-       ComparerT& operator =(const ComparerT& rhs);
-};
-
 namespace Collection
 {
 
index a3114af..c6e9569 100755 (executable)
 #include <FAppPkgPackageAppInfo.h>
 
 #include <FBaseSysLog.h>
+#include <FGrpBitmapCommon.h>
 #include <FSec_AccessController.h>
 #include "FAppPkg_PackageAppInfoImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
 using namespace Tizen::Security;
 
 namespace Tizen { namespace App { namespace Package
@@ -67,34 +69,31 @@ PackageAppInfo::GetAppDisplayName(void) const
 String
 PackageAppInfo::GetAppMenuIconPath(void) const
 {
-       result r = E_SUCCESS;
-
-       r = _AccessController::CheckUserPrivilege(_PRV_PACKAGESETTING);
-       SysTryReturn(NID_APP, r == E_SUCCESS, L"", E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
        return __pPackageAppInfoImpl->GetAppMenuIconPath();
 }
 
 String
 PackageAppInfo::GetAppSettingIconPath(void) const
 {
-       result r = E_SUCCESS;
-
-       r = _AccessController::CheckUserPrivilege(_PRV_PACKAGESETTING);
-       SysTryReturn(NID_APP, r == E_SUCCESS, L"", E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
        return __pPackageAppInfoImpl->GetAppSettingIconPath();
 }
 
 String
 PackageAppInfo::GetAppNotificationIconPath(void) const
 {
-       result r = E_SUCCESS;
+       return __pPackageAppInfoImpl->GetAppNotificationIconPath();
+}
 
-       r = _AccessController::CheckUserPrivilege(_PRV_PACKAGESETTING);
-       SysTryReturn(NID_APP, r == E_SUCCESS, L"", E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+Bitmap*
+PackageAppInfo::GetAppMenuIconN(void) const
+{
+       return __pPackageAppInfoImpl->GetAppMenuIconN();
+}
 
-       return __pPackageAppInfoImpl->GetAppNotificationIconPath();
+IMap*
+PackageAppInfo::GetAppMetadataListN(void) const
+{
+       return __pPackageAppInfoImpl->GetAppMetadataListN();
 }
 
 IList*
index 6cef015..bf2dfdc 100755 (executable)
@@ -159,4 +159,13 @@ PackageInfo::GetType(void) const
        return __pPackageInfoImpl->GetType();
 }
 
+IList*
+PackageInfo::GetPrivilegeListN(void) const
+{
+       //result r = _AccessController::CheckUserPrivilege(_PRV_PACKAGESETTING);
+       //SysTryReturn(NID_APP, r == E_SUCCESS, PACKAGE_TYPE_TPK, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       return __pPackageInfoImpl->GetPrivilegeListN();
+}
+
 }}} // Tizen::App::Package
diff --git a/src/app/package/FAppPkgPackageLicenseManager.cpp b/src/app/package/FAppPkgPackageLicenseManager.cpp
new file mode 100644 (file)
index 0000000..6d64196
--- /dev/null
@@ -0,0 +1,129 @@
+//
+// 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       FAppPkgPackageLicenseManager.cpp
+ * @brief      This is the implementation for the PackageLicenseManager class.
+ */
+#include <FBaseErrorDefine.h>
+#include <FBase_StringConverter.h>
+#include <string.h>
+#include <FSec_AccessController.h>
+#include <FAppPkgPackageLicenseManager.h>
+#include <FBaseSysLog.h>
+
+#include <drm-oem-intel.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace App { namespace Package
+{
+
+PackageLicenseManager::PackageLicenseManager(void)
+{
+}
+
+PackageLicenseManager::~PackageLicenseManager(void)
+{
+}
+
+result
+PackageLicenseManager::GenerateDrmLicenseRequest(const Tizen::Base::String& licenseRequestInfo, Tizen::Base::String& licenseRequest, Tizen::Base::String& licenseUrl)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PACKAGELICENSEMANAGER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+
+       return r;
+}
+
+result 
+PackageLicenseManager::SaveDrmLicense(const Tizen::Base::String& rightObject)
+{
+       result r = E_SUCCESS;
+       char*   pRo = null;
+       int     ret = 0;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PACKAGELICENSEMANAGER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+
+       pRo = _StringConverter::CopyToCharArrayN(rightObject);
+       SysAssertf(pRo != null, "[PackageLicenseManager] pRo is null");
+
+       ret = drm_oem_intel_install_license(pRo, strlen(pRo));
+
+       if(ret == 1)
+       {
+               SysLog(NID_APP, "SaveDrmLicense() called, ro successfully saved.");
+       }
+       else
+       {
+               SysLog(NID_APP, "SaveDrmLicense() called, failed.");
+               r = E_INVALID_DATA;
+       }
+
+CATCH:
+       delete [] pRo;
+       return r;
+}
+
+Tizen::Base::TimeSpan 
+PackageLicenseManager::GetRemainingTimeUntilDrmExpiration(const Tizen::App::PackageId& pkgId)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PACKAGELICENSEMANAGER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+
+       TimeSpan temp(9999,9999,9999);
+
+       return temp;
+}
+
+result 
+PackageLicenseManager::SaveLicenseInfoForPackage(const Tizen::Base::String& licenseInfo)
+{
+       result r = E_SUCCESS;
+       char*   pCek = null;
+       int ret = 0;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PACKAGELICENSEMANAGER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+
+       pCek = _StringConverter::CopyToCharArrayN(licenseInfo);
+       SysAssertf(pCek !=null, "[PackageLicenseManager] pCek is null");
+
+       ret = drm_oem_intel_install_cek(pCek, strlen(pCek));
+
+       if(ret == 1)
+       {
+               SysLog(NID_APP, "SaveLicenseInfoForApp() called, ro successfully saved.");
+       }
+       else
+       {
+               SysLog(NID_APP, "SaveLicenseInfoForApp() called, failed.");
+               r = E_INVALID_DATA;
+       }
+
+CATCH:
+       delete [] pCek;
+       return r;
+}
+
+}}} // Tizen::App::Package
index fb7e9db..f762709 100755 (executable)
@@ -184,6 +184,50 @@ PackageManager::MoveToInternalStorage(const PackageId& packageId)
        return __pPackageManagerImpl->MoveToInternalStorage(packageId);
 }
 
+PackageInfo*
+PackageManager::GetPackageInfoFromFileN(const String& packagePath) const
+{
+       SysAssertf(__pPackageManagerImpl != null, "Not yet constructed. GetInstance() should be called before use.");
+
+       //result r = _AccessController::CheckUserPrivilege(_PRV_PACKAGEINFO);
+       //SysTryReturn(NID_APP, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       return __pPackageManagerImpl->GetPackageInfoFromFileN(packagePath);
+}
+
+IList*
+PackageManager::GetPackageInfoListN(const IMap& packageFilterMap) const
+{
+       SysAssertf(__pPackageManagerImpl != null, "Not yet constructed. GetInstance() should be called before use.");
+
+       //result r = _AccessController::CheckUserPrivilege(_PRV_PACKAGEINFO);
+       //SysTryReturn(NID_APP, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       return __pPackageManagerImpl->GetPackageInfoListN(packageFilterMap);
+}
+
+IList*
+PackageManager::GetPackageAppInfoListN(const IMap& packageAppFilterMap) const
+{
+       SysAssertf(__pPackageManagerImpl != null, "Not yet constructed. GetInstance() should be called before use.");
+
+       //result r = _AccessController::CheckUserPrivilege(_PRV_PACKAGEINFO);
+       //SysTryReturn(NID_APP, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       return __pPackageManagerImpl->GetPackageAppInfoListN(packageAppFilterMap);
+}
+
+IList*
+PackageManager::GetPackageAppInfoListN(const IMap& packageFilterMap, const IMap& packageAppFilterMap) const
+{
+       SysAssertf(__pPackageManagerImpl != null, "Not yet constructed. GetInstance() should be called before use.");
+
+       //result r = _AccessController::CheckUserPrivilege(_PRV_PACKAGEINFO);
+       //SysTryReturn(NID_APP, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       return __pPackageManagerImpl->GetPackageAppInfoListN(packageFilterMap, packageAppFilterMap);
+}
+
 PackageManager*
 PackageManager::GetInstance(void)
 {
index 9d77809..d5284f2 100755 (executable)
@@ -39,6 +39,7 @@
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
 using namespace Tizen::Io;
 
 namespace Tizen { namespace App { namespace Package
@@ -122,30 +123,54 @@ _PackageAppInfoImpl::SetAppNotificationIconPath(const String& notificationIconPa
        return E_SUCCESS;
 }
 
+Bitmap*
+_PackageAppInfoImpl::GetAppMenuIconN(void) const
+{
+       SysTryReturn(NID_APP, __appIconPath.IsEmpty() == false, null, E_FILE_NOT_FOUND, "appIconPath() is empty.");
+
+       return null;
+}
+
+IMap*
+_PackageAppInfoImpl::GetAppMetadataListN(void) const
+{
+       return null;
+}
+
 ArrayList*
 _PackageAppInfoImpl::GetAppCategoryListN(void) const
 {
-       SysTryReturn(NID_APP, __pAppInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __pAppInfoHandle is null.");
-
-       result r = E_SUCCESS;
-       int res = PMINFO_R_OK;
        ArrayList* pList = null;
 
-       pList = new (std::nothrow) ArrayList();
-       SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
-       pList->Construct();
-
-       res = pkgmgrinfo_appinfo_foreach_category(__pAppInfoHandle, CategoryHandler, pList);
-       if (res != PMINFO_R_OK)
+       if (__fromDatabase)
        {
-               SysLog(NID_APP, "pkgmgrinfo_appinfo_foreach_category() is failed. result = [%d]", res);
-               r = E_SYSTEM;
+               SysTryReturn(NID_APP, __pAppInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __pAppInfoHandle is null.");
+
+               result r = E_SUCCESS;
+               int res = PMINFO_R_OK;
+
+               pList = new (std::nothrow) ArrayList();
+               SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
+               pList->Construct();
+
+               res = pkgmgrinfo_appinfo_foreach_category(__pAppInfoHandle, CategoryHandler, pList);
+               if (res != PMINFO_R_OK)
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_appinfo_foreach_category() is failed. result = [%d]", res);
+                       r = E_SYSTEM;
+
+                       pList->RemoveAll(true);
+                       pList = null;
+               }
+
+               SetLastResult(r);
 
-               pList->RemoveAll(true);
-               pList = null;
+       }
+       else
+       {
+               SysLog(NID_APP, "GetAppCategoryListN() is not available.");
        }
 
-       SetLastResult(r);
        return pList;
 }
 
@@ -175,6 +200,16 @@ _PackageAppInfoImpl::SetMainApp(bool mainApp)
        return E_SUCCESS;
 }
 
+result
+_PackageAppInfoImpl::AddCategory(String* pCategory)
+{
+       result r = E_SUCCESS;
+       r = __pAppCategoryList->Add(*pCategory);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "__pAppCategoryList->Add() is failed.");
+
+       return r;
+}
+
 _PackageAppInfoImpl*
 _PackageAppInfoImpl::GetInstance(PackageAppInfo* pPackageAppInfo)
 {
@@ -204,6 +239,8 @@ _PackageAppInfoImpl::Construct(const AppId& appId)
        res = pkgmgrinfo_appinfo_get_appinfo(pAppId.get(), &__pAppInfoHandle);
        SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_appinfo_get_appinfo failed, res = [%d]", res);
 
+       __fromDatabase = true;
+
        SetAppId(appId);
 
        res = pkgmgrinfo_appinfo_get_exec(__pAppInfoHandle, &pExePath);
@@ -273,7 +310,7 @@ _PackageAppInfoImpl::Construct(const AppId& appId)
        {
                SysLog(NID_APP, "pkgmgrinfo_appinfo_get_notification_icon(): NotificationIcon = [%s]", pNotificationIcon);
                String notificationIcon(pNotificationIcon);
-               SetAppSettingIconPath(notificationIcon);
+               SetAppNotificationIconPath(notificationIcon);
        }
        else
        {
@@ -294,7 +331,7 @@ _PackageAppInfoImpl::Construct(const AppId& appId)
        res = pkgmgrinfo_appinfo_is_nodisplay(__pAppInfoHandle, &menuIconVisible);
        if (res == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_appinfo_is_nodisplay(): displayName = [%d]", menuIconVisible);
+               SysLog(NID_APP, "pkgmgrinfo_appinfo_is_nodisplay(): menuIconVisible = [%d]", menuIconVisible);
                SetMenuIconVisible(!menuIconVisible);
        }
        else
@@ -325,11 +362,13 @@ _PackageAppInfoImpl::CategoryHandler(const char* pCategoryName, void* pUserData)
 _PackageAppInfoImpl::_PackageAppInfoImpl(void)
        : __launchingIconVisible(true)
        , __mainApp(false)
+       , __fromDatabase(false)
        , __pLaunchConditionImplList(null)
        , __pNotificationImplList(null)
        , __pAppFeatureImplList(null)
        , __pDataControlImplList(null)
        , __pAppControlImplList(null)
+       , __pAppCategoryList(null)
        , __uniqueId(0)
        , __pkgId(0)
        , __appFeature(0)
@@ -355,6 +394,10 @@ _PackageAppInfoImpl::_PackageAppInfoImpl(void)
        SysTryReturnVoidResult(NID_APP, __pAppControlImplList != null, E_OUT_OF_MEMORY, "__pAppControlImplList instance must not be null.");
        __pAppControlImplList->Construct();
 
+       __pAppCategoryList = new (std::nothrow) ArrayList;
+       SysTryReturnVoidResult(NID_APP, __pAppCategoryList != null, E_OUT_OF_MEMORY, "__pAppCategoryList instance must not be null.");
+       __pAppCategoryList->Construct();
+
        __pNameList = new (std::nothrow) HashMap;
        SysTryReturnVoidResult(NID_APP, __pNameList != null, E_OUT_OF_MEMORY, "__pNameList instance must not be null.");
        __pNameList->Construct();
@@ -378,6 +421,9 @@ _PackageAppInfoImpl::~_PackageAppInfoImpl(void)
        __pAppControlImplList->RemoveAll(true);
        delete __pAppControlImplList;
 
+       __pAppCategoryList->RemoveAll(true);
+       delete __pAppCategoryList;
+
        __pNameList->RemoveAll(true);
        delete __pNameList;
 
@@ -439,7 +485,7 @@ _PackageAppInfoImpl::GetLaunchConditionListN(void) const
 
        query.Format(1024, L"SELECT * FROM LaunchCondition WHERE ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = db.CreateStatementN(query);
@@ -506,7 +552,7 @@ _PackageAppInfoImpl::GetNotificationListN(void) const
 
        query.Format(1024, L"SELECT * FROM Notification WHERE ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = db.CreateStatementN(query);
@@ -573,7 +619,7 @@ _PackageAppInfoImpl::GetAppFeatureListN(void) const
 
        query.Format(1024, L"SELECT * FROM AppFeature WHERE ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = db.CreateStatementN(query);
@@ -629,7 +675,7 @@ _PackageAppInfoImpl::GetAppFeatureMapN(void) const
 
        query.Format(1024, L"SELECT * FROM AppFeature WHERE ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        const DbStatement* pStmt = db.CreateStatementN(query);
@@ -813,7 +859,7 @@ _PackageAppInfoImpl::GetUniqueId(void) const
 
        query.Format(1024, L"SELECT UNIQUE_ID FROM AppInfo WHERE APP_NAME = '%ls' and ID = %d", __name.GetPointer(), __pkgId);
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = db.CreateStatementN(query);
index 990323b..9748972 100755 (executable)
@@ -33,6 +33,7 @@
 #include <FBaseSysLog.h>
 
 #include <FBase_StringConverter.h>
+#include <FBaseUtilStringTokenizer.h>
 
 #include "FAppPkg_PackageManagerImpl.h"
 #include "FAppPkg_PackageInfoImpl.h"
@@ -41,6 +42,7 @@
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
+using namespace Tizen::Base::Utility;
 
 namespace Tizen { namespace App { namespace Package
 {
@@ -204,19 +206,27 @@ _PackageInfoImpl::SetDownloaded(bool downloaded)
 long long
 _PackageInfoImpl::GetSize(void) const
 {
-       SysTryReturn(NID_APP, __packageInfoHandle, 0, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
-
-       int result = PMINFO_R_OK;
        int size = 0;
 
-       result = pkgmgrinfo_pkginfo_get_total_size(__packageInfoHandle, &size);
-       if (result == PMINFO_R_OK)
+       if (__fromDatabase)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size(): size = [%d]", size);
+               SysTryReturn(NID_APP, __packageInfoHandle, 0, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
+
+               int result = PMINFO_R_OK;
+
+               result = pkgmgrinfo_pkginfo_get_total_size(__packageInfoHandle, &size);
+               if (result == PMINFO_R_OK)
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size(): size = [%d]", size);
+               }
+               else
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size() is failed. result = [%d]", result);
+               }
        }
        else
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size() is failed. result = [%d]", result);
+               SysLog(NID_APP, "GetSize() is not available.");
        }
 
        return (long long) size;
@@ -225,19 +235,27 @@ _PackageInfoImpl::GetSize(void) const
 long long
 _PackageInfoImpl::GetDataSize(void) const
 {
-       SysTryReturn(NID_APP, __packageInfoHandle, 0, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
-
-       int result = PMINFO_R_OK;
        int dataSize = 0;
 
-       result = pkgmgrinfo_pkginfo_get_data_size(__packageInfoHandle, &dataSize);
-       if (result == PMINFO_R_OK)
+       if (__fromDatabase)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_data_size(): dataSize = [%d]", dataSize);
+               SysTryReturn(NID_APP, __packageInfoHandle, 0, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
+
+               int result = PMINFO_R_OK;
+
+               result = pkgmgrinfo_pkginfo_get_data_size(__packageInfoHandle, &dataSize);
+               if (result == PMINFO_R_OK)
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_data_size(): dataSize = [%d]", dataSize);
+               }
+               else
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_data_size() is failed. result = [%d]", result);
+               }
        }
        else
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_data_size() is failed. result = [%d]", result);
+               SysLog(NID_APP, "GetDataSize() is not available.");
        }
 
        return (long long) dataSize;
@@ -270,20 +288,60 @@ _PackageInfoImpl::SetStoreClientId(const PackageId& packageId)
 }
 
 ArrayList*
-_PackageInfoImpl::GetPackageAppInfoListN(void) const
+_PackageInfoImpl::GetPackageAppInfoListN(void)
 {
-       SysTryReturn(NID_APP, __packageInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
-
-       int res = 0;
        ArrayList* pList = null;
 
-       pList = new (std::nothrow) ArrayList;
-       SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
+       if (__fromDatabase)
+       {
+               SysTryReturn(NID_APP, __packageInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
+
+               int res = 0;
+
+               pList = new (std::nothrow) ArrayList;
+               SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
+               pList->Construct();
+
+               res = pkgmgrinfo_appinfo_get_list(__packageInfoHandle, PMINFO_UI_APP, PackageAppInfoListHandler, (void *)pList);
+               res = pkgmgrinfo_appinfo_get_list(__packageInfoHandle, PMINFO_SVC_APP, PackageAppInfoListHandler, (void *)pList);
+       }
+       else
+       {
+               SysTryReturn(NID_APP, __pPackageAppInfoList, null, E_SYSTEM, "__pPackageAppInfoList must not be null.");
+
+               result r = E_SUCCESS;
+
+               pList = new (std::nothrow) ArrayList;
+               SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "pList must not be null.");
+               pList->Construct();
+
+               for (int i = 0; i < __pPackageAppInfoList->GetCount(); i++)
+               {
+                       PackageAppInfo* pPackageAppInfo = dynamic_cast <PackageAppInfo*>(__pPackageAppInfoList->GetAt(i));
+                       if (pPackageAppInfo)
+                       {
+                               PackageAppInfo* pInfo = new (std::nothrow) PackageAppInfo;
+                               SysTryReturn(NID_APP, pInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
+
+                               _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pInfo);
+                               SysTryReturn(NID_APP, pPackageAppInfoImpl, null, E_SYSTEM, "pPackageAppInfoImpl is null.");
 
-       pList->Construct();
+                               AppId appId = pPackageAppInfo->GetAppId();
+                               String appName = pPackageAppInfo->GetAppName();
+                               String appDisplayName = pPackageAppInfo->GetAppDisplayName();
+                               bool menuIconVisible = pPackageAppInfo->IsMenuIconVisible();
+                               bool mainApp = pPackageAppInfo->IsMainApp();
 
-       res = pkgmgrinfo_appinfo_get_list(__packageInfoHandle, PMINFO_UI_APP, PackageAppInfoListHandler, (void *)pList);
-       res = pkgmgrinfo_appinfo_get_list(__packageInfoHandle, PMINFO_SVC_APP, PackageAppInfoListHandler, (void *)pList);
+                               pPackageAppInfoImpl->SetAppId(appId);
+                               pPackageAppInfoImpl->SetAppName(appName);
+                               pPackageAppInfoImpl->SetAppDisplayName(appDisplayName);
+                               pPackageAppInfoImpl->SetMenuIconVisible(menuIconVisible);
+                               pPackageAppInfoImpl->SetMainApp(mainApp);
+
+                               r = pList->Add(*pInfo);
+                       }
+                }
+       }
 
        return pList;
 }
@@ -291,29 +349,36 @@ _PackageInfoImpl::GetPackageAppInfoListN(void) const
 PackageAppInfo*
 _PackageInfoImpl::GetPackageAppInfoN(const AppId& appId) const
 {
-       SysTryReturn(NID_APP, __packageInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
+       if (__fromDatabase)
+       {
+               SysTryReturn(NID_APP, __packageInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __packageInfoHandle is null.");
 
-       int res = 0;
-       pkgmgrinfo_appinfo_h appInfoHandle = null;
+               int res = 0;
+               pkgmgrinfo_appinfo_h appInfoHandle = null;
 
-       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
-       SysTryReturn(NID_APP, pAppId, null, E_OUT_OF_MEMORY, "pAppId is null");
+               std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+               SysTryReturn(NID_APP, pAppId, null, E_OUT_OF_MEMORY, "pAppId is null");
 
-       res = pkgmgrinfo_appinfo_get_appinfo(pAppId.get(), &appInfoHandle);
-       if (res == 0)
-       {
-               SysLog(NID_APP, "pkgmgrinfo_appinfo_get_appinfo(): appId = [%s]", pAppId.get());
+               res = pkgmgrinfo_appinfo_get_appinfo(pAppId.get(), &appInfoHandle);
+               if (res == 0)
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_appinfo_get_appinfo(): appId = [%s]", pAppId.get());
 
-               PackageAppInfo* pPackageAppInfo = new (std::nothrow) PackageAppInfo;
-               SysTryReturn(NID_APP, pPackageAppInfo != null, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
+                       PackageAppInfo* pPackageAppInfo = new (std::nothrow) PackageAppInfo;
+                       SysTryReturn(NID_APP, pPackageAppInfo != null, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
 
-               GetPackageAppInfo(appInfoHandle, pPackageAppInfo);
+                       GetPackageAppInfo(appInfoHandle, pPackageAppInfo);
 
-               return pPackageAppInfo;
+                       return pPackageAppInfo;
+               }
+               else
+               {
+                       SysLog(NID_APP, "pkgmgrinfo_appinfo_get_appinfo() is failed. result = [%d]", res);
+               }
        }
        else
        {
-               SysLog(NID_APP, "pkgmgrinfo_appinfo_get_appinfo() is failed. result = [%d]", res);
+               SysLog(NID_APP, "GetPackageAppInfoN() is not available.");
        }
 
        return null;
@@ -358,6 +423,53 @@ _PackageInfoImpl::GetPackageAppInfo(const pkgmgrinfo_appinfo_h handle, PackageAp
        return true;
 }
 
+ArrayList*
+_PackageInfoImpl::GetPrivilegeListN(void) const
+{
+       SysTryReturn(NID_APP, __pPrivilegeList, null, E_SYSTEM, "__pPrivilegeList must not be null.");
+
+       result r = E_SUCCESS;
+
+       ArrayList* pPrivilegeList = new (std::nothrow) ArrayList;
+       SysTryReturn(NID_APP, pPrivilegeList, null, E_OUT_OF_MEMORY, "pPrivilegeList must not be null.");
+       pPrivilegeList->Construct();
+
+       for (int i = 0; i < __pPrivilegeList->GetCount(); i++)
+       {
+               String* pPrivilege = dynamic_cast <String*>(__pPrivilegeList->GetAt(i));
+               if (pPrivilege)
+               {
+                       String* pPrivilegeString = new (std::nothrow) String(*pPrivilege);
+                       SysTryReturn(NID_APP, pPrivilegeString, null, E_OUT_OF_MEMORY, "pPrivilegeString must not be null.");
+
+                       r = pPrivilegeList->Add(*pPrivilegeString);
+               }
+        }
+
+       return pPrivilegeList;
+}
+
+result
+_PackageInfoImpl::AddPrivilege(const String& privilege)
+{
+       result r = E_SUCCESS;
+
+       r = __pPrivilegeList->Add(privilege);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "__pPrivilegeList->Add() is failed.");
+
+       return r;
+}
+
+result
+_PackageInfoImpl::AddPackageAppInfo(const PackageAppInfo& packageAppInfo)
+{
+       result r = E_SUCCESS;
+       r = __pPackageAppInfoList->Add(packageAppInfo);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "__pPackageAppInfoList->Add() is failed.");
+
+       return r;
+}
+
 // to be reviewed
 _PackageInfoImpl::_PackageInfoImpl(void)
        : __appReadOnlySize(0)
@@ -365,19 +477,30 @@ _PackageInfoImpl::_PackageInfoImpl(void)
        , __appStorageType(0)
        , __appState(0)
        , __certType(0)
+       , __pPrivilegeList(null)
        , __pAppInfoImplList(null)
+       , __pPackageAppInfoList(null)
        , __packageInfoHandle(null)
        , __uninstallable(true)
        , __movable(false)
        , __downloaded(false)
        , __iconAvailable(false)
        , __externalStorage(false)
+       , __fromDatabase(false)
        , __packageType(PACKAGE_TYPE_TPK)
        , __pPackageInfo(null)
 {
        __pAppInfoImplList = new (std::nothrow) ArrayList;
        SysTryReturnVoidResult(NID_APP, __pAppInfoImplList != null, E_OUT_OF_MEMORY, "__pAppInfoImplList instance must not be null.");
        __pAppInfoImplList->Construct();
+
+       __pPackageAppInfoList = new (std::nothrow) ArrayList;
+       SysTryReturnVoidResult(NID_APP, __pPackageAppInfoList != null, E_OUT_OF_MEMORY, "__pPackageAppInfoList instance must not be null.");
+       __pPackageAppInfoList->Construct();
+
+       __pPrivilegeList = new (std::nothrow) ArrayList;
+       SysTryReturnVoidResult(NID_APP, __pPrivilegeList != null, E_OUT_OF_MEMORY, "__pPrivilegeList must not be null.");
+       __pPrivilegeList->Construct();
 }
 
 _PackageInfoImpl::~_PackageInfoImpl(void)
@@ -385,9 +508,15 @@ _PackageInfoImpl::~_PackageInfoImpl(void)
        __pAppInfoImplList->RemoveAll(true);
        delete __pAppInfoImplList;
 
+       __pPackageAppInfoList->RemoveAll(true);
+       delete __pPackageAppInfoList;
+
+       __pPrivilegeList->RemoveAll(true);
+       delete __pPrivilegeList;
+
        if (__packageInfoHandle)
        {
-               pkgmgr_pkginfo_destroy_pkginfo(__packageInfoHandle);
+               pkgmgrinfo_pkginfo_destroy_pkginfo(__packageInfoHandle);
        }
 }
 
@@ -573,7 +702,7 @@ _PackageInfoImpl::GetAppInfoListN(void) const
 
        query.Format(1024, L"SELECT * FROM AppInfo WHERE ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = _PackageManagerImpl::CreateStatementN(db, query);
@@ -663,7 +792,7 @@ _PackageInfoImpl::AddAppInfo(const _PackageAppInfoImpl& appInfoImpl)
 }
 
 result
-_PackageInfoImpl::GetPrivileges(String& privileges, String& hmacPrivileges)
+_PackageInfoImpl::GetPrivileges(String& privileges, String& hmacPrivileges, ArrayList& privilegeList)
 {
        result r = E_SUCCESS;
        Database db;
@@ -671,9 +800,14 @@ _PackageInfoImpl::GetPrivileges(String& privileges, String& hmacPrivileges)
        DbEnumerator* pEnum = null;
        String query;
 
+       String privilegeListString;
+       String delim("#");
+       String privilegeToken;
+
+
        query.Format(1024, L"SELECT * FROM PkgPrivileges WHERE ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = _PackageManagerImpl::CreateStatementN(db, query);
@@ -686,6 +820,15 @@ _PackageInfoImpl::GetPrivileges(String& privileges, String& hmacPrivileges)
                {
                        pEnum->GetStringAt(1, privileges);
                        pEnum->GetStringAt(2, hmacPrivileges);
+                       pEnum->GetStringAt(4, privilegeListString);
+               }
+
+               StringTokenizer strTok(privilegeListString, delim);
+
+               while (strTok.HasMoreTokens())
+               {
+                       strTok.GetNextToken(privilegeToken);
+                       privilegeList.Add(new String(privilegeToken));
                }
 
                delete pEnum;
@@ -815,6 +958,8 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &__packageInfoHandle);
        SysTryReturnResult(NID_APP, result == PMINFO_R_OK, E_PKG_NOT_INSTALLED, "pkgmgrinfo_pkginfo_get_pkginfo() is failed. result=[%d], packageId=[%s]", result, pPackageId.get());
 
+       __fromDatabase = true;
+
        result = pkgmgrinfo_pkginfo_get_pkgname(__packageInfoHandle, &pPackage);
        if (result == PMINFO_R_OK)
        {
@@ -989,7 +1134,7 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        // temp
        query.Format(1024, L"SELECT PkgInfo.*, AppInfo.APP_MAINMENU_ICON FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.APP_DEFAULT = 'True' and PkgInfo.PKG_ID = '%ls'", packageId.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = _PackageManagerImpl::CreateStatementN(db, query);
@@ -1001,10 +1146,16 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
                if (pEnum->MoveNext() == E_SUCCESS)
                {
                        String rootPath;
-                       int storageType;
+                       int storageType = 0;
 
-                       pEnum->GetStringAt(16, rootPath);
-                       pEnum->GetIntAt(17, storageType);
+                       if (pEnum->GetColumnType(16) != DB_COLUMNTYPE_NULL)
+                       {
+                               pEnum->GetStringAt(16, rootPath);
+                       }
+                       if (pEnum->GetColumnType(17) != DB_COLUMNTYPE_NULL)
+                       {
+                               pEnum->GetIntAt(17, storageType);
+                       }
 
                        SetAppRootPath(rootPath);
                        SetAppStorageType(storageType);
@@ -1030,7 +1181,7 @@ _PackageInfoImpl::GetUniqueId(void) const
 
        query.Format(1024, L"SELECT UNIQUE_ID FROM PkgInfo WHERE PKG_ID = '%ls'", __id.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = _PackageManagerImpl::CreateStatementN(db, query);
@@ -1069,7 +1220,7 @@ _PackageInfoImpl::GetUiScalabilityInfo(String& baseScreenSize, String& coordinat
        query.Format(1024,
                L"SELECT AppFeature.NAME, AppFeature.VALUE FROM AppFeature, AppInfo WHERE AppFeature.ID = AppInfo.UNIQUE_ID and AppInfo.APP_DEFAULT = 'True' and AppInfo.ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = _PackageManagerImpl::CreateStatementN(db, query);
@@ -1131,7 +1282,7 @@ _PackageInfoImpl::GetAppPackageName(void)
 
        query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo WHERE AppInfo.APP_DEFAULT = 'True' and ID = %d", GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = _PackageManagerImpl::CreateStatementN(db, query);
index 91d5e0b..7d5aaf7 100755 (executable)
@@ -42,6 +42,7 @@
 #include "FAppPkg_PackageManagerImpl.h"
 #include "FAppPkg_PackageInfoImpl.h"
 #include "FAppPkg_PackageAppInfoImpl.h"
+#include "FAppPkg_PackageParser.h"
 #include "FApp_AppInfo.h"
 #include "FApp_PackageManagerProxy.h"
 
@@ -58,8 +59,6 @@ PackageManager* pPackageManagerInstance = null;
 
 Tizen::Base::Collection::HashMap _PackageManagerImpl::__installationList;
 
-const wchar_t PACKAGE_DATABASE_FILE_NAME[] = L"/opt/usr/dbspace/.app-package.db";
-
 void
 _PackageManagerEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
 {
@@ -511,10 +510,6 @@ _PackageManagerImpl::MoveToExternalStorage(const PackageId& packageId)
        SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty");
        SysTryReturnResult(NID_APP, IsPackageInstalled(packageId) == true, E_PKG_NOT_INSTALLED, "package is not installed.");
 
-#if defined(_OSP_EMUL_)
-       SysLog(NID_APP, "MoveToExternalStorage() is unavailable on the emulator.");
-       return E_SYSTEM;
-#else
        int res = 0;
        char* pType = null;
        pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
@@ -574,7 +569,6 @@ _PackageManagerImpl::MoveToExternalStorage(const PackageId& packageId)
        }
 
        return E_SUCCESS;
-#endif
 }
 
 result
@@ -583,10 +577,6 @@ _PackageManagerImpl::MoveToInternalStorage(const PackageId& packageId)
        SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty");
        SysTryReturnResult(NID_APP, IsPackageInstalled(packageId) == true, E_PKG_NOT_INSTALLED, "package is not installed.");
 
-#if defined(_OSP_EMUL_)
-       SysLog(NID_APP, "MoveToInternalStorage() is unavailable on the emulator.");
-       return E_SYSTEM;
-#else
        int res = 0;
        char* pType = null;
        pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
@@ -646,7 +636,6 @@ _PackageManagerImpl::MoveToInternalStorage(const PackageId& packageId)
        }
 
        return E_SUCCESS;
-#endif
 }
 
 int
@@ -656,10 +645,10 @@ _PackageManagerImpl::InstallationEventHandler(int reqId, const char* pType, cons
 
        if (pData)
        {
+               IPackageInstallationResponseListener* pListener = (IPackageInstallationResponseListener*) pData;
+
                if (strcmp(pKey, "end") == 0)
                {
-                       IPackageInstallationResponseListener* pListener = (IPackageInstallationResponseListener*) pData;
-
                        if (strcmp(pVal, "ok") == 0)
                        {
                                pListener->OnPackageInstallationResponseReceived(pPackageId, PACKAGE_INSTALLATION_RESULT_SUCCESS);
@@ -673,6 +662,14 @@ _PackageManagerImpl::InstallationEventHandler(int reqId, const char* pType, cons
 
                        delete pListener;
                }
+               else if (strcmp(pKey, "install_percent") == 0)
+               {
+                       int progress = 0;
+                       sscanf(pVal, "%d", &progress);
+
+                       pListener->OnPackageInstallationInProgressResponseReceived(pPackageId, progress);
+                       SysLog(NID_APP, "OnPackageInstallationInProgressResponseReceived(%s, %d)", pPackageId, progress);
+               }
        }
 
        return 0;
@@ -724,6 +721,69 @@ _PackageManagerImpl::Construct(void)
        return E_SUCCESS;
 }
 
+PackageInfo*
+_PackageManagerImpl::GetPackageInfoFromFileN(const String& filePath) const
+{
+       SysTryReturn(NID_APP, filePath.IsEmpty() == false, null, E_INVALID_ARG, "filePath is empty.");
+       SysTryReturn(NID_APP, File::IsFileExist(filePath) == true, null, E_FILE_NOT_FOUND, "package is not existed.");
+
+       String extension = File::GetFileExtension(filePath);
+       SysTryReturn(NID_APP, extension.IsEmpty() == false, null, E_INVALID_ARG, "extension is empty.");
+
+       std::unique_ptr<char[]> pPackagePath(_StringConverter::CopyToCharArrayN(filePath));
+       SysTryReturn(NID_APP, pPackagePath, null, E_OUT_OF_MEMORY, "pPackagePath is null.");
+
+       std::unique_ptr<char[]> pExtension(_StringConverter::CopyToCharArrayN(extension));
+       SysTryReturn(NID_APP, pExtension, null, E_OUT_OF_MEMORY, "pExtension is null.");
+
+       bool res = false;
+
+       if ((strcasecmp(pExtension.get(), "tpk") == 0) || (strcasecmp(pExtension.get(), "wgt") == 0))
+       {
+               SysLog(NID_APP, "packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
+               res = true;
+       }
+       SysTryReturn(NID_APP, res == true, null, E_UNSUPPORTED_FORMAT, "invalid extension! - packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
+
+       _PackageParser packageParser;
+
+       PackageInfo* pPackageInfo = new (std::nothrow) PackageInfo;
+       SysTryReturn(NID_APP, pPackageInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
+
+       res = packageParser.Construct(pPackageInfo);
+       SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Construct() is failed. [%s]", pPackagePath.get());
+
+       res = packageParser.Parse(filePath);
+       SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Parse() is failed. [%s]", pPackagePath.get());
+
+       return pPackageInfo;
+}
+
+IList*
+_PackageManagerImpl::GetPackageInfoListN(const IMap& packageFilterMap) const
+{
+       SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
+
+       return null;
+}
+
+IList*
+_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageAppFilterMap) const
+{
+       SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
+
+       return null;
+}
+
+IList*
+_PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageFilterMap, const IMap& packageAppFilterMap) const
+{
+       SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
+       SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
+
+       return null;
+}
+
 _PackageManagerImpl::_PackageManagerImpl(void)
 :__pRequestClient(null),
 __pListeningClient(null),
@@ -830,7 +890,7 @@ _PackageManagerImpl::GetPackageInfoN(PackageType packageType, const String& pack
 
        query.Format(   1024, L"SELECT PkgInfo.*, AppInfo.APP_MAINMENU_ICON FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -946,7 +1006,7 @@ _PackageManagerImpl::GetFilteredAppIdListN(const String& feature, const String&
 
        query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, AppFeature WHERE AppFeature.ID = AppInfo.UNIQUE_ID and AppFeature.NAME = '%ls' and AppFeature.VALUE = '%ls' COLLATE NOCASE", feature.GetPointer(), value.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -995,7 +1055,7 @@ _PackageManagerImpl::GetDataControlInfoN(const String& providerId, const String&
 
        query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME, DataControl.ACCESS FROM AppInfo, DataControl WHERE DataControl.ID = AppInfo.UNIQUE_ID and DataControl.PROVIDER_ID = '%ls' and DataControl.TYPE = '%ls' COLLATE NOCASE", providerId.GetPointer(), type.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -1050,7 +1110,7 @@ _PackageManagerImpl::GetUiThemeListN(const PackageId& packageId) const
        query.Format(1024, L"SELECT AppFeature.NAME, AppFeature.VALUE FROM PkgInfo, AppInfo, AppFeature WHERE (AppFeature.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID and PkgInfo.PKG_ID = '%ls') and (AppFeature.NAME = 'SystemTheme' or AppFeature.NAME = 'UserDefinedTheme')"
                        , packageId.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -1159,7 +1219,7 @@ _PackageManagerImpl::GetAppIdOfDataControlN(const String& providerId)
        query.Format(1024, L"SELECT PkgInfo.PKG_ID FROM PkgInfo, AppInfo, DataControl WHERE DataControl.PROVIDER_ID = '%ls' and DataControl.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID",
                        providerId.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -1233,7 +1293,8 @@ _PackageManagerImpl::CreatePackageTables(void)
                                                         "( ID                          INTEGER,"
                                                         "PRIVILEGES                                    TEXT,"
                                                         "HMAC_PPRIVILEGES                      TEXT,"
-                                                        "CERTIFICATE_TYPE              INTEGER )");
+                                                        "CERTIFICATE_TYPE              INTEGER,"
+                                                    "STR_PRIVILEGES            TEXT )");
        r = db.ExecuteSql(createQuery, true);
        SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "MakePackageDb: db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
        createQuery.Clear();
@@ -1587,7 +1648,7 @@ _PackageManagerImpl::GetPackageInfoN(const String& providerId, const String& ope
                        "GROUP BY AppInfoID"
                        , providerId.GetPointer(), operationId.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -1627,7 +1688,7 @@ _PackageManagerImpl::GetAppInfo(int uniqueId, _PackageAppInfoImpl& appInfo) cons
 
        query.Format(1024, L"SELECT * FROM AppInfo WHERE UNIQUE_ID = %d", uniqueId);
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -1702,7 +1763,7 @@ _PackageManagerImpl::GetPackageAppInfoImplListN(const String& packageId) const
        pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
        query.Format(1024, L"SELECT * FROM AppInfo WHERE ID = %d", pPackageInfoImpl->GetUniqueId());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -1839,7 +1900,7 @@ _PackageManagerImpl::GetAppLaunchConditionListN(const String& packageName) const
 
        query.Format(1024, L"SELECT LaunchCondition.* FROM LaunchCondition, AppInfo WHERE AppInfo.UNIQUE_ID = LaunchCondition.ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -2286,7 +2347,7 @@ _PackageManagerImpl::FindRecord(const String& tableName, const String& columnNam
        DbEnumerator* pEnum = null;
        int uniqueId = 0;
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        query.Format(1024, L"SELECT * FROM %ls WHERE %ls = '%ls'", tableName.GetPointer(), columnName.GetPointer(), value.GetPointer());
@@ -2321,7 +2382,7 @@ _PackageManagerImpl::GetRecord(const String& tableName, int uniqueId, const Stri
        DbStatement* pStmt = null;
        DbEnumerator* pEnum = null;
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        query.Format(1024, L"SELECT %ls FROM %ls WHERE UNIQUE_ID = %d", columnName.GetPointer(), tableName.GetPointer(), uniqueId);
@@ -2425,7 +2486,7 @@ _PackageManagerImpl::GetPackageName(const PackageId& packageId, const String* pN
                        pName->GetPointer(), packageId.GetPointer());
        }
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
@@ -2468,7 +2529,7 @@ _PackageManagerImpl::GetDefaultAppExecutableName(const PackageId& packageId)
                L"SELECT AppInfo.APP_NAME FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.APP_DEFAULT = '%s' and PkgInfo.PKG_ID = '%ls'",
                "True", packageId.GetPointer());
 
-       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, false);
+       r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
        SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
 
        pStmt = CreateStatementN(db, query);
diff --git a/src/app/package/FAppPkg_PackageParser.cpp b/src/app/package/FAppPkg_PackageParser.cpp
new file mode 100755 (executable)
index 0000000..13496b0
--- /dev/null
@@ -0,0 +1,951 @@
+//
+// 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       FAppPkg_PackageParser.cpp
+ * @brief      This is the implementation for the _PackageParser class.
+ */
+
+#include <libxml/parserInternals.h>
+
+#include <FAppPkgPackageAppInfo.h>
+#include <FBaseSysLog.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FAppPkg_PackageAppInfoImpl.h>
+#include <FAppPkg_PackageInfoImpl.h>
+#include <FAppPkg_PackageParser.h>
+#include <FBase_StringConverter.h>
+#include <FSys_SystemInfoImpl.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::App;
+using namespace Tizen::Io;
+using namespace Tizen::System;
+
+namespace Tizen { namespace App { namespace Package
+{
+
+_PackageXmlAttribute::_PackageXmlAttribute(void)
+:__pName(null)
+,__pValue(null)
+,__pNext(null)
+{
+}
+
+_PackageXmlAttribute::~_PackageXmlAttribute(void)
+{
+       delete[] __pName;
+       delete[] __pValue;
+       delete __pNext;
+}
+
+bool
+_PackageXmlAttribute::Construct(const char* pName, const char* pValue)
+{
+       if (pName == 0 || pValue == 0)
+       {
+               return true;
+       }
+
+       __pName = new (std::nothrow) char[strlen(pName)+1];
+       SysTryReturn(NID_APP, __pName, false, E_OUT_OF_MEMORY, "__pName is null");
+       strcpy(__pName, pName);
+
+       __pValue = new (std::nothrow) char[strlen(pValue)+1];
+       SysTryReturn(NID_APP, __pValue, false, E_OUT_OF_MEMORY, "__pValue is null");
+       strcpy(__pValue, pValue);
+
+       return true;
+}
+
+char*
+_PackageXmlAttribute::Find(const char* pName)
+{
+       if (pName == 0)
+       {
+               return null;
+       }
+
+       if (__pName == 0 || __pValue == 0)
+       {
+               return null;
+       }
+
+       if (strcasecmp(pName, __pName) == 0)
+       {
+               return __pValue;
+       }
+
+       if (__pNext)
+       {
+               return __pNext->Find(pName);
+       }
+
+       return null;
+}
+
+bool
+_PackageXmlAttribute::Add(const char* pName, const char* pValue)
+{
+       if (pName == 0 || pValue == 0)
+       {
+               return true;
+       }
+
+       if (__pNext)
+       {
+               _PackageXmlAttribute* pNext = __pNext;
+               while (pNext->__pNext)
+               {
+                       pNext = pNext->__pNext;
+               }
+
+               return pNext->Add(pName, pValue);
+       }
+       else
+       {
+               __pNext = new (std::nothrow) _PackageXmlAttribute();
+               SysTryReturn(NID_APP, __pNext, false, E_OUT_OF_MEMORY, "__pNext is null");
+
+               __pNext->Construct(pName, pValue);
+       }
+
+       return true;
+}
+
+
+_PackageXmlHandler::_PackageXmlHandler(void)
+:__pAttr(null)
+,__pElementName(null)
+,__pCharacters(null)
+,__error(false)
+{
+}
+
+_PackageXmlHandler::~_PackageXmlHandler(void)
+{
+       delete __pAttr;
+       __pAttr = null;
+
+       delete[] __pElementName;
+       __pElementName = null;
+}
+
+bool
+_PackageXmlHandler::OnStartDocument(void)
+{
+       return true;
+}
+
+bool
+_PackageXmlHandler::OnEndDocument(void)
+{
+       return true;
+}
+
+bool
+_PackageXmlHandler::OnStartElement(const char* pName)
+{
+       return true;
+}
+
+bool
+_PackageXmlHandler::OnEndElement(const char* pName)
+{
+       return true;
+}
+
+bool
+_PackageXmlHandler::OnCharacters(const char* pCharacters)
+{
+       return true;
+}
+
+void
+_PackageXmlHandler::StartElement(void* pCtx, const xmlChar* pName, const xmlChar** ppAtts)
+{
+       if (pName == 0)
+       {
+               return;
+       }
+
+       _PackageXmlHandler* pHandler = null;
+       pHandler = (_PackageXmlHandler*) pCtx;
+       bool xmlResult = false;
+
+       pHandler->SetElementName((const char *) pName);
+
+       if (ppAtts)
+       {
+               _PackageXmlAttribute* pAttr = 0;
+
+               if (ppAtts[0] != null && ppAtts[1] != null)
+               {
+                       pAttr = new (std::nothrow) _PackageXmlAttribute();
+                       SysTryReturnVoidResult(NID_APP, pAttr, E_OUT_OF_MEMORY, "pAttr is null.");
+
+                       pAttr->Construct((const char *)ppAtts[0], (const char *)ppAtts[1]);
+                       ppAtts = &ppAtts[2];
+               }
+
+               while (ppAtts != null && ppAtts[0] != null && ppAtts[1] != null)
+               {
+                       pAttr->Add((const char *)ppAtts[0], (const char *)ppAtts[1]);
+                       ppAtts = &ppAtts[2];
+               }
+
+               pHandler->SetAttribute(pAttr);
+       }
+
+       xmlResult = pHandler->OnStartElement((const char *)pName);
+       if (xmlResult == false)
+       {
+               pHandler->SetError();
+       }
+}
+
+void
+_PackageXmlHandler::EndElement(void* pCtx, const xmlChar* pName)
+{
+       _PackageXmlHandler* pHandler = null;
+       pHandler = (_PackageXmlHandler*) pCtx;
+       bool xmlResult = false;
+       char* pCharacters = pHandler->GetCharacters();
+
+       if (pCharacters && (strlen(pCharacters) > 0))
+       {
+               xmlResult = pHandler->OnCharacters(pCharacters);
+               if (xmlResult == false)
+               {
+                       pHandler->SetError();
+               }
+       }
+
+       xmlResult = pHandler->OnEndElement((const char *)pName);
+       if (xmlResult == false)
+       {
+               pHandler->SetError();
+       }
+
+       pHandler->DeleteElement();
+       pHandler->DeleteAttribute();
+       pHandler->DeleteCharacters();
+}
+
+void
+_PackageXmlHandler::Characters(void* pCtx, const xmlChar* pCh, int len)
+{
+       SysTryReturnVoidResult(NID_APP, pCh, E_SYSTEM, "pCh is null.");
+
+       _PackageXmlHandler* pHandler = null;
+       pHandler = (_PackageXmlHandler*) pCtx;
+       char* pCharacters = null;
+
+       if (pCh[0] == 0x20 || pCh[0] == 0x09 || pCh[0] == 0x0D || pCh[0] == 0x0A)
+       {
+               return;
+       }
+
+       pCharacters = new (std::nothrow) char[len+1];
+       SysTryReturnVoidResult(NID_APP, pCharacters, E_OUT_OF_MEMORY, "pCharacters is null.");
+
+       strncpy(pCharacters, (const char *)pCh, len);
+       pCharacters[len] = 0;
+
+       pHandler->SetCharacters(pCharacters);
+
+       delete[] pCharacters;
+}
+
+bool
+_PackageXmlHandler::ParseNormalizedDocument(const char* pFilepath)
+{
+       xmlSAXHandler* pSAXHandler = null;
+       xmlParserCtxtPtr ctxt = 0;
+       bool ret = true;
+       File file;
+       FileAttributes attr;
+       result r = E_SUCCESS;
+       char* pBuf = null;
+       char* pNormalizedBuf = null;
+       int size = 0;
+       int normalizedSize = 0;
+       int readSize = 0;
+
+       r = file.Construct(pFilepath, L"r");
+       TryCatch(r == E_SUCCESS, ret = false, "file.Construct is failed. [%s]", pFilepath);
+
+       r = file.GetAttributes(pFilepath, attr);
+       TryCatch(IsFailed(r) == false, ret = false, "file.GetAttributes is failed. [%s]", pFilepath);
+
+       size = (int)attr.GetFileSize();
+       TryCatch(size > 0, ret = false, "size is invalid. [%s]", pFilepath);
+
+       pBuf = new (std::nothrow) char[size+1];
+       TryCatch(pBuf, ret = false, "pBuf is null");
+
+       pNormalizedBuf = new (std::nothrow) char[size+1];
+       TryCatch(pNormalizedBuf, ret = false, "pNormalizedBuf is null");
+
+       memset(pBuf, 0, size+1);
+       memset(pNormalizedBuf, 0, size+1);
+
+       readSize = file.Read(pBuf, size);
+       TryCatch(readSize > 0, ret = false, "file.Read is failed. [%s][%d]", pFilepath, readSize);
+
+       normalizedSize = Normalize(pBuf, size, pNormalizedBuf);
+       TryCatch(normalizedSize > 0, ret = false, "normalizedSize [%d]", readSize);
+
+       ctxt = xmlCreateMemoryParserCtxt(pNormalizedBuf, normalizedSize);
+       TryCatch(ctxt, ret = false, "invalid xml file, %s", pFilepath);
+
+       pSAXHandler = new (std::nothrow) xmlSAXHandler;
+       TryCatch(pSAXHandler, ret = false, "pSAXHandler is null");
+       memset(pSAXHandler, 0, sizeof(xmlSAXHandler));
+
+       ctxt->userData = (void *)this;
+
+       pSAXHandler->startElement = _PackageXmlHandler::StartElement;
+       pSAXHandler->endElement = _PackageXmlHandler::EndElement;
+       pSAXHandler->characters = _PackageXmlHandler::Characters;
+
+       ctxt->sax = pSAXHandler;
+
+       xmlParseDocument(ctxt);
+       xmlFreeParserCtxt(ctxt);
+
+       TryCatch(GetError() != true, ret = false, "xml parsing error is occurred.");
+
+CATCH:
+       delete[] pBuf;
+       delete[] pNormalizedBuf;
+
+       return ret;
+}
+
+int
+_PackageXmlHandler::Normalize(const char* pBuf, int size, char* pNormalizedBuf)
+{
+       int idx = 0;
+       int normalizedIdx = 0;
+
+       while (pBuf[idx] && idx < size)
+       {
+               if (pBuf[idx] == 0x0D)
+               {
+                       if (pBuf[idx + 1] == 0x0A)
+                       {
+                               idx++;
+                       }
+                       pNormalizedBuf[normalizedIdx] = 0x0A;
+                       normalizedIdx++;
+               }
+               else if((pBuf[idx] == 0X0A) && (pBuf[idx + 1] == 0x4d) && (pBuf[idx - 1] == 0x3E))
+               {
+                       idx++;
+                       pNormalizedBuf[normalizedIdx] = pBuf[idx];
+                       normalizedIdx++;
+               }
+               else
+               {
+                       pNormalizedBuf[normalizedIdx] = pBuf[idx];
+                       normalizedIdx++;
+               }
+
+               idx++;
+       }
+
+       return normalizedIdx;
+}
+
+bool
+_PackageXmlHandler::SetElementName(const char* pElementName)
+{
+       SysTryReturn(NID_APP, pElementName, false, E_SYSTEM, "pElementName is null");
+
+       if (__pElementName)
+       {
+               delete[] __pElementName;
+               __pElementName = null;
+       }
+
+       __pElementName = new (std::nothrow) char[strlen(pElementName)+1];
+       SysTryReturn(NID_APP, __pElementName, false, E_OUT_OF_MEMORY, "__pElementName is null");
+       strcpy(__pElementName, pElementName);
+
+       __elementStack.Push(*new (std::nothrow) String(pElementName));
+
+       return true;
+}
+
+char*
+_PackageXmlHandler::GetElementName(void)
+{
+       return __pElementName;
+}
+
+void
+_PackageXmlHandler::DeleteElement(void)
+{
+       delete[]__pElementName;
+       __pElementName = 0;
+
+       __elementStack.Pop();
+}
+
+bool
+_PackageXmlHandler::SetCharacters(const char* pCharacter)
+{
+       SysTryReturn(NID_APP, pCharacter, false, E_SYSTEM, "pCharacter is null");
+
+       if (__pCharacters == null)
+       {
+               __pCharacters = new (std::nothrow) char[4096];
+               SysTryReturn(NID_APP, __pCharacters, false, E_OUT_OF_MEMORY, "__pCharacters is null");
+
+               memset(__pCharacters, 0, 4096);
+       }
+
+       strncat(__pCharacters, pCharacter, strlen(pCharacter));
+
+       return true;
+}
+
+char*
+_PackageXmlHandler::GetCharacters(void)
+{
+       return __pCharacters;
+}
+
+void
+_PackageXmlHandler::DeleteCharacters(void)
+{
+       delete[] __pCharacters;
+       __pCharacters = null;
+}
+
+void
+_PackageXmlHandler::SetAttribute(_PackageXmlAttribute* pAttr)
+{
+       __pAttr = pAttr;
+}
+
+_PackageXmlAttribute*
+_PackageXmlHandler::GetAttribute(void)
+{
+       return __pAttr;
+}
+
+void
+_PackageXmlHandler::DeleteAttribute(void)
+{
+       delete __pAttr;
+       __pAttr = null;
+}
+
+IEnumerator*
+_PackageXmlHandler::GetElementEnumeratorN(void)
+{
+       return __elementStack.GetEnumeratorN();
+}
+
+int
+_PackageXmlHandler::GetElementCount(void)
+{
+       return __elementStack.GetCount();
+}
+
+void
+_PackageXmlHandler::SetError(void)
+{
+       __error = true;
+}
+
+bool
+_PackageXmlHandler::GetError(void)
+{
+       return __error;
+}
+
+
+_PackageParser::_PackageParser(void)
+:__pPackageInfoImpl(null)
+,__pAppInfo(null)
+,__pDefaultIconType(null)
+,__isDefaultName(false)
+{
+}
+
+_PackageParser::~_PackageParser(void)
+{
+       delete[] __pDefaultIconType;
+       __pDefaultIconType = null;
+}
+
+bool
+_PackageParser::Construct(PackageInfo* pPackageInfo)
+{
+       SysTryReturn(NID_APP, pPackageInfo, false, E_INVALID_ARG, "pPackageInfo is null.");
+
+       _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+       SysTryReturn(NID_APP, pPackageInfoImpl, false, E_SYSTEM, "pPackageInfoImpl is null.");
+
+       __pPackageInfoImpl = pPackageInfoImpl;
+       return true;
+}
+
+bool
+_PackageParser::Parse(const String& packagepath)
+{
+       bool res = true;
+       FileUnzipper unzipper;
+
+       result r = unzipper.Construct(packagepath);
+       SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "unzipper.Construct() failed.");
+
+       r = unzipper.UnzipTo(L"/tmp", L"info/manifest.xml");
+       SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "unzipper.UnzipTo() failed.");
+
+       res = ParseNormalizedDocument("/tmp/info/manifest.xml");
+
+       Directory::Remove("/tmp/info", true);
+
+       return res;
+}
+
+bool
+_PackageParser::OnStartElement(const char* pName)
+{
+       SysTryReturn(NID_APP, pName, true, E_SYSTEM, "pName is null.");
+
+       bool status = true;
+
+       if (strcasecmp(pName, "UiApp") == 0)
+       {
+               status = OnUiAppStartElement();
+       }
+       else if (strcasecmp(pName, "ServiceApp") == 0)
+       {
+               status = OnServiceAppStartElement();
+       }
+       else if (strcasecmp(pName, "Icons") == 0)
+       {
+               status = OnIconsStartElement();
+       }
+
+       if (!status)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_PackageParser::OnEndElement(const char* pName)
+{
+       SysTryReturn(NID_APP, pName, true, E_SYSTEM, "pName is null.");
+
+       bool status = true;
+
+       if (strcasecmp(pName, "UiApp") == 0)
+       {
+               status = OnUiAppEndElement();
+       }
+       else if (strcasecmp(pName, "ServiceApp") == 0)
+       {
+               status = OnServiceAppEndElement();
+       }
+       else if (strcasecmp(pName, "DisplayNames") == 0)
+       {
+               status = OnDisplayNamesEndElement();
+       }
+
+       if (!status)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_PackageParser::OnCharacters(const char* pCharacters)
+{
+       bool status = true;
+
+       char* pName = GetElementName();
+       SysTryReturn(NID_APP, pName, false, E_SYSTEM, "pName is null.");
+
+       if (strcasecmp(pName, "Id") == 0)
+       {
+               status = OnIdValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "Version") == 0)
+       {
+               status = OnVersionValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "Url") == 0)
+       {
+               status = OnUrlValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "Privilege") == 0)
+       {
+               status = OnPrivilegeValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "DisplayName") == 0)
+       {
+               status = OnDisplayNameValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "Author") == 0)
+       {
+               status = OnAuthorValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "Description") == 0)
+       {
+               status = OnDescriptionValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "Icon") == 0)
+       {
+               status = OnIconValue(pCharacters);
+       }
+       else if (strcasecmp(pName, "Category") == 0)
+       {
+               status = OnCategoryValue(pCharacters);
+       }
+
+       if (!status)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_PackageParser::OnUiAppStartElement(void)
+{
+       __pAppInfo = new (std::nothrow) PackageAppInfo;
+       SysTryReturn(NID_APP, __pAppInfo, false, E_OUT_OF_MEMORY, "__pAppInfo is null.");
+
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
+
+       _PackageXmlAttribute* pAttr = GetAttribute();
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+
+       ParseAppAttribute(pAttr, true);
+
+       return true;
+}
+
+bool
+_PackageParser::OnServiceAppStartElement(void)
+{
+       __pAppInfo = new (std::nothrow) PackageAppInfo;
+       SysTryReturn(NID_APP, __pAppInfo, false, E_OUT_OF_MEMORY, "__pAppInfo is null.");
+
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
+
+       _PackageXmlAttribute* pAttr = GetAttribute();
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+
+       ParseAppAttribute(pAttr, false);
+
+       return true;
+}
+
+bool
+_PackageParser::OnIconsStartElement(void)
+{
+       result r = E_SUCCESS;
+       int width = 0;
+       String defaultIconType;
+
+       r = _SystemInfoImpl::GetSysInfo(L"ScreenWidth", width);
+       if (IsFailed(r))
+       {
+               defaultIconType = L"Xhigh";
+       }
+       else
+       {
+               if (width == 480)
+               {
+                       defaultIconType = L"High";
+               }
+               else
+               {
+                       defaultIconType = L"Xhigh";
+               }
+       }
+
+       __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType);
+       SysTryReturn(NID_APP, __pDefaultIconType, false, E_OUT_OF_MEMORY, "__pDefaultIconType is null.");
+
+       SysLog(NID_APP, "ScreenWidth = [%d], DefaultIconType = [%s]", width, __pDefaultIconType);
+
+       return true;
+}
+
+bool
+_PackageParser::OnUiAppEndElement(void)
+{
+       __pPackageInfoImpl->AddPackageAppInfo(*__pAppInfo);
+       __pAppInfo = null;
+
+       __isDefaultName = false;
+
+       return true;
+}
+
+bool
+_PackageParser::OnServiceAppEndElement(void)
+{
+       __pPackageInfoImpl->AddPackageAppInfo(*__pAppInfo);
+       __pAppInfo = null;
+
+       __isDefaultName = false;
+
+       return true;
+}
+
+bool
+_PackageParser::OnDisplayNamesEndElement(void)
+{
+       // fall-back
+
+       return true;
+}
+
+bool
+_PackageParser::OnIdValue(const char* pCharacters)
+{
+       SysLog(NID_APP, "Id = [%s]", pCharacters);
+       __pPackageInfoImpl->SetId(pCharacters);
+
+       return true;
+}
+
+bool
+_PackageParser::OnVersionValue(const char* pCharacters)
+{
+       SysLog(NID_APP, "Version = [%s]", pCharacters);
+       __pPackageInfoImpl->SetVersion(pCharacters);
+
+       return true;
+}
+
+bool
+_PackageParser::OnAuthorValue(const char* pCharacters)
+{
+       SysLog(NID_APP, "Author = [%s]", pCharacters);
+       __pPackageInfoImpl->SetAuthor(pCharacters);
+
+       return true;
+}
+
+bool
+_PackageParser::OnUrlValue(const char* pCharacters)
+{
+       SysLog(NID_APP, "Url = [%s]", pCharacters);
+       __pPackageInfoImpl->SetUrl(pCharacters);
+
+       return true;
+}
+
+bool
+_PackageParser::OnPrivilegeValue(const char* pCharacters)
+{
+       SysLog(NID_APP, "Privilege = [%s]", pCharacters);
+       __pPackageInfoImpl->AddPrivilege(*new (std::nothrow) String(pCharacters));
+
+       return true;
+}
+
+bool
+_PackageParser::OnIconValue(const char* pCharacters)
+{
+       SysTryReturn(NID_APP, __pDefaultIconType, false, E_SYSTEM, "__pDefaultIconType is null");
+
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
+
+       _PackageXmlAttribute* pAttr = GetAttribute();
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+
+       char* pSection = pAttr->Find("Section");
+       SysTryReturn(NID_APP, pSection, true, E_SYSTEM, "pSection is null");
+
+       String iconRelPath;
+
+       if (strcasecmp(__pDefaultIconType, "Xhigh") == 0)
+       {
+               iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters);
+       }
+       else if (strcasecmp(__pDefaultIconType, "High") == 0)
+       {
+               iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters);
+       }
+       else
+       {
+               SysTryReturn(NID_APP, 0, false, E_SYSTEM, "Invalid __pDefaultIconType [%s]", __pDefaultIconType);
+       }
+
+       if (strcasecmp(pSection, "MainMenu") == 0)
+       {
+               pPackageAppInfoImpl->SetAppMenuIconPath(iconRelPath);
+       }
+       else if (strcasecmp(pSection, "Setting") == 0)
+       {
+               pPackageAppInfoImpl->SetAppSettingIconPath(iconRelPath);
+       }
+       else if (strcasecmp(pSection, "Notification") == 0)
+       {
+               pPackageAppInfoImpl->SetAppNotificationIconPath(iconRelPath);
+       }
+
+       SysLog(NID_APP, "Section = [%s], Icon = [%ls]", pSection, iconRelPath.GetPointer());
+
+       return true;
+}
+
+bool
+_PackageParser::OnDisplayNameValue(const char* pCharacters)
+{
+       _PackageXmlAttribute* pAttr = 0;
+       char* pAttrValue = 0;
+
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
+
+       pAttr = GetAttribute();
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+
+       pAttrValue = pAttr->Find("Locale");
+       SysTryReturn(NID_APP, pAttrValue, true, E_SYSTEM, "pAttrValue is null");
+
+       if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
+       {
+               pPackageAppInfoImpl->SetAppDisplayName(pCharacters);
+
+               if (__isDefaultName == true)
+               {
+                       __pPackageInfoImpl->SetDisplayName(pCharacters);
+               }
+       }
+
+       String* pValue = new (std::nothrow) String;
+       StringUtil::Utf8ToString(pCharacters, *pValue);
+
+       pPackageAppInfoImpl->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue);
+
+       SysLog(NID_APP, "DisplayName Locale = [%s][%s]", pAttrValue, pCharacters);
+
+       return true;
+}
+
+bool
+_PackageParser::OnDescriptionValue(const char* pCharacters)
+{
+       _PackageXmlAttribute *pAttr = 0;
+       char *pAttrValue = 0;
+
+       pAttr = GetAttribute();
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+
+       pAttrValue = pAttr->Find("Locale");
+       SysTryReturn(NID_APP, pAttrValue, true, E_SYSTEM, "pAttrValue is null");
+
+       if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
+       {
+               __pPackageInfoImpl->SetDescription(pCharacters);
+       }
+
+       SysLog(NID_APP, "Description Locale =[%s][%s]", pAttrValue, pCharacters);
+
+       return true;
+}
+
+bool
+_PackageParser::OnCategoryValue(const char* pCharacters)
+{
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
+
+       pPackageAppInfoImpl->AddCategory(new (std::nothrow) String(pCharacters));
+
+       SysLog(NID_APP, "Category = [%s]", pCharacters);
+
+       return true;
+}
+
+bool
+_PackageParser::ParseAppAttribute(_PackageXmlAttribute* pAttr, bool isUiApp)
+{
+       _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
+       SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
+
+       char* pName = pAttr->Find("Name");
+       SysTryReturn(NID_APP, pName, true, E_SYSTEM, "pName is null");
+
+       SysLog(NID_APP, "Name = [%s]", pName);
+       pPackageAppInfoImpl->SetAppName(pName);
+
+       AppId appId = __pPackageInfoImpl->GetId() + L"." + pName;
+       pPackageAppInfoImpl->SetAppId(appId);
+
+       char* pMain = pAttr->Find("Main");
+       if (pMain)
+       {
+               SysLog(NID_APP, "Main = [%s]", pMain);
+               if (strcasecmp(pMain, "True") == 0)
+               {
+                       __isDefaultName = true;
+                       __pPackageInfoImpl->SetMainAppId(appId);
+                       pPackageAppInfoImpl->SetMainApp(true);
+               }
+       }
+
+       if (isUiApp == true)
+       {
+               char* pMenuIconVisible = pAttr->Find("MenuIconVisible");
+               if (pMenuIconVisible)
+               {
+                       if (strcasecmp(pMenuIconVisible, "True") == 0)
+                       {
+                               pPackageAppInfoImpl->SetMenuIconVisible(true);
+                       }
+                       else
+                       {
+                               pPackageAppInfoImpl->SetMenuIconVisible(false);
+                       }
+
+                       SysLog(NID_APP, "MenuIconVisible = [%s]", pMenuIconVisible);
+               }
+       }
+       else
+       {
+               pPackageAppInfoImpl->SetMenuIconVisible(false);
+       }
+
+       return true;
+}
+
+} } } // Tizen::App::Package
index 58ced5e..cc9d420 100755 (executable)
@@ -50,16 +50,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-app-manager" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-package-manager" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-content-mime-type" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-location-manager")
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-sound-manager" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-serial" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-power" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-device" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-sensor" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-info" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-system-settings")
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-runtime-info")
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-telephony-sim" )
 TARGET_LINK_LIBRARIES(${this_target} "-lappsvc" )
 TARGET_LINK_LIBRARIES(${this_target} "-laul" )
 TARGET_LINK_LIBRARIES(${this_target} "-lbundle" )
@@ -73,6 +64,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" )
 TARGET_LINK_LIBRARIES(${this_target} "-lheynoti" )
 TARGET_LINK_LIBRARIES(${this_target} "-licui18n" )
 TARGET_LINK_LIBRARIES(${this_target} "-licuuc" )
+TARGET_LINK_LIBRARIES(${this_target} "-lmessage-port" )
 TARGET_LINK_LIBRARIES(${this_target} "-lnotification" )
 TARGET_LINK_LIBRARIES(${this_target} "-lpcre" )
 TARGET_LINK_LIBRARIES(${this_target} "-lpkgmgr-client" )
@@ -80,15 +72,13 @@ TARGET_LINK_LIBRARIES(${this_target} "-lpkgmgr-info" )
 TARGET_LINK_LIBRARIES(${this_target} "-lpmapi" )
 TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
 TARGET_LINK_LIBRARIES(${this_target} "-lrt" )
-TARGET_LINK_LIBRARIES(${this_target} "-lsensor")
 TARGET_LINK_LIBRARIES(${this_target} "-lsqlite3" )
-TARGET_LINK_LIBRARIES(${this_target} "-lsoup-2.4" )
 TARGET_LINK_LIBRARIES(${this_target} "-luuid" )
 TARGET_LINK_LIBRARIES(${this_target} "-lvconf" )
 TARGET_LINK_LIBRARIES(${this_target} "-lxml2" )
 TARGET_LINK_LIBRARIES(${this_target} "-lz" )
-TARGET_LINK_LIBRARIES(${this_target} "-ldukgenerator" )
-TARGET_LINK_LIBRARIES(${this_target} "-lcryptsvc" )
+#TARGET_LINK_LIBRARIES(${this_target} "-ldukgenerator" )
+#TARGET_LINK_LIBRARIES(${this_target} "-lcryptsvc" )
 TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib -ldrm-service-core-intel")
 TARGET_LINK_LIBRARIES(${this_target} "-lecore" )
 
index 63f2bb0..73468d0 100755 (executable)
@@ -38,6 +38,7 @@ SET (${this_target}_SOURCE_FILES
        FBaseShortComparer.cpp
        FBaseString.cpp
        FBaseStringComparer.cpp
+       FBaseStringHashCodeProvider.cpp
        FBase_StringConverter.cpp
        FBaseSys.cpp
        FBaseTimeSpan.cpp
@@ -110,6 +111,8 @@ SET (${this_target}_SOURCE_FILES
        utility/FBaseUtil_RegularExpressionImpl.cpp
        utility/FBaseUtil_FileZipperImpl.cpp
        utility/FBaseUtil_IcuConverter.cpp
+       utility/FBaseUtilScanner.cpp
+       utility/FBaseUtil_ScannerImpl.cpp
 )
 
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
index 90eab78..72d970f 100644 (file)
@@ -830,6 +830,12 @@ ByteBuffer::GetPointer(void) const
        return __pArrayStart;
 }
 
+byte*
+ByteBuffer::GetPointer(void)
+{
+       return __pArrayStart;
+}
+
 bool
 ByteBuffer::Equals(const Tizen::Base::Object& obj) const
 {
index ced0cea..a445e46 100644 (file)
@@ -27,7 +27,6 @@
 #include <FBaseSysLog.h>
 #include <unique_ptr.h>
 
-
 namespace Tizen { namespace Base
 {
 
@@ -39,24 +38,31 @@ enum DateTimeLimits
        MIN_HOUR = 0,
        MIN_MINUTE = 0,
        MIN_SECOND = 0,
+       MIN_TICK = 0,
        _MAX_YEAR = 9999,
        MAX_MONTH = 12,
        MAX_DAY = 31,
        MAX_HOUR = 23,
        MAX_MINUTE = 59,
        MAX_SECOND = 59,
+       MAX_TICK = 999,
        NUM_OF_SEC_IN_DAY = 86400,
        NUM_OF_SEC_IN_HOUR = 3600,
        NUM_OF_SEC_IN_MINUTE = 60,
-       NUM_OF_MILLISEC_IN_DAY = 86400000LL,
-       NUM_OF_MILLISEC_IN_HOUR = 3600000LL,
-       NUM_OF_MILLISEC_IN_MINUTE = 60000LL
+       NUM_OF_TICKS_IN_DAY = 86400000LL,
+       NUM_OF_TICKS_IN_HOUR = 3600000LL,
+       NUM_OF_TICKS_IN_MINUTE = 60000LL,
+       NUM_OF_TICKS_IN_SECOND = 1000LL
 };
 
+static const int TICKS_PER_MILLISECOND = 1;
 static const long SEC_IN_A_DAY = (24L * 60L * 60L);
 static const long long MINIMUM_VALUE_IN_SEC = 86400LL;
 static const int DAYS_IN_LEAP_YEAR[] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
 static const int DAYS[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
+static const int INT_HALF_BIT = 16;
+static const int LOW_16BIT = 0xFFFF;
+static const long long TOTAL_MAX_TICKS = DateTime::GetMaxValue().GetTicks();
 
 DateTime::DateTime(void)
        : __pDateTimeImpl(null)
@@ -77,15 +83,14 @@ DateTime::~DateTime(void)
 result
 DateTime::SetValue(const TimeSpan& value)
 {
-       long long total = (long long) (value.GetTicks() / 1000) + MINIMUM_VALUE_IN_SEC;
-       SysTryReturn(NID_BASE, total >= NUM_OF_SEC_IN_DAY, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+       long long total = value.GetTicks();
+       SysTryReturn(NID_BASE, total >= MIN_TICK, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
 
-       long long maxSeconds = (long long) (DateTime::GetMaxValue().GetTime().GetTicks() / 1000) + MINIMUM_VALUE_IN_SEC;
-       SysTryReturn(NID_BASE, total <= maxSeconds, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+       SysTryReturn(NID_BASE, total <= TOTAL_MAX_TICKS, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
 
-       return ConvertSecondsToDate(total, &__dateTime);
+       return ConvertTicksToDate(total, &__dateTime);
 }
 
 void
@@ -102,21 +107,22 @@ DateTime::SetValue(const DateTime& value)
 result
 DateTime::SetValue(int year, int month, int day, int hour, int minute, int second)
 {
-       SysTryReturn(NID_BASE, 
+       SysTryReturn(NID_BASE,
                ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
                 (month >= MIN_MONTH && month <= MAX_MONTH) &&
                 (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
                 (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
-                (second >= MIN_SECOND && second <= MAX_SECOND)),
+                ((second & LOW_16BIT) >= MIN_SECOND && (second & LOW_16BIT) <= MAX_SECOND) &&
+                ((second >> INT_HALF_BIT) >= MIN_TICK && (second >> INT_HALF_BIT) <= MAX_TICK)),
                E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-               "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), and second(%d) is in out of allowable range.",
-               GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second);
+               "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
+               GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second & LOW_16BIT, second >> INT_HALF_BIT);
 
        int daysInMonth = 0;
        result r = GetDaysInMonth(year, month, daysInMonth);
        SysTryReturn(NID_BASE, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
        SysTryReturn(NID_BASE, (day >= MIN_DAY && day <= daysInMonth), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-               ("[%s] day is in out of allowable range."), GetErrorMessage(E_OUT_OF_RANGE));
+               ("[%s] day is out of allowable range."), GetErrorMessage(E_OUT_OF_RANGE));
 
        __dateTime.year = year;
        __dateTime.month = month;
@@ -124,8 +130,42 @@ DateTime::SetValue(int year, int month, int day, int hour, int minute, int secon
        __dateTime.hour = hour;
        __dateTime.minute = minute;
        __dateTime.second = second;
+       return E_SUCCESS;
+}
+
+result
+DateTime::SetValue(int year, int month, int day, int hour, int minute, int second, int millisecond)
+{
+       SysTryReturn(NID_BASE,
+               ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
+                (month >= MIN_MONTH && month <= MAX_MONTH) &&
+                (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
+                (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
+                (second >= MIN_SECOND && second <= MAX_SECOND) &&
+                ((millisecond * TICKS_PER_MILLISECOND >= MIN_TICK) && (millisecond * TICKS_PER_MILLISECOND <= MAX_TICK))),
+               E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+               "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
+               GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second, millisecond * TICKS_PER_MILLISECOND);
+
+       int daysInMonth = 0;
+       result r = GetDaysInMonth(year, month, daysInMonth);
+       SysTryReturn(NID_BASE, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_BASE, (day >= MIN_DAY && day <= daysInMonth), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+               ("[%s] day is out of allowable range."), GetErrorMessage(E_OUT_OF_RANGE));
 
-       return(E_SUCCESS);
+       __dateTime.year = year;
+       __dateTime.month = month;
+       __dateTime.day = day;
+       __dateTime.hour = hour;
+       __dateTime.minute = minute;
+       __dateTime.second = ((millisecond * TICKS_PER_MILLISECOND) << INT_HALF_BIT) | second;
+       return E_SUCCESS;
+}
+
+result
+DateTime::SetValue(long long ticks)
+{
+       return ConvertTicksToDate(ticks, &__dateTime);
 }
 
 DateTime&
@@ -136,7 +176,7 @@ DateTime::operator =(const DateTime& rhs)
                SetValue(rhs);
        }
 
-       return(*this);
+       return *this;
 }
 
 bool
@@ -196,7 +236,15 @@ DateTime::operator <(const DateTime& rhs) const
        {
                return false;
        }
-       if (__dateTime.second < rhs.__dateTime.second)
+       if ((__dateTime.second & LOW_16BIT) < (rhs.__dateTime.second & LOW_16BIT))
+       {
+               return true;
+       }
+       if ((__dateTime.second & LOW_16BIT) > (rhs.__dateTime.second & LOW_16BIT))
+       {
+               return false;
+       }
+       if ((__dateTime.second >> INT_HALF_BIT) < (rhs.__dateTime.second >> INT_HALF_BIT))
        {
                return true;
        }
@@ -247,44 +295,39 @@ DateTime::operator >(const DateTime& rhs) const
        {
                return false;
        }
-       if (__dateTime.second > rhs.__dateTime.second)
+       if ((__dateTime.second & LOW_16BIT) > (rhs.__dateTime.second & LOW_16BIT))
+       {
+               return true;
+       }
+       if ((__dateTime.second & LOW_16BIT) < (rhs.__dateTime.second & LOW_16BIT))
+       {
+               return false;
+       }
+       if ((__dateTime.second >> INT_HALF_BIT) > (rhs.__dateTime.second >> INT_HALF_BIT))
        {
                return true;
        }
+
        return false;
 }
 
 bool
 DateTime::operator <=(const DateTime& rhs) const
 {
-       return((*this == rhs) || (*this < rhs));
+       return ((*this == rhs) || (*this < rhs));
 }
 
 bool
 DateTime::operator >=(const DateTime& rhs) const
 {
-       return((*this == rhs) || (*this > rhs));
+       return ((*this == rhs) || (*this > rhs));
 }
 
 result
 DateTime::Add(const TimeSpan& t)
 {
-
-       long long seconds = ConvertDateToSeconds(&__dateTime);
-       long long total = (long long) (t.GetTicks() / 1000) + seconds;
-
-       SysTryReturn(NID_BASE, total >= NUM_OF_SEC_IN_DAY, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-               "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
-
-       long long maxSeconds = ConvertDateToSeconds(&(DateTime::GetMaxValue().__dateTime));
-       SysTryReturn(NID_BASE, total <= maxSeconds, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-               "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
-
-       result r = ConvertSecondsToDate(total, &__dateTime);
-       if (r != E_SUCCESS)
-       {
-               SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
+       result r = AddTicks(t.GetTicks());
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return r;
 }
@@ -292,13 +335,10 @@ DateTime::Add(const TimeSpan& t)
 result
 DateTime::AddDays(int days)
 {
-       TimeSpan ts(days * NUM_OF_SEC_IN_DAY * 1000LL);
+       long long ticks = static_cast< long long >(days) * NUM_OF_TICKS_IN_DAY;
 
-       result r = Add(ts);
-       if (IsFailed(r))
-       {
-               SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
+       result r = AddTicks(ticks);
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return r;
 }
@@ -306,13 +346,10 @@ DateTime::AddDays(int days)
 result
 DateTime::AddHours(int hours)
 {
-       TimeSpan ts(hours * NUM_OF_SEC_IN_HOUR * 1000LL);
+       long long ticks = static_cast< long long >(hours) * NUM_OF_TICKS_IN_HOUR;
 
-       result r = Add(ts);
-       if (IsFailed(r))
-       {
-               SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
+       result r = AddTicks(ticks);
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return r;
 }
@@ -320,13 +357,10 @@ DateTime::AddHours(int hours)
 result
 DateTime::AddMinutes(int minutes)
 {
-       TimeSpan ts(minutes * NUM_OF_SEC_IN_MINUTE * 1000LL);
+       long long ticks = static_cast< long long >(minutes) * NUM_OF_TICKS_IN_MINUTE;
 
-       result r = Add(ts);
-       if (IsFailed(r))
-       {
-               SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
+       result r = AddTicks(ticks);
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return r;
 }
@@ -337,56 +371,49 @@ DateTime::AddMonths(int months)
        DateTime tmp;
        tmp.SetValue(*this);
 
-       tmp.__dateTime.year += months / MAX_MONTH;
+       tmp.__dateTime.year += months / MAX_MONTH; // Get the year to add
 
        int tempMonth = tmp.__dateTime.month + months % MAX_MONTH;
-       if (tempMonth > MAX_MONTH)
+       if (tempMonth > MAX_MONTH)      // Month was added and moved to next year
        {
                tmp.__dateTime.year++;
                tmp.__dateTime.month = tempMonth - MAX_MONTH;
        }
-       else if (tempMonth < 0)
+       else if (tempMonth <= 0)        // Month was subtracted and moved to previous year
        {
                tmp.__dateTime.year--;
                tmp.__dateTime.month = MAX_MONTH + tempMonth;
        }
-       else if (tempMonth == 0)
-       {
-               tmp.__dateTime.year--;
-               tmp.__dateTime.month = MAX_MONTH;
-       }
-       else
+       else                                            // Keep current year
        {
                tmp.__dateTime.month += months % MAX_MONTH;
        }
 
        // Check the days in Month
-       if (tmp.__dateTime.month != 2)      // Not Feb
+       if (tmp.__dateTime.month != 2)      // Current month is not Feb
        {
-               if (tmp.__dateTime.day == 31)
+               if (tmp.__dateTime.day == 31)   // Previous day is 31th
                {
                        result r = SetValue(tmp.__dateTime.year, tmp.__dateTime.month, tmp.__dateTime.day);
-                       if (IsFailed(r))
+                       if (IsFailed(r))                        // Current month doesn't have 31th
                        {
-                               r = tmp.AddDays(-1);
-                               SysTryReturn(NID_BASE, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+                               tmp.__dateTime.day = 30;        // Set day to 30th
                        }
                }
        }
-       else                                // Feb
+       else                                                                    // Current month is Feb
        {
-               if (tmp.__dateTime.day > 28)
+               if (tmp.__dateTime.day > 28)            // Previous day is over 28th
                {
-                       if (tmp.IsLeapYear())
+                       if (tmp.IsLeapYear())                   // Leap year
                        {
-                               tmp.__dateTime.day = 29;
+                               tmp.__dateTime.day = 29;        // Set day to 29th
                        }
-                       else
+                       else                                                    // Not leap year
                        {
-                               tmp.__dateTime.day = 28;
+                               tmp.__dateTime.day = 28;        // Set day to 28th
                        }
                }
-
        }
 
        SysTryReturn(NID_BASE, (tmp <= DateTime::GetMaxValue()) && (tmp >= DateTime::GetMinValue()), E_OUT_OF_RANGE,
@@ -400,13 +427,33 @@ DateTime::AddMonths(int months)
 result
 DateTime::AddSeconds(int seconds)
 {
-       TimeSpan ts(seconds * 1000LL);
+       long long ticks = static_cast< long long >(seconds) * NUM_OF_TICKS_IN_SECOND;
 
-       result r = Add(ts);
-       if (IsFailed(r))
-       {
-               SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
+       result r = AddTicks(ticks);
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+DateTime::AddMilliseconds(long long milliseconds)
+{
+       long long ticks = milliseconds * TICKS_PER_MILLISECOND;
+
+       result r = AddTicks(ticks);
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+DateTime::AddTicks(long long ticks)
+{
+       long long total = ConvertDateToTicks(&__dateTime);
+       total += ticks;
+
+       result r = ConvertTicksToDate(total, &__dateTime);
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return r;
 }
@@ -457,10 +504,8 @@ DateTime::Compare(const DateTime& dt1, const DateTime& dt2)
        {
                return -1;
        }
-       else
-       {
-               return(0);
-       }
+
+       return 0;
 }
 
 int
@@ -478,7 +523,7 @@ DateTime::Equals(const Object& obj) const
                return false;
        }
 
-       return(*this == *pOther);
+       return (*this == *pOther);
 }
 
 int
@@ -486,7 +531,7 @@ DateTime::GetHashCode(void) const
 {
        TimeSpan t = GetTime();
        int hash = t.GetHashCode();
-       return(hash ^ (hash >> 16));
+       return (hash ^ (hash >> INT_HALF_BIT));
 }
 
 TimeSpan
@@ -506,7 +551,7 @@ DateTime::GetTimeOfDay(void) const
 
        long long span = total - since;
 
-       return(TimeSpan(span * 1000));
+       return (TimeSpan(span * NUM_OF_TICKS_IN_SECOND));
 }
 
 result
@@ -527,7 +572,7 @@ DateTime::GetDaysInMonth(int year, int month, int& days)
        }
        else
        {
-               days = (daysInMonth[month]);
+               days = daysInMonth[month];
        }
 
        return E_SUCCESS;
@@ -536,24 +581,18 @@ DateTime::GetDaysInMonth(int year, int month, int& days)
 result
 DateTime::Subtract(const TimeSpan& t)
 {
-       long long total = ConvertDateToSeconds(&__dateTime);
-       long long span = total - (t.GetTicks() / 1000);
+       DateTime dt1;
+       long long total = ConvertDateToTicks(&__dateTime);
+       long long span = total - t.GetTicks();
 
-       SysTryReturn(NID_BASE, span > 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] The arguments contain invalid values.",
+       SysTryReturn(NID_BASE, span >= MIN_TICK, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] The arguments contain invalid values.",
                GetErrorMessage(E_OUT_OF_RANGE));
 
-       SysTryReturn(NID_BASE, span >= NUM_OF_SEC_IN_DAY, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-               "[%s] The arguments contain invalid values.", GetErrorMessage(E_OUT_OF_RANGE));
-
-       long long maxSeconds = ConvertDateToSeconds(&(DateTime::GetMaxValue().__dateTime));
-       SysTryReturn(NID_BASE, span <= maxSeconds, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+       SysTryReturn(NID_BASE, span <= TOTAL_MAX_TICKS, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
 
-       result r = ConvertSecondsToDate(span, &__dateTime);
-       if (r != E_SUCCESS)
-       {
-               SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
+       result r = ConvertTicksToDate(span, &__dateTime);
+       SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return r;
 }
@@ -565,7 +604,7 @@ DateTime::ToString(void) const
 
        swprintf(date, (sizeof(date) / sizeof(wchar_t)), L"%2d/%2d/%4d %2d:%2d:%2d",
                         __dateTime.month, __dateTime.day, __dateTime.year, __dateTime.hour, __dateTime.minute,
-                        __dateTime.second);
+                        (__dateTime.second & LOW_16BIT));
 
        if (__dateTime.month < 10)
        {
@@ -603,14 +642,12 @@ DateTime::ToString(void) const
                date[14] = L'0';
        }
 
-       if (__dateTime.second < 10)
+       if ((__dateTime.second & LOW_16BIT) < 10)
        {
                date[17] = L'0';
        }
 
-       String string(date);
-
-       return string;
+       return String(date);
 }
 
 result
@@ -626,43 +663,43 @@ DateTime::Parse(const String& str, DateTime& dt)
        SysTryReturn(NID_BASE, pTmp != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
-       wchar_t* pMchar = (wchar_t*) str.GetPointer();
+       wchar_t* pMchar = const_cast< wchar_t* >(str.GetPointer());
 
        // month
        wcsncpy(pTmp.get(), pMchar, 2);
        pTmp[2] = L'\0';
 
-       int month = (int) wcstol(pTmp.get(), null, 10);
+       int month = static_cast< int >(wcstol(pTmp.get(), null, 10));
 
        // day
        wcsncpy(pTmp.get(), pMchar + 3, 2);
        pTmp[2] = L'\0';
 
-       int day = (int) wcstol(pTmp.get(), null, 10);
+       int day = static_cast< int >(wcstol(pTmp.get(), null, 10));
 
        // year
        wcsncpy(pTmp.get(), pMchar + 6, 4);
        pTmp[4] = L'\0';
 
-       int year = (int) wcstol(pTmp.get(), null, 10);
+       int year = static_cast< int >(wcstol(pTmp.get(), null, 10));
 
        // hour
        wcsncpy(pTmp.get(), pMchar + 11, 2);
        pTmp[2] = L'\0';
 
-       int hour = (int) wcstol(pTmp.get(), null, 10);
+       int hour = static_cast< int >(wcstol(pTmp.get(), null, 10));
 
        // minute
        wcsncpy(pTmp.get(), pMchar + 14, 2);
        pTmp[2] = L'\0';
 
-       int minute = (int) wcstol(pTmp.get(), null, 10);
+       int minute = static_cast< int >(wcstol(pTmp.get(), null, 10));
 
        // second
        wcsncpy(pTmp.get(), pMchar + 17, 2);
        pTmp[2] = L'\0';
 
-       int sec = (int) wcstol(pTmp.get(), null, 10);
+       int sec = static_cast< int >(wcstol(pTmp.get(), null, 10));
 
        // construct date time
        DateTime tmpDt;
@@ -707,7 +744,25 @@ DateTime::GetMinute(void) const
 int
 DateTime::GetSecond(void) const
 {
-       return __dateTime.second;
+       return (__dateTime.second & LOW_16BIT);
+}
+
+int
+DateTime::GetMillisecond(void) const
+{
+       return ((__dateTime.second >> INT_HALF_BIT) / TICKS_PER_MILLISECOND);
+}
+
+long long
+DateTime::GetTicks(void) const
+{
+       return ConvertDateToTicks(&__dateTime);
+}
+
+int
+DateTime::GetTicksPerSecond(void)
+{
+       return NUM_OF_TICKS_IN_SECOND;
 }
 
 TimeSpan
@@ -715,13 +770,13 @@ DateTime::GetTime(void) const
 {
        long long seconds = ConvertDateToSeconds(&__dateTime) - ConvertDateToSeconds(&(DateTime::GetMinValue().__dateTime));
 
-       return TimeSpan(seconds * 1000);
+       return TimeSpan(seconds * NUM_OF_TICKS_IN_SECOND);
 }
 
 const DateTime&
 DateTime::GetMaxValue(void)
 {
-       static DateTime maxValue(_MAX_YEAR, MAX_MONTH, MAX_DAY, MAX_HOUR, MAX_MINUTE, MAX_SECOND);
+       static DateTime maxValue(_MAX_YEAR, MAX_MONTH, MAX_DAY, MAX_HOUR, MAX_MINUTE, MAX_SECOND, MAX_TICK);
 
        return maxValue;
 }
@@ -729,7 +784,7 @@ DateTime::GetMaxValue(void)
 const DateTime&
 DateTime::GetMinValue(void)
 {
-       static DateTime minValue(MIN_YEAR, MIN_MONTH, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND);
+       static DateTime minValue(MIN_YEAR, MIN_MONTH, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND, MIN_TICK);
 
        return minValue;
 }
@@ -746,147 +801,106 @@ DateTime::IsLeapYear(int year)
        return year >= 0 && (!(year % 4) && ((year % 100) || !(year % 400)));
 }
 
-DateTime::DateTime(int year, int month, int day, int hour, int minute, int second)
+DateTime::DateTime(int year, int month, int day, int hour, int minute, int second, int tick)
        : __pDateTimeImpl(null)
 {
-       SetValue(year, month, day, hour, minute, second);
+       SetValue(year, month, day, hour, minute, (tick << INT_HALF_BIT) | second);
 }
 
 result
-DateTime::ConvertSecondsToDate(long long seconds, TmDateTime* pDateTime)
+DateTime::ConvertTicksToDate(long long ticks, TmDateTime* pDateTime)
 {
-       DateTime dt;
+       SysTryReturnResult(NID_BASE, (ticks >= MIN_TICK) && (ticks <= TOTAL_MAX_TICKS), E_OUT_OF_RANGE,
+               "[%s] The arguments (%lld) contain invalid values.", GetErrorMessage(E_OUT_OF_RANGE), ticks);
 
-       int year = 0;
        int month = 0;
        int day = 0;
        int hour = 0;
        int minute = 0;
        int second = 0;
-       int totalDays = 0;
-       int tempDays = 0;
-       int tempSeconds = 0;
-       bool leapYear = false;
+       int tempTicks = 0;
 
-       totalDays = (int) (seconds / SEC_IN_A_DAY);
+       int totalDays = static_cast< int >(ticks / NUM_OF_TICKS_IN_DAY) + 1;
 
        // Get a year and leapYear
-       year = CountYears(totalDays);
-       SysTryReturn(NID_BASE, year >= MIN_YEAR && year <= _MAX_YEAR, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-               "[%s] The arguments (%d) contain invalid values.", GetErrorMessage(E_OUT_OF_RANGE), seconds);
+       int year = CountYears(totalDays);
 
        // Check a leapYear
-       leapYear = DateTime::IsLeapYear(year);
+       bool leapYear = DateTime::IsLeapYear(year);
 
        // Get days without year;
-       tempDays = totalDays - CountDays(year);
-
-       // Check the boundary of days
-       if (leapYear)
-       {
-               if (tempDays > 366)
-               {
-                       year += 1;
-                       tempDays -= 366;
-               }
-       }
-       else
-       {
-               if (tempDays > 365)
-               {
-                       year += 1;
-                       tempDays -= 365;
-               }
-       }
+       int tempDays = totalDays - CountDays(year);
 
        // Get month
        if (tempDays == 0)      //  month = 0 , day = 0
        {
-               dt.__dateTime.year = year;
-               dt.__dateTime.month = 0;
-               dt.__dateTime.day = 0;
-               dt.__dateTime.hour = 0;
-               dt.__dateTime.minute = 0;
-               dt.__dateTime.second = 0;
-
-               tempSeconds = (int) (seconds - ConvertDateToSeconds(&(dt.__dateTime)));
-
-               // Get Hour
-               hour = tempSeconds / NUM_OF_SEC_IN_HOUR;
-
-               tempSeconds -= hour * NUM_OF_SEC_IN_HOUR;
-
-               // Get Minute
-               minute = tempSeconds / NUM_OF_SEC_IN_MINUTE;
-
-               // Get Second
-               second = tempSeconds - minute * NUM_OF_SEC_IN_MINUTE;
-
-               SetValue(year, 1, 1, hour, minute, second);
-
-               return E_SUCCESS;
+               month = 0;
+               day = 0;
        }
        else if (leapYear)
        {
-               int leapYearDaysCount = 0;
+               int idx = 0;
 
-               for (; leapYearDaysCount < 12; leapYearDaysCount++)
+               for (; idx < 12; ++idx)
                {
-                       if ((DAYS_IN_LEAP_YEAR[leapYearDaysCount] < tempDays) && (tempDays <= DAYS_IN_LEAP_YEAR[leapYearDaysCount + 1]))
+                       if ((DAYS_IN_LEAP_YEAR[idx] < tempDays) && (tempDays <= DAYS_IN_LEAP_YEAR[idx + 1]))
                        {
-                               month = leapYearDaysCount + 1;
                                break;
                        }
                }
 
-               SysTryReturn(NID_BASE, leapYearDaysCount != 12, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-                       "[%s] The arguments (%d) contain invalid values.", GetErrorMessage(E_OUT_OF_RANGE), seconds);
-
-               day = tempDays - DAYS_IN_LEAP_YEAR[month - 1];
+               month = idx + 1;
+               day = tempDays - DAYS_IN_LEAP_YEAR[idx];
        }
        else
        {
-               int daysCount = 0;
+               int idx = 0;
 
-               for (; daysCount < 12; daysCount++)
+               for (; idx < 12; ++idx)
                {
-                       if ((DAYS[daysCount] < tempDays) && (tempDays <= DAYS[daysCount + 1]))
+                       if ((DAYS[idx] < tempDays) && (tempDays <= DAYS[idx + 1]))
                        {
-                               month = daysCount + 1;
                                break;
                        }
                }
 
-               SysTryReturn(NID_BASE, daysCount != 12, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
-                       "[%s] The arguments (%d) contain invalid values.", GetErrorMessage(E_OUT_OF_RANGE), seconds);
-
-               // Get day
-               day = tempDays - DAYS[month - 1];
+               month = idx + 1;
+               day = tempDays - DAYS[idx];
        }
 
-       dt.SetValue(year, month, day, 0, 0, 0);
+       DateTime dt(year, month, day, 0, 0, 0, 0);
 
        // Get Hour
-       tempSeconds = (int) (seconds - ConvertDateToSeconds(&(dt.__dateTime)));
-       hour = tempSeconds / NUM_OF_SEC_IN_HOUR;
+       tempTicks = static_cast< int >(ticks - ConvertDateToTicks(&(dt.__dateTime)));
+       hour = tempTicks / NUM_OF_TICKS_IN_HOUR;
 
        // Get Minute
-       tempSeconds -= hour * NUM_OF_SEC_IN_HOUR;
-       minute = tempSeconds / NUM_OF_SEC_IN_MINUTE;
+       tempTicks -= hour * NUM_OF_TICKS_IN_HOUR;
+       minute = tempTicks / NUM_OF_TICKS_IN_MINUTE;
 
        // Get Second
-       second = tempSeconds - minute * NUM_OF_SEC_IN_MINUTE;
+       tempTicks -= minute * NUM_OF_TICKS_IN_MINUTE;
+       second = tempTicks / NUM_OF_TICKS_IN_SECOND;
+
+       // Get Tick
+       tempTicks -= second * NUM_OF_TICKS_IN_SECOND;
+       second = ((tempTicks << INT_HALF_BIT) | second);
 
-       SetValue(year, month, day, hour, minute, second);
+       pDateTime->year = year;
+       pDateTime->month = month;
+       pDateTime->day = day;
+       pDateTime->hour = hour;
+       pDateTime->minute = minute;
+       pDateTime->second = second;
 
        return E_SUCCESS;
 }
 
 long long
-DateTime::ConvertDateToSeconds(const TmDateTime* pDateTime) const
+DateTime::ConvertDateToTicks(const TmDateTime* pDateTime) const
 {
        long long days = 0;
-       long long seconds = 0;
+       long long ticks = 0;
 
        // Add year
        days = CountDays(pDateTime->year);
@@ -905,21 +919,42 @@ DateTime::ConvertDateToSeconds(const TmDateTime* pDateTime) const
        }
 
        // Add days
-       days += pDateTime->day;
+       days += pDateTime->day - 1;
 
-       // Convert to Seconds
-       seconds = days * NUM_OF_SEC_IN_DAY;
+       // Convert to ticks
+       ticks = days * NUM_OF_TICKS_IN_DAY;
 
        // Add hours
-       seconds += pDateTime->hour * NUM_OF_SEC_IN_HOUR;
+       ticks += pDateTime->hour * NUM_OF_TICKS_IN_HOUR;
 
        // Add minutes
-       seconds += pDateTime->minute * NUM_OF_SEC_IN_MINUTE;
+       ticks += pDateTime->minute * NUM_OF_TICKS_IN_MINUTE;
 
-       // Add minutes
-       seconds += pDateTime->second;
+       // Add seconds
+       ticks += ((pDateTime->second) & LOW_16BIT) * NUM_OF_TICKS_IN_SECOND;
+
+       // Add ticks
+       ticks += ((pDateTime->second) >> INT_HALF_BIT);
+
+       return ticks;
+}
+
+result
+DateTime::ConvertSecondsToDate(long long seconds, TmDateTime* pDateTime)
+{
+       long long ticks = seconds * NUM_OF_TICKS_IN_SECOND;
 
-       return seconds;
+       return ConvertTicksToDate(ticks, pDateTime);
+}
+
+long long
+DateTime::ConvertDateToSeconds(const TmDateTime* pDateTime) const
+{
+       long long ticks = ConvertDateToTicks(pDateTime);
+
+       return ticks / NUM_OF_TICKS_IN_SECOND;
 }
 
 }} // Tizen::Base
+
+
index 3851d48..91a8876 100644 (file)
@@ -161,15 +161,31 @@ LongLong::Parse(const String& s, long long& ret)
        wchar_t* pEnd = null;
 
        int len = s.GetLength();
-       SysTryReturn(NID_BASE, (len > 0), E_NUM_FORMAT, E_NUM_FORMAT, "[E_NUM_FORMAT] The length of s MUST be greater than 0.");
+       SysTryReturnResult(NID_BASE, (len > 0), E_NUM_FORMAT, "[%s] The length of s MUST be greater than 0.",
+               GetErrorMessage(E_NUM_FORMAT));
+
+       return Parse(s, Character::RADIX_DECIMAL, ret);
+}
+
+result
+LongLong::Parse(const String& s, int radix, long long& ret)
+{
+       SysTryReturnResult(NID_BASE, radix == Character::RADIX_BINARY || radix == Character::RADIX_OCTAL ||
+               radix == Character::RADIX_DECIMAL || radix == Character::RADIX_HEXADECIMAL, E_OUT_OF_RANGE,
+               "[%s] The radix(%d) MUST be one of 2, 8, 10 and 16.", GetErrorMessage(E_OUT_OF_RANGE), radix);
+
+       wchar_t* pEnd = null;
+
+       int len = s.GetLength();
+       SysTryReturnResult(NID_BASE, (len > 0), E_NUM_FORMAT, "[%s] The length of s MUST be greater than 0.",
+               GetErrorMessage(E_NUM_FORMAT));
 
        errno = 0;
-       ret = wcstoll(s.GetPointer(), &pEnd, 10);
-       SysTryReturn(NID_BASE, (!(ret == 0 && errno == EINVAL) && (pEnd[0] == 0)), E_NUM_FORMAT, E_NUM_FORMAT,
-                          "[E_NUM_FORMAT] LongLong parse failed. Scan stopped at (%ls)",
-                          pEnd);
-       SysTryReturn(NID_BASE, !(errno == ERANGE && (ret == LLONG_MAX || ret == LLONG_MIN)), E_NUM_FORMAT, E_NUM_FORMAT,
-                          "[E_NUM_FORMAT] Parsed value cannot fit into a LongLong.");
+       ret = wcstoll(s.GetPointer(), &pEnd, radix);
+       SysTryReturnResult(NID_BASE, (pEnd[0] == 0), E_NUM_FORMAT, "[%s] LongLong parse failed. Scan stopped at (%ls).",
+               GetErrorMessage(E_NUM_FORMAT), pEnd);
+       SysTryReturnResult(NID_BASE, !(errno == ERANGE && (ret == LLONG_MAX || ret == LLONG_MIN)), E_NUM_FORMAT,
+               "[%s] Parsed value cannot fit into a long long.", GetErrorMessage(E_NUM_FORMAT));
 
        return E_SUCCESS;
 }
index 63eec30..8808f9f 100644 (file)
@@ -95,7 +95,8 @@ const char* __errTable1300[] =
        "E_CONNECTION_FAILED",      //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1302))
        "E_CONNECTION_RESET",       //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1303))
        "E_CREDENTIAL_EXPIRED",     //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1304))
-       "E_CERTIFICATE_VERIFICATION_FAILED"     //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1305))
+       "E_CERTIFICATE_VERIFICATION_FAILED",    //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1305))
+       "E_CONTEXT_UNAVAILABLE"     //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1306))
 };
 
 const char* __errTable1400[] =
diff --git a/src/base/FBaseStringHashCodeProvider.cpp b/src/base/FBaseStringHashCodeProvider.cpp
new file mode 100644 (file)
index 0000000..4fd311a
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FBaseStringHashCodeProvider.cpp
+ * @brief              This is the implementation file for StringHashCodeProvider class.
+ */
+
+#include <FBaseString.h>
+#include <FBaseStringHashCodeProvider.h>
+
+namespace Tizen { namespace Base
+{
+
+StringHashCodeProvider::StringHashCodeProvider(void)
+{
+}
+
+StringHashCodeProvider::~StringHashCodeProvider(void)
+{
+}
+
+int
+StringHashCodeProvider::GetHashCode(const Tizen::Base::String& str) const
+{
+       return str.GetHashCode();
+}
+
+int
+StringHashCodeProvider::GetHashCode(const Tizen::Base::Object& obj) const
+{
+       return obj.GetHashCode();
+}
+
+}} //Tizen::Base
index 24375a5..5cfda1d 100644 (file)
@@ -55,6 +55,9 @@ bool iniLoaded = false;
 static bool appNameLoaded = false;
 static char appName[LOG_MODULE_NAME_LEN_MAX];
 
+static bool envLoaded = false;
+static bool envPlatformInfoEnabled = true;
+
 #define APP_RESERVED(X) NID_APP+X
 #define BASE_RESERVED(X) NID_BASE+X
 #define CNT_RESERVED(X) NID_CNT+X
@@ -424,12 +427,12 @@ AppassertInternal(const char* pFunction, int lineNumber)
 
        if( (platformDebug == false) && (appDebug == 0) )
        {
-               snprintf(logBody, LOG_LEN_MAX, "%s (%d). > App assertion passed due to debug mode off!", pFunction, lineNumber);
+               snprintf(logBody, LOG_LEN_MAX, "%s(%d) > App assertion passed due to debug mode off!", pFunction, lineNumber);
                ALOG(LOG_ERROR, logTag, logBody);
                return;
        }
 
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > AppAssert!", pFunction, lineNumber);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > AppAssert!", pFunction, lineNumber);
        ALOG(LOG_ERROR, logTag, logBody);
 
        assert(false);
@@ -467,6 +470,33 @@ void
 SysLogInternal(unsigned long nid, const char* pFunction, int lineNumber, const char* pFormat, ...)
 {
        va_list args;
+       char* envValuePlatformlogging;
+       char* envValueDebug;
+
+       if (!envLoaded)
+       {
+               envValuePlatformlogging = getenv("TIZEN_PLATFORMLOGGING_MODE");
+               envValueDebug = getenv("TIZEN_DEBUG_MODE");
+
+               if ((envValuePlatformlogging != NULL) && (envValuePlatformlogging[0] == '1'))
+               {
+                       envPlatformInfoEnabled = true;
+               }
+               else if ((envValueDebug != NULL) && (envValueDebug[0] == '1'))
+               {
+                       envPlatformInfoEnabled = true;
+               }
+               else
+               {
+                       envPlatformInfoEnabled = false;
+               }
+               envLoaded = true;
+       }
+
+       if (!envPlatformInfoEnabled)
+       {
+               return;
+       }
 
        if (!logInfo.platformInfoEnabled)
        {
@@ -503,6 +533,33 @@ void
 SysLogTagInternal(unsigned long nid, const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
 {
        va_list args;
+       char* envValuePlatformlogging;
+       char* envValueDebug;
+
+       if (!envLoaded)
+       {
+               envValuePlatformlogging = getenv("TIZEN_PLATFORMLOGGING_MODE");
+               envValueDebug = getenv("TIZEN_DEBUG_MODE");
+
+               if ((envValuePlatformlogging != NULL) && (envValuePlatformlogging[0] == '1'))
+               {
+                       envPlatformInfoEnabled = true;
+               }
+               else if ((envValueDebug != NULL) && (envValueDebug[0] == '1'))
+               {
+                       envPlatformInfoEnabled = true;
+               }
+               else
+               {
+                       envPlatformInfoEnabled = false;
+               }
+               envLoaded = true;
+       }
+
+       if (!envPlatformInfoEnabled)
+       {
+               return;
+       }
 
        if (!logInfo.platformInfoEnabled)
        {
@@ -552,7 +609,7 @@ SysAssertInternal(const char* pFileName, int lineNumber, const char* pFunction)
                return;
        }
 
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > SysAssert!", pFunction, lineNumber);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > SysAssert!", pFunction, lineNumber);
 
        ALOG(LOG_ERROR, LOG_TAG_ASSERT, logBody);
 
@@ -575,7 +632,7 @@ SysAssertfInternal(const char* expr, const char* pFunction, int lineNumber, cons
 
        va_start(args, pFormat);
 
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > %s", pFunction, lineNumber, pFormat);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
        logBody[LOG_LEN_MAX - 1] = '\0';
 
        ALOG_VA(LOG_ERROR, LOG_TAG_ASSERT, logBody, args);
@@ -589,7 +646,7 @@ void
 SysPropagateInternal(const char* pFunction, int lineNumber, unsigned long nid, result r)
 {
        char logBody[PROPAGATION_LEN_MAX];
-       snprintf(logBody, PROPAGATION_LEN_MAX, "%s (%d). > [%s] Propagating to caller...", pFunction, lineNumber, GetErrorMessage(r));
+       snprintf(logBody, PROPAGATION_LEN_MAX, "%s(%d) > [%s] Propagating to caller...", pFunction, lineNumber, GetErrorMessage(r));
 
        char logTag[LOG_MODULE_NAME_LEN_MAX];
        snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(nid)));
@@ -623,7 +680,7 @@ SysTryReturnResultInternal(unsigned long id, result r, const char* pFunction, in
        va_start(args, pFormat);
 
        char logBody[LOG_LEN_MAX];
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > [%s] %s", pFunction, lineNumber, GetErrorMessage(r), pFormat);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > [%s] %s", pFunction, lineNumber, GetErrorMessage(r), pFormat);
        logBody[LOG_LEN_MAX -1] = '\0';
 
        char logTag[LOG_MODULE_NAME_LEN_MAX];
@@ -647,7 +704,7 @@ __PrintLog(_LogType type, const char* pFunction, int lineNumber, const char* pFo
        }
 
        char logBody[LOG_LEN_MAX];
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > %s", pFunction, lineNumber, pFormat);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
        logBody[LOG_LEN_MAX - 1] = '\0';
 
        char logTag[LOG_MODULE_NAME_LEN_MAX];
@@ -696,7 +753,7 @@ __PrintLogTag(const char* pTag, _LogType type, const char* pFunction, int lineNu
        }
 
        char logBody[LOG_LEN_MAX];
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > %s", pFunction, lineNumber, pFormat);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
        logBody[LOG_LEN_MAX -1] = '\0';
 
        char logTag[LOG_TAG_LEN_MAX];
@@ -743,7 +800,7 @@ __PrintSysLog(_LogType type, LogID id, const char* pFunction, int lineNumber, co
        }
 
        char logBody[LOG_LEN_MAX];
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > %s", pFunction, lineNumber, pFormat);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
        logBody[LOG_LEN_MAX -1] = '\0';
 
        char logTag[LOG_MODULE_NAME_LEN_MAX];
@@ -789,7 +846,7 @@ __PrintSysLogTag(const char* pTag, _LogType type, LogID id, const char* pFunctio
        }
 
        char logBody[LOG_LEN_MAX];
-       snprintf(logBody, LOG_LEN_MAX, "%s (%d). > %s", pFunction, lineNumber, pFormat);
+       snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
        logBody[LOG_LEN_MAX -1] = '\0';
 
        char logTag[LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX];
index 9e97a31..a781049 100644 (file)
@@ -25,9 +25,6 @@
 #include <system_info.h>
 #include <power.h>
 #include <alarm.h>
-#include <haptic.h>
-#include <telephony_network.h>
-#include <media/sound_manager.h>
 #include "FBase_NativeError.h"
 #include <FBaseSysLog.h>
 #include "device.h"
@@ -58,28 +55,28 @@ E_UNKNOWN,                  // ENOTBLK              15      /* Block device required */
 E_DEVICE_BUSY,              // EBUSY           16      /* Device or resource busy */
 E_FILE_ALREADY_EXIST,       // EEXIST          17      /* File exists */
 E_UNKNOWN,                  // EXDEV           18      /* Cross-device link */
-E_UNKNOWN,                  // ENODEV          19      /* No such device */
-E_UNKNOWN,                  // ENOTDIR         20      /* Not a directory */
-E_UNKNOWN,                  // EISDIR          21      /* Is a directory */
+E_IO,                       // ENODEV          19      /* No such device */
+E_INVALID_ARG,              // ENOTDIR         20      /* Not a directory */
+E_INVALID_ARG,              // EISDIR          21      /* Is a directory */
 E_INVALID_ARG,              // EINVAL          22      /* Invalid argument */
-E_OVERFLOW,                 // ENFILE          23      /* File table overflow */
+E_MAX_EXCEEDED,             // ENFILE          23      /* File table overflow */
 E_MAX_EXCEEDED,             // EMFILE          24      /* Too many open files */
 E_UNKNOWN,                  // ENOTTY          25      /* Not a typewriter */
 E_UNKNOWN,                  // ETXTBSY         26      /* Text file busy */
-E_UNKNOWN,                  // EFBIG           27      /* File too large */
+E_IO,                       // EFBIG           27      /* File too large */
 E_STORAGE_FULL,             // ENOSPC          28      /* No space left on device */
 E_ILLEGAL_ACCESS,           // ESPIPE          29      /* Illegal seek */
-E_READ_ONLY,                // EROFS           30      /* Read-only file system */
+E_ILLEGAL_ACCESS,           // EROFS           30      /* Read-only file system */
 E_UNKNOWN,                  // EMLINK          31      /* Too many links */
 E_UNKNOWN,                  // EPIPE           32      /* Broken pipe */
 E_INVALID_DOMAIN,           // EDOM                    33      /* Math argument out of domain of func */
 E_OUT_OF_RANGE,             // ERANGE          34      /* Math result not representable ;
 E_UNKNOWN,                  // EDEADLK         35      /* Resource deadlock would occur */
-E_UNKNOWN,                  // ENAMETOOLONG    36      /* File name too long */
+E_INVALID_ARG,              // ENAMETOOLONG    36      /* File name too long */
 E_UNKNOWN,                  // ENOLCK          37      /* No record locks available */
 E_UNKNOWN,                  // ENOSYS          38      /* Function not implemented */
 E_UNKNOWN,                  // ENOTEMPTY       39      /* Directory not empty */
-E_UNKNOWN,                  // ELOOP           40      /* Too many symbolic links encountered */
+E_INVALID_ARG,              // ELOOP           40      /* Too many symbolic links encountered */
 E_WOULD_BLOCK,              // EWOULDBLOCK     EAGAIN  /* Operation would block */
 E_UNKNOWN,                  // ENOMSG          42      /* No message of desired type */
 E_UNKNOWN,                  // EIDRM           43      /* Identifier removed */
@@ -116,7 +113,7 @@ E_UNKNOWN,                  // EPROTO               71      /* Protocol error */
 E_UNKNOWN,                  // EMULTIHOP       72      /* Multihop attempted */
 E_UNKNOWN,                  // EDOTDOT         73      /* RFS specific error */
 E_UNKNOWN,                  // EBADMSG         74      /* Not a data message */
-E_OVERFLOW,                 // EOVERFLOW       75      /* Value too large for defined data type */
+E_IO,                       // EOVERFLOW       75      /* Value too large for defined data type */
 E_UNKNOWN,                  // ENOTUNIQ                76      /* Name not unique on network */
 E_UNKNOWN,                  // EBADFD          77      /* File descriptor in bad state */
 E_UNKNOWN,                  // EREMCHG         78      /* Remote address changed */
@@ -255,9 +252,10 @@ _NativeError::ConvertNativeErrorToResult(int errNo, const char* pFile, int line,
                SysLog(NID_BASE, "A native error (%d) occurred at (%s:%d).", errNo, pFile, line);
        }
 
-       if (E_UNKNOWN == r)
+       if (r == E_UNKNOWN)
        {
-               SysLogException(NID_BASE, E_UNKNOWN, "Failed to convert native error(%d-%s) to result.", errNo, strerror(errNo));
+               SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d, %s) to result.", errNo, strerror(errNo));
+               return E_SYSTEM;
        }
 
        return r;
@@ -278,9 +276,10 @@ _NativeError::ConvertNativeErrorToResult(int errNo, bool logNativeErr)
                SysLog(NID_BASE, "A native error (%d) occurred.", errNo);
        }
 
-       if (E_UNKNOWN == r)
+       if (r == E_UNKNOWN)
        {
-               SysLogException(NID_BASE, E_UNKNOWN, "Failed to convert native error(%d-%s) to result.", errNo, strerror(errNo));
+               SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d, %s) to result.", errNo, strerror(errNo));
+               return E_SYSTEM;
        }
 
        return r;
@@ -421,6 +420,12 @@ _NativeError::ConvertNativeSqliteErrorToResult(int err)
                r = sqlErrorToResultTable[err];
        }
 
+       if (r == E_UNKNOWN)
+       {
+               SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d) to result.", err);
+               return E_SYSTEM;
+       }
+
        return r;
 }
 
@@ -434,6 +439,12 @@ _NativeError::ConvertNativeSqliteErrorToDetailResult(int err)
                r = sqlErrorToDetailResultTable[err];
        }
 
+       if (r == E_UNKNOWN)
+       {
+               SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d) to result.", err);
+               return E_SYSTEM;
+       }
+
        return r;
 }
 
index a523413..aa77a80 100644 (file)
@@ -285,13 +285,13 @@ result
 ArrayList::IndexOf(const Object& obj, int startIndex, int& index) const
 {
        SysTryReturnResult(NID_BASE_COL, startIndex >= 0 && startIndex < __count, E_OUT_OF_RANGE, "The startIndex(%d) MUST be greater than or equal to 0, and less than the number of elements(%d).", startIndex, __count);
-
        return IndexOf(obj, startIndex, (__count - startIndex), index);
 }
 
 result
 ArrayList::IndexOf(const Object& obj, int startIndex, int count, int& index) const
 {
+       SysTryReturnResult(NID_BASE_COL, __count != 0, E_OBJ_NOT_FOUND, "The arraylist is empty.");
        SysTryReturnResult(NID_BASE_COL, startIndex >= 0 && count >= 0, E_OUT_OF_RANGE, "Both of the startIndex(%d) and count(%d) MUST be greater than or equal to 0.", startIndex, count);
        SysTryReturnResult(NID_BASE_COL, startIndex < __count, E_OUT_OF_RANGE,
                "The startIndex(%d) MUST be less than the number of elements(%d).", startIndex, __count);
@@ -323,6 +323,7 @@ ArrayList::LastIndexOf(const Object& obj, int& index) const
                }
        }
 
+       SysLogException(NID_BASE_COL, E_OBJ_NOT_FOUND, "The object is not in the list.");
        return E_OBJ_NOT_FOUND;
 }
 
@@ -393,15 +394,10 @@ ArrayList::Remove(const Object& obj)
 {
        int index = 0;
        result r = IndexOf(obj, index);
-       if (IsFailed(r))
-       {
-               return E_OBJ_NOT_FOUND;
-       }
-       else
-       {
-               return RemoveAt(index);
-       }
-
+       SysTryReturnResult(NID_BASE_COL, r == E_SUCCESS, r, "Propagating.");
+       r = RemoveAt(index);
+       SysTryReturnResult(NID_BASE_COL, r == E_SUCCESS, r, "Propagating.")
+       return r;
 }
 
 result
index d893149..be7fbb5 100644 (file)
@@ -293,31 +293,20 @@ LinkedList::GetItemsN(int startIndex, int count) const
 result
 LinkedList::IndexOf(const Object& obj, int& index) const
 {
-       result r = E_SUCCESS;
-       if (__count == 0)
-       {
-               r = E_OBJ_NOT_FOUND;
-       }
-       else
-       {
-               r = IndexOf(obj, 0, __count, index);
-       }
-
-       return r;
+       return IndexOf(obj, 0, __count, index);
 }
 
 result
 LinkedList::IndexOf(const Object& obj, int startIndex, int& index) const
 {
        SysTryReturn(NID_BASE_COL, (startIndex >= 0 && startIndex < __count), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] The startIndex(%d) MUST be greater than or equal to 0, and less than the number of elements(%d).", GetErrorMessage(E_OUT_OF_RANGE), startIndex, __count);
-
        return IndexOf(obj, startIndex, (__count - startIndex), index);
 }
 
 result
 LinkedList::IndexOf(const Object& obj, int startIndex, int count, int& index) const
 {
-       SysTryReturnResult(NID_BASE_COL, __count != 0, E_OBJ_NOT_FOUND, "The number of elements on this list is equal to 0.");
+       SysTryReturnResult(NID_BASE_COL, __count != 0, E_OBJ_NOT_FOUND, "The linkedlist is empty.");
        SysTryReturnResult(NID_BASE_COL, startIndex >= 0 && count >= 0, E_OUT_OF_RANGE, "Both of the startIndex(%d) and count(%d) MUST be greater than or equal to 0.", startIndex, count);
        SysTryReturnResult(NID_BASE_COL, startIndex < __count, E_OUT_OF_RANGE,
                "The startIndex(%d) MUST be less than the number of elements(%d).", startIndex, __count);
@@ -425,26 +414,24 @@ LinkedList::InsertItemsFrom(const ICollection& collection, int startIndex)
 result
 LinkedList::LastIndexOf(const Object& obj, int& index) const
 {
-       result r = E_OBJ_NOT_FOUND;
        _ListNode* pNode = __pListTail;
        for (int i = (__count - 1); i >= 0; i--)
        {
                if (pNode->pObj->Equals(obj))
                {
                        index = i;
-                       r = E_SUCCESS;
-                       break;
+                       return E_SUCCESS;
                }
                pNode = pNode->pPrev;
        }
 
-       return r;
+       SysLogException(NID_BASE_COL, E_OBJ_NOT_FOUND, "The object is not in the list.");
+       return E_OBJ_NOT_FOUND;
 }
 
 result
 LinkedList::Remove(const Object& obj)
 {
-       result r = E_OBJ_NOT_FOUND;
        _ListNode* pNode = __pListHead;
        for (int i = 0; i < __count; i++)
        {
@@ -453,13 +440,13 @@ LinkedList::Remove(const Object& obj)
                        __modCount++;
                        RemoveNode(pNode);
                        __count--;
-                       r = E_SUCCESS;
-                       break;
+                       return E_SUCCESS;
                }
                pNode = pNode->pNext;
        }
 
-       return r;
+       SysLogException(NID_BASE_COL, E_OBJ_NOT_FOUND, "The object is not in the list.");
+       return E_OBJ_NOT_FOUND;
 }
 
 result
old mode 100644 (file)
new mode 100755 (executable)
index e39cda5..f642a07
@@ -156,7 +156,7 @@ public:
        /**
         * Fires the event with an argument asynchronously.
         *
-        * @since 2.1
+        * @since 2.0
         *
         * @return              The number of listeners in the current event instance.
         */
old mode 100644 (file)
new mode 100755 (executable)
index 409a157..f28ef03
@@ -52,6 +52,32 @@ Mutex::Create(void)
 }
 
 result
+Mutex::Create(NonRecursiveMutexTag)
+{
+       // Object is not allowed to construct twice
+       SysAssertf(__pMutexImpl == null,
+               "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
+
+       result r = E_SUCCESS;
+
+       __pMutexImpl = new (std::nothrow) _MutexImpl;
+       SysTryReturnResult(NID_BASE_RT, __pMutexImpl != null, E_OUT_OF_MEMORY, "Not enough memory.");
+
+       r = __pMutexImpl->CreateNonRecursiveMutex();
+       SysTryCatch(NID_BASE_RT, !IsFailed(r), , r, "[%s] Mutex initialization failed.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+
+CATCH:
+       delete __pMutexImpl;
+       __pMutexImpl = null;
+
+       return r;
+
+}
+
+
+result
 Mutex::Create(const String& name)
 {
        // Object is not allowed to construct twice
index fb396fa..9d02315 100755 (executable)
@@ -38,7 +38,7 @@ WaitingLoop::~WaitingLoop(void)
        delete __pWaitingLoopImpl;
 }
 
-WaitingLoop*
+WaitingLoop* 
 WaitingLoop::GetInstance(void)
 {
        static WaitingLoop* pWaitingLoop = null;
@@ -52,43 +52,43 @@ WaitingLoop::GetInstance(void)
                {
                        pWaitingLoop->__pWaitingLoopImpl->Notify();
                        delete pWaitingLoop;
-
-                       pWaitingLoop = _WaitingLoopImpl::GetInstanceN();
+                       
+                       pWaitingLoop = _WaitingLoopImpl::GetInstanceN();        
                }
        }
 
        return pWaitingLoop;
 }
 
-result
+result 
 WaitingLoop::Wait(int timeout)
 {
        return __pWaitingLoopImpl->Wait(timeout);
 }
 
-result
+result 
 WaitingLoop::Wait(IWaitingLoopCondition& condition)
 {
        return __pWaitingLoopImpl->Wait(condition);
 }
 
-result
+result 
 WaitingLoop::Wait(int timeout, IWaitingLoopCondition& condition)
 {
        return __pWaitingLoopImpl->Wait(timeout, condition);
 }
 
-void
+void 
 WaitingLoop::Notify(void)
 {
        __pWaitingLoopImpl->Notify();
 }
 
-void
+void 
 WaitingLoop::SetMaxTimeoutForWaiting(int timeout)
 {
        WaitingLoop* pWaitingLoop = WaitingLoop::GetInstance();
-
+               
        if (pWaitingLoop != null)
        {
                pWaitingLoop->__pWaitingLoopImpl->SetMaxTimeoutForWaiting(timeout);
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 6e9b76b..3611f4a
@@ -55,6 +55,47 @@ _MutexImpl::Create(void)
 }
 
 result
+_MutexImpl::CreateNonRecursiveMutex(void)
+{
+       result r = E_SUCCESS;
+       pthread_mutex_t* pMutex = null;
+
+       int ret = -1;
+       pthread_mutexattr_t mutexAttr;
+       // create mutex
+       pMutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
+       SysTryReturnResult(NID_BASE_RT, pMutex != null, E_OUT_OF_MEMORY,
+                                         "Mutex memory allocation failed.")
+
+       // set mutex attributes
+       pthread_mutexattr_init(&mutexAttr);
+       pthread_mutexattr_setpshared(&mutexAttr, PTHREAD_PROCESS_PRIVATE);
+       pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_ERRORCHECK_NP);
+
+       // intialize the mutex
+       ret = pthread_mutex_init(pMutex, &mutexAttr);
+       SysTryCatch(NID_BASE_RT, ret == 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Mutex intialization failed.", __ConvertNativeErrorToMessage(ret));
+
+       // destroy the attributes
+       pthread_mutexattr_destroy(&mutexAttr);
+
+       __pMutex = pMutex;
+
+       return E_SUCCESS;
+
+CATCH:
+       if (pMutex != null)
+       {
+               free(pMutex);
+       }
+
+       return r;
+
+}
+
+
+result
 _MutexImpl::Create(const Tizen::Base::String& name)
 {
        result r = E_SUCCESS;
old mode 100644 (file)
new mode 100755 (executable)
index ab6ad8b..e38d5c5
@@ -91,6 +91,16 @@ public:
        result Create(void);
 
        /**
+        *      Creates a non-recursive mutex.
+        *
+        *      @since 2.0
+        *      @return                 An error code
+        *      @exception      E_SUCCESS               The method was successful.
+        *      @exception      E_SYSTEM                An unknown operating system error occurred.
+        */
+       result CreateNonRecursiveMutex(void);
+
+       /**
         *      Creates a named Mutex. @n
         *      If there is already a Mutex with the specified name, this creates a Mutex which references that particular Mutex.
         *
index 7ec514e..6ab4c7b 100755 (executable)
@@ -38,6 +38,7 @@ namespace Tizen { namespace Base { namespace Runtime
 static int __sleepTime = 10;
 static int __waitingCount = 10;
 static int __waitingRepeatableTime = 100;
+static int __maxTime = 50;
 
 _WaitingLoopImpl::_WaitingLoopImpl(void)
        : __pTimer(null)
@@ -49,15 +50,18 @@ _WaitingLoopImpl::_WaitingLoopImpl(void)
        , __waitStatus(WAIT_OFF)
        , __pWaitingLoopCondition(null)
        , __timerCalledCount(0)
-       , __MaxTimeout(10000)
+       , __maxTimeout(10000)
 {
 
 }
 
 _WaitingLoopImpl::~_WaitingLoopImpl(void)
 {
-       __pTimer->Cancel();
-       delete __pTimer;
+       if (__pTimer != null)
+       {
+               __pTimer->Cancel();
+               delete __pTimer;
+       }
 }
 
 result
@@ -128,6 +132,12 @@ _WaitingLoopImpl::Wait(int timeout)
        
        __timeout = false;
        __waitType = WAIT_TIMEOUT;
+
+       if (__maxTimeout < timeout)
+       {
+               timeout = __maxTimeout;
+       }
+
        result r = __pTimer->Start(timeout);
 
        SysTryReturn(NID_BASE_RT, r == E_SUCCESS, r, r,"[%s]Timer does not start.", GetErrorMessage(r));
@@ -200,6 +210,11 @@ _WaitingLoopImpl::Wait(int timeout, IWaitingLoopCondition& condition)
        __waitType = WAIT_TIMEOUT_CONDITION;
        __pWaitingLoopCondition = &condition;
 
+       if(timeout > __maxTimeout)
+       {
+               timeout = __maxTimeout;
+       }
+
        if (timeout < __waitingRepeatableTime)
        {
                result r = __pTimer->StartAsRepeatable(__waitingRepeatableTime);
@@ -251,7 +266,14 @@ _WaitingLoopImpl::Notify(void)
 void 
 _WaitingLoopImpl::SetMaxTimeoutForWaiting(int timeout)
 {
-       __MaxTimeout = timeout;
+       if (timeout < __maxTime)
+       {
+               __maxTimeout = __maxTime;
+       }
+       else
+       {
+               __maxTimeout = timeout;
+       }
 }
 
 void 
index 4e0b54b..56da6d5 100755 (executable)
@@ -197,7 +197,7 @@ private:
        WaitStatus __waitStatus;
        IWaitingLoopCondition* __pWaitingLoopCondition;
        int __timerCalledCount;
-       int __MaxTimeout;
+       int __maxTimeout;
                
 }; // _WaitingLoopImpl
 
diff --git a/src/base/utility/FBaseUtilScanner.cpp b/src/base/utility/FBaseUtilScanner.cpp
new file mode 100644 (file)
index 0000000..900f453
--- /dev/null
@@ -0,0 +1,334 @@
+#include <sys/stat.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <FBaseCharacter.h>
+#include <FBaseResult.h>
+#include <FBaseUtilScanner.h>
+#include "FBaseUtilRegularExpression.h"
+#include <FBaseColArrayList.h>
+#include <FBaseSysLog.h>
+#include "FBaseUtil_ScannerImpl.h"
+
+
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Base { namespace Utility
+{
+Scanner::Scanner(void)
+       :__pScannerImpl(null)
+{
+
+}
+
+Scanner::~Scanner()
+{
+       delete __pScannerImpl;
+       __pScannerImpl = null;
+}
+
+result Scanner::Construct(const String& inputStr)
+{
+       result r = E_SUCCESS;
+       SysAssertf(__pScannerImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysTryReturnResult(NID_BASE_UTIL, !inputStr.IsEmpty(), E_INVALID_ARG, "[E_INVALID_ARG] The length of the input data is zero.");
+       __pScannerImpl = new (std::nothrow) _ScannerImpl();
+       SysTryReturnResult(NID_BASE_UTIL, __pScannerImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
+
+       r = __pScannerImpl->Construct(inputStr);
+       return r;
+}
+
+result Scanner::Construct(const String& inputFilePath, const String& encodingScheme)
+{
+       result r = E_SUCCESS;
+       SysAssertf(__pScannerImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysTryReturn(NID_BASE_UTIL, !inputFilePath.IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The length of the file name is zero.");
+       SysTryReturn(NID_BASE_UTIL, !encodingScheme.IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The length of the encoding scheme is zero.");
+
+       __pScannerImpl = new (std::nothrow) _ScannerImpl();
+       SysTryReturnResult(NID_BASE_UTIL, __pScannerImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
+
+       r = __pScannerImpl->Construct(inputFilePath, encodingScheme);
+       return r;
+}
+
+bool Scanner::HasNextToken(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->HasNextToken();
+}
+
+bool Scanner::HasNextToken(const RegularExpression& pattern) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->HasNextToken(pattern);
+}
+
+bool Scanner::HasNextToken(const String& pattern) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->HasNextToken(pattern);
+}
+
+
+result Scanner::GetNextToken(String& nextTok) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextToken(nextTok);
+}
+
+result Scanner::GetNextToken(const RegularExpression& pattern, String& nextTok) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextToken(pattern, nextTok);
+}
+
+result Scanner::GetNextToken(const String& pattern, String& nextTok) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextToken(pattern, nextTok);
+}
+
+result Scanner::GetNextSignedChar(signed char& nextSignedChar) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return  __pScannerImpl->GetNextSignedChar(nextSignedChar );
+}
+
+result Scanner::GetNextSignedChar(signed char& nextSignedChar, int radix) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, ((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) || (radix == Character::RADIX_DECIMAL) ||
+                               (radix == Character::RADIX_HEXADECIMAL)),E_NUM_FORMAT,
+                               "[E_NUM_FORMAT] The radix(%d) MUST be one of 2, 8, 10 and 16.", radix);
+
+       return  __pScannerImpl->GetNextSignedChar(nextSignedChar, radix);
+}
+
+bool Scanner::IsNextTokenConvertibleToSignedChar(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+       return __pScannerImpl->IsNextTokenConvertibleToSignedChar();
+}
+
+bool Scanner::IsNextTokenConvertibleToSignedChar(int radix) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, ((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) || (radix == Character::RADIX_DECIMAL) ||
+                               (radix == Character::RADIX_HEXADECIMAL)),E_NUM_FORMAT,
+                               "[E_NUM_FORMAT] The radix(%d) MUST be one of 2, 8, 10 and 16.", radix);
+
+       return __pScannerImpl->IsNextTokenConvertibleToSignedChar(radix);
+}
+
+result Scanner::GetNextInt(int& nextInt) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextInt(nextInt);
+}
+
+result Scanner::GetNextInt(int& nextInt, int radix) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, ((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) || (radix == Character::RADIX_DECIMAL) ||
+                               (radix == Character::RADIX_HEXADECIMAL)),E_NUM_FORMAT,
+                               "[E_NUM_FORMAT] The radix(%d) MUST be one of 2, 8, 10 and 16.", radix);
+
+       return __pScannerImpl->GetNextInt(nextInt, radix);
+}
+
+bool Scanner::IsNextTokenConvertibleToInt(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->IsNextTokenConvertibleToInt();
+}
+
+bool Scanner::IsNextTokenConvertibleToInt(int radix) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, ((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) || (radix == Character::RADIX_DECIMAL) ||
+                               (radix == Character::RADIX_HEXADECIMAL)),E_NUM_FORMAT,
+                               "[E_NUM_FORMAT] The radix(%d) MUST be one of 2, 8, 10 and 16.", radix);
+
+       return __pScannerImpl->IsNextTokenConvertibleToInt(radix);
+}
+
+result Scanner::GetNextShort(short& nextShort) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextShort(nextShort);
+}
+
+result Scanner::GetNextShort(short& nextShort, int radix) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, ((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) || (radix == Character::RADIX_DECIMAL) ||
+                               (radix == Character::RADIX_HEXADECIMAL)),E_NUM_FORMAT,
+                               "[E_NUM_FORMAT] The radix(%d) MUST be one of 2, 8, 10 and 16.", radix);
+
+       return __pScannerImpl->GetNextShort(nextShort, radix);
+}
+
+bool Scanner::IsNextTokenConvertibleToShort(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->IsNextTokenConvertibleToShort();
+}
+
+bool Scanner::IsNextTokenConvertibleToShort(int radix) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, ((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) || (radix == Character::RADIX_DECIMAL) ||
+                               (radix == Character::RADIX_HEXADECIMAL)),E_NUM_FORMAT,
+                               "[E_NUM_FORMAT] The radix(%d) MUST be one of 2, 8, 10 and 16.", radix);
+
+
+       return __pScannerImpl->IsNextTokenConvertibleToShort(radix);
+}
+
+result Scanner::GetNextLongLong(long long& nextLongLong) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextLongLong(nextLongLong);
+}
+
+result Scanner::GetNextLongLong(long long& nextLongLong, int radix) const
+{
+//This always returns nextLongLong in radix 10. This function will be implemented correctly once LongLong::Parse() is implemnted for different radix
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, ((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) || (radix == Character::RADIX_DECIMAL) ||
+                               (radix == Character::RADIX_HEXADECIMAL)),E_NUM_FORMAT,
+                               "[E_NUM_FORMAT] The radix(%d) MUST be one of 2, 8, 10 and 16.", radix);
+       return __pScannerImpl->GetNextLongLong(nextLongLong);
+}
+
+bool Scanner::IsNextTokenConvertibleToLongLong(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->IsNextTokenConvertibleToLongLong();
+}
+
+result Scanner::GetNextFloat(float& nextFloat) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextFloat(nextFloat);
+}
+
+
+bool Scanner::IsNextTokenConvertibleToFloat(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->IsNextTokenConvertibleToFloat();
+}
+
+result Scanner::GetNextDouble(double& nextDouble) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextDouble(nextDouble);
+}
+
+bool Scanner::IsNextTokenConvertibleToDouble(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->IsNextTokenConvertibleToDouble();
+}
+
+result Scanner::GetNextBool(bool& nextBool) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextBool(nextBool);
+}
+
+bool Scanner::IsNextTokenConvertibleToBool(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->IsNextTokenConvertibleToBool();
+}
+
+bool Scanner::HasNextLine(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->HasNextLine();
+}
+
+
+result Scanner::GetNextLine(String& nextLine) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetNextLine(nextLine);
+
+}
+
+result Scanner::FindInLine(const String& patternStr, String& matchedStr)
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturnResult(NID_BASE_UTIL, !patternStr.IsEmpty(), E_INVALID_ARG, "[E_INVALID_ARG] The length of the input data is zero.");
+       return __pScannerImpl->FindInLine(patternStr, matchedStr);
+}
+
+result Scanner::FindInLine(const RegularExpression& pattern, String& matchedStr)
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       String str(pattern.GetPattern());
+       SysTryReturnResult(NID_BASE_UTIL, !str.IsEmpty(), E_INVALID_ARG, "[E_INVALID_ARG] The length of the input data is zero.");
+       return __pScannerImpl->FindInLine(pattern, matchedStr);
+}
+
+void Scanner::Skip(const String& patternStr)
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturn(NID_BASE_UTIL, !patternStr.IsEmpty(), , E_INVALID_ARG, "[%s] The length of the input data is zero.", GetErrorMessage(E_INVALID_ARG));
+       __pScannerImpl->Skip(patternStr);
+
+}
+
+void Scanner::Skip(const RegularExpression& pattern)
+{
+       String str(pattern.GetPattern());
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       SysTryReturn(NID_BASE_UTIL, !str.IsEmpty(), , E_INVALID_ARG, "[%s] The length of the input data is zero.", GetErrorMessage(E_INVALID_ARG));
+       __pScannerImpl->Skip(pattern);
+
+}
+
+int Scanner::GetRadix(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetRadix();
+}
+
+String Scanner::GetDelimiter(void) const
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       return __pScannerImpl->GetDelimiter();
+}
+
+void Scanner::SetDelimiter(const String& patternStr)
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       __pScannerImpl->SetDelimiter(patternStr);
+}
+
+void Scanner::SetDelimiter(const RegularExpression& pattern)
+{
+       SysAssertf(__pScannerImpl != null, "Not yet constructed! Construct() should be called before use.");
+       String delimPat(pattern.GetPattern());
+       __pScannerImpl->SetDelimiter(delimPat);
+}
+
+void Scanner::SetRadix(int radix)
+{
+       if(__pScannerImpl)
+       {
+               if(((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) ||
+                       (radix == Character::RADIX_DECIMAL) || (radix == Character::RADIX_HEXADECIMAL)))
+               {
+                       __pScannerImpl->SetRadix(radix);
+               }
+       }
+}
+}}}   // Osp::Base::Utility
index d1548e1..7048c10 100644 (file)
@@ -51,6 +51,8 @@ public:
        Tizen::Base::String GetPattern(void) const;
        result SetOptions(unsigned long options);
        unsigned long GetOptions(void) const;
+       int GetLastMatchStart(void);
+       int GetLastMatchEnd(void);
 
 
 private:
@@ -76,8 +78,6 @@ private:
        String GetLastMatchedString(const Tizen::Base::String& text);
        int GetLastGroupCount(void);
 
-       int GetLastMatchStart(void);
-       int GetLastMatchEnd(void);
        result PcreCompileErrorToSystemError(int compileErr);
        result PcreExecErrorToSystemError(int err);
 
diff --git a/src/base/utility/FBaseUtil_ScannerImpl.cpp b/src/base/utility/FBaseUtil_ScannerImpl.cpp
new file mode 100644 (file)
index 0000000..0d70dbe
--- /dev/null
@@ -0,0 +1,823 @@
+#include <sys/stat.h>
+#include <stdio.h>
+#include <errno.h>
+#include <wchar.h>
+
+#include <FBaseCharacter.h>
+#include <FBaseInt8.h>
+#include <FBaseInteger.h>
+#include <FBaseShort.h>
+#include <FBaseLong.h>
+#include <FBaseLongLong.h>
+#include <FBaseFloat.h>
+#include <FBaseDouble.h>
+#include <FBaseResult.h>
+#include "FBaseUtil_ScannerImpl.h"
+#include "FBaseUtilRegularExpression.h"
+#include <FBaseColArrayList.h>
+#include <FBaseSysLog.h>
+#include "FBaseUtil_RegularExpressionImpl.h"
+#include "FBase_StringConverter.h"
+#include "FBaseUtil_IcuConverter.h"
+#include "FBase_NativeError.h"
+
+#define ANY_PATTERN L"\\s*[^\\s]*"
+#define DEFAULT_DELIMITER_PATTERN L"\\s*"
+//#define DEFAULT_LINE_SEPARATOR_PATTERN L".*(\r\n|[\u000A\n\r\u2028\u2029\u0085])|.+$"
+#define COMPLETE_LINE_PATTERN L".*(\r\n|[\u000A\n\r\u2028\u2029\u0085])|.+$"
+#define DEFAULT_LINE_SEPARATOR_PATTERN L"[\u000A\n\r\u2028\u2029\u0085]*"
+
+
+#define DEFAULT_GROUP_SEPARATOR L","
+#define DEFAULT_DECIMAL_SEPARATOR L"."
+#define DEFAULT_NEGATIVE_PREFIX L"-"
+
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Base { namespace Utility
+{
+_ScannerImpl::_ScannerImpl(void)
+       :__radix(10),
+        __delimiter(DEFAULT_DELIMITER_PATTERN),
+        __pParseStr(null),
+        __isAllocatedOnHeap(false),
+        __position(0)
+{
+
+}
+
+_ScannerImpl::~_ScannerImpl()
+{
+       if(__isAllocatedOnHeap == true)
+       {
+               delete[] __pParseStr;
+               __pParseStr = null;
+       }
+}
+
+result _ScannerImpl::Construct(const String& str)
+{
+       result r = E_SUCCESS;
+       __pParseStr = str.GetPointer();
+       return r;
+}
+
+result _ScannerImpl::Construct(const String& filePath, const String& encodingScheme)
+{
+       result r = E_SUCCESS;
+       FILE* pFile = null;
+       char* pFilePath = null;
+       bool res =  false;
+       _ICUConverter converter;
+       struct stat st;
+       off_t fileSize = 0;
+       char* buffer = null;
+       int retVal = 0;
+       long int readCnt = 0;
+
+       pFilePath = _StringConverter::CopyToCharArrayN(filePath);
+       SysTryReturnResult(NID_BASE_UTIL, pFilePath != null, r = GetLastResult(), "File path length < 0 or E_OUT_OF_MEMORY");
+
+       res = converter.OpenConverter(encodingScheme);
+       r = GetLastResult();
+       SysTryCatch(NID_BASE_UTIL, res == true, , r, "[%s] Encoding scheme not supported", GetErrorMessage(r));
+
+       pFile = fopen(pFilePath, "r");
+       SysTryCatch(NID_BASE_UTIL, pFile != null, r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+                       "[%s] Failed to open the file.", GetErrorMessage(__ConvertNativeErrorToResult(errno)));
+
+       retVal = stat(pFilePath, &st);
+       SysTryCatch(NID_BASE_UTIL, retVal != 0, r = E_IO, E_IO,
+                       "[%s] Failed to get information about the file.", GetErrorMessage(__ConvertNativeErrorToResult(errno)));
+
+       fileSize = st.st_size;
+
+       buffer = static_cast<char*>(calloc(fileSize, sizeof(char)));
+       SysTryCatch(NID_BASE_UTIL, buffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+       readCnt = fread(buffer, 1, fileSize, pFile);
+
+       if (readCnt < fileSize)
+       {
+               int ret = ferror(pFile);
+               SysTryCatch(NID_BASE_UTIL, ret != 0, r = E_IO, E_IO, "[E_IO] Failed to perform read operation.");
+       }
+
+       __pParseStr = converter.ConvertToUcharN(buffer, fileSize);
+       SysTryCatch(NID_BASE_UTIL, __pParseStr != null, r = E_IO, E_IO , "[E_IO] charcater conversion failed.");
+       __isAllocatedOnHeap = true;
+
+CATCH:
+       delete[] pFilePath;
+       pFilePath = null;
+
+       delete[] buffer;
+       buffer = null;
+
+       if(pFile != null)
+       {
+               fclose(pFile);
+               pFile = null;
+       }
+
+       return r;
+}
+
+bool _ScannerImpl::HasNextToken(void)
+{
+       String pattern(ANY_PATTERN);
+       return HasNextToken(pattern);
+}
+
+bool _ScannerImpl::HasNextToken(const RegularExpression& pattern)
+{
+       String patStr(pattern.GetPattern());
+       return HasNextToken(patStr);
+}
+
+bool _ScannerImpl::HasNextToken(const String& pattern)
+{
+       result r = E_SUCCESS;
+       String token;
+       int length = 0;
+
+       r = GetNextToken(pattern, token, length);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] Can not get the next token");
+
+       return true;
+}
+
+
+result _ScannerImpl::GetNextToken(String& nextStr)
+{
+       result r = E_SUCCESS;
+       String pattern(ANY_PATTERN);
+       int length = 0;
+
+       r = GetNextToken(pattern, nextStr, length);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_ENOUGH, "Can not get the next token");
+
+       __position =  __position + length;
+
+       return r;
+}
+
+result _ScannerImpl::GetNextToken(const RegularExpression& pattern, String& nextStr)
+{
+       String patStr(pattern.GetPattern());
+       return GetNextToken(patStr, nextStr);
+}
+
+result _ScannerImpl::GetNextToken(const String& pattern, String& nextStr)
+{
+       result r = E_SUCCESS;
+       int length = 0;
+
+       String str1;
+       String str2;
+       String anyPattern(ANY_PATTERN);
+
+       r = GetNextToken(anyPattern, str1, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "The next token does not match to the pattern");
+
+       r = GetNextToken(pattern, str2, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r != E_SUCCESS) && (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH,
+                       "[E_DATA_NOT_ENOUGH] Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "The next token does not match to the pattern");
+
+       if(str1 == str2)
+       {
+               nextStr = str1;
+               __position =  __position + length;
+       }
+
+       return r;
+}
+
+result _ScannerImpl::GetNextSignedChar(signed char& nextSignedChar)
+{
+       return GetNextSignedChar(nextSignedChar, __radix);
+}
+
+result _ScannerImpl::GetNextSignedChar(signed char& nextSignedChar, int radix)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       char ch = 0x00;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to signed char");
+/*     if(out.GetLength() > 1)
+       {
+               return E_OPERATION_FAILED;
+       }*/
+
+       r = Int8::Parse(out, radix, ch);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to signed char");
+
+       nextSignedChar = static_cast<signed char>(ch);
+       __position =  __position + length;
+
+       return r;
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToSignedChar(void)
+{
+       return IsNextTokenConvertibleToSignedChar(__radix);
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToSignedChar(int radix)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+       char ch = 0;
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get the next token as signed char");
+
+/*     if(out.GetLength() > 1)
+       {
+               return E_OPERATION_FAILED;
+       }*/
+
+       r = Int8::Parse(out, radix, ch);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not parse the token to signed char");
+
+       return true;
+}
+
+result _ScannerImpl::GetNextInt(int& nextInt)
+{
+       return GetNextInt(nextInt, __radix);
+}
+
+result _ScannerImpl::GetNextInt(int& nextInt, int radix)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to integer");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Integer::Parse(out, radix, nextInt);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to integer");
+
+       __position =  __position + length;
+
+       return r;
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToInt(void)
+{
+       return IsNextTokenConvertibleToInt(__radix);
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToInt(int radix)
+{
+       result r = E_SUCCESS;
+       String out;
+       int val = 0;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get the next token as integer");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Integer::Parse(out, radix, val);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next Integer");
+
+       return true;
+}
+
+result _ScannerImpl::GetNextShort(short& nextShort)
+{
+       return GetNextShort(nextShort, __radix);
+}
+
+result _ScannerImpl::GetNextShort(short& nextShort, int radix)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to short");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Short::Parse(out, radix, nextShort);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to short");
+
+       __position =  __position + length;
+
+       return r;
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToShort(void)
+{
+       return IsNextTokenConvertibleToShort(__radix);
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToShort(int radix)
+{
+       result r = E_SUCCESS;
+       String out;
+       short val = 0;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next token as short");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Short::Parse(out, radix, val);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next short");
+
+       return true;
+}
+
+result _ScannerImpl::GetNextLongLong(long long& nextLongLong)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to long long");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = LongLong::Parse(out, nextLongLong);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to long long");
+
+       __position =  __position + length;
+
+       return r;
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToLongLong(void)
+{
+       result r = E_SUCCESS;
+       String out;
+       long long val = 0;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturn(NID_BASE_UTIL, (r == E_SUCCESS), false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next token as long long");
+
+       r = LongLong::Parse(out, val);
+       SysTryReturn(NID_BASE_UTIL, (r == E_SUCCESS), false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next long long");
+
+       return true;
+}
+
+result _ScannerImpl::GetNextFloat(float& nextFloat)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to float");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Float::Parse(out, nextFloat);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to float");
+
+       __position =  __position + length;
+
+       return r;
+}
+
+
+bool _ScannerImpl::IsNextTokenConvertibleToFloat(void)
+{
+       result r = E_SUCCESS;
+       String out;
+       RegularExpression re;
+       float val = 0.0f;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturn(NID_BASE_UTIL, (r == E_SUCCESS), false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next token as float");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Float::Parse(out, val);
+       SysTryReturn(NID_BASE_UTIL, (r == E_SUCCESS), false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next float");
+
+       return true;
+}
+
+result _ScannerImpl::GetNextDouble(double& nextDouble)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to double");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Double::Parse(out, nextDouble);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to double");
+
+       __position =  __position + length;
+
+       return r;
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToDouble(void)
+{
+       result r = E_SUCCESS;
+       String out;
+       double val = 0.0f;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturn(NID_BASE_UTIL, (r == E_SUCCESS), false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next token as double");
+
+       out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
+       r = Double::Parse(out, val);
+       SysTryReturn(NID_BASE_UTIL, (r == E_SUCCESS), false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next token");
+
+       return true;
+}
+
+result _ScannerImpl::GetNextBool(bool& nextBool)
+{
+       result r = E_SUCCESS;
+       String out;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturnResult(NID_BASE_UTIL, ((r == E_SUCCESS) || (r == E_DATA_NOT_ENOUGH)), E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
+
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to bool");
+
+       String temp;
+       r = out.ToUpper(temp);
+       SysTryReturnResult(NID_BASE_UTIL, (r == E_SUCCESS), E_NUM_FORMAT, "Can not get next bool");
+
+       if(!temp.CompareTo(L"TRUE"))
+       {
+               nextBool = true;
+               __position =  __position + length;
+       }
+       else if(!temp.CompareTo(L"FALSE"))
+       {
+               nextBool = false;
+               __position =  __position + length;
+       }
+       else
+       {
+               r =  E_NUM_FORMAT;
+       }
+
+       return r;
+}
+
+bool _ScannerImpl::IsNextTokenConvertibleToBool(void)
+{
+       result r = E_SUCCESS;
+       String out;
+       bool ret = false;
+       int length = 0;
+       String pattern(ANY_PATTERN);
+
+       r = GetNextToken(pattern, out, length);
+       SysTryReturn(NID_BASE_UTIL, (r == E_SUCCESS), false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next token as bool");
+
+       String temp;
+       out.ToUpper(temp);
+       if((!temp.CompareTo(L"TRUE")) || (!temp.CompareTo(L"FALSE")))
+       {
+               ret = true;
+       }
+       else
+       {
+               ret = false;
+       }
+
+       return ret;
+}
+
+bool _ScannerImpl::HasNextLine(void)
+{
+       result r = E_SUCCESS;
+       String pattern(DEFAULT_LINE_SEPARATOR_PATTERN);
+       RegularExpression regex;
+       ArrayList matchedStrList;
+       bool res = false;
+
+       r = regex.Construct(pattern, REGEX_UNICODE);
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_DATA_NOT_ENOUGH, "[E_DATA_NOT_ENOUGH] Regular expression construction failed");
+
+       r = matchedStrList.Construct();
+       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_DATA_NOT_ENOUGH, "[E_DATA_NOT_ENOUGH] Arraylist construction failed");
+
+       res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
+       SysTryReturn(NID_BASE_UTIL, (res == true), false, E_DATA_NOT_ENOUGH, "[E_DATA_NOT_ENOUGH] Match Failed");
+
+       return res;
+}
+
+
+result _ScannerImpl::GetNextLine(String& nextLine)
+{
+       result r = E_SUCCESS;
+       String pattern(COMPLETE_LINE_PATTERN);
+       RegularExpression regex;
+       ArrayList matchedStrList;
+       bool res = false;
+       int matches = 0;
+
+       r = regex.Construct(pattern, REGEX_UNICODE);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_ENOUGH, "Regular expression construction failed");
+
+       r = matchedStrList.Construct();
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_ENOUGH, "Arraylist construction failed");
+
+       res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
+       SysTryReturnResult(NID_BASE_UTIL, (res == true), E_DATA_NOT_ENOUGH, "Match Failed");
+
+       matches = matchedStrList.GetCount();
+       if(matches > 0)
+       {
+               String temp = *(String *)matchedStrList.GetAt(0);
+               __position = __position + temp.GetLength();
+
+               RegularExpression re;
+               r = re.Construct(DEFAULT_LINE_SEPARATOR_PATTERN, REGEX_UNICODE);
+               re.Replace(temp, L"", true);
+               nextLine = temp;
+
+               matchedStrList.RemoveAll();
+       }
+
+       return r;
+
+}
+
+result _ScannerImpl::FindInLine(const String& str, String& MatchedStr)
+{
+       result r = E_SUCCESS;
+       _RegularExpressionImpl regex;
+       ArrayList matchedStrList;
+       bool res = false;
+       int matches = 0;
+
+       r = regex.Construct(str, REGEX_UNICODE);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "Regular expression construction failed");
+
+       r = matchedStrList.Construct();
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "Arraylist construction failed");
+
+       res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
+       SysTryReturnResult(NID_BASE_UTIL, (res == true), E_DATA_NOT_FOUND, "Match Failed");
+
+       matches = matchedStrList.GetCount();
+       if(matches > 0)
+       {
+               MatchedStr = *(String *)matchedStrList.GetAt(0);
+               int matchEnd = regex.GetLastMatchEnd();
+               __position = __position + matchEnd;
+               matchedStrList.RemoveAll();
+       }
+       return r;
+
+}
+
+result _ScannerImpl::FindInLine(const RegularExpression& pattern, String& MatchedStr)
+{
+       String patStr(pattern.GetPattern());
+       return FindInLine(patStr, MatchedStr);
+}
+
+void _ScannerImpl::Skip(const String& str)
+{
+       result r = E_SUCCESS;
+       RegularExpression regex;
+       ArrayList matchedStrList;
+       bool res = false;
+       int matches = 0;
+
+       r = regex.Construct(str, REGEX_UNICODE);
+       SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] Regular expression construction failed", GetErrorMessage(r));
+
+       r = matchedStrList.Construct();
+       SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] ArrayList construction failed", GetErrorMessage(r));
+
+       res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
+       SysTryCatch(NID_BASE_UTIL, res == true, , E_SYSTEM, "[%s] Regular expression match failed", GetErrorMessage(E_SYSTEM));
+
+       matches = matchedStrList.GetCount();
+        if(matches > 0)
+        {
+                       String temp = *(String *)matchedStrList.GetAt(0);
+                       int length = temp.GetLength();
+                       const wchar_t* wstr1 = temp.GetPointer();
+                       const wchar_t* wstr2 = __pParseStr + __position;
+                       bool isSame = true;
+
+                       while(*wstr1 != 0x0000)
+                       {
+                               if(*wstr1++ != *wstr2++)
+                               {
+                                       isSame =  false;
+                                       break;
+                               }
+                       }
+                       if(isSame == true)
+                       {
+                               __position = __position + length;
+                       }
+                       matchedStrList.RemoveAll();
+
+                       //Skip if there is any delimiters before the next token
+                       RegularExpression re;
+                       r = re.Construct(DEFAULT_DELIMITER_PATTERN, REGEX_UNICODE);
+                       res = re.Match(String(__pParseStr + __position), false, &matchedStrList);
+                       matches = matchedStrList.GetCount();
+                        if(matches > 0)
+                        {
+                                       String temp = *(String *)matchedStrList.GetAt(0);
+                                       int length = temp.GetLength();
+                                       __position = __position + length;
+                                       matchedStrList.RemoveAll();
+                        }
+
+        }
+
+CATCH:
+       return;
+}
+
+void _ScannerImpl::Skip(const RegularExpression& pattern)
+{
+       String patStr(pattern.GetPattern());
+       return Skip(patStr);
+}
+
+int _ScannerImpl::GetRadix(void)
+{
+       return __radix;
+}
+
+String _ScannerImpl::GetDelimiter(void)
+{
+       return __delimiter;
+}
+
+void _ScannerImpl::SetDelimiter(const String& delimiter)
+{
+       __delimiter = delimiter;
+}
+
+void _ScannerImpl::SetDelimiter(const RegularExpression& pattern)
+{
+       __delimiter = pattern.GetPattern();
+}
+
+void _ScannerImpl::SetRadix(int radix)
+{
+       if(((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) ||
+               (radix == Character::RADIX_DECIMAL) || (radix == Character::RADIX_HEXADECIMAL)))
+       {
+               __radix = radix;
+       }
+}
+
+result _ScannerImpl::GetNextToken(const String& pattern, String& ret, int& length)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_BASE_UTIL, __pParseStr != null, E_DATA_NOT_ENOUGH, "Input has no remaining tokens.");
+       SysTryReturnResult(NID_BASE_UTIL, *__pParseStr != 0x0000, E_DATA_NOT_ENOUGH, "Input has no remaining tokens.");
+
+       RegularExpression regex;
+       ArrayList matchedStrList;
+       bool res = false;
+       int matches = 0;
+       String regPattern(pattern);
+
+       regPattern.Append(__delimiter);
+
+       r = regex.Construct(regPattern, REGEX_UNICODE);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Regular expression construction failed");
+
+       r = matchedStrList.Construct();
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Arraylist construction failed");
+
+       res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
+       SysTryReturnResult(NID_BASE_UTIL, res == true, E_OPERATION_FAILED, "Match Failed");
+
+       matches = matchedStrList.GetCount();
+       if(matches > 0)
+       {
+               String temp = *(String *)matchedStrList.GetAt(0);
+               length = temp.GetLength();
+               RegularExpression re;
+               r = re.Construct(__delimiter, REGEX_UNICODE);
+               re.Replace(temp, L"", true);
+               ret = temp;
+               matchedStrList.RemoveAll();
+       }
+
+       return r;
+}
+
+result _ScannerImpl::GetNextMatchingString(const String& pattern, String& ret, int& length)
+{
+       result r = E_SUCCESS;
+       RegularExpression regex;
+       ArrayList matchedStrList;
+
+       bool res = false;
+       int matches = 0;
+       String nextToken;
+       String matchToken;
+
+       String strPat(ANY_PATTERN);
+       strPat.Append(DEFAULT_DELIMITER_PATTERN);
+
+       r = regex.Construct(strPat, REGEX_UNICODE);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Regular expression construction failed");
+
+       r = matchedStrList.Construct();
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Arraylist construction failed");
+
+       res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
+
+       SysTryReturnResult(NID_BASE_UTIL, res == true, E_OPERATION_FAILED, "Match Failed");
+
+       matches = matchedStrList.GetCount();
+       if(matches > 0)
+       {
+               nextToken = *(String *)matchedStrList.GetAt(0);
+               matchedStrList.RemoveAll();
+       }
+
+       strPat = pattern;
+       strPat.Append(DEFAULT_DELIMITER_PATTERN);
+       r = regex.Construct(strPat, REGEX_UNICODE);
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Regular expression construction failed");
+
+       r = matchedStrList.Construct();
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Arraylist construction failed");
+
+       res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
+       SysTryReturnResult(NID_BASE_UTIL, res == true, E_OPERATION_FAILED, "Match Failed");
+
+       matches = matchedStrList.GetCount();
+       if(matches > 0)
+       {
+               matchToken = *(String *)matchedStrList.GetAt(0);
+               matchedStrList.RemoveAll();
+
+               if((nextToken == matchToken) == true)
+               {
+                       length = matchToken.GetLength();
+                       RegularExpression re;
+                       r = re.Construct(DEFAULT_DELIMITER_PATTERN, REGEX_UNICODE);
+                       re.Replace(matchToken, L"", true);
+                       ret = matchToken;
+               }
+               else
+               {
+                       r = E_OPERATION_FAILED;
+               }
+       }
+
+
+       return r;
+}
+}}}   // Osp::Base::Utility
diff --git a/src/base/utility/FBaseUtil_ScannerImpl.h b/src/base/utility/FBaseUtil_ScannerImpl.h
new file mode 100644 (file)
index 0000000..350cf9d
--- /dev/null
@@ -0,0 +1,105 @@
+//
+// 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       FBaseUtil_ScannerImpl.h
+ * @brief      This is the header file for the _ScannerImpl class.
+ *
+ * This header file contains declarations and definitions of the _ScannerImpl class. 
+ *
+ */
+
+#ifndef _FBASE_UTIL_SCANNER_IMPL_H_
+#define _FBASE_UTIL_SCANNER_IMPL_H_
+
+#include <FBaseString.h>
+#include <FBaseUtilRegularExpression.h>
+
+namespace Tizen { namespace Base { namespace Utility
+{
+
+class _OSP_EXPORT_ _ScannerImpl
+       : public Tizen::Base::Object
+{
+public:
+       _ScannerImpl(void);
+       _ScannerImpl(const _ScannerImpl& scanner);
+       _ScannerImpl& operator =(const _ScannerImpl& scanner);
+       virtual ~_ScannerImpl(void);
+//     virtual int GetHashCode(void);
+
+       result Construct(const String& str);
+       result Construct(const String& filePath, const String& encodingScheme);
+
+       result FindInLine(const String& str, String& MatchedStr); 
+       result FindInLine(const RegularExpression& pattern, String& MatchedStr); 
+       
+       result GetNextSignedChar(signed char& nextSignedChar);
+       result GetNextSignedChar(signed char& nextSignedChar, int radix);
+       result GetNextInt(int& nextInt);
+       result GetNextInt(int& nextInt, int radix);
+       result GetNextShort(short& nextShort);
+       result GetNextShort(short& nextShort, int radix);
+       result GetNextLongLong(long long& nextLongLong);
+       result GetNextFloat(float& nextFloat);
+       result GetNextDouble(double& nextDouble);
+       result GetNextBool(bool& nextBool);
+       result GetNextLine(String& nextLine);
+       result GetNextToken(String& nextStr);
+       result GetNextToken(const String& pattern, String& nextStr);
+       result GetNextToken(const RegularExpression& pattern, String& nextStr);
+
+       int GetRadix(void);
+       String GetDelimiter(void);
+
+       bool HasNextToken(void);
+       bool HasNextToken(const String& pattern);
+       bool HasNextToken(const RegularExpression& pattern);
+       bool IsNextTokenConvertibleToSignedChar(void); 
+       bool IsNextTokenConvertibleToSignedChar(int radix);
+       bool IsNextTokenConvertibleToInt(void);
+       bool IsNextTokenConvertibleToInt(int radix);
+       bool IsNextTokenConvertibleToShort(void);
+       bool IsNextTokenConvertibleToShort(int radix);
+       bool IsNextTokenConvertibleToLongLong(void);
+       bool IsNextTokenConvertibleToFloat(void);
+       bool IsNextTokenConvertibleToDouble(void);
+       bool IsNextTokenConvertibleToBool(void);
+       bool HasNextLine(void);
+
+       void SetRadix(int radix);
+       void SetDelimiter(const String& delimiter);
+       void SetDelimiter(const RegularExpression& pattern);
+
+       void Skip(const String& str);
+       void Skip(const RegularExpression& pattern);
+       result GetNextToken(const String& pattern, String& ret, int& matTokenLen);
+       result GetNextMatchingString(const String& pattern, String& ret, int& length);
+
+public:
+       int __radix;
+       String __delimiter;
+       const wchar_t* __pParseStr;
+       bool __isAllocatedOnHeap;
+       int __position;
+
+       friend class Scanner;
+}; // _ScannerImpl
+
+}}}   // Osp::Base::Utility
+
+#endif // _FBASE_UTIL_SCANNER_IMPL_H_
old mode 100755 (executable)
new mode 100644 (file)
index c5f3185..0258a3b
@@ -11,13 +11,6 @@ INCLUDE_DIRECTORIES (
        )
 
 SET (${this_target}_SOURCE_FILES
-       FIo_ChannelManager.cpp
-       FIo_Channel.cpp
-       FIoClientChannel.cpp
-       FIo_ClientChannelImpl.cpp
-       FIo_ChannelService.cpp
-       FIoServerChannel.cpp
-       FIo_ServerChannelImpl.cpp
        FIoDatabase.cpp
        FIo_DatabaseImpl.cpp
        FIoDbEnumerator.cpp
@@ -48,12 +41,16 @@ SET (${this_target}_SOURCE_FILES
        FIo_RegistryImpl.cpp
        FIo_RegistryCore.cpp
        FIo_IpcClient.cpp
-       FIo_IpcServer.cpp
        FIo_IIpcClientEventListener.cpp
        FIo_IIpcServerEventListener.cpp
        FIo_ChannelMessages.cpp
+       FIo_ChannelManager.cpp
+       FIo_Channel.cpp
+       FIoClientChannel.cpp
+       FIo_ClientChannelImpl.cpp
+       FIoServerChannel.cpp
+       FIo_ServerChannelImpl.cpp
        FIo_ChannelServiceProxy.cpp
-       FIo_ChannelServiceStub.cpp
        FIo_ChannelServiceManager.cpp
        FIo_DataControlResultSetImpl.cpp
        FIo_DataControlResultSetEnumerator.cpp
@@ -63,8 +60,6 @@ SET (${this_target}_SOURCE_FILES
        FIo_ServiceMessage.cpp
        FIoMemoryMappedFile.cpp
        FIo_MemoryMappedFileImpl.cpp
-       FIo_ChannelCAppStub.cpp
-       FIo_ChannelWebAppStub.cpp
        FIoMmcStorageManager.cpp
        FIo_MmcStorageManagerImpl.cpp
        FIo_MmcStorageManagerIpcMessages.cpp
@@ -75,8 +70,10 @@ SET (${this_target}_SOURCE_FILES
        FIo_LocalMessagePortImpl.cpp
        FIoRemoteMessagePort.cpp
        FIo_RemoteMessagePortImpl.cpp
-       FIo_MessagePortMessages.cpp
        FIo_MessagePortProxy.cpp
+       FIo_ZipFileArchive.cpp
+       FIoFileLock.cpp
+       FIo_FileLockImpl.cpp
        )
 
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
@@ -92,3 +89,4 @@ SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EX
 ## Create Library
 ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES})
 
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-serial" )
index 6d4c8ce..32fbf78 100644 (file)
@@ -309,5 +309,33 @@ File::ConvertToSecureFile(const String& plainFilePath, const String& secureFileP
        return _FileImpl::ConvertToSecureFile(plainFilePath, secureFilePath, key);
 }
 
+FileLock*
+File::LockN(FileLockType lockType)
+{
+       SysAssertf(__pFileImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileImpl->LockN(lockType);
+}
+
+FileLock*
+File::LockN(FileLockType lockType, int offset, int length)
+{
+       SysAssertf(__pFileImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileImpl->LockN(lockType, offset, length);
+}
+
+FileLock*
+File::TryToLockN(FileLockType lockType)
+{
+       SysAssertf(__pFileImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileImpl->TryToLockN(lockType);
+}
+
+FileLock*
+File::TryToLockN(FileLockType lockType, int offset, int length)
+{
+       SysAssertf(__pFileImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileImpl->TryToLockN(lockType, offset, length);
+}
+
 }} // Tizen::Io
 
diff --git a/src/io/FIoFileLock.cpp b/src/io/FIoFileLock.cpp
new file mode 100644 (file)
index 0000000..8329d1e
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// 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       FIoFileLock.cpp
+ * @brief      This is the implementation file for %FileLock class.
+ */
+
+#include <new>
+#include <limits.h>
+#include <unique_ptr.h>
+
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FIoFileLock.h>
+#include "FIo_FileImpl.h"
+#include "FIo_FileLockImpl.h"
+
+namespace Tizen { namespace Io
+{
+
+FileLock::FileLock(void)
+       : __pFileLockImpl(null)
+{
+}
+
+FileLock::~FileLock(void)
+{
+       delete __pFileLockImpl;
+}
+
+result
+FileLock::Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid)
+{
+       SysAssertf(__pFileLockImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class\n");
+
+       std::unique_ptr<_FileLockImpl> pFileLockImpl(new (std::nothrow) _FileLockImpl);
+       SysTryReturnResult(NID_IO, pFileLockImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       result r = pFileLockImpl->Construct(pFileImpl, lockType, offset, size, pid);
+       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pFileLockImpl = pFileLockImpl.release();
+       return r;
+}
+
+bool
+FileLock::IsShared(void) const
+{
+       SysAssertf(__pFileLockImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileLockImpl->IsShared();
+}
+
+bool
+FileLock::IsExclusive(void) const
+{
+       SysAssertf(__pFileLockImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileLockImpl->IsExclusive();
+}
+
+bool
+FileLock::IsValid(void) const
+{
+       SysAssertf(__pFileLockImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileLockImpl->IsValid();
+}
+
+}} // Tizen::Io
index ff34cf6..e0ed870 100644 (file)
@@ -123,7 +123,19 @@ MmcStorageManager::AddMmcStorageMountListener(IMmcStorageMountListener& listener
 {
        SysAssertf(__pMmcStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
 
-       return __pMmcStorageManagerImpl->AddMmcStorageMountListener(listener);
+       // Compatibility issue
+       result r = __pMmcStorageManagerImpl->AddMmcStorageMountListener(listener);
+       switch(r)
+       {
+               case E_OBJ_ALREADY_EXIST:
+                       return E_SUCCESS;
+               case E_INVALID_OPERATION:
+                       return E_SYSTEM;
+               default:
+                       break;
+       }
+
+       return r;
 }
 
 result
@@ -131,7 +143,17 @@ MmcStorageManager::RemoveMmcStorageMountListener(IMmcStorageMountListener& liste
 {
        SysAssertf(__pMmcStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
 
-       return __pMmcStorageManagerImpl->RemoveMmcStorageMountListener(listener);
+       // Compatibility issue
+       result r = __pMmcStorageManagerImpl->RemoveMmcStorageMountListener(listener);
+       switch(r)
+       {
+               case E_OBJ_NOT_FOUND:
+                       return E_SUCCESS;
+               default:
+                       break;
+       }
+
+       return r;
 }
 
 result
@@ -139,7 +161,19 @@ MmcStorageManager::AddMmcStorageFormatListener(IMmcStorageFormatListener& listen
 {
        SysAssertf(__pMmcStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
 
-       return __pMmcStorageManagerImpl->AddMmcStorageFormatListener(listener);
+       // Compatibility issue
+       result r = __pMmcStorageManagerImpl->AddMmcStorageFormatListener(listener);
+       switch(r)
+       {
+               case E_OBJ_ALREADY_EXIST:
+                       return E_SUCCESS;
+               case E_INVALID_OPERATION:
+                       return E_SYSTEM;
+               default:
+                       break;
+       }
+
+       return r;
 }
 
 result
@@ -147,7 +181,16 @@ MmcStorageManager::RemoveMmcStorageFormatListener(IMmcStorageFormatListener& lis
 {
        SysAssertf(__pMmcStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
 
-       return __pMmcStorageManagerImpl->RemoveMmcStorageFormatListener(listener);
+       result r = __pMmcStorageManagerImpl->RemoveMmcStorageFormatListener(listener);
+       switch(r)
+       {
+               case E_OBJ_NOT_FOUND:
+                       return E_SUCCESS;
+               default:
+                       break;
+       }
+
+       return r;
 }
 
 }} // Tizen::Io
index a928e2e..ab817fd 100644 (file)
@@ -546,5 +546,19 @@ Registry::ConvertToSecureRegistry(const String& plainRegPath, const String& secu
        return _RegistryImpl::ConvertToSecureRegistry(plainRegPath, secureRegPath, &key);
 }
 
+FileLock*
+Registry::LockN(FileLockType lockType)
+{
+       SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pRegistryImpl->LockN(lockType);
+}
+
+FileLock*
+Registry::TryToLockN(FileLockType lockType)
+{
+       SysAssertf(__pRegistryImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pRegistryImpl->TryToLockN(lockType);
+}
+
 }} // Tizen::Io
 
diff --git a/src/io/FIo_ChannelCAppStub.cpp b/src/io/FIo_ChannelCAppStub.cpp
deleted file mode 100644 (file)
index 6a29aac..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-//
-// 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       FIo_ChannelCAppStub.cpp
- * @brief      This is the implementation file for the  _ChannelCAppStub class.
- *
- */
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <cerrno>
-#include <iostream>
-
-#include <unique_ptr.h>
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/un.h>
-#include <errno.h>
-
-#include <FBase_StringConverter.h>
-#include <FBaseDataType.h>
-#include <FBaseLong.h>
-#include <FBaseColArrayList.h>
-
-#include <FBaseRt_EventDispatcher.h>
-#include <FBaseSysLog.h>
-#include <FBaseUtilStringTokenizer.h>
-#include <FIo_ChannelServiceStub.h>
-#include <FApp_AppInfo.h>
-
-#include "FIo_ChannelCAppStub.h"
-
-#define MAX_BUFFER_LENGTH 4096
-
-static const int TOKEN_LENGTH = 7;
-static const int CAPP_PADDING_LENGTH = 7;
-
-using namespace std;
-
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
-using namespace Tizen::Base::Utility;
-using namespace Tizen::Io;
-using namespace Tizen::App;
-
-using namespace std;
-
-namespace Tizen { namespace Io
-{
-
-_ChannelCAppStub::_ChannelCAppStub(void)
-       :__pChannelService(null)
-       , __pGMainContext(null)
-       , __pConnectGSource(null)
-{
-}
-
-_ChannelCAppStub::~_ChannelCAppStub(void)
-{
-       if (__pConnectGSource != null)
-       {
-               g_source_destroy(__pConnectGSource);
-               g_source_unref(__pConnectGSource);
-               __pConnectGSource = null;
-       }
-       __clients.clear();
-}
-
-_ChannelCAppStub::_ChannelInfo::_ChannelInfo(void)
-       : pClientInfo(null)
-       , pGIOChannel(null)
-       , pGSource(null)
-       , destroySource(true)
-{
-
-}
-_ChannelCAppStub::_ChannelInfo::~_ChannelInfo(void)
-{
-       if (pGIOChannel != null)
-       {
-               g_io_channel_unref(pGIOChannel);
-       }
-
-       if (pGSource != null)
-       {
-               if (destroySource)
-               {
-                       g_source_destroy(pGSource);
-               }
-
-               g_source_unref(pGSource);
-       }
-}
-
-_ChannelCAppStub::_ClientInfo::_ClientInfo(void)
-       : clientId(-1)
-       , pChannelStub(null)
-{
-
-}
-
-_ChannelCAppStub::_ClientInfo::~_ClientInfo(void)
-{
-       channels.clear();
-}
-
-result
-_ChannelCAppStub::Construct(void)
-{
-       GSource* pGSource = null;
-       GIOChannel* pGIOChannel = null;
-       const char* pSocketName = "/tmp/osp.io.socketserver.channelmanager\0";
-       size_t socketNameLength = 0;
-       struct sockaddr_un serverAddress;
-       int serverSocket = -1;
-       socklen_t serverLen = 0;
-       int ret = 0;
-       result r = E_SUCCESS;
-
-       socketNameLength = strlen(pSocketName) + 1;
-       SysTryReturnResult(NID_IO, socketNameLength < 108, E_SYSTEM,
-                       "Server name is too long.");
-
-       __pGMainContext = g_main_context_get_thread_default(); //get own gmain context except default thread
-       if (__pGMainContext == null)
-       {
-               __pGMainContext = g_main_context_default(); //get gmain context from me (default)
-               SysTryReturnResult(NID_IO, __pGMainContext != null, E_SYSTEM,
-                               "Failed to get glib context.");
-       }
-
-       ret = unlink(pSocketName);
-       SysTryLog(NID_IO, ret == 0, "Unlinking a socket %s has failed.. but it is not a problem.", pSocketName);
-
-       serverSocket = socket(AF_UNIX, SOCK_STREAM, 0);
-       SysTryReturnResult(NID_IO, serverSocket != -1, E_SYSTEM,
-                       "Failed to create a socket.");
-
-       bzero(&serverAddress, sizeof(serverAddress));
-       serverAddress.sun_family = AF_UNIX;
-       strncpy(serverAddress.sun_path, pSocketName, socketNameLength);
-       serverLen = sizeof(serverAddress);
-
-       ret = bind(serverSocket, (const struct sockaddr*) &serverAddress, serverLen);
-       SysTryCatch(NID_IO, ret != -1, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to bind a socket(%d, %s): %s", serverSocket, pSocketName, strerror(errno));
-
-       ret = chmod(pSocketName, 0666);
-       SysTryCatch(NID_IO, ret == 0, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to change permission of a socket(%d, %s): %s", serverSocket,
-                       pSocketName, strerror(errno));
-
-       listen(serverSocket, 5);
-
-       pGIOChannel = g_io_channel_unix_new(serverSocket);
-       SysTryCatch(NID_IO, pGIOChannel != null, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to create GIOChannel for socket.");
-
-       // socket will be closed when pGIOChannel is deleted.
-       g_io_channel_set_close_on_unref(pGIOChannel, TRUE);
-       serverSocket = -1;
-
-       pGSource = g_io_create_watch(pGIOChannel, (GIOCondition)(G_IO_IN | G_IO_ERR | G_IO_NVAL | G_IO_HUP));
-       SysTryCatch(NID_IO, pGSource != null, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to create GSource for socket.");
-
-       // channel will be delete when pGSource is deleted.
-       g_io_channel_unref(pGIOChannel);
-       pGIOChannel = null;
-
-       g_source_set_callback(pGSource, (GSourceFunc) OnConnectionRequest, this, NULL);
-       g_source_attach(pGSource, __pGMainContext);
-
-       __pConnectGSource = pGSource;
-
-       return E_SUCCESS;
-
-CATCH:
-       if (pGIOChannel != null)
-       {
-               g_io_channel_unref(pGIOChannel);
-       }
-
-       if (serverSocket != -1)
-       {
-               close(serverSocket);
-       }
-
-       if (__pGMainContext)
-       {
-               g_main_context_unref(__pGMainContext);
-               __pGMainContext = null;
-       }
-
-       return r;
-}
-
-void
-_ChannelCAppStub::SetChannelService(_ChannelService& service)
-{
-       __pChannelService = &service;
-}
-
-struct HelloMessage
-{
-       int pid;
-       char appId[256];
-};
-
-gboolean
-_ChannelCAppStub::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpointer data)
-{
-       int serverFd = -1;
-       int clientFd = -1;
-       struct sockaddr_un clientAddress;
-       socklen_t clientLen = sizeof(clientAddress);
-       GSource* pGSource = null;
-       GIOChannel* pGIOChannel = null;
-       GError* pGError = null;
-       _ClientInfo* pClientInfo = null;
-       _ChannelInfo* pChannelInfo = null;
-       HelloMessage helloMessage;
-       int readSize = 0;
-
-       _ChannelCAppStub* pChannelStub = static_cast< _ChannelCAppStub* >(data);
-       SysTryReturn(NID_IO, pChannelStub != null, FALSE, E_SYSTEM,
-                       "[E_SYSTEM] pChannelStub is null.");
-
-       serverFd = g_io_channel_unix_get_fd(source);
-       clientFd = accept(serverFd, (struct sockaddr*) &clientAddress, &clientLen);
-       SysTryReturn(NID_IO, clientFd != -1, E_SYSTEM, FALSE, "[E_SYSTEM] Failed to accept.");
-
-
-       readSize = read(clientFd, &helloMessage, sizeof(helloMessage));
-       helloMessage.appId[255] = '\0';
-
-       SysLog(NID_IO, " >> Channel Service: accepted client fd: %d, client pid: %d, appid: %s",
-                       clientFd, helloMessage.pid, helloMessage.appId);
-
-       pGIOChannel = g_io_channel_unix_new(clientFd);
-       SysTryCatch(NID_IO, pGIOChannel != null, , E_SYSTEM,
-                       "[E_SYSTEM] Failed to create GIOChannel.");
-
-       g_io_channel_set_encoding(pGIOChannel, NULL, &pGError);
-       g_io_channel_set_flags(pGIOChannel, G_IO_FLAG_NONBLOCK, &pGError);
-
-       g_io_channel_set_close_on_unref(pGIOChannel, TRUE);
-       clientFd = -1;
-
-       pClientInfo = pChannelStub->__clients[helloMessage.pid];
-       if (pClientInfo == null) // first connection request from this client
-       {
-               SysLog(NID_IO, "First connection!! [%s]", helloMessage.appId);
-
-               pClientInfo = new (std::nothrow) _ClientInfo;
-               SysTryCatch(NID_IO, pClientInfo != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
-               pClientInfo->pChannelStub = pChannelStub;
-               pClientInfo->clientId = helloMessage.pid;
-               pClientInfo->appId = helloMessage.appId;
-
-               pChannelStub->__clients[helloMessage.pid] = pClientInfo;
-       }
-
-       pChannelInfo = new (std::nothrow) _ChannelInfo;
-       SysTryCatch(NID_IO, pChannelInfo != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
-       pGSource = g_io_create_watch(pGIOChannel, (GIOCondition) (G_IO_IN | G_IO_ERR | G_IO_NVAL | G_IO_HUP));
-       g_source_set_callback(pGSource, (GSourceFunc) OnReadMessage, pChannelInfo, NULL);
-       g_source_attach(pGSource, pChannelStub->__pGMainContext);
-
-       pChannelInfo->pClientInfo = pClientInfo;
-       pChannelInfo->pGIOChannel = pGIOChannel;
-       pChannelInfo->pGSource = pGSource;
-
-       pClientInfo->channels.push_back(pChannelInfo);
-
-       // Stores client info to _ChannelService
-       pChannelStub->__pChannelService->RegisterChannel(pClientInfo->appId, helloMessage.pid, pGIOChannel);
-
-       return TRUE;
-
-CATCH:
-       if (pGIOChannel != null)
-       {
-               g_io_channel_unref(pGIOChannel);
-       }
-
-       if (clientFd != -1)
-       {
-               close(clientFd);
-       }
-
-       return FALSE;
-}
-
-gboolean
-_ChannelCAppStub::OnReadMessage(GIOChannel* source, GIOCondition condition, gpointer data)
-{
-       gboolean ret = FALSE;
-
-       _ChannelInfo* pChannelInfo = (_ChannelInfo*) data;
-       _ClientInfo* pClientInfo = pChannelInfo->pClientInfo;
-       _ChannelCAppStub* pChannelStub = (_ChannelCAppStub*) pClientInfo->pChannelStub;
-
-       ret = pChannelStub->HandleReceivedMessage(source, condition, data);
-
-       return ret;
-}
-
-gboolean
-_ChannelCAppStub::HandleReceivedMessage(GIOChannel* source, GIOCondition condition, gpointer data)
-{
-       GIOStatus status;
-       GError* pGError = null;
-       gsize readBytes = 0;
-       result r = E_SUCCESS;
-
-       SysLog(NID_IO, "fd: %d, condition :0x%x", g_io_channel_unix_get_fd(source), condition);
-
-       _ChannelInfo* pChannelInfo = (_ChannelInfo*) data;
-       _ClientInfo* pClientInfo = pChannelInfo->pClientInfo;
-       _ChannelCAppStub* pChannelStub = pClientInfo->pChannelStub;
-
-       if (condition & G_IO_HUP)
-       {
-               SysLog(NID_IO, " G_IO_HUP, the connection is closed");
-               int clientId = pClientInfo->clientId;
-
-               g_io_channel_shutdown(source, FALSE, &pGError);
-
-               for (unsigned int i = 0; i < pClientInfo->channels.size(); i++)
-               {
-                       if (pChannelInfo == pClientInfo->channels[i])
-                       {
-                               pClientInfo->channels.erase(pClientInfo->channels.begin() + i);
-
-                               pChannelInfo->destroySource = false;
-                               delete pChannelInfo;
-
-                               break;
-                       }
-
-               }
-
-               if (pClientInfo->channels.size() == 0)
-               {
-                       SysLog(NID_IO, "All connections of client(%d) are closed. delete client info", clientId);
-
-                       pChannelStub->__pChannelService->UnregisterChannel(clientId);
-
-                       __clients[clientId] = null;
-
-                       delete pClientInfo;
-               }
-
-               return FALSE;
-       }
-       else if (condition & G_IO_IN)
-       {
-               unique_ptr<char[]> pBuffer(new char[MAX_BUFFER_LENGTH]);
-               pGError = null;
-               status = g_io_channel_read_chars(source, pBuffer.get(), MAX_BUFFER_LENGTH, &readBytes, &pGError);
-               if (status != G_IO_STATUS_NORMAL)
-               {
-                       if (status == G_IO_STATUS_EOF || status == G_IO_STATUS_ERROR)
-                       {
-                               if (status == G_IO_STATUS_EOF)
-                               {
-                                       SysLog(NID_IO, "G_IO_STATUS_EOF, the connection is closed.");
-                               }
-                               else
-                               {
-                                       SysLog(NID_IO, "G_IO_STATUS_ERROR, the connection is closed. ");
-                               }
-
-                               pGError = null;
-                               g_io_channel_shutdown(source, FALSE, &pGError);
-
-                               int clientId = pClientInfo->clientId;
-
-                               for (unsigned int i = 0; i < pClientInfo->channels.size(); i++)
-                               {
-                                       if (pChannelInfo == pClientInfo->channels[i])
-                                       {
-                                               pClientInfo->channels.erase(pClientInfo->channels.begin() + i);
-
-                                               //pChannelInfo->destroySource = false;
-                                               pChannelInfo->destroySource = true;
-                                               delete pChannelInfo;
-                                               break;
-                                       }
-                               }
-
-                               if (pClientInfo->channels.size() == 0)
-                               {
-                                       SysLog(NID_IO, "All connections of client(%d) are closed. delete client info", clientId);
-
-                                       pChannelStub->__pChannelService->UnregisterChannel(clientId);
-
-                                       __clients[clientId] = null;
-
-                                       delete pClientInfo;
-                               }
-
-                               return FALSE;
-                       }
-               }
-
-               SysLog(NID_IO, "CAppChannel >> Channel Server: readBytes: %d, readBuf: %s", readBytes, pBuffer.get());
-
-               SysTryReturn(NID_IO, readBytes != 0, FALSE, E_SYSTEM, "[E_SYSTEM] Received data is empty.");
-
-               String srcAppId = pClientInfo->appId;
-
-               // Parse the header
-               string buffer(pBuffer.get());
-               string tokenStr("::");
-               RequestId reqId = 0;
-               size_t pos = 0;
-               size_t lastPos = 0;
-
-               lastPos = buffer.find(tokenStr);
-
-               // AppId
-               String appId((buffer.substr(pos, lastPos-pos)).c_str());
-
-               SysLog(NID_IO, "CAppChannel >> src = %ls / dest = %ls", srcAppId.GetPointer(), appId.GetPointer());
-
-               pos = lastPos + tokenStr.length();
-               lastPos = buffer.find(tokenStr, pos);
-
-               // Request ID
-               string requestId(buffer.substr(pos, lastPos-pos));
-               reqId = atol(requestId.c_str());
-
-               SysLog(NID_IO, "CAppChannel >> requestId = %d", reqId);
-
-               pos = lastPos + tokenStr.length();
-
-               // Parse the data
-               ArrayList list;
-               list.Construct();
-
-               size_t bufferSize = buffer.length();
-               int tokenCount = 0;
-               string token;
-               while (pos < bufferSize)
-               {
-                       // Get length of each token
-                       token = buffer.substr(pos, TOKEN_LENGTH);
-                       pos += TOKEN_LENGTH;
-
-                       if (token == "0000000")
-                       {
-                               SysLog(NID_IO, "CAppChannel >> length = 0, token = empty string");
-                               list.Add(*(new String()));
-                       }
-                       else
-                       {
-                               tokenCount = atoi(token.c_str());
-                               token = buffer.substr(pos, tokenCount);
-                               pos += tokenCount;
-
-                               SysLog(NID_IO, "CAppChannel >> length = %d, token = %s", tokenCount, token.c_str());
-                               list.Add(*(new String(token.c_str())));
-                       }
-               }
-
-               r = pChannelStub->__pChannelService->SendRequest(srcAppId, appId, list, reqId);
-               SysTryReturn(NID_IO, !IsFailed(r), FALSE, E_SYSTEM, "[E_SYSTEM] Failed to send request.");
-
-               list.RemoveAll(true);
-       }
-       else
-       {
-               SysLog(NID_IO, " >> Channel Service: else !!!");
-       }
-
-       return TRUE;
-}
-
-bool
-_ChannelCAppStub::SendResponse(int requestId, void* pGIOChannel, const ArrayList& args)
-{
-       gsize writtenBytes = 0;
-       GError* pGError = null;
-
-       // Parse the data
-       String str;
-       String item;
-       String lengthString;
-       int count = args.GetCount();
-       int itemLength = 0;
-       int paddingLength = 0;
-       result r = E_SUCCESS;
-       SysLog(NID_IO, "item count: %d", count);
-
-       for (int i = 0; i < count; ++i)
-       {
-               item = *((String*)args.GetAt(i));
-               itemLength = item.GetLength();
-               lengthString = Integer::ToString(itemLength);
-               r = item.Insert(lengthString, 0);
-               SysTryReturn(NID_IO, !IsFailed(r), false, E_SYSTEM, "[E_SYSTEM] Failed to compose the response message.");
-
-               // padding 7 digit
-               paddingLength = CAPP_PADDING_LENGTH - lengthString.GetLength();
-               for (int j = 0; j < paddingLength; j++)
-               {
-                       r = item.Insert(L'0', 0);
-                       SysTryReturn(NID_IO, !IsFailed(r), false, E_SYSTEM, "[E_SYSTEM] Failed to compose the response message.");
-               }
-
-               str.Append(item);
-       }
-
-       SysLog(NID_IO, "data: %ls, length: %d", str.GetPointer(), str.GetLength());
-
-       // Add a RequestId
-       str.Append(L"|||");
-       str.Append(requestId);
-       str.Append(L"|");
-
-       // Send a data
-       unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(str));
-
-       itemLength = strlen(pStr.get());
-
-       g_io_channel_write_chars((GIOChannel*)pGIOChannel, (char*)pStr.get(), itemLength, &writtenBytes, &pGError);
-       g_io_channel_flush((GIOChannel*)pGIOChannel, &pGError);
-
-       return true;
-}
-
-}}
-
diff --git a/src/io/FIo_ChannelService.cpp b/src/io/FIo_ChannelService.cpp
deleted file mode 100644 (file)
index dd79574..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-//
-// 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       FIo_ChannelService.cpp
- * @brief      This is the implementation file for the _ChannelService class.
- *
- */
-
-#include <vector>
-#include <new>
-#include <glib.h>
-
-#include <unique_ptr.h>
-
-#include <FBaseStringComparer.h>
-#include <FBaseSysLog.h>
-#include <FBase_StringConverter.h>
-#include <FBaseRt_EventDispatcher.h>
-#include "FIo_ChannelService.h"
-#include "FIo_ChannelMessages.h"
-#include "FIo_IChannelServiceStub.h"
-#include "FIo_ChannelCAppStub.h"
-#include "FIo_ChannelWebAppStub.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 Io
-{
-
-_ChannelService::_ChannelService(void)
-       : __pIChannelServiceStub(null)
-{
-
-}
-
-_ChannelService::~_ChannelService(void)
-{
-
-}
-
-result
-_ChannelService::Construct(_IChannelServiceStub& stub)
-{
-       static _StringHashProvider hashProvider;
-       static _StringComparer stringComparer;
-       result r = E_SUCCESS;
-
-       __channels.Construct(0, 0, hashProvider, stringComparer);
-
-       __pIChannelServiceStub = &stub;
-
-       __pIChannelServiceStub->SetChannelService(*this);
-
-       // Create a CAppStub
-       unique_ptr<_ChannelCAppStub> pCStub(new (std::nothrow) _ChannelCAppStub());
-       SysTryReturnResult(NID_IO, pCStub != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       r = pCStub->Construct();
-       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to create a CAppStub.");
-
-       pCStub->SetChannelService(*this);
-
-       // Create a WebAppStub
-       unique_ptr<_ChannelWebAppStub> pWebStub(new (std::nothrow) _ChannelWebAppStub());
-       SysTryReturnResult(NID_IO, pWebStub != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       r = pWebStub->Construct();
-       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to create a WebAppStub.");
-
-       pWebStub->SetChannelService(*this);
-
-       pCStub.release();
-       pWebStub.release();
-
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::RegisterChannel(const String& channelId, const _IChannelServiceEventListener& listener)
-{
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::RegisterChannel(const String& channelId, int clientId, unsigned int type)
-{
-       result r = E_SUCCESS;
-       _ChannelInfo* pChannelInfo = null;
-
-       SysLog(NID_IO, "Register a channel : %ls.", channelId.GetPointer());
-
-       r = __channels.GetValue(channelId, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo == null, E_SYSTEM,  "Channel has already been registered.");
-
-       pChannelInfo = new (std::nothrow) _ChannelInfo;
-       SysTryReturnResult(NID_IO, pChannelInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       pChannelInfo->channelId = channelId;
-       pChannelInfo->clientId = clientId;
-       pChannelInfo->type = type;
-       pChannelInfo->pGIOChannel = null;
-
-       __channels.Add(channelId, pChannelInfo);
-
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::RegisterChannel(const String& channelId, int clientId, void* pGIOChannel)
-{
-       result r = E_SUCCESS;
-       _ChannelInfo* pChannelInfo = null;
-
-       SysLog(NID_IO, "Register a channel : [%ls]", channelId.GetPointer());
-
-       r = __channels.GetValue(channelId, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo == null, E_SYSTEM, "Channel has already been registered.");
-
-       pChannelInfo = new (std::nothrow) _ChannelInfo;
-       SysTryReturnResult(NID_IO, pChannelInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       pChannelInfo->channelId = channelId;
-       pChannelInfo->clientId = clientId;
-       pChannelInfo->type = CAPP_CHANNEL;
-       pChannelInfo->pGIOChannel = pGIOChannel;
-
-       __channels.Add(channelId, pChannelInfo);
-
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::UnregisterChannel(const String& channelId)
-{
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::UnregisterChannel(int clientId)
-{
-       SysLog(NID_IO, "Unregister - clientId =  %d", clientId);
-
-       result r = E_OBJ_NOT_FOUND;
-
-       String key;
-       _ChannelInfo* pValue = null;
-       IListT<String>* pKeys = __channels.GetKeysN();
-       SysTryReturnResult(NID_IO, pKeys != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       int count = __channels.GetCount();
-
-       for (int i = 0; i < count; i++)
-       {
-               pKeys->GetAt(i, key);
-               __channels.GetValue(key, pValue);
-               if (pValue != null && pValue->clientId == clientId)
-               {
-                       SysLog(NID_IO, "Unregister - ChannelId = %ls", key.GetPointer());
-                       __channels.Remove(key);
-                       delete pValue;
-
-                       r = E_SUCCESS;
-               }
-       }
-
-       delete pKeys;
-
-       return r;
-}
-
-result
-_ChannelService::SendRequest(const String& src,
-                                                        const String& dest,
-                                                        const ArrayList& args,
-                                                        int requestId)
-{
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
-
-       _ChannelInfo* pChannelInfo = null;
-
-       __channels.GetValue(dest, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo != null, E_OBJ_NOT_FOUND,
-                               "Destination channel is not found.");
-
-       // Channel for WebApp
-       if (pChannelInfo->type == WEBAPP_CHANNEL)
-       {
-               bool ret = _ChannelWebAppStub::SendResponse(pChannelInfo->clientId, args);
-               SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to send the data to a WebApp.");
-       }
-       // Channel for OspApp
-       else
-       {
-               result r = __pIChannelServiceStub->SendRequest(pChannelInfo->clientId, src, dest, args, requestId);
-               SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to send the request data.");
-       }
-
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::SendNullRequest(const String& src,
-                                                        const String& dest,
-                                                        int requestId)
-{
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
-
-       _ChannelInfo* pChannelInfo = null;
-
-       __channels.GetValue(dest, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo != null, E_OBJ_NOT_FOUND,
-                               "Destination channel is not found.");
-
-       // Channel for WebApp
-       if (pChannelInfo->type == WEBAPP_CHANNEL)
-       {
-               SysLog(NID_IO, "WebApp Channel, the data are not JSON types");
-               return E_SYSTEM;
-       }
-       // Channel for OspApp
-       else
-       {
-               __pIChannelServiceStub->SendNullRequest(pChannelInfo->clientId, src, dest, requestId);
-       }
-
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::SendResponse(const String& src,
-                                                         const String& dest,
-                                                         const ArrayList& args,
-                                                         int requestId)
-{
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
-
-       _ChannelInfo* pChannelInfo = null;
-
-       __channels.GetValue(dest, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo != null, E_OBJ_NOT_FOUND,
-                               "Destination channel not found.");
-
-       // Channel for WebApp
-       if (pChannelInfo->type == WEBAPP_CHANNEL)
-       {
-               bool ret = _ChannelWebAppStub::SendResponse(pChannelInfo->clientId, args);
-               SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to send the data to a WebApp.");
-       }
-       // Channel for CApp
-       else if (pChannelInfo->type == CAPP_CHANNEL)
-       {
-               bool ret = _ChannelCAppStub::SendResponse(requestId, pChannelInfo->pGIOChannel, args);
-               SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to send the data to a CApp.");
-       }
-       // Channel for OspApp
-       else
-       {
-               result r = __pIChannelServiceStub->SendResponse(pChannelInfo->clientId, src, dest, args, requestId);
-               SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to send the response data");
-       }
-
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::SendNullResponse(const String& src,
-                                                         const String& dest,
-                                                         int requestId)
-{
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
-
-       _ChannelInfo* pChannelInfo = null;
-
-       __channels.GetValue(dest, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo != null, E_OBJ_NOT_FOUND,
-                               "Destination channel not found.");
-
-       // Channel for WebApp
-       if (pChannelInfo->type == WEBAPP_CHANNEL)
-       {
-               SysLog(NID_IO, "WebApp Channel, the data are not JSON types");
-               return E_SYSTEM;
-       }
-       // Channel for OspApp
-       else
-       {
-               __pIChannelServiceStub->SendNullResponse(pChannelInfo->clientId, src, dest, requestId);
-       }
-
-       return E_SUCCESS;
-}
-
-bool
-_ChannelService::IsChannelRegistered(const String& channelId)
-{
-       bool out = false;
-
-       __channels.ContainsKey(channelId, out);
-
-       return out;
-}
-
-}}
index f3605b7..fdf2b3f 100644 (file)
@@ -24,8 +24,6 @@
 #include <FBaseSysLog.h>
 #include "FIo_ChannelServiceManager.h"
 #include "FIo_ChannelServiceProxy.h"
-#include "FIo_ChannelServiceStub.h"
-#include "FIo_ChannelService.h"
 
 namespace Tizen { namespace Io
 {
diff --git a/src/io/FIo_ChannelServiceStub.cpp b/src/io/FIo_ChannelServiceStub.cpp
deleted file mode 100644 (file)
index f9abe4a..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-//
-// 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       FIo_ChannelServiceStub.cpp
- * @brief      This is the implementation file for the  _ChannelServiceStub class.
- *
- */
-
-#include <string>
-#include <vector>
-#include <iostream>
-#include <new>
-
-#include <FBaseSysLog.h>
-#include <FBaseRt_EventDispatcher.h>
-#include "FIo_IpcServer.h"
-#include "FIo_ChannelServiceStub.h"
-#include "FIo_ChannelMessages.h"
-#include "FIo_ChannelService.h"
-
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
-using namespace Tizen::Io;
-
-using namespace std;
-
-namespace Tizen { namespace Io
-{
-
-_ChannelServiceStub::_ChannelServiceStub(void)
-       : __pIpcServer(null)
-       , __pChannelService(null)
-{
-
-}
-
-_ChannelServiceStub::~_ChannelServiceStub(void)
-{
-       delete __pIpcServer;
-}
-
-result
-_ChannelServiceStub::Construct(void)
-{
-       SysAssertf(__pIpcServer == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
-       SysLog(NID_IO, "Constructed");
-
-       result r = E_SUCCESS;
-       _IpcServer* pIpcServer = null;
-
-       pIpcServer = new (std::nothrow) _IpcServer;
-       SysTryReturnResult(NID_IO, pIpcServer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       r = pIpcServer->Construct("osp.io.ipcserver.channelmanager", *this, false);
-       SysTryCatch(NID_IO, !IsFailed(r), , r, "[%s] Failed to create IPC server(ChannelService)", GetErrorMessage(r));
-
-       __pIpcServer = pIpcServer;
-
-       return E_SUCCESS;
-
-CATCH:
-       delete pIpcServer;
-
-       return r;
-}
-
-void
-_ChannelServiceStub::SetChannelService(_ChannelService& service)
-{
-       __pChannelService = &service;
-}
-
-bool
-_ChannelServiceStub::OnRegisterChannelMessage(const Tizen::Base::String& appId, int* pResult)
-{
-       SysAssertf(__pChannelService != null, "Channel service has not been initialized.\n");
-
-       int clientId = __pIpcServer->GetClientId();
-
-       *pResult = __pChannelService->RegisterChannel(appId, clientId);
-
-       return true;
-}
-
-bool
-_ChannelServiceStub::OnSendRequestMessage(const String& src,
-                                                                                 const String& dest,
-                                                                                 const ArrayList& args,
-                                                                                 int requestId,
-                                                                                 int* pResult)
-{
-       SysAssertf(__pChannelService != null, "Channel service has not been initialized.\n");
-
-       *pResult = __pChannelService->SendRequest(src, dest, args, requestId);
-
-       const_cast<ArrayList*>(&args)->RemoveAll(true);
-
-       return true;
-}
-
-bool
-_ChannelServiceStub::OnSendNullRequestMessage(const String& src,
-                                                                                 const String& dest,
-                                                                                 int requestId,
-                                                                                 int* pResult)
-{
-       SysAssertf(__pChannelService != null, "Channel service has not been initialized.\n");
-
-       *pResult = __pChannelService->SendNullRequest(src, dest, requestId);
-
-       return true;
-}
-
-bool
-_ChannelServiceStub::OnSendResponseMessage(const String& src,
-                                                                                  const String& dest,
-                                                                                  const ArrayList& args,
-                                                                                  int requestId,
-                                                                                  int* pResult)
-{
-       SysAssertf(__pChannelService != null, "Channel service has not been initialized.\n");
-
-       *pResult = __pChannelService->SendResponse(src, dest, args, requestId);
-
-       const_cast<ArrayList*>(&args)->RemoveAll(true);
-
-       return true;
-}
-
-bool
-_ChannelServiceStub::OnSendNullResponseMessage(const String& src,
-                                                                                  const String& dest,
-                                                                                  int requestId,
-                                                                                  int* pResult)
-{
-       SysAssertf(__pChannelService != null, "Channel service has not been initialized.\n");
-
-       *pResult = __pChannelService->SendNullResponse(src, dest, requestId);
-
-       return true;
-}
-
-result
-_ChannelServiceStub::SendRequest(int clientId, const String& src, const String& dest, const ArrayList& args, int requestId)
-{
-       SysAssertf(__pIpcServer != null, "Not yet constructed. Construct() should be called before use.\n");
-
-       return __pIpcServer->SendResponse(clientId, new ChannelServiceMsg_sendRequestAsync(src, dest, args, requestId));
-}
-
-result
-_ChannelServiceStub::SendNullRequest(int clientId, const String& src, const String& dest, int requestId)
-{
-       SysAssertf(__pIpcServer != null, "Not yet constructed. Construct() should be called before use.\n");
-
-       return __pIpcServer->SendResponse(clientId, new ChannelServiceMsg_sendNullRequestAsync(src, dest, requestId));
-}
-
-result
-_ChannelServiceStub::SendResponse(int clientId, const String& src, const String& dest, const ArrayList& args, int requestId)
-{
-       SysAssertf(__pIpcServer != null, "Not yet constructed. Construct() should be called before use.\n");
-
-       return __pIpcServer->SendResponse(clientId, new ChannelServiceMsg_sendResponseAsync(src, dest, args, requestId));
-}
-
-result
-_ChannelServiceStub::SendNullResponse(int clientId, const String& src, const String& dest, int requestId)
-{
-       SysAssertf(__pIpcServer != null, "Not yet constructed. Construct() should be called before use.\n");
-
-       return __pIpcServer->SendResponse(clientId, new ChannelServiceMsg_sendNullResponseAsync(src, dest, requestId));
-}
-
-void
-_ChannelServiceStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
-{
-       IPC_BEGIN_MESSAGE_MAP(_ChannelServiceStub, message)
-       IPC_MESSAGE_HANDLER_EX(ChannelServiceMsg_register, &server, OnRegisterChannelMessage)
-       IPC_MESSAGE_HANDLER_EX(ChannelServiceMsg_sendRequest, &server, OnSendRequestMessage)
-       IPC_MESSAGE_HANDLER_EX(ChannelServiceMsg_sendNullRequest, &server, OnSendNullRequestMessage)
-       IPC_MESSAGE_HANDLER_EX(ChannelServiceMsg_sendResponse, &server, OnSendResponseMessage)
-       IPC_MESSAGE_HANDLER_EX(ChannelServiceMsg_sendNullResponse, &server, OnSendNullResponseMessage)
-       IPC_END_MESSAGE_MAP_EX()
-}
-
-void
-_ChannelServiceStub::OnIpcServerStarted(const _IpcServer& server)
-{
-
-}
-
-void
-_ChannelServiceStub::OnIpcServerStopped(const _IpcServer& server)
-{
-
-}
-
-void
-_ChannelServiceStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
-{
-
-}
-
-void
-_ChannelServiceStub::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
-{
-       SysAssertf(__pChannelService != null, "Channel service has not been initialized.\n");
-       SysLog(NID_IO, "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
-       __pChannelService->UnregisterChannel(clientId);
-       SysLog(NID_IO, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
-}
-
-}}
diff --git a/src/io/FIo_ChannelWebAppStub.cpp b/src/io/FIo_ChannelWebAppStub.cpp
deleted file mode 100644 (file)
index fe2fb6d..0000000
+++ /dev/null
@@ -1,1125 +0,0 @@
-//
-// 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       FIo_ChannelWebAppStub.cpp
- * @brief      This is the implementation file for the  _ChannelWebAppStub class.
- *
- */
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <cerrno>
-#include <iostream>
-#include <sstream>
-
-#include <unique_ptr.h>
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <errno.h>
-
-#include <openssl/md5.h>
-#include <openssl/sha.h>
-#include <openssl/bio.h>
-#include <openssl/evp.h>
-#include <openssl/buffer.h>
-
-#include <FBase_StringConverter.h>
-#include <FBaseDataType.h>
-#include <FBaseLong.h>
-#include <FBaseColArrayList.h>
-
-#include <FBaseRt_EventDispatcher.h>
-#include <FBaseSysLog.h>
-#include <FBaseUtilStringTokenizer.h>
-#include <FIo_ChannelServiceStub.h>
-#include <FApp_AppInfo.h>
-
-#include "FIo_ChannelWebAppStub.h"
-
-#define MAX_BUFFER_LENGTH 4096
-
-#define htonll(x)   ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32))
-#define ntohll(x)   ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32))
-
-using namespace std;
-
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
-using namespace Tizen::Base::Utility;
-using namespace Tizen::Io;
-using namespace Tizen::App;
-
-namespace Tizen { namespace Io
-{
-
-static const size_t _MAX_CONNECTIONS = 10;
-static const size_t _MAX_BUFFER_SIZE = 1024;
-static const int _PORT = 8080;
-
-//static const char* webSocketServerAddr = "127.0.0.1";
-static const char* webSocketHeaderId("Upgrade"); // web socket header identifier
-static const char* webSocketHeaderKey("Sec-WebSocket-Key"); // hybi10
-static const char* webSocketHeaderKey1("Sec-WebSocket-Key1"); // hybi00
-static const char* webSocketHeaderKey2("Sec-WebSocket-Key2"); // hybi00
-static const char* webSocketHeaderIdHybi10("websocket");
-static const char* webSocketHeaderIdHybi00("WebSocket");
-static const char* webSocketMagicString("258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
-
-static const int _CHALLENGE_NUMBER_SIZE = 4;
-static const int _CHALLENGE_THIRD_INFO_SIZE = 8;
-static const int _CHALLENGE_RESPONSE_SIZE = 16;
-
-const unsigned char _SIMPLE_PAYLOAD_MAX_LEN = 125;
-const unsigned char _EXTEND_PAYLOAD_TYPE_LEN16 = 0x7e; //126
-const unsigned char _EXTEND_PAYLOAD_TYPE_LEN64 = 0x7f; //127
-
-WebSocketType gHeaderType = WS_NONE;
-
-enum WebSocketOpcode
-{
-       OPCODE_CONTINUE = 0x0,
-       OPCODE_TEXT_MESSAGE = 0x1,
-       OPCODE_BIN_MESSAGE = 0x2,
-       OPCODE_CONNECTION_CLOSE = 0x8,
-       OPCODE_PING = 0x9,
-       OPCODE_PONG = 0xA
-};
-
-
-_ChannelWebAppStub::_WebSocketMessage::_WebSocketMessage(void)
-       : m_payloadOffset(0)
-       , m_payloadLen(0)
-       , m_headerParsed(false)
-       , m_payload(null)
-{
-}
-
-_ChannelWebAppStub::_WebSocketMessage::~_WebSocketMessage(void)
-{
-       delete[] m_payload;
-}
-
-size_t
-_ChannelWebAppStub::_WebSocketMessage::CreateMessage(std::string& payload, std::string& message)
-{
-       message.clear();
-       uint8_t *pCurrent = reinterpret_cast<uint8_t*>(const_cast<char *>(message.c_str()));
-       uint8_t *pStart = pCurrent;
-
-       // fin: 1 , opcode: 1
-       *pCurrent |= 0x81;
-       pCurrent++;
-       // masked : 0 (no mask)
-       *pCurrent &= 0x00;
-
-       // set payload len
-       if (payload.size() > _SIMPLE_PAYLOAD_MAX_LEN)
-       {
-               if (payload.size() < 64 * 1024)
-               {
-                       *pCurrent |= _EXTEND_PAYLOAD_TYPE_LEN16;
-                       pCurrent++;
-                       uint16_t length = payload.size();
-
-                       // Change the byte order
-                       length = htons(length);
-
-                       memcpy(pCurrent, &length, 2);
-                       pCurrent = pCurrent + 2;
-               }
-               else
-               {
-                       *pCurrent |= _EXTEND_PAYLOAD_TYPE_LEN64;
-                       pCurrent++;
-                       uint64_t length = payload.size();
-
-                       // Change the byte order
-                       length = htonll(length);
-
-                       memcpy(pCurrent, &length, 8);
-                       pCurrent = pCurrent + 8;
-               }
-       }
-       else
-       {
-               *pCurrent |= payload.size();
-               pCurrent++;
-       }
-
-       memcpy(pCurrent, payload.c_str(), payload.size());
-       pCurrent = pCurrent + payload.size();
-       //*pCurrent = '\0';
-       //pCurrent++;
-
-       return pCurrent - pStart;
-}
-
-int
-_ChannelWebAppStub::_WebSocketMessage::ParseHeader(uint8_t* message, int messageLen)
-{
-       SysTryLogReturn(NID_IO, message != null, -1, "message is null");
-
-       SysLog(NID_IO, "message = %s, size = %d", message, messageLen);
-
-       uint8_t* pCurrent = message;
-
-       // check 'fin' bit
-       m_header.factors.fin = 0x1 & *pCurrent >> 7;
-       // check 'opcode' bit
-       m_header.factors.opcode = 0xf & *pCurrent;
-       pCurrent++;
-
-       // check 'masked' bit
-       m_header.factors.masked = 0x1 & *pCurrent >> 7;
-       // check 'payload' type bit
-       m_header.factors.payloadLen = 0x7f & *pCurrent;
-       pCurrent++;
-
-       // set payload length
-       m_payloadLen = 0;
-       if (m_header.factors.payloadLen == _EXTEND_PAYLOAD_TYPE_LEN16)
-       {
-               SysLog(NID_IO, "extended payload len 16");
-
-               uint16_t length = 0;
-               memcpy(&length, pCurrent, 2);
-
-               // Change the byte order
-               m_payloadLen = ntohs(length);
-
-               pCurrent = pCurrent + 2; // jump two byte
-       }
-       else if (m_header.factors.payloadLen == _EXTEND_PAYLOAD_TYPE_LEN64)
-       {
-               SysLog(NID_IO, "extended payload len 64");
-
-               uint64_t length = 0;
-               memcpy(&length, pCurrent, 8);
-
-               // Change the byte order
-               m_payloadLen = ntohll(length);
-
-               pCurrent = pCurrent + 8; // jump eight byte
-       }
-       else
-       {
-               SysLog(NID_IO, "default payload len");
-               m_payloadLen = m_header.factors.payloadLen;
-       }
-
-       SysLog(NID_IO, "m_payloadLen = %lld", m_payloadLen);
-
-       SysTryLogReturn(NID_IO, m_payloadLen <= (uint64_t)messageLen, -1, "header parsing error!");
-
-       // set masking-key
-       if (m_header.factors.masked == 1)
-       {
-               memcpy(m_maskingKey, pCurrent, 4);
-               pCurrent = pCurrent + 4; // jump four byte
-       }
-
-       m_payloadOffset = pCurrent - message;
-       m_headerParsed = true;
-
-       SysLog(NID_IO, "m_payloadOffset = %d", m_payloadOffset);
-
-       return 0;
-}
-
-int
-_ChannelWebAppStub::_WebSocketMessage::ParsePayload(uint8_t* message, int messageLen)
-{
-       SysTryLogReturn(NID_IO, message != null, -1, "message is null");
-
-       SysLog(NID_IO, "message = %s", message);
-
-       SysTryLogReturn(NID_IO, m_payloadLen <= (uint64_t)messageLen, -1, "payloadLen is invalid!");
-       SysTryLogReturn(NID_IO, m_headerParsed == true, -1, "header not existed!");
-
-       // set payload length
-       m_payload = new (std::nothrow) uint8_t[m_payloadLen + 1];
-       SysTryLogReturn(NID_IO, m_payload != null, -1, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
-       memcpy(m_payload, message + m_payloadOffset, m_payloadLen);
-
-       // apply masking key to payload
-       if (m_header.factors.masked == 1)
-       {
-               uint8_t *payload = m_payload;
-               for (uint64_t i = 0; i < m_payloadLen; i++)
-               {
-                       payload[i] ^= m_maskingKey[i % 4];
-               }
-               payload[m_payloadLen] = '\0';
-       }
-
-       return 0;
-}
-
-void
-_ChannelWebAppStub::_WebSocketMessage::ConsoleMessage(void) const
-{
-       SysLog(NID_IO, "fin: %d", static_cast<bool>(m_header.factors.fin));
-       SysLog(NID_IO, "masked: %d", static_cast<bool>(m_header.factors.masked));
-       SysLog(NID_IO, "opcode: %d", static_cast<uint8_t>(m_header.factors.opcode));
-       SysLog(NID_IO, "payload: %s", m_payload);
-       SysLog(NID_IO, "payload len: %d", m_payloadLen);
-}
-
-_ChannelWebAppStub::_ChannelInfo::_ChannelInfo(void)
-       : pClientInfo(null)
-       , pGIOChannel(null)
-       , pGSource(null)
-       , destroySource(true)
-{
-}
-
-_ChannelWebAppStub::_ChannelInfo::~_ChannelInfo(void)
-{
-       if (pGIOChannel != null)
-       {
-               g_io_channel_unref(pGIOChannel);
-       }
-
-       if (pGSource != null)
-       {
-               if (destroySource)
-               {
-                       g_source_destroy(pGSource);
-               }
-
-               g_source_unref(pGSource);
-       }
-}
-
-_ChannelWebAppStub::_ClientInfo::_ClientInfo(void)
-       : pChannelStub(null)
-{
-}
-
-_ChannelWebAppStub::_ClientInfo::~_ClientInfo(void)
-{
-       channels.clear();
-}
-
-_ChannelWebAppStub::_ChannelWebAppStub(void)
-       : __pChannelService(null)
-       , __pGMainContext(null)
-       , __pServerGSource(null)
-       , __pClientGSource(null)
-       , __pClients(null)
-{
-}
-
-_ChannelWebAppStub::~_ChannelWebAppStub(void)
-{
-       if (__pServerGSource != null)
-       {
-               g_source_destroy(__pServerGSource);
-               g_source_unref(__pServerGSource);
-               __pServerGSource = null;
-       }
-}
-
-result
-_ChannelWebAppStub::Construct(void)
-{
-       GSource* pGSource = null;
-       GIOChannel* pGIOChannel = null;
-       struct sockaddr_in socketInfo;
-       int serverSocket = -1;
-       int ret = 0;
-       result r = E_SUCCESS;
-
-       __pClients = new (std::nothrow) HashMap();
-       SysTryReturnResult(NID_IO, __pClients != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-       __pClients->Construct(50);
-
-       __pGMainContext = g_main_context_get_thread_default(); //get own gmain context except default thread
-       if (__pGMainContext == null)
-       {
-               __pGMainContext = g_main_context_default(); //get gmain context from me (default)
-               SysTryReturnResult(NID_IO, __pGMainContext != null, E_SYSTEM,
-                               "Failed to get glib context.");
-       }
-
-       // create native socket
-       // set non-blocking socket mode
-       serverSocket = socket(AF_INET,
-                     SOCK_STREAM | SOCK_NONBLOCK,
-                     IPPROTO_TCP);
-
-       SysTryReturnResult(NID_IO, serverSocket != -1, E_SYSTEM,
-                       "Failed to create a socket.");
-
-       int reuse = 1;
-       ret = setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse));
-       SysTryCatch(NID_IO, ret != -1, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to set options on socket(%d, %s): %d", serverSocket, strerror(errno), errno);
-
-       // create native socket of server
-       memset(&socketInfo, 0, sizeof(socketInfo));
-       socketInfo.sin_family = AF_INET;
-       //socketInfo.sin_addr.s_addr = inet_addr(webSocketServerAddr);
-       //socketInfo.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-       socketInfo.sin_addr.s_addr = htonl(INADDR_ANY);
-       socketInfo.sin_port = htons(_PORT);
-
-       // bind local address
-       ret = bind(serverSocket,
-                       (const struct sockaddr*) &socketInfo,
-                       sizeof(struct sockaddr_in));
-       SysTryCatch(NID_IO, ret != -1, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to bind a socket(%d, %s): %d", serverSocket, strerror(errno), errno);
-
-       listen(serverSocket, _MAX_CONNECTIONS);
-
-       pGIOChannel = g_io_channel_unix_new(serverSocket);
-       SysTryCatch(NID_IO, pGIOChannel != null, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to create GIOChannel for socket.");
-
-       // socket will be closed when pGIOChannel is deleted.
-       g_io_channel_set_close_on_unref(pGIOChannel, TRUE);
-       serverSocket = -1;
-
-       pGSource = g_io_create_watch(pGIOChannel, (GIOCondition)(G_IO_IN | G_IO_ERR | G_IO_NVAL | G_IO_HUP));
-       SysTryCatch(NID_IO, pGSource != null, r = E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] Failed to create GSource for socket.");
-
-       // channel will be delete when pGSource is deleted.
-       g_io_channel_unref(pGIOChannel);
-       pGIOChannel = null;
-
-       g_source_set_callback(pGSource, (GSourceFunc) OnConnectionRequest, this, NULL);
-       g_source_attach(pGSource, __pGMainContext);
-
-       __pServerGSource = pGSource;
-
-       return E_SUCCESS;
-
-CATCH:
-       if (pGIOChannel != null)
-       {
-               g_io_channel_unref(pGIOChannel);
-       }
-
-       if (serverSocket != -1)
-       {
-               close(serverSocket);
-       }
-
-       if (__pGMainContext)
-       {
-               g_main_context_unref(__pGMainContext);
-               __pGMainContext = null;
-       }
-
-       return r;
-}
-
-void
-_ChannelWebAppStub::SetChannelService(_ChannelService& service)
-{
-       __pChannelService = &service;
-}
-
-gboolean
-_ChannelWebAppStub::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpointer data)
-{
-       int serverFd = -1;
-       int clientFd = -1;
-       struct sockaddr_in socketInfo;
-       socklen_t socketInfoLength = sizeof(socketInfo);
-       GSource* pGSource = null;
-       GIOChannel* pGIOChannel = null;
-       GError* pGError = null;
-       _ClientInfo* pClientInfo = null;
-       _ChannelInfo* pChannelInfo = null;
-       WebSocketType headerType;
-       SoupMessageHeaders* pSoupHeader = null;
-       int len = -1;
-       bool out = false;
-
-       AppId srcAppId;
-       AppId destAppId;
-       String key;
-
-       _ChannelWebAppStub* pChannelStub = static_cast< _ChannelWebAppStub* >(data);
-       SysTryReturn(NID_IO, pChannelStub != null, FALSE, E_SYSTEM,
-                       "[E_SYSTEM] pChannelStub is null.");
-
-       serverFd = g_io_channel_unix_get_fd(source);
-
-       clientFd = accept(serverFd,
-                                       (struct sockaddr*) &socketInfo,
-                                       &socketInfoLength);
-       SysTryReturn(NID_IO, clientFd != -1, FALSE, E_SYSTEM, "[E_SYSTEM] Failed to accept.");
-
-       // Get a http header
-       std::string headerData;
-       char header[_MAX_BUFFER_SIZE + 1] = {0,};
-       int headerLength = recv(clientFd, (char*)(header), _MAX_BUFFER_SIZE, 0);
-       if (headerLength < 0)
-       {
-               SysLog(NID_IO, "errno = %d %s", errno, strerror(errno));
-               SysLog(NID_IO, "headerLength = %d", headerLength);
-               SysLog(NID_IO, "Recv header = %s", header);
-
-               SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to recv, header length is less than 0.");
-               goto CATCH;
-       }
-
-       SysLog(NID_IO, "recv - header length = %d", headerLength);
-       SysLog(NID_IO, "recv - header data = %s", header);
-
-       pGIOChannel = g_io_channel_unix_new(clientFd);
-       SysTryCatch(NID_IO, pGIOChannel != null, , E_SYSTEM,    "[E_SYSTEM] Failed to create GIOChannel.");
-
-       g_io_channel_set_encoding(pGIOChannel, NULL, &pGError);
-       g_io_channel_set_flags(pGIOChannel, G_IO_FLAG_NONBLOCK, &pGError);
-
-       g_io_channel_set_close_on_unref(pGIOChannel, TRUE);
-       //clientFd = -1;
-
-       // Handshake with WebApp
-       // check if header of app socket is not for websocket
-       headerData = header;
-       headerType = VerifyHttpHeaderType(headerData, headerLength);
-
-       SysLog(NID_IO, "VerifyHttpHeader, type = %d", headerType);
-
-       if (headerType == WS_NONE)
-       {
-               SysLog(NID_IO, "Unpermitted header type");
-               close(clientFd);
-       }
-
-       // Set the header type
-       gHeaderType = headerType;
-
-
-       // create soup header
-       pSoupHeader = soup_message_headers_new(SOUP_MESSAGE_HEADERS_REQUEST);
-       //soup_headers_parse(header.c_str(), headerLength, pSoupHeader);
-       soup_headers_parse(header, headerLength, pSoupHeader);
-
-       if (headerType == WS_HYBI00)
-       {
-               SysLog(NID_IO, "WS_HYBI00");
-
-               // get third information from http header
-               unsigned int firstInfo = ExtractChallengeNumber(
-                               soup_message_headers_get_one(pSoupHeader, webSocketHeaderKey1));
-               unsigned int secondInfo = ExtractChallengeNumber(
-                               soup_message_headers_get_one(pSoupHeader, webSocketHeaderKey2));
-               unsigned char thirdInfo[8];
-               //char *pThirdInfoPos = const_cast<char*>(header.c_str()) + headerLength - _CHALLENGE_THIRD_INFO_SIZE;
-               char *pThirdInfoPos = const_cast<char*>(header) + headerLength - _CHALLENGE_THIRD_INFO_SIZE;
-               memcpy(thirdInfo, reinterpret_cast<unsigned char*>(pThirdInfoPos), _CHALLENGE_THIRD_INFO_SIZE);
-
-               // make challenge response data for hybi00
-               const std::string response = MakeHybi00Response(firstInfo, secondInfo, thirdInfo);
-               // create response header to be sent to app
-               std::string responseHeader = CreateResponseHeader(clientFd, pSoupHeader, response);
-               // send response header
-               len = send(clientFd, responseHeader.c_str(), responseHeader.size(), 0);
-
-       }
-       else if (headerType == WS_HYBI10)
-       {
-               SysLog(NID_IO, "WS_HYBI10");
-
-               const char* pSecureKeyValue = soup_message_headers_get_one(
-                               pSoupHeader, webSocketHeaderKey);
-
-               std::string secureKey(pSecureKeyValue);
-               secureKey.append(webSocketMagicString);
-
-               // make Sec-WebSocket-Accept data for hybi10
-               const std::string response = MakeHybi10Response(secureKey);
-
-               // create response header to be sent to app
-               std::string responseHeader = CreateResponseHeader(clientFd, pSoupHeader, response);
-
-               // send response header
-               SysLog(NID_IO, "Send responseHeader = %s", responseHeader.c_str());
-               len = send(clientFd, responseHeader.c_str(), responseHeader.size(), 0);
-               if (len < 1)
-               {
-                       SysLog(NID_IO, "errno = %d %s", errno, strerror(errno));
-                       SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send responseHeader, length is less than 1.");
-                       goto CATCH;
-               }
-       }
-       else
-       {
-               SysLog(NID_IO, "ELSE");
-       }
-
-       if (len == -1)
-       {
-               SysLog(NID_IO, "Failed to send responseHeader");
-               SysLog(NID_IO, "errno = %d %s", errno, strerror(errno));
-               close(clientFd);
-               return false;
-       }
-
-       // Parse and set appId for WebApp
-       {
-               String tempStr;
-               String headerString(header);
-
-               // header = "GET /ipc?src=abcde1234.WebApp&dest=4z6olle215.Dictionary HTTP/1.1^M"
-               StringTokenizer st(headerString, L" /?=&");
-               st.GetNextToken(tempStr); // GET
-               st.GetNextToken(tempStr); // ipc
-               st.GetNextToken(tempStr); // src
-               st.GetNextToken(srcAppId);
-               st.GetNextToken(tempStr); // dest
-               st.GetNextToken(destAppId);
-       }
-
-       // Check the destAppId
-       out = pChannelStub->__pChannelService->IsChannelRegistered(destAppId);
-       SysTryCatch(NID_IO, out, , E_SYSTEM, "[E_SYSTEM] Destination channel is not found.");
-
-       // Set a ClientInfo
-       key = srcAppId;
-       pChannelStub->__pClients->ContainsKey(key, out);
-       if (!out) // first connection request from this client
-       {
-               SysLog(NID_IO, "First Connection of WebApp - AppId = %ls", srcAppId.GetPointer());
-
-               pClientInfo = new (std::nothrow) _ClientInfo();
-
-               pClientInfo->srcAppId = srcAppId;
-               //pClientInfo->srcAppExecName = srcAppExecName;
-               pClientInfo->pChannelStub = pChannelStub;
-               //pClientInfo->clientId = clientFd;
-               pClientInfo->key = key;
-
-               pChannelStub->__pClients->Add(*(new String(key)), *pClientInfo);
-
-               // Stores client info to _ChannelService
-               SysLog(NID_IO, "Register Channel for WebApp");
-
-               pChannelStub->__pChannelService->RegisterChannel(srcAppId, clientFd, WEBAPP_CHANNEL);
-       }
-
-       SysLog(NID_IO, "srcAppId = %ls, destAppId = %ls", srcAppId.GetPointer(), destAppId.GetPointer());
-
-       // Set the callbak
-       pChannelInfo = new (std::nothrow) _ChannelInfo;
-       SysTryCatch(NID_IO, pChannelInfo != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
-       pGSource = g_io_create_watch(pGIOChannel, (GIOCondition) (G_IO_IN | G_IO_ERR | G_IO_NVAL | G_IO_HUP));
-
-       g_source_set_callback(pGSource, (GSourceFunc) OnReadMessage, pChannelInfo, NULL);
-       g_source_attach(pGSource, ((_ChannelWebAppStub*)data)->__pGMainContext);
-
-       pChannelStub->__pClientGSource = pGSource;
-
-
-       // Set a ChannelInfo
-       pChannelInfo->pClientInfo = pClientInfo;
-       pChannelInfo->pGIOChannel = pGIOChannel;
-       pChannelInfo->pGSource = pGSource;
-       pChannelInfo->destAppId = destAppId;
-
-       pClientInfo->channels.push_back(pChannelInfo);
-
-
-       return true;
-
-CATCH:
-       if (pGIOChannel != null)
-       {
-               g_io_channel_unref(pGIOChannel);
-       }
-
-       if (clientFd != -1)
-       {
-               close(clientFd);
-       }
-
-       return true;
-}
-
-gboolean
-_ChannelWebAppStub::OnReadMessage(GIOChannel* source, GIOCondition condition, gpointer data)
-{
-       SysLog(NID_IO, "Callback");
-
-       gboolean ret = FALSE;
-
-       _ChannelInfo* pChannelInfo = (_ChannelInfo*) data;
-       _ClientInfo* pClientInfo = pChannelInfo->pClientInfo;
-       _ChannelWebAppStub* pChannelStub = (_ChannelWebAppStub*) pClientInfo->pChannelStub;
-       ret = pChannelStub->HandleReceivedMessage(source, condition, data);
-
-       return ret;
-}
-
-gboolean
-_ChannelWebAppStub::HandleReceivedMessage(GIOChannel* source, GIOCondition condition, gpointer data)
-{
-       result r = E_SUCCESS;
-       GError* pGError = null;
-       int clientFd = g_io_channel_unix_get_fd(source);
-
-       SysLog(NID_IO, "HandleMessage - client = %d", clientFd);
-
-       _ChannelInfo* pChannelInfo = (_ChannelInfo*) data;
-       _ClientInfo* pClientInfo = pChannelInfo->pClientInfo;
-       _ChannelWebAppStub* pChannelStub = (_ChannelWebAppStub*) pClientInfo->pChannelStub;
-
-       if (condition & G_IO_HUP)
-       {
-               SysLog(NID_IO, "G_IO_HUP - connection closed");
-
-               g_io_channel_shutdown(source, FALSE, &pGError);
-
-               for (unsigned int i = 0; i < pClientInfo->channels.size(); i++)
-               {
-                       if (pChannelInfo == pClientInfo->channels[i])
-                       {
-                               pClientInfo->channels.erase(pClientInfo->channels.begin() + i);
-
-                               // Do not destroy a source in a dispatch callback
-                               // because main loop will do it if the callback return FALSE.
-                               pChannelInfo->destroySource = false;
-                               delete pChannelInfo;
-
-                               break;
-                       }
-               }
-
-               if (pClientInfo->channels.size() == 0)
-               {
-                       SysLog(NID_IO, "All connections of client(%ls) are closed. delete client info", pClientInfo->srcAppId.GetPointer());
-
-                       String key = pClientInfo->srcAppId;
-                       __pClients->Remove(key, false);
-
-                       delete pClientInfo;
-
-                       pChannelStub->__pChannelService->UnregisterChannel(clientFd);
-               }
-
-               return FALSE;
-       }
-       else if (condition & G_IO_IN)
-       {
-               SysLog(NID_IO, "G_IO_IN");
-
-               unique_ptr<char[]> pBuffer(new char[MAX_BUFFER_LENGTH]);
-               int len = recv(clientFd, (char *)pBuffer.get(), MAX_BUFFER_LENGTH, 0);
-               if (len < 0)
-               {
-                       SysLog(NID_IO, "recv error: errno = %d %s", errno, strerror(errno));
-                       SysLog(NID_IO, "headerLength = %d", len);
-                       SysLog(NID_IO, "Recv header = %s", pBuffer.get());
-
-                       SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to recv, length is less than 0.");
-
-                       return FALSE;
-               }
-               else if (len == 0)
-               {
-                       SysLog(NID_IO, "The peer has performed an orderly shutdown, recv = %d", len);
-
-                       g_io_channel_shutdown(source, FALSE, &pGError);
-
-                       for (unsigned int i = 0; i < pClientInfo->channels.size(); i++)
-                       {
-                               if (pChannelInfo == pClientInfo->channels[i])
-                               {
-                                       pClientInfo->channels.erase(pClientInfo->channels.begin() + i);
-
-                                       // Do not destroy a source in a dispatch callback
-                                       // because main loop will do it if the callback return FALSE.
-                                       pChannelInfo->destroySource = false;
-                                       delete pChannelInfo;
-
-                                       break;
-                               }
-                       }
-
-                       if (pClientInfo->channels.size() == 0)
-                       {
-                               SysLog(NID_IO, "All connections of client(%ls) are closed. delete client info", pClientInfo->srcAppId.GetPointer());
-
-                               String key = pClientInfo->srcAppId;
-                               __pClients->Remove(key, false);
-
-                               delete pClientInfo;
-
-                               pChannelStub->__pChannelService->UnregisterChannel(clientFd);
-                       }
-
-                       return FALSE;
-               }
-
-               if (gHeaderType == WS_HYBI00)
-               {
-                       // Not supported because of old websocket protocol
-                       SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Not supported protocol.");
-
-                       return FALSE;
-               }
-               else if (gHeaderType == WS_HYBI10)
-               {
-                       SysLog(NID_IO,"WS_HYBI10 is supported, received data: %s (%d)", pBuffer.get(), len);
-
-                       // Current webkit of tizen support
-                       _WebSocketMessage message;
-                       int ret = 0;
-                       ret = message.ParseHeader(reinterpret_cast<uint8_t*>(pBuffer.get()), len);
-                       SysTryReturn(NID_IO, ret >= 0, FALSE, E_SYSTEM, "[E_SYSTEM] Fail to parse the header!");
-
-                       ret = message.ParsePayload(reinterpret_cast<uint8_t*>(pBuffer.get()), len);
-                       SysTryReturn(NID_IO, ret >= 0, FALSE, E_SYSTEM, "[E_SYSTEM] Fail to parse the payload!");
-
-                       message.ConsoleMessage();
-
-                       // do something for opcode or custom protocol of payload
-                       if (message.m_header.factors.opcode == OPCODE_CONNECTION_CLOSE)
-                       {
-                               SysLog(NID_IO,"OPCODE_CONNECTION_CLOSE with clientFd: %d", clientFd);
-
-                               g_io_channel_shutdown(source, FALSE, &pGError);
-
-                               for (unsigned int i = 0; i < pClientInfo->channels.size(); i++)
-                               {
-                                       if (pChannelInfo == pClientInfo->channels[i])
-                                       {
-                                               pClientInfo->channels.erase(pClientInfo->channels.begin() + i);
-
-                                               // Do not destroy a source in a dispatch callback
-                                               // because main loop will do it if the callback return FALSE.
-                                               pChannelInfo->destroySource = false;
-                                               delete pChannelInfo;
-
-                                               break;
-                                       }
-                               }
-
-                               if (pClientInfo->channels.size() == 0)
-                               {
-                                       SysLog(NID_IO, "All connections of client(%ls) are closed. delete client info", pClientInfo->srcAppId.GetPointer());
-
-                                       String key = pClientInfo->srcAppId;
-                                       __pClients->Remove(key, false);
-
-                                       delete pClientInfo;
-
-                                       pChannelStub->__pChannelService->UnregisterChannel(clientFd);
-                               }
-
-                               return FALSE;
-                       }
-                       else if (message.m_header.factors.opcode == OPCODE_TEXT_MESSAGE)
-                       {
-                               // Parse the data
-                               RequestId reqId = 0;
-
-                               ArrayList list;
-                               list.Construct();
-
-                               list.Add(*(new String((char*)message.m_payload)));
-
-                               SysLog(NID_IO, "srcAppId = %ls, destAppId = %ls", pClientInfo->srcAppId.GetPointer(), pChannelInfo->destAppId.GetPointer());
-
-                               r = pChannelStub->__pChannelService->SendRequest(pClientInfo->srcAppId,
-                                               pChannelInfo->destAppId, list, reqId);
-                               SysTryReturn(NID_IO, !IsFailed(r), FALSE, E_SYSTEM, "[E_SYSTEM] Failed to send request.");
-
-                               list.RemoveAll(true);
-                       }
-                       else
-                       {
-                               // Not yet supported opcode
-                               SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Not supported Opcode.");
-
-                               return FALSE;
-                       }
-               }
-               else
-               {
-                       SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Not supported protocol.");
-
-                       return FALSE;
-               }
-
-       }
-       else
-       {
-               SysLog(NID_IO, "G_IO else");
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-WebSocketType
-_ChannelWebAppStub::VerifyHttpHeaderType(std::string header, int headerLength)
-{
-       // parse http header
-       SoupMessageHeaders* pSoupHeader =
-               soup_message_headers_new(SOUP_MESSAGE_HEADERS_REQUEST);
-       if (!soup_headers_parse(header.c_str(), headerLength, pSoupHeader))
-       {
-               return WS_NONE;
-       }
-
-       WebSocketType headerType;
-       const char* pHeaderValue =
-               soup_message_headers_get_one(pSoupHeader, webSocketHeaderId);
-
-       if (!pHeaderValue)
-       {
-               SysLog(NID_IO, "Not for web socket header.");
-               return WS_NONE;
-       }
-
-       if (strcmp(pHeaderValue, webSocketHeaderIdHybi00) == 0)
-       {
-               headerType = WS_HYBI00;
-       }
-       if (strcmp(pHeaderValue, webSocketHeaderIdHybi10) == 0)
-       {
-               headerType = WS_HYBI10;
-       }
-       else
-       {
-               headerType = WS_NONE;
-       }
-
-       return headerType;
-}
-
-std::string
-_ChannelWebAppStub::CreateResponseHeader(int appSocket, SoupMessageHeaders *header,
-               const std::string& response)
-{
-       std::string responseHeader;
-
-       //if (m_appSockets[appSocket] == WS_HYBI00) {
-       if (gHeaderType == WS_HYBI00)
-       {
-               responseHeader.append("HTTP/1.1 101 WebSocket Protocol Handshake\r\n");
-               responseHeader.append("Upgrade: WebSocket\r\n");
-               responseHeader.append("Connection: Upgrade\r\n");
-               responseHeader.append("Sec-WebSocket-Origin: ");
-               responseHeader.append(soup_message_headers_get_one(header, "Origin"));
-               responseHeader.append("\r\n");
-               responseHeader.append("Sec-WebSocket-Location: ws://");
-               responseHeader.append(soup_message_headers_get_one(header, "Host"));
-               responseHeader.append("\r\n");
-               responseHeader.append("\r\n");
-               responseHeader.append(response.c_str());
-               //} else if (m_appSockets[appSocket] == WS_HYBI10) {
-       }
-       else if (gHeaderType == WS_HYBI10)
-       {
-               responseHeader.append("HTTP/1.1 101 Switching Protocols\r\n");
-               responseHeader.append("Upgrade: websocket\r\n");
-               responseHeader.append("Connection: Upgrade\r\n");
-               responseHeader.append("Sec-WebSocket-Accept: ");
-               responseHeader.append(response.c_str());
-               responseHeader.append("\r\n");
-               responseHeader.append("\r\n");
-               // TODO Sec-WebSocket-Protocol support
-       }
-       else
-       {
-               responseHeader = std::string();
-       }
-
-       return responseHeader;
-}
-
-std::string
-_ChannelWebAppStub::MakeHybi00Response(uint32_t first, uint32_t second, uint8_t* third)
-{
-       SysAssertf(third != null, "The input parameter third should not be null.");
-
-       if (sizeof(third) != _CHALLENGE_NUMBER_SIZE)
-       {
-               SysLog(NID_IO, "Invalid third argument.");
-               return NULL;
-       }
-
-       bool result = false;
-       uint8_t temp[_CHALLENGE_RESPONSE_SIZE];
-       result = AppendChallengeNumber(first, &temp[0]);
-       if (!result)
-       {
-               SysLog(NID_IO, "Failed to set challenge number.");
-               return NULL;
-       }
-
-       result = AppendChallengeNumber(second, &temp[4]);
-       if (!result)
-       {
-               SysLog(NID_IO, "Failed to set challenge number.");
-               return NULL;
-       }
-
-       memcpy(temp + 8, third, _CHALLENGE_THIRD_INFO_SIZE);
-       SysLog(NID_IO,"Challenge Response before md5 : %s", reinterpret_cast<char *>(temp));
-
-       // set MD5 hash
-       unsigned char hash[16];
-       MD5((unsigned char*) temp, _CHALLENGE_RESPONSE_SIZE, hash);
-
-       return std::string(reinterpret_cast<const char*>(hash));
-}
-
-std::string
-_ChannelWebAppStub::MakeHybi10Response(std::string& secureAccept)
-{
-       if (secureAccept.empty())
-       {
-               SysLog(NID_IO, "Invalid argruments");
-               return NULL;
-       }
-
-       unsigned char hash[20];
-       SHA1(reinterpret_cast<const unsigned char*>(secureAccept.c_str()),
-                       secureAccept.size(),
-                       hash);
-
-       return std::string(EncodeBase64(hash, 20));
-}
-
-bool
-_ChannelWebAppStub::AppendChallengeNumber(uint32_t number, unsigned char *response)
-{
-       if (!response)
-       {
-               SysLog(NID_IO, "Invalid response string");
-               return false;
-       }
-
-       // by spec, challenge number should be added as big endian
-       unsigned char* pIdx = response + 3;
-       for (int i = 0; i < 4; i++)
-       {
-               *pIdx = 0xff & number;
-               pIdx--;
-               number >>= 8;
-       }
-
-       return true;
-}
-
-unsigned int
-_ChannelWebAppStub::ExtractChallengeNumber(const char* keyString)
-{
-       if (!keyString)
-       {
-               SysLog(NID_IO, "Invalid secure key");
-               return 0;
-       }
-
-       int space = 0;
-       std::string digits;
-       std::string secureKey(keyString);
-       std::string::iterator it;
-
-       for (it = secureKey.begin(); it < secureKey.end(); it++)
-       {
-               if (*it == ' ')
-               {
-                       space++;
-               }
-               else if ((*it >= '0') && (*it <= '9'))
-               {
-                       digits.insert(digits.end(), 1, *it);
-               }
-       }
-
-       std::istringstream stream(digits);
-       unsigned int numFromDigits = 0;
-       stream >> numFromDigits;
-
-       return space ? (numFromDigits / space) : numFromDigits;
-}
-
-char*
-_ChannelWebAppStub::EncodeBase64(unsigned char *string, int len)
-{
-       BIO* pBmem = null;
-       BIO* pB64 = null;
-       BUF_MEM* pBptr = null;
-
-       pB64 = BIO_new(BIO_f_base64());
-       pBmem = BIO_new(BIO_s_mem());
-       pB64 = BIO_push(pB64, pBmem);
-       BIO_write(pB64, string, len);
-       BIO_flush(pB64);
-       BIO_get_mem_ptr(pB64, &pBptr);
-
-       char* pBuff = (char *)malloc(pBptr->length);
-       SysTryLogReturn(NID_IO, pBuff != NULL, NULL, "The memory is insufficient.");
-       memcpy(pBuff, pBptr->data, pBptr->length-1);
-       pBuff[pBptr->length-1] = 0;
-
-       BIO_free_all(pB64);
-       return pBuff;
-}
-
-bool
-_ChannelWebAppStub::SendResponse(int clientId, const ArrayList& args)
-{
-       unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(*((String*)args.GetAt(0))));
-
-       SysLog(NID_IO, "clientId = %d, data = %s", clientId, pStr.get());
-
-       string response;
-       string payload(pStr.get());
-
-       int respSize = _WebSocketMessage::CreateMessage(payload, response);
-       int ret = send(clientId, response.c_str(), respSize, 0);
-       SysTryLogReturn(NID_IO, ret >= 1, false, "Failed to send data. Length is less than 1. errno = %d %s", errno, strerror(errno));
-
-       SysLog(NID_IO, "response = %s, size = %d", response.c_str(), ret);
-
-       _WebSocketMessage message;
-       ret = message.ParseHeader(reinterpret_cast<uint8_t*>(const_cast<char*>(response.c_str())), respSize);
-       SysTryLogReturn(NID_IO, ret >= 0, false, "ParseHeader error!");
-
-       ret = message.ParsePayload(reinterpret_cast<uint8_t*>(const_cast<char*>(response.c_str())), respSize);
-       SysTryLogReturn(NID_IO, ret >= 0, false, "ParsePayloadr error!");
-
-       message.ConsoleMessage();
-
-       return true;
-}
-
-}}
-
index ea28465..a4d8588 100644 (file)
@@ -57,12 +57,7 @@ _ClientChannelImpl::~_ClientChannelImpl(void)
 result
 _ClientChannelImpl::Construct(ClientChannel* pClientChannel, const Tizen::Base::String& channelName)
 {
-       const String& appId = _AppInfo::GetAppId();
-       const String& appExecutableName = _AppInfo::GetAppExecutableName();
-
-       String channelId(appId);
-       channelId.Append(L'.');
-       channelId.Append(appExecutableName);
+       String channelId(_AppInfo::GetApplicationId());
 
        if (!channelName.IsEmpty())
        {
index 5421f05..0d4b883 100644 (file)
@@ -435,7 +435,6 @@ _DataControlResultSetEnumerator::GetStringAt(int columnIndex, String& value) con
        int type = -1;
        int size = 0;
        int i = 0;
-       String retString;
        result r = E_SUCCESS;
        int ret = 0;
 
@@ -486,14 +485,17 @@ _DataControlResultSetEnumerator::GetStringAt(int columnIndex, String& value) con
        ret = pFile->Read(&size, sizeof(int));
        SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
 
-       unique_ptr<char[]> pReadBuffer(new (std::nothrow) char[size + 1]);
-       SysTryReturnResult(NID_IO, pReadBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory for the read buffer.");
+       if (size > 0)
+       {
+               unique_ptr<char[]> pReadBuffer(new (std::nothrow) char[size + 1]);
+               SysTryReturnResult(NID_IO, pReadBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory for the read buffer.");
 
-       memset(pReadBuffer.get(), 0, size + 1);
-       ret = pFile->Read(pReadBuffer.get(), size);
-       SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
+               memset(pReadBuffer.get(), 0, size + 1);
 
-       value = String(pReadBuffer.get());
+               ret = pFile->Read(pReadBuffer.get(), size);
+               SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
+               value = String(pReadBuffer.get());
+       }
 
        return E_SUCCESS;
 }
@@ -504,7 +506,6 @@ _DataControlResultSetEnumerator::GetBlobAt(int columnIndex, ByteBuffer& value) c
        int type = -1;
        int size = 0;
        int i = 0;
-       String retString;
        result r = E_SUCCESS;
        int ret = 0;
 
@@ -554,15 +555,18 @@ _DataControlResultSetEnumerator::GetBlobAt(int columnIndex, ByteBuffer& value) c
        ret = pFile->Read(&size, sizeof(int));
        SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
 
-       unique_ptr<byte[]> pReadBuffer(new (std::nothrow) byte[size + 1]);
-       SysTryReturnResult(NID_IO, pReadBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory for the read buffer.");
+       if (size > 0)
+       {
+               unique_ptr<byte[]> pReadBuffer(new (std::nothrow) byte[size + 1]);
+               SysTryReturnResult(NID_IO, pReadBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory for the read buffer.");
 
-       memset(pReadBuffer.get(), 0, size + 1);
-       ret = pFile->Read(pReadBuffer.get(), size);
-       SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
+               memset(pReadBuffer.get(), 0, size + 1);
+               ret = pFile->Read(pReadBuffer.get(), size);
+               SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
 
-       r = value.SetArray(pReadBuffer.get(), 0, size);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+               r = value.SetArray(pReadBuffer.get(), 0, size);
+               SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+       }
 
        return E_SUCCESS;
 }
@@ -573,7 +577,6 @@ _DataControlResultSetEnumerator::GetBlobAt(int columnIndex, void* buffer, int bu
        int type = -1;
        int size = 0;
        int i = 0;
-       String retString;
        result r = E_SUCCESS;
        int ret = 0;
 
@@ -625,14 +628,17 @@ _DataControlResultSetEnumerator::GetBlobAt(int columnIndex, void* buffer, int bu
 
        SysTryReturnResult(NID_IO, size <= bufSize, E_OVERFLOW, "The output buffer is insufficient.");
 
-       unique_ptr<byte[]> pReadBuffer(new (std::nothrow) byte[size + 1]);
-       SysTryReturnResult(NID_IO, pReadBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory for the read buffer.");
+       if (size > 0)
+       {
+               unique_ptr<byte[]> pReadBuffer(new (std::nothrow) byte[size + 1]);
+               SysTryReturnResult(NID_IO, pReadBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory for the read buffer.");
 
-       memset(pReadBuffer.get(), 0, size + 1);
-       ret = pFile->Read(pReadBuffer.get(), size);
-       SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
+               memset(pReadBuffer.get(), 0, size + 1);
+               ret = pFile->Read(pReadBuffer.get(), size);
+               SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to read data from the result set of the data control provider.");
 
-       memcpy(buffer, pReadBuffer.get(), size);
+               memcpy(buffer, pReadBuffer.get(), size);
+       }
 
        return E_SUCCESS;
 }
@@ -644,7 +650,6 @@ _DataControlResultSetEnumerator::GetDateTimeAt(int columnIndex, DateTime& value)
        int size = 0;
        char* pReadBuffer = null;
        int i = 0;
-       String retString;
        result r = E_SUCCESS;
        int ret = 0;
 
@@ -699,22 +704,25 @@ _DataControlResultSetEnumerator::GetDateTimeAt(int columnIndex, DateTime& value)
                SysTryReturn(NID_IO, false, E_SYSTEM, E_SYSTEM, "[%s] system error", GetErrorMessage(r));
        }
 
-       pReadBuffer = (char*) malloc(size + 1);
-       SysTryReturn(NID_IO, pReadBuffer != NULL, E_SYSTEM, E_SYSTEM, "[E_OUT_OF_MEMORY] system error occurred.");
-       memset(pReadBuffer, 0, size + 1);
-
-       ret = pFile->Read(pReadBuffer, size);
-       if (ret == 0)
+       if (size > 0)
        {
-               r = GetLastResult();
+               pReadBuffer = (char*) malloc(size + 1);
+               SysTryReturn(NID_IO, pReadBuffer != NULL, E_SYSTEM, E_SYSTEM, "[E_OUT_OF_MEMORY] system error occurred.");
+               memset(pReadBuffer, 0, size + 1);
+
+               ret = pFile->Read(pReadBuffer, size);
+               if (ret == 0)
+               {
+                       r = GetLastResult();
+                       free(pReadBuffer);
+                       SysTryReturnResult(NID_IO, !(r == E_END_OF_FILE), E_INVALID_ARG, "columnIndex is out of range");
+                       SysTryReturn(NID_IO, false, E_SYSTEM, E_SYSTEM, "[%s] system error", GetErrorMessage(r));
+               }
+
+               r = DateTime::Parse(pReadBuffer, value);
                free(pReadBuffer);
-               SysTryReturnResult(NID_IO, !(r == E_END_OF_FILE), E_INVALID_ARG, "columnIndex is out of range");
-               SysTryReturn(NID_IO, false, E_SYSTEM, E_SYSTEM, "[%s] system error", GetErrorMessage(r));
        }
 
-       r = DateTime::Parse(pReadBuffer, value);
-       free(pReadBuffer);
-
        return r;
 }
 
@@ -736,6 +744,8 @@ _DataControlResultSetEnumerator::GetColumnType(int columnIndex) const
 {
        DbColumnType columnType = DB_COLUMNTYPE_UNDEFINED;
        int type = -1;
+       int i = 0;
+       int size = 0;
        result r = E_SUCCESS;
        int ret = 0;
 
@@ -753,17 +763,37 @@ _DataControlResultSetEnumerator::GetColumnType(int columnIndex) const
        SysTryReturn(NID_IO, pFile != null, columnType, E_INVALID_STATE,
                                "[E_INVALID_STATE] This instance has not been properly constructed yet or has already been finalized.");
 
-       r = pFile->Seek(FILESEEKPOSITION_BEGIN, __columnTypeOffset + columnIndex * sizeof(int));
-       SysTryReturn(NID_IO, !IsFailed(r), columnType, E_SYSTEM, "Failed to seek.");
+       r = pFile->Seek(FILESEEKPOSITION_BEGIN, __currentOffset);
+       SysTryReturn(NID_IO, !IsFailed(r), columnType, E_SYSTEM, "[E_SYSTEM] Failed to seek.");
+
+       for (i = 0; i < columnIndex; i++) // move to column index
+       {
+               ret = pFile->Read(&type, sizeof(int));
+               if (ret == 0)
+               {
+                       r = GetLastResult();
+                       SysTryReturn(NID_IO, !(r == E_END_OF_FILE), columnType, E_INVALID_ARG, "[E_INVALID_ARG] The columnIndex is out of range.");
+                       SysTryReturn(NID_IO, false, columnType, E_SYSTEM, "[%s] system error", GetErrorMessage(r));
+               }
+               ret = pFile->Read(&size, sizeof(int));
+               SysTryReturn(NID_IO, ret, columnType, E_SYSTEM, "[E_SYSTEM] Failed to read data from the result set of the data control provider.");
+
+               r = pFile->Seek(FILESEEKPOSITION_CURRENT, size);
+               SysTryReturn(NID_IO, !IsFailed(r), columnType, E_SYSTEM, "[E_SYSTEM] Failed to seek.");
+       }
+
        ret = pFile->Read(&type, sizeof(int));
        if (ret == 0)
        {
                r = GetLastResult();
                SysTryReturn(NID_IO, !(r == E_END_OF_FILE), DB_COLUMNTYPE_UNDEFINED, E_INVALID_ARG,
                                        "[E_INVALID_ARG] columnIndex is out of range");
-               SysTryReturn(NID_IO, false, DB_COLUMNTYPE_UNDEFINED, E_SYSTEM, "[%s] system error, errno: %d", GetErrorMessage(r), errno);
+               SysTryReturn(NID_IO, false, DB_COLUMNTYPE_UNDEFINED, E_SYSTEM,
+                                       "[%s] system error, errno: %d", GetErrorMessage(r), errno);
        }
 
+       SetLastResult(E_SUCCESS);
+
        switch (type)
        {
        case 1: // int64
@@ -782,12 +812,15 @@ _DataControlResultSetEnumerator::GetColumnType(int columnIndex) const
                columnType = DB_COLUMNTYPE_BLOB;
                break;
 
+       case 5: // null
+               columnType = DB_COLUMNTYPE_NULL;
+               break;
+
        default:
-               SetLastResult(E_INVALID_STATE);
+               SysLogException(NID_IO, E_SYSTEM, "Found undefined column type (%d).", type);
                break;
        }
 
-       SetLastResult(E_SUCCESS);
        return columnType;
 }
 
index 33174ef..b6f7f26 100644 (file)
@@ -235,8 +235,14 @@ _DataControlResultSetImpl::FillWith(IDbEnumerator* pDbEnum)
                        break;
                }
 
+               case DB_COLUMNTYPE_NULL:
+               {
+                       type = 5; // null type
+                       break;
+               }
+
                default:
-                       SysLog(NID_IO, "type: UNDEFINDE (%d)", type);
+                       SysLog(NID_IO, "type: UNDEFINED (%d)", type);
                        break;
                }
                r = pFile->Write(&type, sizeof(int));
@@ -296,7 +302,6 @@ _DataControlResultSetImpl::FillWith(IDbEnumerator* pDbEnum)
 
                                r = pFile->Write(&size, sizeof(int));
                                SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
-
                                r = pFile->Write(&int64Value, sizeof(long long));
                                SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
                                break;
@@ -342,9 +347,11 @@ _DataControlResultSetImpl::FillWith(IDbEnumerator* pDbEnum)
                                r = pFile->Write(&size, sizeof(int));
                                SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
 
-                               r = pFile->Write(pContent.get(), size);
-                               SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
-
+                               if (size > 0)
+                               {
+                                       r = pFile->Write(pContent.get(), size);
+                                       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
+                               }
                                break;
                        }
 
@@ -367,7 +374,23 @@ _DataControlResultSetImpl::FillWith(IDbEnumerator* pDbEnum)
                                r = pFile->Write(&size, sizeof(int));
                                SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
 
-                               r = pFile->Write(blobValue);
+                               if (size > 0)
+                               {
+                                       r = pFile->Write(blobValue);
+                                       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
+                               }
+                               break;
+                       }
+
+                       case DB_COLUMNTYPE_NULL:
+                       {
+                               int type = 5; // null
+                               int size = 0;
+
+                               r = pFile->Write(&type, sizeof(int));
+                               SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
+
+                               r = pFile->Write(&size, sizeof(int));
                                SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] System error was occurred.", GetErrorMessage(r));
                                break;
                        }
index 1d309ec..05de4cc 100644 (file)
@@ -24,6 +24,7 @@
 #include <serial.h>
 
 #include <FBaseSysLog.h>
+#include <FIo_DataRouter.h>
 #include <FIo_IDataRouterEventListener.h>
 
 using namespace Tizen::Base;
@@ -33,22 +34,30 @@ namespace Tizen { namespace Io
 
 const char* _VCONF_KEY_DATA_ROUTER_READY_EVENT = "memory/data_router/osp_serial_open";
 
-static serial_h gSerialHandle = 0;
+static serial_h gSerialHandle = null;
 static _DataRouter* gp_DataRouter = null;
+static int __refCount = 0;
 
 void
 SerialStateChangedCallback(serial_error_e result, serial_state_e state, void* userData)
 {
-
+       int ret = 0;
        if (gp_DataRouter != null)
        {
                if (state == SERIAL_STATE_OPENED)
                {
                        gp_DataRouter->StateChanged(_DATA_ROUTER_STATE_OPENED);
                }
-               else
+               else if (state == SERIAL_STATE_CLOSED)
                {
                        gp_DataRouter->StateChanged(_DATA_ROUTER_STATE_CLOSED);
+                       ret = serial_unset_state_changed_cb(gSerialHandle);             
+                       ret = serial_unset_data_received_cb(gSerialHandle);
+                       ret = serial_destroy(gSerialHandle);
+               }
+               else
+               {
+                       SysLogException(NID_IO, E_SYSTEM, "Undefined state is required.");
                }
        }
 }
@@ -96,9 +105,9 @@ SerialStateReadyCallback(keynode_t* node, void* userData)
 CATCH:
        if (r != E_SUCCESS)
        {
-               ret = serial_close(gSerialHandle);
-               ret = serial_unset_state_changed_cb(gSerialHandle);
+               ret = serial_unset_state_changed_cb(gSerialHandle);             
                ret = serial_unset_data_received_cb(gSerialHandle);
+               ret = serial_close(gSerialHandle);
                ret = serial_destroy(gSerialHandle);
        }
 }
@@ -122,33 +131,35 @@ _DataRouter::~_DataRouter(void)
        {
                SysLogException(NID_IO, E_SYSTEM, "Failed to release handle of serial. Error:%d", ret);
        }
+
+       gSerialHandle = null;
 }
 
 result
 _DataRouter::Construct(_IDataRouterEventListener& listener)
 {
-       result r = E_SUCCESS;
-
        int ret = 0;
-       SysAssertf(__initialized == false, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class\n");
 
        __pDataRouterEventListener = &listener;
-       __initialized = true;
-
-       ret = vconf_notify_key_changed(_VCONF_KEY_DATA_ROUTER_READY_EVENT, SerialStateReadyCallback, null);
-       SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "Failed to register vconf event for data router ready");
 
-CATCH:
-       return r;
+       if(__initialized == false)
+       {
+               ret = vconf_notify_key_changed(_VCONF_KEY_DATA_ROUTER_READY_EVENT, SerialStateReadyCallback, null);
+               SysTryReturnResult(NID_IO, ret == 0, E_SYSTEM, "It is failed to register vconf event for data router ready.");
+               __initialized = true;
+       }
+       return E_SUCCESS;
 }
 
 result
 _DataRouter::Write(const char* data, int length)
 {
        int ret = 0;
-       ret = serial_write(gSerialHandle, data, length);
+       SysTryReturnResult(NID_IO, gSerialHandle != null, E_SYSTEM, "DataRouter is not ready.");
 
+       ret = serial_write(gSerialHandle, data, length);
        SysTryReturnResult(NID_IO, ret >= 0, E_SYSTEM, "Write is failed %d", ret);
+
        return E_SUCCESS;
 }
 
@@ -169,6 +180,7 @@ _DataRouter::StateChanged(_DataRouterState state)
                __pDataRouterEventListener->OnDataRouterStateChanged(state);
        }
 }
+
 _DataRouter*
 _DataRouter::GetInstance(void)
 {
@@ -176,20 +188,25 @@ _DataRouter::GetInstance(void)
        {
                gp_DataRouter = new (std::nothrow) _DataRouter();
                SysTryReturn(NID_IO, gp_DataRouter != null, null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-               return gp_DataRouter;
        }
-       return null;
+
+       __refCount++;
+
+       return gp_DataRouter;
 }
 
 void
 _DataRouter::ReleaseInstance(void)
 {
-       if (gp_DataRouter != null)
+       if(__refCount != 0)
+               __refCount--;
+
+       if (gp_DataRouter != null && __refCount == 0)
        {
                delete gp_DataRouter;
                gp_DataRouter = null;
        }
 }
 
-}} // Tizen::Io
+} } // Tizen::Io
 
index eda5577..d78de83 100644 (file)
@@ -597,8 +597,7 @@ _DatabaseImpl::CreateStatementN(const String& statement)
        _DbStatementImpl::GetInstance(*pDbStatement)->__pStmt = pSqlStmt;
        _DbStatementImpl::GetInstance(*pDbStatement)->__pDatabase = __pDatabase;
 
-       // "SELECT" or other statement?
-       if (strncasecmp(pStrStmt, "select", 5) == 0)
+       if (strncasecmp(pStrStmt, "select", 6) == 0)
        {
                _DbStatementImpl::GetInstance(*pDbStatement)->__stmtType = DB_STATEMENT_TYPE_SELECT;
        }
@@ -796,8 +795,7 @@ _DatabaseImpl::ExecuteSql(const String& sql, bool autoCommit)
                pSqlStr++;
        }
 
-       // "SELECT" or other statement?
-       if (strncasecmp(pSqlStr, "select", 5) == 0)
+       if (strncasecmp(pSqlStr, "select", 6) == 0)
        {
                r = E_INVALID_OPERATION;
                goto CATCH;
@@ -859,8 +857,7 @@ _DatabaseImpl::QueryN(const String& query)
                pQuery++;
        }
 
-       // "SELECT" or other statement?
-       if (strncasecmp(pQuery, "select", 5) != 0)
+       if (strncasecmp(pQuery, "select", 6) != 0)
        {
                r = E_INVALID_OPERATION;
                goto CATCH;
index 365f7d4..8a3a799 100644 (file)
@@ -795,180 +795,126 @@ _DbEnumeratorImpl::Reset(void)
 result
 _DbEnumeratorImpl::GetIntAt(int columnIndex, int& value) const
 {
-       result r = E_SUCCESS;
-
        SysTryReturnResult(NID_IO, __pEnum != null, E_INVALID_STATE,
                                "The Object is not constructed or the database is already been closed.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pDbEnumeratorCache != null, E_INVALID_STATE,
                                "The method has tried to fetch the column data of a result set that is not activated.");
+       SysTryReturnResult(NID_IO, __pDbEnumeratorCache->__pCurrentDbRow != null, E_SYSTEM,
+                               "Result row is not activated.");
 
-       if (__pDbEnumeratorCache->__pCurrentDbRow)
-       {
-               _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
-               if (pDbColumn)
-               {
-                       if (pDbColumn->type != SQLITE_INTEGER)
-                       {
-                               r = E_TYPE_MISMATCH;
-                               SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type.");
-                               goto CATCH;
-                       }
+       _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
+       SysTryReturnResult(NID_IO, pDbColumn != null, E_SYSTEM, "The specified column at index %d is not found from the result set.", columnIndex);
 
-                       value = *((int *)pDbColumn->pData.get());
-               }
-       }
-       return E_SUCCESS;
+       SysTryReturnResult(NID_IO, pDbColumn->type == SQLITE_INTEGER, E_TYPE_MISMATCH,
+                       "Trying to access column of different type.");
 
-CATCH:
-       return r;
+       SysTryReturnResult(NID_IO, pDbColumn->pData != null, E_SYSTEM,  "Data for specified column does not exist.");
+
+       value = *((int *)pDbColumn->pData.get());
+
+       return E_SUCCESS;
 }
 
 result
 _DbEnumeratorImpl::GetInt64At(int columnIndex, long long& value) const
 {
-       result r = E_SUCCESS;
-
        SysTryReturnResult(NID_IO, __pEnum != null, E_INVALID_STATE,
                                "The Object is not constructed or the database is already been closed.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pDbEnumeratorCache != null, E_INVALID_STATE,
                                "The method has tried to fetch the column data of a result set that is not activated.");
+       SysTryReturnResult(NID_IO, __pDbEnumeratorCache->__pCurrentDbRow != null, E_SYSTEM,
+                               "Result row is not activated.");
 
-       if (__pDbEnumeratorCache->__pCurrentDbRow)
-       {
-               _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
-               if (pDbColumn)
-               {
-                       if (pDbColumn->type != SQLITE_INTEGER)
-                       {
-                               r = E_TYPE_MISMATCH;
-                               SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type.");
-                               goto CATCH;
-                       }
+       _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
+       SysTryReturnResult(NID_IO, pDbColumn != null, E_SYSTEM, "The specified column at index %d is not found from the result set.", columnIndex);
 
-                       value = *((long long *)pDbColumn->pData.get());
-               }
-       }
-       return E_SUCCESS;
+       SysTryReturnResult(NID_IO, pDbColumn->type == SQLITE_INTEGER, E_TYPE_MISMATCH,
+                       "Trying to access column of different type.");
+       SysTryReturnResult(NID_IO, pDbColumn->pData != null, E_SYSTEM,  "Data for specified column does not exist.");
 
-CATCH:
-       return r;
+       value = *((long long *)pDbColumn->pData.get());
+
+       return E_SUCCESS;
 }
 
 result
 _DbEnumeratorImpl::GetDoubleAt(int columnIndex, double& value) const
 {
-       result r = E_SUCCESS;
-
        SysTryReturnResult(NID_IO, __pEnum != null, E_INVALID_STATE,
                                "The Object is not constructed or the database is already been closed.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pDbEnumeratorCache != null, E_INVALID_STATE,
                                "The method has tried to fetch the column data of a result set that is not activated.");
+       SysTryReturnResult(NID_IO, __pDbEnumeratorCache->__pCurrentDbRow != null, E_SYSTEM,
+                               "Result row is not activated.");
 
-       if (__pDbEnumeratorCache->__pCurrentDbRow)
-       {
-               _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
-               if (pDbColumn)
-               {
-                       if (pDbColumn->type != SQLITE_FLOAT)
-                       {
-                               r = E_TYPE_MISMATCH;
-                               SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type.");
-                               goto CATCH;
-                       }
+       _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
+       SysTryReturnResult(NID_IO, pDbColumn != null, E_SYSTEM, "The specified column at index %d is not found from the result set.", columnIndex);
+       SysTryReturnResult(NID_IO, pDbColumn->type == SQLITE_FLOAT, E_TYPE_MISMATCH, "Trying to access column of different type.");
+       SysTryReturnResult(NID_IO, pDbColumn->pData != null, E_SYSTEM,  "Data for specified column does not exist.");
 
-                       value = *((double *)pDbColumn->pData.get());
-               }
-       }
-       return E_SUCCESS;
+       value = *((double *)pDbColumn->pData.get());
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 result
 _DbEnumeratorImpl::GetStringAt(int columnIndex, String& value) const
 {
-       result r = E_SUCCESS;
-
        SysTryReturnResult(NID_IO, __pEnum != null, E_INVALID_STATE,
                                "The Object is not constructed or the database is already been closed.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pDbEnumeratorCache != null, E_INVALID_STATE,
                                "The method has tried to fetch the column data of a result set that is not activated.");
+       SysTryReturnResult(NID_IO, __pDbEnumeratorCache->__pCurrentDbRow != null, E_SYSTEM,
+                               "Result row is not activated.");
 
-       if (__pDbEnumeratorCache->__pCurrentDbRow)
-       {
-               _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
-               if (pDbColumn)
-               {
-                       if (pDbColumn->type != SQLITE_TEXT)
-                       {
-                               r = E_TYPE_MISMATCH;
-                               SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type.");
-                               goto CATCH;
-                       }
+       _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
+       SysTryReturnResult(NID_IO, pDbColumn != null, E_SYSTEM, "The specified column at index %d is not found from the result set.", columnIndex);
+       SysTryReturnResult(NID_IO, pDbColumn->type == SQLITE_TEXT, E_TYPE_MISMATCH, "Trying to access column of different type.");
+       SysTryReturnResult(NID_IO, pDbColumn->pData != null, E_SYSTEM,  "Data for specified column does not exist.");
 
-                       value = String((const char*)pDbColumn->pData.get());
-               }
-       }
-       return E_SUCCESS;
+       result r = StringUtil::Utf8ToString(const_cast< char* >(pDbColumn->pData.get()), value);
+       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 result
 _DbEnumeratorImpl::GetBlobAt(int columnIndex, ByteBuffer& value) const
 {
-       result r = E_SUCCESS;
-       int blobLen = 0;
-       const byte* pBlob = null;
-
        SysTryReturnResult(NID_IO, __pEnum != null, E_INVALID_STATE,
                                "The Object is not constructed or the database is already been closed.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pDbEnumeratorCache != null, E_INVALID_STATE,
                                "The method has tried to fetch the column data of a result set that is not activated.");
+       SysTryReturnResult(NID_IO, __pDbEnumeratorCache->__pCurrentDbRow != null, E_SYSTEM,
+                               "Result row is not activated.");
 
-       if (__pDbEnumeratorCache->__pCurrentDbRow)
-       {
-               _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
-               if (pDbColumn)
-               {
-                       if (pDbColumn->type != SQLITE_BLOB)
-                       {
-                               r = E_TYPE_MISMATCH;
-                               SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type.");
-                               goto CATCH;
-                       }
+       _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
+       SysTryReturnResult(NID_IO, pDbColumn != null, E_SYSTEM, "The specified column at index %d is not found from the result set.", columnIndex);
+       SysTryReturnResult(NID_IO, pDbColumn->type == SQLITE_BLOB, E_TYPE_MISMATCH, "Trying to access column of different type.");
 
-                       blobLen = pDbColumn->size;
-                       pBlob = (const byte*)pDbColumn->pData.get();
+       int blobLen = pDbColumn->size;
+       SysTryReturnResult(NID_IO, pDbColumn->pData != null, E_SYSTEM,  "Data for specified column does not exist.");
 
-                       r = value.SetArray(pBlob, 0, blobLen);
-               }
-       }
+       const byte* pBlob = reinterpret_cast< const byte* >(pDbColumn->pData.get());
+       result r = value.SetArray(pBlob, 0, blobLen);
+       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
-       // fall thru
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 result
 _DbEnumeratorImpl::GetBlobAt(int columnIndex, void* buffer, int size) const
 {
-       result r = E_SUCCESS;
-       int blobLen = 0;
-       const byte* pBlob = null;
-
        SysTryReturnResult(NID_IO, __pEnum != null, E_INVALID_STATE,
                                "The Object is not constructed or the database is already been closed.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
@@ -977,69 +923,50 @@ _DbEnumeratorImpl::GetBlobAt(int columnIndex, void* buffer, int size) const
        SysTryReturnResult(NID_IO, size > 0, E_INVALID_ARG, "Invalid size was passed.");
        SysTryReturnResult(NID_IO, __pDbEnumeratorCache != null, E_INVALID_STATE,
                                "The method has tried to fetch the column data of a result set that is not activated.");
+       SysTryReturnResult(NID_IO, __pDbEnumeratorCache->__pCurrentDbRow != null, E_SYSTEM,
+                               "Result row is not activated.");
 
-       if (__pDbEnumeratorCache->__pCurrentDbRow)
-       {
-               _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
-               if (pDbColumn)
-               {
-                       if (pDbColumn->type != SQLITE_BLOB)
-                       {
-                               r = E_TYPE_MISMATCH;
-                               SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type.");
-                               goto CATCH;
-                       }
+       _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
+       SysTryReturnResult(NID_IO, pDbColumn != null, E_SYSTEM, "The specified column at index %d is not found from the result set.", columnIndex);
+       SysTryReturnResult(NID_IO, pDbColumn->type == SQLITE_BLOB, E_TYPE_MISMATCH, "Trying to access column of different type.");
 
-                       blobLen = pDbColumn->size;
-                       pBlob = (const byte*)pDbColumn->pData.get();
-                       memcpy(buffer, pBlob, (blobLen < size) ? blobLen : size);
-               }
-       }
+       int blobLen = pDbColumn->size;
+       SysTryReturnResult(NID_IO, pDbColumn->pData != null, E_SYSTEM,  "Data for specified column does not exist.");
+
+       const byte* pBlob = reinterpret_cast< const byte* >(pDbColumn->pData.get());
+       memcpy(buffer, pBlob, (blobLen < size) ? blobLen : size);
 
        if (size < blobLen)
        {
-               r = E_OVERFLOW;
+               return E_OVERFLOW;
        }
 
-       // fall thru
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 result
 _DbEnumeratorImpl::GetDateTimeAt(int columnIndex, DateTime& value) const
 {
-       result r = E_SUCCESS;
-       const char* pStr = null;
-
        SysTryReturnResult(NID_IO, __pEnum != null, E_INVALID_STATE,
                                "The Object is not constructed or the database is already been closed.");
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                "Given column index is out of range.");
        SysTryReturnResult(NID_IO, __pDbEnumeratorCache != null, E_INVALID_STATE,
                                "The method has tried to fetch the column data of a result set that is not activated.");
+       SysTryReturnResult(NID_IO, __pDbEnumeratorCache->__pCurrentDbRow != null, E_SYSTEM,
+                               "Result row is not activated.");
 
-       if (__pDbEnumeratorCache->__pCurrentDbRow)
-       {
-               _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
-               if (pDbColumn)
-               {
-                       if (pDbColumn->type != SQLITE_TEXT)
-                       {
-                               r = E_TYPE_MISMATCH;
-                               SysLog(NID_IO, "[E_TYPE_MISMATCH] Trying to access column of different type.");
-                               goto CATCH;
-                       }
+       _DbColumn* pDbColumn = dynamic_cast < _DbColumn* >(__pDbEnumeratorCache->__pCurrentDbRow->dbValuesList.GetAt(columnIndex));
+       SysTryReturnResult(NID_IO, pDbColumn != null, E_SYSTEM, "The specified column at index %d is not found from the result set.", columnIndex);
+       SysTryReturnResult(NID_IO, pDbColumn->type == SQLITE_TEXT, E_TYPE_MISMATCH, "Trying to access column of different type.");
+       SysTryReturnResult(NID_IO, pDbColumn->pData != null, E_SYSTEM,  "Data for specified column does not exist.");
 
-                       pStr = (const char*) pDbColumn->pData.get();
-               }
-       }
+       const char* pStr = const_cast< char* >(pDbColumn->pData.get());
 
-       r = DateTime::Parse(pStr, value);
+       result r = DateTime::Parse(pStr, value);
+       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
-       // fall thru
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 int
index 673ec90..3f44ee4 100644 (file)
@@ -139,7 +139,7 @@ _DirectoryImpl::Create(const String& dirPath, bool createParentDirsToo)
 
        // By the time we are here.. we assume we have a legal path to create
        // the below logic works under the assumption that the path name does not end with '/'
-       ret = mkdir(pDirPath.get(), S_IRUSR | S_IWUSR | S_IXUSR);
+       ret = mkdir(pDirPath.get(), 0755);
        if (ret == -1)
        {
                // if parent directory does not exist and if we are asked to create them
@@ -361,8 +361,24 @@ _DirectoryImpl::Rename(const String& orgDirPath, const String& newDirPath)
        ret = rename(pOldpath.get(), pNewpath.get());
        if (ret != 0)
        {
-               r = _NativeError::ConvertNativeErrorToResult(errno, true);
-               SysLog(NID_IO, "errno[%d], [%s] could not rename dirpath [%s].", errno, GetErrorMessage(r), pOldpath.get());
+               switch (errno)
+               {
+               case EBUSY:
+               // fall through
+               case EMLINK:
+                       r = E_IO;
+                       break;
+               case ENOTEMPTY:
+                       r = E_FILE_ALREADY_EXIST;
+                       break;
+               case EXDEV:
+                       r = E_INVALID_ARG;
+                       break;
+               default:
+                       r = _NativeError::ConvertNativeErrorToResult(errno, true);
+                       break;
+               }
+               SysLogException(NID_IO, r, "[%s] Renaming the directory path (%s) is failed, errno: %d (%s)", GetErrorMessage(r), pOldpath.get(), errno, strerror(errno));
        }
 
        return r;
index 6b96261..eb53de7 100644 (file)
@@ -30,6 +30,7 @@
 #include <errno.h>
 #include <new>
 #include <unique_ptr.h>
+#include <fcntl.h>
 
 #include <FBaseSysLog.h>
 #include <FAppPkgPackageInfo.h>
@@ -42,6 +43,7 @@
 #include <FApp_AppInfo.h>
 #include <FAppPkg_PackageInfoImpl.h>
 #include <FSys_EnvironmentImpl.h>
+#include <FBase_NativeError.h>
 
 #include "FIo_FileImpl.h"
 #include "FIo_NormalFile.h"
@@ -50,6 +52,7 @@
 #include "FIo_SecureIoUtil.h"
 #include "FIo_IFileCore.h"
 #include "FIo_FileUtil.h"
+#include "FIo_FileLockImpl.h"
 
 using namespace std;
 using namespace Tizen::Base;
@@ -89,12 +92,17 @@ _FileImpl::_FileImpl(void)
        , __write(false)
        , __truncate(false)
        , __append(false)
+       , __pFileLockImpl(null)
 {
 }
 
 _FileImpl::~_FileImpl(void)
 {
        delete __pCore;
+       if (__pFileLockImpl != null)
+       {
+               __pFileLockImpl->__pFileImpl = null;
+       }
 }
 
 _FileImpl::_FileImpl(const _FileImpl& fileImpl)
@@ -393,6 +401,131 @@ _FileImpl::GetFilePointer(void) const
        return __pCore->GetFilePointer();
 }
 
+FileLock*
+_FileImpl::LockN(FileLockType lockType)
+{
+       SysAssertf(__pCore != null, "Not yet constructed. Construct() should be called before use.\n");
+       return LockN(lockType, FILE_LOCK_MODE_BLOCKING, 0, 0);
+}
+
+FileLock*
+_FileImpl::LockN(FileLockType lockType, int offset, int length)
+{
+       SysAssertf(__pCore != null, "Not yet constructed. Construct() should be called before use.\n");
+       return LockN(lockType, FILE_LOCK_MODE_BLOCKING, offset, length);
+}
+
+FileLock*
+_FileImpl::TryToLockN(FileLockType lockType)
+{
+       SysAssertf(__pCore != null, "Not yet constructed. Construct() should be called before use.\n");
+       return LockN(lockType, FILE_LOCK_MODE_NON_BLOCKING, 0, 0);
+}
+
+FileLock*
+_FileImpl::TryToLockN(FileLockType lockType, int offset, int length)
+{
+       SysAssertf(__pCore != null, "Not yet constructed. Construct() should be called before use.\n");
+       return LockN(lockType, FILE_LOCK_MODE_NON_BLOCKING, offset, length);
+}
+
+FileLock*
+_FileImpl::LockN(FileLockType lockType, _FileLockMode lockMode, int offset, int length)
+{
+       SysAssertf(__pCore != null, "Not yet constructed. Construct() should be called before use.\n");
+       SysTryReturn(NID_IO, offset >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified offset is negative.");
+       SysTryReturn(NID_IO, length >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified length is negative.");
+
+       struct flock lock;
+       switch (lockType)
+       {
+       case FILE_LOCK_SHARED:
+               SysTryReturn(NID_IO, __read == true, null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] File is not opened for reading.");
+               lock.l_type = F_RDLCK;
+               break;
+       case FILE_LOCK_EXCLUSIVE:
+               SysTryReturn(NID_IO, __write == true, null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] File is not opened for writing.");
+               lock.l_type = F_WRLCK;
+               break;
+       default:
+               SysLogException(NID_IO, E_INVALID_ARG, "[E_INVALID_ARG] The specified lock type is invalid.");
+               return null;
+       }
+
+       int fd = fileno(this->GetFilePointer());
+       int lockCommand = -1;
+       int ret = -1;
+       switch (lockMode)
+       {
+       case FILE_LOCK_MODE_BLOCKING:
+               lockCommand = F_SETLKW;
+               break;
+       case FILE_LOCK_MODE_NON_BLOCKING:
+       {
+               lockCommand = F_SETLK;
+               break;
+       }
+       default:
+               SysLogException(NID_IO, E_INVALID_ARG, "[E_INVALID_ARG] The specified lock mode is invalid.");
+               return null;
+       }
+
+       lock.l_whence = SEEK_SET;
+       lock.l_start = offset;
+       lock.l_len = length;
+       lock.l_pid = getpid();
+
+       ret = fcntl(fd, lockCommand, &lock);
+       if (ret != 0)
+       {
+               result r = E_SUCCESS;
+               switch (errno)
+               {
+               case ENOLCK:
+                       r = E_MAX_EXCEEDED;
+                       break;
+               case EDEADLK:
+               {
+                       if (lockMode == FILE_LOCK_MODE_BLOCKING)
+                       {
+                               r = E_WOULD_DEADLOCK;
+                       }
+                       else
+                       {
+                               r = E_SYSTEM;
+                       }
+                       break;
+               }
+               case EAGAIN:
+                       // fall through
+               case EACCES:
+                       if (lockMode == FILE_LOCK_MODE_NON_BLOCKING)
+                       {
+                               r = E_OBJECT_LOCKED;
+                               break;
+                       }
+                       // else fall through
+               case EFAULT:
+                       // fall through
+               case EBADF:
+                       r = E_SYSTEM;
+                       break;
+               default:
+                       r = _NativeError::ConvertNativeErrorToResult(errno, true);
+                       break;
+               }
+
+               SysLogException(NID_IO, r, "[%s] Aquiring file lock of type (%d) is failed, errno: %d (%s)", GetErrorMessage(r), lockType, errno, strerror(errno));
+               return null;
+       }
+
+       unique_ptr<FileLock> pFileLock(_FileLockImpl::CreateFileLockInstanceN(this, lockType, lock.l_start, lock.l_len, lock.l_pid));
+       SysTryReturn(NID_IO, pFileLock != null, null, GetLastResult(), "[%s] Propagating to caller....", GetErrorMessage(GetLastResult()));
+       __pFileLockImpl = _FileLockImpl::GetInstance(*pFileLock);
+       SetLastResult(E_SUCCESS);
+       return pFileLock.release();
+}
+
 result
 _FileImpl::Remove(const String& filePath)
 {
diff --git a/src/io/FIo_FileLockImpl.cpp b/src/io/FIo_FileLockImpl.cpp
new file mode 100644 (file)
index 0000000..d088d38
--- /dev/null
@@ -0,0 +1,141 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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       FIo_FileLockImpl.cpp
+ * @brief      This is the implementation file for _FileLockImpl class.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <new>
+#include <unique_ptr.h>
+
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+
+#include <FBase_NativeError.h>
+#include "FIo_FileImpl.h"
+#include "FIo_FileLockImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Io
+{
+
+_FileLockImpl::_FileLockImpl(void)
+       : __pFileImpl(null)
+       , __lockType(FileLockType(-1))
+       , __offset(-1)
+       , __size(-1)
+       , __pid(-1)
+{
+}
+
+_FileLockImpl::~_FileLockImpl(void)
+{
+       if (__pFileImpl != null)
+       {
+               __pFileImpl->__pFileLockImpl = null;
+               int fd = fileno(__pFileImpl->GetFilePointer());
+               struct stat statbuf;
+               SysTryReturnVoidResult(NID_IO, fstat(fd, &statbuf) == 0, E_SYSTEM,
+                               "[E_SYSTEM] Failed to get file status. errno: %d (%s)", errno, strerror(errno));
+               // release the lock
+               struct flock lock;
+               if (__lockType == FILE_LOCK_SHARED)
+               {
+                       lock.l_type = F_RDLCK;
+               }
+               else if (__lockType == FILE_LOCK_EXCLUSIVE)
+               {
+                       lock.l_type = F_WRLCK;
+               }
+               lock.l_whence = SEEK_SET;
+               lock.l_start = __offset;
+               lock.l_len = __size;
+               lock.l_pid = __pid;
+               SysTryReturnVoidResult(NID_IO, fcntl(fd, F_UNLCK, &lock) == 0, E_SYSTEM,
+                               "[E_SYSTEM] Failed to release the lock. errno: %d (%s)", errno, strerror(errno));
+       }
+}
+
+result
+_FileLockImpl::Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid)
+{
+       SysTryReturnResult(NID_IO, pFileImpl != null, E_SYSTEM, "File instance is null.");
+
+       __pFileImpl = const_cast< _FileImpl* >(pFileImpl);
+       __lockType = lockType;
+       __offset = offset;
+       __size = size;
+       __pid = pid;
+       return E_SUCCESS;
+}
+
+_FileLockImpl*
+_FileLockImpl::GetInstance(FileLock& fileLock)
+{
+       return fileLock.__pFileLockImpl;
+}
+
+const _FileLockImpl*
+_FileLockImpl::GetInstance(const FileLock& fileLock)
+{
+       return fileLock.__pFileLockImpl;
+}
+
+bool
+_FileLockImpl::IsShared(void) const
+{
+       SetLastResult(E_SUCCESS);
+       return (__lockType == FILE_LOCK_SHARED) ? true : false;
+}
+
+bool
+_FileLockImpl::IsExclusive(void) const
+{
+       SetLastResult(E_SUCCESS);
+       return (__lockType == FILE_LOCK_EXCLUSIVE) ? true : false;
+}
+
+bool
+_FileLockImpl::IsValid(void) const
+{
+       struct stat statbuf;
+       SysTryReturn(NID_IO, __pFileImpl != null && (fstat(fileno(__pFileImpl->GetFilePointer()), &statbuf) == 0), false, E_SYSTEM, "[E_SYSTEM} File lock is invalid.");
+       SetLastResult(E_SUCCESS);
+       return true;
+}
+
+FileLock*
+_FileLockImpl::CreateFileLockInstanceN(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid)
+{
+       std::unique_ptr<FileLock> pFileLock(new (std::nothrow) FileLock());
+       SysTryReturn(NID_IO, pFileLock != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       result r = pFileLock->Construct(pFileImpl, lockType, offset, size, pid);
+       SysTryReturn(NID_IO, !IsFailed(r), null, r, "[%s] Propagating to caller...", GetErrorMessage(r));
+
+       SetLastResult(E_SUCCESS);
+       return pFileLock.release();
+}
+
+}} // Tizen::Io
index 7fc3c56..471dcd6 100644 (file)
@@ -188,24 +188,21 @@ _FileUtil::Move(const String& oldFilePath, const String& newFilePath)
        SysTryReturnResult(NID_IO, S_ISDIR(statBuf.st_mode) == false, E_INVALID_ARG,
                           "The old path is a directory.");
 
-       // TODO: Use rename() for move operation in same mount point
-       // and need API versioning.
-#if 0
        int ret = rename(pOldPath.get(), pNewPath.get());
-       if (ret != 0)
+       if (ret != 0 && errno != EXDEV)
        {
                r = __ConvertNativeErrorToResult(errno);
-               SysLog(NID_IO, "[%s] rename() failed, errno: %d, strerror: %s", errno, strerror(errno));
+               SysLog(NID_IO, "[%s] rename() failed, errno: %d (%s)", GetErrorMessage(r), errno, strerror(errno));
                return r;
        }
-#else
-       // To work across different mount points
-       r = File::Copy(oldFilePath, newFilePath, true);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+       else if (errno == EXDEV)
+       {
+               r = File::Copy(oldFilePath, newFilePath, true);
+               SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
 
-       r = File::Remove(oldFilePath);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
-#endif
+               r = File::Remove(oldFilePath);
+               SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
+       }
 
        return E_SUCCESS;
 }
@@ -213,13 +210,13 @@ _FileUtil::Move(const String& oldFilePath, const String& newFilePath)
 result
 _FileUtil::Copy(const String& srcFilePath, const String& destFilePath, bool failIfExist)
 {
-       result r = E_SUCCESS;
        int srcFd = -1;
        int dstFd = -1;
-       int size = 0;
-       void* pSrcMap = MAP_FAILED;
-       void* pDstMap = MAP_FAILED;
-       unique_ptr<char[]> pBuffer(null);
+       ssize_t readBytes = -1;
+       ssize_t writtenBytes = -1;
+       ssize_t remainingBytes = -1;
+       char* pBuffer = null;
+       result r = E_SUCCESS;
 
        unique_ptr<char[]> pSrcpath(_StringConverter::CopyToCharArrayN(srcFilePath));
        SysTryReturn(NID_IO, pSrcpath != null, GetLastResult(), GetLastResult(),
@@ -239,84 +236,78 @@ _FileUtil::Copy(const String& srcFilePath, const String& destFilePath, bool fail
                return r;
        }
 
-       // try linux way to optimally use mmap.
        srcFd = open(pSrcpath.get(), O_RDONLY);
-       r = __ConvertNativeErrorToResult(errno);
-       SysTryReturn(NID_IO, (srcFd != -1), r, r, "[%s] Failed to open file (%s).", __ConvertNativeErrorToMessage(errno), pSrcpath.get());
-
-       dstFd = open(pDstpath.get(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
-       r = __ConvertNativeErrorToResult(errno);
-       SysTryCatch(NID_IO, (dstFd != -1), , r, "[%s] Failed to open file (%s), errno: %d (%s)",
-                          __ConvertNativeErrorToMessage(errno), pDstpath.get(), errno, strerror(errno));
-
-       // First try the mmap method
-       size = lseek(srcFd, 0, SEEK_END);
-       r = __ConvertNativeErrorToResult(errno);
-       SysTryCatch(NID_IO, (size != -1), , r, "[%s] Failed to reach the end of file (%s).", __ConvertNativeErrorToMessage(
-                                  errno), pDstpath.get());
-
-       pSrcMap = mmap(0, size, PROT_READ, MAP_SHARED, srcFd, 0);
-       pDstMap = mmap(0, size, PROT_WRITE, MAP_SHARED, dstFd, 0);
-
-       if ((pSrcMap != MAP_FAILED) && (pDstMap != MAP_FAILED))
+       if (srcFd == -1)
        {
-               // do the copy and commit
-               memcpy(pDstMap, pSrcMap, size);
-               msync(pDstMap, size, MS_SYNC);
+               r = __ConvertNativeErrorToResult(errno);
+               SysLogException(NID_IO, r, "[%s] Failed to open file (%s).", GetErrorMessage(r), pSrcpath.get());
+               return r;
        }
-       else    // mmap method filed due to memory limitations.. try regular copy
+       dstFd = open(pDstpath.get(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
+       if (dstFd == -1)
        {
-               off_t start = lseek(srcFd, 0, SEEK_SET);
                r = __ConvertNativeErrorToResult(errno);
-               SysTryCatch(NID_IO, (start != -1), , r, "[%s] Failed to reach the end of file (%s).", __ConvertNativeErrorToMessage(
-                                          errno), pDstpath.get());
+               SysLogException(NID_IO, r, "[%s] Failed to open file (%s), errno: %d (%s)",
+                                  GetErrorMessage(r), pDstpath.get(), errno, strerror(errno));
+               goto CATCH;
+       }
 
-               pBuffer = unique_ptr<char[]> (new (std::nothrow) char[_MAX_COPY_BYTES]);
-               SysTryCatch(NID_IO, (pBuffer != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+       pBuffer = new (std::nothrow) char[_MAX_COPY_BYTES];
+       SysTryCatch(NID_IO, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-               ssize_t bytesRead = -1;
-               ssize_t bytesWritten = -1;
+       do
+       {
                do
                {
-                       bytesRead = read(srcFd, pBuffer.get(), _MAX_COPY_BYTES);
+                       readBytes = read(srcFd, pBuffer, _MAX_COPY_BYTES);
+               }
+               while (readBytes < 0 && errno == EINTR);
+               if (readBytes < 0)
+               {
                        r = __ConvertNativeErrorToResult(errno);
-                       SysTryCatch(NID_IO, bytesRead != -1, , r, "[%s] Failed to read from file (%s), errno: %d",
-                                          __ConvertNativeErrorToMessage(errno), pSrcpath.get(), errno);
-
-                       bytesWritten = write(dstFd, pBuffer.get(), bytesRead);
+                       SysLogException(NID_IO, r, "[%s] Failed to read from source file (%s), errno: %d (%s)",
+                                       GetErrorMessage(r), pSrcpath.get(), errno, strerror(errno));
+                       goto CATCH;
+               }
+               else if (readBytes == 0)
+               {
+                       break;
+               }
+               remainingBytes = readBytes;
+RETRY:
+               do
+               {
+                       writtenBytes = write(dstFd, pBuffer, remainingBytes);
+               }
+               while (writtenBytes < 0 && errno == EINTR);
+               if (writtenBytes < 0)
+               {
                        r = __ConvertNativeErrorToResult(errno);
-                       SysTryCatch(NID_IO, bytesWritten != -1, , r, "[%s] Failed to write to file (%s), errno: %d",
-                                          __ConvertNativeErrorToMessage(
-                                                  errno), pDstpath.get(), errno);
+                       SysLogException(NID_IO, r, "[%s] Failed to write to destination file (%s), errno: %d (%s)",
+                                       GetErrorMessage(r), pDstpath.get(), errno, strerror(errno));
+                       goto CATCH;
+               }
+               else if (writtenBytes < remainingBytes)
+               {
+                       remainingBytes = remainingBytes - writtenBytes;
+                       pBuffer = const_cast< char* >(pBuffer) + writtenBytes;
+                       goto RETRY;
                }
-               while (bytesRead);
        }
+       while (readBytes);
 
-       r = E_SUCCESS;
-
-       // fall thru
+       // fall through
 CATCH:
-
        if (srcFd != -1)
        {
                close(srcFd);
        }
-
        if (dstFd != -1)
        {
                fsync(dstFd);
                close(dstFd);
        }
-
-       if (pSrcMap != MAP_FAILED && size != -1)
-       {
-               munmap(pSrcMap, size);
-       }
-
-       if (pDstMap != MAP_FAILED && size != -1)
-       {
-               munmap(pDstMap, size);
-       }
+       delete pBuffer;
 
        return r;
 }
index 1b788bc..a8ac658 100644 (file)
@@ -130,7 +130,7 @@ struct HelloMessage
 {
        int pid;
        bool reverse;
-       char appId[256];
+       char pkgId[256];
        char appExecutableName[256];
 };
 
@@ -165,20 +165,19 @@ _IpcClient::MakeConnection(bool forReverse)
 
        if (__fdCount == 0)
        {
-               // Set an appId
-               String appId = _AppInfo::GetAppId();
-               int length = (appId.GetLength() + 1) * sizeof(wchar_t);
+               // Set an pkgId
+               String pkgId = _AppInfo::GetPackageId();
+               int length = (pkgId.GetLength() + 1) * sizeof(wchar_t);
                if (length > 255)
                {
                        length = 255;
                }
 
-               SysTryReturnResult(NID_IO, appId.GetLength() > 0, E_SYSTEM, "AppId dose not exist.");
+               SysTryReturnResult(NID_IO, pkgId.GetLength() > 0, E_SYSTEM, "AppId dose not exist.");
 
-               memcpy(helloMessage.appId, appId.GetPointer(), length);
+               memcpy(helloMessage.pkgId, pkgId.GetPointer(), length);
 
                // Set an executableName
-               //String appExecutableName = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(appId);
                String appExecutableName = _AppInfo::GetAppExecutableName();
                length = (appExecutableName.GetLength() + 1) * sizeof(wchar_t);
                if (length > 255)
@@ -186,7 +185,6 @@ _IpcClient::MakeConnection(bool forReverse)
                        length = 255;
                }
 
-               //SysTryReturnResult(NID_IO, appExecutableName.GetLength() > 0, E_SYSTEM, "App Executable name of AppId(%ls) dose not exist.", appId.GetPointer());
                if (appExecutableName.GetLength() != 0)
                {
                        memcpy(helloMessage.appExecutableName, appExecutableName.GetPointer(), length);
index d25f73d..ec0ccc4 100644 (file)
@@ -48,9 +48,14 @@ class _MessagePortEventArg
        : public IEventArg
 {
 public:
-       _MessagePortEventArg()
+       _MessagePortEventArg(IMap* pMap)
                : __pRemotePort(null)
-               , __pMap(null)
+               , __pMap(pMap)
+       {
+       }
+       _MessagePortEventArg(RemoteMessagePort* pRemotePort, IMap* pMap)
+               : __pRemotePort(pRemotePort)
+               , __pMap(pMap)
        {
        }
        RemoteMessagePort* __pRemotePort;
@@ -137,10 +142,11 @@ _LocalMessagePortImpl::IsTrusted(void) const
 void
 _LocalMessagePortImpl::OnMessageReceivedN(IMap* pMap)
 {
-       _MessagePortEventArg* pEventArg= new (std::nothrow) _MessagePortEventArg();
+       SysLog(NID_IO, "A message is received.");
+
+       _MessagePortEventArg* pEventArg= new (std::nothrow) _MessagePortEventArg(pMap);
        if(pEventArg != null)
        {
-               pEventArg->__pMap = pMap;
                __pEvent->Fire(*pEventArg);
        }
 }
@@ -155,11 +161,9 @@ _LocalMessagePortImpl::OnMessageReceivedN(const AppId& remoteAppId, const String
 
        RemoteMessagePort* pRemotePort = pManager->GetRemoteMessagePort(remoteAppId, remotePort, isTrusted);
 
-       _MessagePortEventArg* pEventArg = new (std::nothrow) _MessagePortEventArg();
+       _MessagePortEventArg* pEventArg = new (std::nothrow) _MessagePortEventArg(pRemotePort, pMap);
        if(pEventArg != null)
        {
-               pEventArg->__pRemotePort = pRemotePort;
-               pEventArg->__pMap = pMap;
                __pEvent->Fire(*pEventArg);
        }
 }
@@ -176,7 +180,7 @@ _LocalMessagePortImpl::GetMessagePort(const String& port, bool isTrusted)
        SysTryCatch(NID_IO, pImpl != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        r = pImpl->Construct(port, isTrusted);
-       SysTryCatch(NID_IO, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to initialize a message port.");
+       SysTryCatch(NID_IO, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
        pLocalMessagePort->__pLocalMessagePortImpl = pImpl.release();
 
index 4f4ebb3..4cc91b7 100644 (file)
  */
 
 #include <string.h>
+#include <typeinfo>
 #include <unique_ptr.h>
 
 #include <package_manager.h>
 
+#include <message-port.h>
+
 #include <FBaseSysLog.h>
 #include <FBase_StringConverter.h>
 #include <FApp_AppInfo.h>
-#include "FIo_IpcClient.h"
+
 #include "FIo_MessagePortProxy.h"
-#include "FIo_MessagePortMessages.h"
 
 using namespace std;
 
@@ -44,106 +46,231 @@ using namespace Tizen::Base::Runtime;
 namespace Tizen { namespace Io
 {
 
-_MessagePortProxy::_MessagePortProxy(void)
-       : __pIpcClient(null)
+static void
+ConvertBundleToMap(const char *pKey, const int type, const bundle_keyval_t *pVal, void *pData)
 {
+       SysLog(NID_IO, "CB key = %s", pKey);
+
+       HashMap* pMap = static_cast<HashMap*>(pData);
+
+       if (pKey && pVal && pMap)
+       {
+               size_t size = 0;
+               char* pStr = NULL;
+               switch (type)
+               {
+                       case BUNDLE_TYPE_STR:
+                               bundle_keyval_get_basic_val(const_cast<bundle_keyval_t*>(pVal), reinterpret_cast<void**>(&pStr), &size);
+                               if (pStr)
+                               {
+                                       pMap->Add(new (std::nothrow) String(pKey), new (std::nothrow) String(pStr));
+                               }
+
+                               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();
+                                       SysTryReturn(NID_IO, pMap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                                       result r = pBuffer->Construct(size);
+                                       SysTryReturn(NID_IO, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                                       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;
+               }
+       }
 }
 
-_MessagePortProxy::~_MessagePortProxy(void)
+static void
+OnMessageReceived(int id, const char* remote_app_id, const char* remote_port, bool trusted_port, bundle* data)
 {
+       SysLog(NID_IO, "Message received");
+
+       _MessagePortProxy* p = _MessagePortProxy::GetProxy();
+
+       int ret = 0;
+       char* pLocalPort = null;
+
+       ret = messageport_get_local_port_name(id, &pLocalPort);
+       if (pLocalPort == null)
+       {
+               SysLog(NID_IO, "No local port for id: %d", id);
+
+               bundle_free(data);
+               return;
+       }
+
+       SysLog(NID_IO, "local port name: %s", pLocalPort);
+
+       _IMessagePortListener* pListener = null;
+       p->__listeners.GetValue(pLocalPort, pListener);
+
+       free(pLocalPort);
+
+       if (pListener != null)
+       {
+               HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+               SysTryCatch(NID_IO, pMap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               result r = pMap->Construct();
+               SysTryCatch(NID_IO, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               SysLog(NID_IO, "bundle to map");
+
+               bundle_foreach(data, ConvertBundleToMap, pMap);
+
+               if (remote_app_id == null) // Uni-directional
+               {
+                       pListener->OnMessageReceivedN(pMap);
+               }
+               else // Bi-directional
+               {
+                       SysLog(NID_IO, "Message received from [%s:%s], trusted: %d", remote_app_id, remote_port, trusted_port);
+
+                       pListener->OnMessageReceivedN(remote_app_id, remote_port, trusted_port, pMap);
+               }
+       }
+
+CATCH:
+       bundle_free(data);
 }
 
-result
-_MessagePortProxy::Construct(void)
+static void
+OnTrustedMessageReceived(int id, const char* remote_app_id, const char* remote_port, bool trusted_port, bundle* data)
 {
-       SysAssertf(__pIpcClient == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysLog(NID_IO, "Trusted message received");
 
-       result r = E_SUCCESS;
+       _MessagePortProxy* p = _MessagePortProxy::GetProxy();
 
-       static _StringHashProvider hashProvider;
-       static _StringComparer stringComparer;
+       int ret = 0;
+       char* pLocalPort = null;
+       ret = messageport_get_local_port_name(id, &pLocalPort);
+       if (pLocalPort == null)
+       {
+               SysLog(NID_IO, "No local port for id: %d", id);
 
-       __listeners.Construct(0, 0, hashProvider, stringComparer);
-       __trustedListeners.Construct(0, 0, hashProvider, stringComparer);
+               bundle_free(data);
+               return;
+       }
 
-       unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient);
-       SysTryReturnResult(NID_IO, pIpcClient != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+       _IMessagePortListener* pListener = null;
+       p->__trustedListeners.GetValue(pLocalPort, pListener);
 
-       r = pIpcClient->Construct("osp.io.ipcserver.messageportmanager", this);
-       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Failed to connect to IPC server.", GetErrorMessage(r));
+       free(pLocalPort);
 
-       __pIpcClient = pIpcClient.release();
+       if (pListener != null)
+       {
+               HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+               SysTryCatch(NID_IO, pMap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-       const String& appId = _AppInfo::GetAppId();
-       const String& appExecutableName = _AppInfo::GetAppExecutableName();
+               result r = pMap->Construct();
+               SysTryCatch(NID_IO, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-       __appId.Append(appId);
-       __appId.Append(L'.');
-       __appId.Append(appExecutableName);
+               bundle_foreach(data, ConvertBundleToMap, pMap);
 
-       return E_SUCCESS;
+               if (remote_app_id == null) // Uni-directional
+               {
+                       pListener->OnMessageReceivedN(pMap);
+               }
+               else // Bi-directional
+               {
+                       SysLog(NID_IO, "Trusted message received from [%s:%s], trusted: %d", remote_app_id, remote_port, trusted_port);
+                       pListener->OnMessageReceivedN(remote_app_id, remote_port, trusted_port, pMap);
+               }
+       }
+
+CATCH:
+       bundle_free(data);
+}
+
+_MessagePortProxy::_MessagePortProxy(void)
+{
 }
 
+_MessagePortProxy::~_MessagePortProxy(void)
+{
+}
 
-void
-_MessagePortProxy::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message)
+result
+_MessagePortProxy::Construct(void)
 {
-       IPC_BEGIN_MESSAGE_MAP(_MessagePortProxy, message)
-       IPC_MESSAGE_HANDLER_EX(MessagePortService_sendMessageAsync, &client, OnSendMessage)
-       IPC_MESSAGE_HANDLER_EX(MessagePortService_sendBidirMessageAsync, &client, OnSendBidirMessage)
-       IPC_END_MESSAGE_MAP_EX()
+       static _StringHashProvider hashProvider;
+       static _StringComparer stringComparer;
+
+       __listeners.Construct(0, 0, hashProvider, stringComparer);
+       __trustedListeners.Construct(0, 0, hashProvider, stringComparer);
+       __ids.Construct(0, 0, hashProvider, stringComparer);
+       __trustedIds.Construct(0, 0, hashProvider, stringComparer);
+
+       __appId = _AppInfo::GetApplicationId();
+
+       return E_SUCCESS;
 }
 
+
 result
 _MessagePortProxy::RegisterMessagePort(const String& localPort,        bool isTrusted,
                                                                        const _IMessagePortListener& listener)
 {
-       SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.\n");
-
        SysLog(NID_IO, "Register a message port : [%ls:%ls]", __appId.GetPointer(), localPort.GetPointer());
 
        result r = E_SUCCESS;
        int ret = 0;
        bool contain = false;
-       String key = localPort;
+
+       unique_ptr<char[]> pLocal(_StringConverter::CopyToCharArrayN(localPort));
 
        if (!isTrusted)
        {
-               __listeners.ContainsKey(key, contain);
+               ret = messageport_register_local_port(pLocal.get(), OnMessageReceived);
+               SysTryReturnResult(NID_IO, ret >= 0, E_SYSTEM, "Failed to register the local message port. %d", ret);
+
+               __listeners.ContainsKey(localPort, contain);
 
                if (!contain)
                {
-                       __listeners.Add(key, const_cast<_IMessagePortListener*>(&listener));
-
+                       __listeners.Add(localPort, const_cast<_IMessagePortListener*>(&listener));
+                       __ids.Add(localPort, ret);
                }
                else
                {
-                       __listeners.SetValue(key, const_cast<_IMessagePortListener*>(&listener));
+                       __listeners.SetValue(localPort, const_cast<_IMessagePortListener*>(&listener));
+                       __ids.SetValue(localPort, ret);
                }
+
        }
        else
        {
-               __trustedListeners.ContainsKey(key, contain);
+               ret = messageport_register_trusted_local_port(pLocal.get(), OnTrustedMessageReceived);
+               SysTryReturnResult(NID_IO, ret >= 0, E_SYSTEM, "Failed to register the trusted local message port. %d", ret);
+
+               __trustedListeners.ContainsKey(localPort, contain);
 
                if (!contain)
                {
-                       __trustedListeners.Add(key, const_cast<_IMessagePortListener*>(&listener));
-
+                       __trustedListeners.Add(localPort, const_cast<_IMessagePortListener*>(&listener));
+                       __trustedIds.Add(localPort, ret);
                }
                else
                {
-                       __trustedListeners.SetValue(key, const_cast<_IMessagePortListener*>(&listener));
+                       __trustedListeners.SetValue(localPort, const_cast<_IMessagePortListener*>(&listener));
+                       __trustedIds.SetValue(localPort, ret);
                }
 
        }
 
-       unique_ptr<IPC::Message> pMsg(new (std::nothrow) MessagePortService_register(__appId, localPort, isTrusted, &ret));
-       SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       r = __pIpcClient->SendRequest(pMsg.get());
-       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to register a message port.", GetErrorMessage(r));
-       SysTryReturnResult(NID_IO, ret == E_SUCCESS,  ret, "Failed to register a message port.", GetErrorMessage(ret));
-
        return E_SUCCESS;
 }
 
@@ -152,41 +279,36 @@ _MessagePortProxy::RequestRemotePort(const AppId& remoteAppId,
                                                                        const String& remotePort,
                                                                        bool isTrusted)
 {
-       SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.\n");
-
        SysLog(NID_IO, "Request a remote message port [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
 
        result r = E_SUCCESS;
        int ret = 0;
+       bool exist = false;
 
-       if (isTrusted)
+       unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(remoteAppId));
+       unique_ptr<char[]> pPort(_StringConverter::CopyToCharArrayN(remotePort));
+
+       if (!isTrusted)
+       {
+               ret = messageport_check_remote_port(pAppId.get(), pPort.get(), &exist);
+       }
+       else
        {
-               package_manager_compare_result_type_e res;
+               ret = messageport_check_trusted_remote_port(pAppId.get(), pPort.get(), &exist);
+       }
 
-               unique_ptr<char[]> pLocal(_StringConverter::CopyToCharArrayN(__appId));
-               unique_ptr<char[]> pRemote(_StringConverter::CopyToCharArrayN(remoteAppId));
+       if (ret < 0)
+       {
+               r = ConvertToResult(ret);
 
-               if (package_manager_compare_app_cert_info(pLocal.get(), pRemote.get(), &res) == 0)
-               {
-                       if (res != PACAKGE_MANAGER_COMPARE_MATCH)
-                       {
-                               SysLogException(NID_IO, E_CERTIFICATE_VERIFICATION_FAILED, "[E_CERTIFICATE_VERIFICATION_FAILED] The target application is not signed with the same certificate.");
-                               return E_CERTIFICATE_VERIFICATION_FAILED;
-                       }
-               }
-               else
-               {
-                       SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to compare the cerificate infomation.");
-                       return E_SYSTEM;
-               }
-       }
+               SysTryReturnResult(NID_IO, r != E_CERTIFICATE_VERIFICATION_FAILED, E_CERTIFICATE_VERIFICATION_FAILED, "The target application is not signed with the same certificate.");
+
+               SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to request the remote message port.");
 
-       unique_ptr<IPC::Message> pMsg(new (std::nothrow) MessagePortService_requestRemotePort(remoteAppId, remotePort, isTrusted, &ret));
-       SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+               return r;
+       }
 
-       r = __pIpcClient->SendRequest(pMsg.get());
-       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to request a message port.", GetErrorMessage(r));
-       SysTryReturnResult(NID_IO, ret == E_SUCCESS,  ret, "Failed to request a message port.", GetErrorMessage(ret));
+       SysTryReturnResult(NID_IO, exist, E_OBJ_NOT_FOUND, "The remote message port is not found.");
 
        return E_SUCCESS;
 }
@@ -194,129 +316,96 @@ _MessagePortProxy::RequestRemotePort(const AppId& remoteAppId,
 result
 _MessagePortProxy::SendMessage(const AppId& remoteAppId, const String& remotePort, bool isTrusted, const HashMap* pMap)
 {
-       SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.\n");
-
        SysLog(NID_IO, "Send a unidirectional message to remote port [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
 
-       result r = E_SUCCESS;
        int ret = 0;
 
-       if (pMap != null)
+       // Convert Map to bundle
+       bundle* b = ConvertMapToBundleN(pMap);
+       SysTryReturnResult(NID_IO, b != null, E_SYSTEM, "Internal system errors.");
+
+       unique_ptr<char[]> pRemoteAppId(_StringConverter::CopyToCharArrayN(remoteAppId));
+       unique_ptr<char[]> pRemotePort(_StringConverter::CopyToCharArrayN(remotePort));
+
+       if (!isTrusted)
        {
-               unique_ptr<IPC::Message> pMsg(new (std::nothrow) MessagePortService_sendMessage(remoteAppId, remotePort, isTrusted, *pMap, &ret));
-               SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-               r = __pIpcClient->SendRequest(pMsg.get() );
+               ret = messageport_send_message(pRemoteAppId.get(), pRemotePort.get(), b);
+       }
+       else
+       {
+               ret = messageport_send_trusted_message(pRemoteAppId.get(), pRemotePort.get(), b);
        }
 
-       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Failed to send a message.", GetErrorMessage(r));
-       SysTryReturn(NID_IO, ret == E_SUCCESS, ret, ret, "[%s] Failed to send a message.", GetErrorMessage(ret));
-
-       return E_SUCCESS;
-}
+       bundle_free(b);
 
-result
-_MessagePortProxy::SendMessage(const String& localPort, bool isTrustedLocal, const AppId& remoteAppId, const String& remotePort, bool isTrustedRemote, const HashMap* pMap)
-{
-       SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.\n");
+       if (ret < 0)
+       {
+               result r = ConvertToResult(ret);
 
-       result r = E_SUCCESS;
-       int ret = 0;
+               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.");
 
-       SysLog(NID_IO, "Send a bidirectional message from [%ls:%ls] to [%ls:%ls]", __appId.GetPointer(), localPort.GetPointer(), remoteAppId.GetPointer(), remotePort.GetPointer());
+               SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to request the remote message port.");
 
-       if (pMap != null)
-       {
-               if (!isTrustedRemote)
-               {
-                       unique_ptr<IPC::Message> pMsg(new (std::nothrow) MessagePortService_sendBidirMessage(__appId, localPort, isTrustedLocal, remoteAppId, remotePort, *pMap, &ret));
-                       SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-                       r = __pIpcClient->SendRequest(pMsg.get());
-               }
-               else
-               {
-                       unique_ptr<IPC::Message> pMsg(new (std::nothrow) MessagePortService_sendTrustedBidirMessage(__appId, localPort, isTrustedLocal, remoteAppId, remotePort, *pMap, &ret));
-                       SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-                       r = __pIpcClient->SendRequest(pMsg.get());
-               }
+               return r;
        }
 
-       SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Failed to send a message.", GetErrorMessage(r));
-       SysTryReturn(NID_IO, ret == E_SUCCESS, ret, ret, "[%s] Failed to send a message.", GetErrorMessage(ret));
-
        return E_SUCCESS;
 }
 
-bool
-_MessagePortProxy::OnSendMessage(const String& localPort, bool isTrusted, const HashMap& map)
+result
+_MessagePortProxy::SendMessage(const String& localPort, bool isTrustedLocal, const AppId& remoteAppId, const String& remotePort, bool isTrustedRemote, const HashMap* pMap)
 {
-       SysLog(NID_IO, "A message is received to local port [%ls:%ls].", __appId.GetPointer(), localPort.GetPointer());
-
-       _IMessagePortListener* pListener = null;
+       SysLog(NID_IO, "Send a bidirectional message from [%ls:%ls] to [%ls:%ls]", __appId.GetPointer(), localPort.GetPointer(), remoteAppId.GetPointer(), remotePort.GetPointer());
 
-       String key = localPort;
+       result r = E_SUCCESS;
+       int id = 0;
 
-       if (!isTrusted)
+       if (!isTrustedLocal)
        {
-               __listeners.GetValue(key, pListener);
+               r = __ids.GetValue(localPort, id);
        }
        else
        {
-               __trustedListeners.GetValue(key, pListener);
+               r = __trustedIds.GetValue(localPort, id);
        }
 
-       HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
-       SysTryReturn(NID_IO, pMap != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Internal system errors.");
 
-       pMap->Construct(map);
+       // Convert Map to bundle
+       bundle* b = ConvertMapToBundleN(pMap);
+       SysTryReturnResult(NID_IO, b != null, E_SYSTEM, "Internal system errors.");
 
-       if (pListener)
-       {
-               pListener->OnMessageReceivedN(pMap);
+       unique_ptr<char[]> pRemoteAppId(_StringConverter::CopyToCharArrayN(remoteAppId));
+       unique_ptr<char[]> pRemotePort(_StringConverter::CopyToCharArrayN(remotePort));
 
-               return true;
+       int ret = 0;
+       if (!isTrustedRemote)
+       {
+               ret = messageport_send_bidirectional_message(id, pRemoteAppId.get(), pRemotePort.get(), b);
        }
        else
        {
-               delete pMap;
+               ret = messageport_send_bidirectional_trusted_message(id, pRemoteAppId.get(), pRemotePort.get(), b);
        }
 
-       return false;
-}
-
-bool
-_MessagePortProxy::OnSendBidirMessage(const String& localPort, bool isTrustedLocal, const AppId& remoteAppId, const String& remotePort, bool isTrustedRemote, const HashMap& map)
-{
-       SysLog(NID_IO, "A message is received to local port [%ls:%ls], from remote port [%ls:%ls].", __appId.GetPointer(), localPort.GetPointer(), remoteAppId.GetPointer(), remotePort.GetPointer());
-
-       _IMessagePortListener* pListener = null;
-
-       String key = localPort;
+       bundle_free(b);
 
-       if (!isTrustedLocal)
+       if (ret < 0)
        {
-               __listeners.GetValue(key, pListener);
-       }
-       else
-       {
-               __trustedListeners.GetValue(key, pListener);
-       }
+               result r = ConvertToResult(ret);
 
-       HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
-       SysTryReturn(NID_IO, pMap != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+               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.");
 
-       pMap->Construct(map);
+               SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to request the remote message port.");
 
-       if (pListener)
-       {
-               pListener->OnMessageReceivedN(remoteAppId, remotePort, isTrustedRemote, pMap);
-               return true;
-       }
-       else
-       {
-               delete pMap;
+               return r;
        }
 
-       return false;
+       return E_SUCCESS;
 }
 
 _MessagePortProxy*
@@ -339,4 +428,89 @@ _MessagePortProxy::GetProxy(void)
        return pProxy;
 }
 
+result
+_MessagePortProxy::ConvertToResult(int error)
+{
+       SysLog(NID_IO, "Native error = %d", error);
+
+       switch (error)
+       {
+               case MESSAGEPORT_ERROR_IO_ERROR:
+                       return E_SYSTEM;
+
+               case MESSAGEPORT_ERROR_OUT_OF_MEMORY:
+                       return E_OUT_OF_MEMORY;
+
+               case MESSAGEPORT_ERROR_INVALID_PARAMETER:
+                       return E_INVALID_ARG;
+
+               case MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND:
+                       return E_OBJ_NOT_FOUND;
+
+               case MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH:
+                       return E_CERTIFICATE_VERIFICATION_FAILED;
+
+               case MESSAGEPORT_ERROR_MAX_EXCEEDED:
+                       return E_MAX_EXCEEDED;
+
+               default:
+                       return E_SYSTEM;
+       }
+
+       return E_SYSTEM;
+}
+
+bundle*
+_MessagePortProxy::ConvertMapToBundleN(const HashMap* pMap)
+{
+       bundle *b = bundle_create();
+
+       std::unique_ptr<IMapEnumerator> pEnum (pMap->GetMapEnumeratorN());
+       while(pEnum->MoveNext() == E_SUCCESS)
+       {
+               const String* pKey = dynamic_cast<const String*>(pEnum->GetKey());
+               const Object* pValue = pEnum->GetValue();
+
+               if (pKey && pValue)
+               {
+                       unique_ptr<char[]> pKeyData(_StringConverter::CopyToCharArrayN(*pKey));
+
+                       if (typeid(*pValue) == typeid(const String)) // String
+                       {
+                               unique_ptr<char[]> pValueData(_StringConverter::CopyToCharArrayN(*(static_cast<const String*>(pValue))));
+
+                               //SysLog(NID_IO, "key: %s, value: %s", pKeyData.get(), pValueData.get());
+
+                               bundle_add(b, pKeyData.get(), pValueData.get());
+                       }
+                       else // ByteBuffer
+                       {
+                               if (typeid(*pValue) == typeid(const ByteBuffer)) // ByteBuffer
+                               {
+                                       const ByteBuffer* pBuffer = static_cast<const ByteBuffer*>(pValue);
+
+                                       // Add a byte data to bundle
+                                       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");
+
+                                       return null;
+                               }
+                       }
+               }
+               else
+               {
+                       SysLog(NID_IO, "Not supported");
+
+                       return null;
+               }
+       }
+
+       return b;
+}
+
 }}
index a2e761a..ddaaad7 100644 (file)
  * @brief      This is the implementation file for _MmcStorageManagerImpl class.
  */
 
-#include <limits.h>
 #include <unique_ptr.h>
-#include <new>
 
 #include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
 #include <FBase_NativeError.h>
-#include <FIo_MmcStorageManagerImpl.h>
+#include <FIoIMmcStorageMountListener.h>
+#include <FIoIMmcStorageFormatListener.h>
 
+#include "FIo_MmcStorageManagerImpl.h"
 #include "FIo_MmcStorageManagerProxy.h"
 
+using namespace std;
+
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
 
 namespace Tizen { namespace Io
 {
 
+static const int MOUNT_TYPE = 0;
+static const int UNMOUNT_TYPE = 1;
+
+class _MountEventArg
+       : public IEventArg
+{
+public:
+       _MountEventArg(int type, result r)
+               : __type(type)
+               , __r(r)
+       {
+       }
+       int __type;
+       result __r;
+};
+
+class _FormatEventArg
+       : public IEventArg
+{
+public:
+       _FormatEventArg(result r)
+               : __r(r)
+       {
+       }
+       result __r;
+};
+
+class _MountEvent
+       : public Event
+{
+protected:
+       virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
+       {
+               const _MountEventArg* pArg = dynamic_cast<const _MountEventArg*>(&arg);
+               if (pArg != null)
+               {
+                       IMmcStorageMountListener* pListener = dynamic_cast<IMmcStorageMountListener*> (&listener);
+                       if (pListener != null)
+                       {
+                               if (pArg->__type == MOUNT_TYPE) // Mount
+                               {
+                                       pListener->OnMmcStorageMounted(pArg->__r);
+                               }
+                               else    // Unmount
+                               {
+                                       pListener->OnMmcStorageUnmounted(pArg->__r);
+                               }
+                       }
+               }
+       }
+
+};
+
+class _FormatEvent
+       : public Event
+{
+protected:
+       virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
+       {
+               IMmcStorageFormatListener* pListener = dynamic_cast<IMmcStorageFormatListener*> (&listener);
+               if (pListener != null)
+               {
+                       const _FormatEventArg* pArg = dynamic_cast<const _FormatEventArg*>(&arg);
+                       if (pArg != null)
+                       {
+                               pListener->OnMmcStorageFormatted(pArg->__r);
+                       }
+
+               }
+       }
+
+};
+
 _MmcStorageManagerImpl::_MmcStorageManagerImpl(void)
        : __pMmcStorageManagerProxy(null)
+       , __pMountEvent(null)
+       , __pFormatEvent(null)
 {
 }
 
 _MmcStorageManagerImpl::~_MmcStorageManagerImpl(void)
 {
+       delete __pMountEvent;
+       delete __pFormatEvent;
 }
 
 result
@@ -50,14 +131,23 @@ _MmcStorageManagerImpl::Construct(void)
 {
        result r = E_SUCCESS;
 
-       std::unique_ptr<_MmcStorageManagerProxy> pMmcStorageManagerProxy(new (std::nothrow) _MmcStorageManagerProxy);
+       unique_ptr<_MmcStorageManagerProxy> pMmcStorageManagerProxy(new (std::nothrow) _MmcStorageManagerProxy);
        SysTryReturnResult(NID_IO, pMmcStorageManagerProxy != null, E_OUT_OF_MEMORY, "The memory is insufficient");
 
        r = pMmcStorageManagerProxy->Construct(this);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] __pMmcStorageManagerProxy->Construct() failed.", GetErrorMessage(r));
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "__pMmcStorageManagerProxy->Construct() failed.");
+
+       unique_ptr<_MountEvent> pMountEvent(new (std::nothrow) _MountEvent);
+       SysTryReturnResult(NID_IO, pMountEvent != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       unique_ptr<_FormatEvent> pFormatEvent(new (std::nothrow) _FormatEvent);
+       SysTryReturnResult(NID_IO, pFormatEvent != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
        __pMmcStorageManagerProxy = pMmcStorageManagerProxy.release();
 
+       __pMountEvent = pMountEvent.release();
+       __pFormatEvent = pFormatEvent.release();
+
        return E_SUCCESS;
 }
 
@@ -67,7 +157,7 @@ _MmcStorageManagerImpl::GetInstance(void)
        static _MmcStorageManagerImpl* pImpl = null;
        if (pImpl == null)
        {
-               std::unique_ptr<_MmcStorageManagerImpl> p(new (std::nothrow) _MmcStorageManagerImpl);
+               unique_ptr<_MmcStorageManagerImpl> p(new (std::nothrow) _MmcStorageManagerImpl);
                SysTryReturn(NID_IO, p != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                result r = p->Construct();
@@ -101,105 +191,55 @@ _MmcStorageManagerImpl::Format(void)
 result
 _MmcStorageManagerImpl::AddMmcStorageMountListener(IMmcStorageMountListener& listener)
 {
-       result r = __pMmcMountListener.Add(&listener);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return E_SUCCESS;
+       return __pMountEvent->AddListener(listener);
 }
 
 result
 _MmcStorageManagerImpl::RemoveMmcStorageMountListener(IMmcStorageMountListener& listener)
 {
-       result r = __pMmcMountListener.Remove(&listener);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return E_SUCCESS;
+       return __pMountEvent->RemoveListener(listener);
 }
 
 result
 _MmcStorageManagerImpl::AddMmcStorageFormatListener(IMmcStorageFormatListener& listener)
 {
-       result r = __pMmcFormatListener.Add(&listener);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return E_SUCCESS;
+       return __pFormatEvent->AddListener(listener);
 }
 
 result
 _MmcStorageManagerImpl::RemoveMmcStorageFormatListener(IMmcStorageFormatListener& listener)
 {
-       result r = E_SUCCESS;
-
-       r = __pMmcFormatListener.Remove(&listener);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return E_SUCCESS;
+       return __pFormatEvent->RemoveListener(listener);
 }
 
-result
+void
 _MmcStorageManagerImpl::OnMmcMountResponseReceived(result r)
 {
-       std::unique_ptr< IEnumeratorT< IMmcStorageMountListener* > >
-               pEnum(__pMmcMountListener.GetEnumeratorN());
-       if (pEnum.get())
+       _MountEventArg* pEventArg= new (std::nothrow) _MountEventArg(MOUNT_TYPE, r);
+       if(pEventArg != null)
        {
-               while (pEnum->MoveNext() == E_SUCCESS)
-               {
-                       IMmcStorageMountListener* pListener = null;
-                       pEnum->GetCurrent(pListener);
-                       if (pListener != null)
-                       {
-                               SysLog(NID_IO, "Final Mount() response sent to Application : [%s]", GetErrorMessage(r));
-                               pListener->OnMmcStorageMounted(r);
-                       }
-               }
+               __pMountEvent->Fire(*pEventArg);
        }
-
-       return E_SUCCESS;
 }
 
-result
+void
 _MmcStorageManagerImpl::OnMmcUnmountResponseReceived(result r)
 {
-       std::unique_ptr< IEnumeratorT< IMmcStorageMountListener* > >
-               pEnum(__pMmcMountListener.GetEnumeratorN());
-       if (pEnum.get())
+       _MountEventArg* pEventArg= new (std::nothrow) _MountEventArg(UNMOUNT_TYPE, r);
+       if(pEventArg != null)
        {
-               while (pEnum->MoveNext() == E_SUCCESS)
-               {
-                       IMmcStorageMountListener* pListener = null;
-                       pEnum->GetCurrent(pListener);
-                       if (pListener != null)
-                       {
-                               SysLog(NID_IO, "Final Unmount() response sent to Application : [%s]", GetErrorMessage(r));
-                               pListener->OnMmcStorageUnmounted(r);
-                       }
-               }
+               __pMountEvent->Fire(*pEventArg);
        }
-
-       return E_SUCCESS;
 }
 
-result
+void
 _MmcStorageManagerImpl::OnMmcFormatResponseReceived(result r)
 {
-       std::unique_ptr<IEnumeratorT< IMmcStorageFormatListener* > >
-               pEnum(__pMmcFormatListener.GetEnumeratorN());
-       if (pEnum.get())
+       _FormatEventArg* pEventArg= new (std::nothrow) _FormatEventArg(r);
+       if(pEventArg != null)
        {
-               while (pEnum->MoveNext() == E_SUCCESS)
-               {
-                       IMmcStorageFormatListener* pListener = null;
-                       pEnum->GetCurrent(pListener);
-                       if (pListener != null)
-                       {
-                               SysLog(NID_IO, "Final Format() response sent to Application : [%s]", GetErrorMessage(r));
-                               pListener->OnMmcStorageFormatted(r);
-                       }
-               }
+               __pFormatEvent->Fire(*pEventArg);
        }
-
-       return E_SUCCESS;
 }
 
 }} // Tizen::Io
index b1d9f73..f3b43b4 100644 (file)
@@ -20,8 +20,7 @@
  * @brief      This is the implementation for the _MmcStorageManagerProxy class.
  */
 
-#include <new>
-#include <memory>
+#include <unique_ptr.h>
 
 #include <FBaseErrors.h>
 #include <FBaseSysLog.h>
 #include "FIo_MmcStorageManagerProxy.h"
 #include "FIo_MmcStorageManagerIpcMessages.h"
 
+using namespace std;
+
 using namespace Tizen::Base;
 
 namespace Tizen { namespace Io
 {
 
-_IMmcStorageServiceEventListener* _MmcStorageManagerProxy::__pImpl = null;
-
 _MmcStorageManagerProxy::_MmcStorageManagerProxy(void)
        : __pIpcClient(null)
 {
@@ -49,15 +48,16 @@ _MmcStorageManagerProxy::~_MmcStorageManagerProxy(void)
 }
 
 result
-_MmcStorageManagerProxy::Construct(_IMmcStorageServiceEventListener* pImpl)
+_MmcStorageManagerProxy::Construct(_IMmcStorageServiceEventListener* pListener)
 {
-       __pIpcClient = new (std::nothrow) _IpcClient();
-       SysTryReturnResult(NID_IO, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
+       unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient);
+       SysTryReturnResult(NID_IO, pIpcClient != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
-       result r = __pIpcClient->Construct("osp.io.ipcserver.mmcstoragemanager", this);
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] _IpcClient::Construct failed.", GetErrorMessage(r));
+       result r = pIpcClient->Construct("osp.io.ipcserver.mmcstoragemanager", this);
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to connect to IPC server.");
 
-       __pImpl = pImpl;
+       __pIpcClient = pIpcClient.release();
+       __pListener = pListener;
 
        return E_SUCCESS;
 }
@@ -65,45 +65,51 @@ _MmcStorageManagerProxy::Construct(_IMmcStorageServiceEventListener* pImpl)
 result
 _MmcStorageManagerProxy::Mount(void)
 {
-       SysTryReturnResult(NID_IO, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
+       SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
 
        result response = E_SUCCESS;
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Mount(&response));
+       unique_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Mount(&response));
+       SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
        result r = __pIpcClient->SendRequest(pMsg.get());
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "SendRequest is failed.");
 
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] SendRequest is failed.", GetErrorMessage(r));
+       SysLog(NID_IO, "Received sync mount response msg from server is: [%s]", GetErrorMessage(response));
 
-       SysLog(NID_IO, "Received sync mount response msg from server is: [%s]\n", GetErrorMessage(response));
        return response;
 }
 
 result
 _MmcStorageManagerProxy::Unmount(void)
 {
-       SysTryReturnResult(NID_IO, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
+       SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
 
        result response = E_SUCCESS;
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Unmount(&response));
+       unique_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Unmount(&response));
+       SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
        result r = __pIpcClient->SendRequest(pMsg.get());
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "SendRequest is failed.");
 
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] SendRequest is failed.", GetErrorMessage(r));
+       SysLog(NID_IO, "Received sync unmount response msg from server is: [%s]", GetErrorMessage(response));
 
-       SysLog(NID_IO, "Received sync unmount response msg from server is: [%s]\n", GetErrorMessage(response));
        return response;
 }
 
 result
 _MmcStorageManagerProxy::Format(void)
 {
-       SysTryReturnResult(NID_IO, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
+       SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
 
        result response = E_SUCCESS;
-       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Format(&response));
+       unique_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Format(&response));
+       SysTryReturnResult(NID_IO, pMsg != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
        result r = __pIpcClient->SendRequest(pMsg.get());
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "SendRequest is failed.");
 
-       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] SendRequest is failed.", GetErrorMessage(r));
+       SysLog(NID_IO, "Received sync format response msg from server is: [%s]", GetErrorMessage(response));
 
-       SysLog(NID_IO, "Received sync format response msg from server is: [%s]\n", GetErrorMessage(response));
        return response;
 }
 
@@ -120,22 +126,25 @@ _MmcStorageManagerProxy::OnIpcResponseReceived(Tizen::Io::_IpcClient& client, co
 void
 _MmcStorageManagerProxy::MountResponseReceived(result r)
 {
-       SysLog(NID_IO, "Received Async mount response msg from server is : [%s]\n", GetErrorMessage(r));
-       __pImpl->OnMmcMountResponseReceived(r);
+       SysLog(NID_IO, "Received Async mount response msg from server is : [%s]", GetErrorMessage(r));
+
+       __pListener->OnMmcMountResponseReceived(r);
 }
 
 void
 _MmcStorageManagerProxy::UnmountResponseReceived(result r)
 {
-       SysLog(NID_IO, "Received Async unmount response msg from server is : [%s]\n", GetErrorMessage(r));
-       __pImpl->OnMmcUnmountResponseReceived(r);
+       SysLog(NID_IO, "Received Async unmount response msg from server is : [%s]", GetErrorMessage(r));
+
+       __pListener->OnMmcUnmountResponseReceived(r);
 }
 
 void
 _MmcStorageManagerProxy::FormatResponseReceived(result r)
 {
-       SysLog(NID_IO, "Received Async format response msg from server is : [%s]\n", GetErrorMessage(r));
-       __pImpl->OnMmcFormatResponseReceived(r);
+       SysLog(NID_IO, "Received Async format response msg from server is : [%s]", GetErrorMessage(r));
+
+       __pListener->OnMmcFormatResponseReceived(r);
 }
 
 } } // Tizen::Io
index d86808f..26539f9 100644 (file)
@@ -51,7 +51,7 @@ _NormalRegistry::_NormalRegistry(void)
 
 _NormalRegistry::~_NormalRegistry(void)
 {
-       if (_write == true && _FileImpl::IsFileExist(_regPath) == true)
+       if (_write == true && _FileImpl::IsFileExist(_regPath) == true && _update == true)
        {
                this->Flush();
        }
index 28b443a..5ca9166 100644 (file)
@@ -88,13 +88,16 @@ _RegistryCore::_RegistryCore(void)
        , _write(false)
        , _truncate(false)
        , _append(false)
+       , _update(false)
        , _pBuffer(null)
        , _length(0)
+       , __pFileImpl(null)
 {
 }
 
 _RegistryCore::~_RegistryCore(void)
 {
+       delete __pFileImpl;
 }
 
 bool
@@ -370,6 +373,8 @@ _RegistryCore::Load(const String& regPath, const char* pOpenMode)
                }
        }
 
+       __pFileImpl = pFileImpl.release();
+
        return r;
 }
 
@@ -417,6 +422,7 @@ _RegistryCore::AddSection(const String& sectionName)
        r = _sectionList.Add(*(pRegSection.release()));
        SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
 
+       _update = true;
        return E_SUCCESS;
 }
 
@@ -462,6 +468,7 @@ _RegistryCore::RemoveSection(const String& sectionName)
        r = _sectionList.Remove(*pRegSection, true);
        SysTryReturnResult(NID_IO, !IsFailed(r), E_IO, "system error");
 
+       _update = true;
        return E_SUCCESS;
 }
 
@@ -804,6 +811,7 @@ _RegistryCore::AddValue(const String& sectionName, const String& entryName, cons
        r = pRegSection->__entryList.Add(*(pRegEntry.release()));
        SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
 
+       _update = true;
        return E_SUCCESS;
 }
 
@@ -891,6 +899,7 @@ _RegistryCore::SetValue(const String& sectionName, const String& entryName, cons
        r = pRegSection->__entryList.SetAt(*pRegEntry, entryIndex);
        SysTryReturnResult(NID_IO, !IsFailed(r), E_IO, "system error");
 
+       _update = true;
        return E_SUCCESS;
 }
 
@@ -962,6 +971,7 @@ _RegistryCore::RemoveValue(const String& sectionName, const String& entryName)
        r = pRegSection->__entryList.Remove(*pRegEntry, true);
        SysTryReturnResult(NID_IO, !IsFailed(r), E_IO, "system error");
 
+       _update = true;
        return E_SUCCESS;
 }
 
@@ -1787,8 +1797,25 @@ _RegistryCore::ConvertToSecureRegistry(const String& plainRegPath, const String&
                SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
        }
 
+       r = pSecureReg->Flush();
+       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
        return E_SUCCESS;
 }
 
+FileLock*
+_RegistryCore::LockN(FileLockType lockType)
+{
+       SysAssertf(_constructed == true && __pFileImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileImpl->LockN(lockType);
+}
+
+FileLock*
+_RegistryCore::TryToLockN(FileLockType lockType)
+{
+       SysAssertf(_constructed == true && __pFileImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pFileImpl->TryToLockN(lockType);
+}
+
 }} // Tizen::Io
 
index be71c3f..50c9590 100644 (file)
@@ -324,5 +324,19 @@ _RegistryImpl::GetInstance(const Registry& registry)
        return registry.__pRegistryImpl;
 }
 
+FileLock*
+_RegistryImpl::LockN(FileLockType lockType)
+{
+       SysAssertf(__pRegistryCore != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pRegistryCore->LockN(lockType);
+}
+
+FileLock*
+_RegistryImpl::TryToLockN(FileLockType lockType)
+{
+       SysAssertf(__pRegistryCore != null, "Not yet constructed. Construct() should be called before use.\n");
+       return __pRegistryCore->TryToLockN(lockType);
+}
+
 }} // Tizen::Io
 
index 92d19ca..00df8cf 100644 (file)
@@ -143,7 +143,8 @@ _RemoteMessagePortImpl::GetMessagePort(const AppId& remoteAppId, const String& r
        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_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();
index ddf0a69..eea2dfc 100644 (file)
@@ -116,6 +116,7 @@ _SecureIoUtil::GetSecureKeyN(const ByteBuffer* pUserKey)
 
        }
 
+
        pKey->Flip();
 
        SetLastResult(r);
index 321dc86..5baf8f1 100644 (file)
@@ -84,7 +84,7 @@ _SecureRegistry::_SecureRegistry(void)
 
 _SecureRegistry::~_SecureRegistry(void)
 {
-       if (_write == true && _FileImpl::IsFileExist(_regPath) == true)
+       if (_write == true && _FileImpl::IsFileExist(_regPath) == true && _update == true)
        {
                this->Flush();
        }
index cb2547d..6f798de 100644 (file)
@@ -55,12 +55,7 @@ _ServerChannelImpl::~_ServerChannelImpl(void)
 result
 _ServerChannelImpl::Construct(ServerChannel* pServerChannel, const Tizen::Base::String& channelName)
 {
-       const String& appId = _AppInfo::GetAppId();
-       const String& appExecutableName = _AppInfo::GetAppExecutableName();
-
-       String channelId(appId);
-       channelId.Append(L'.');
-       channelId.Append(appExecutableName);
+       String channelId(_AppInfo::GetApplicationId());
 
        if (!channelName.IsEmpty())
        {
diff --git a/src/io/FIo_ZipFileArchive.cpp b/src/io/FIo_ZipFileArchive.cpp
new file mode 100644 (file)
index 0000000..43674bf
--- /dev/null
@@ -0,0 +1,289 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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       FIo_ZipFileArchive.cpp
+ * @brief      This is the implementation file for _ZipFileArchive class.
+ */
+
+#include <new>
+#include <errno.h>
+#include <unistd.h>
+#include <unzip.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unique_ptr.h>
+
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FIo.h>
+
+#include <FBase_StringConverter.h>
+#include <FBase_NativeError.h>
+#include <FIo_DirEnumeratorImpl.h>
+#include <FApp_AppInfo.h>
+
+#include "FIo_ZipFileArchive.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::App;
+
+namespace Tizen { namespace Io
+{
+
+static const int MAX_WRITE_BUF_LEN = 4096;
+const char _ZIP_ARCHIVE_DIR[] = "/tmp/osp/ZipArchive/\0";
+
+struct CloseUnzipFile
+{
+       void operator ()(void* p)
+       {
+               if (p != null)
+               {
+                       unzClose(p);
+               }
+       }
+};
+
+struct CloseFile
+{
+       void operator ()(FILE* p)
+       {
+               if (p != null)
+               {
+                       fclose(p);
+               }
+       }
+};
+
+result
+_ZipFileArchive::CreateDirectories(char* pFilePath)
+{
+       char* pPos = pFilePath;
+       while ((pPos = strchr(pPos + 1, '/')) != null)
+       {
+               *pPos = '\0';
+               if (access(pFilePath, F_OK) != 0)
+               {
+                       int ret = mkdir(pFilePath, S_IRUSR | S_IWUSR | S_IXUSR);
+                       if (ret == -1)
+                       {
+                               result r = __ConvertNativeErrorToResult(errno);
+                               SysTryReturnResult(NID_IO, r == E_FILE_ALREADY_EXIST, r, "Failed to create directory (%s)", pFilePath);
+                       }
+               }
+               *pPos = '/';
+       }
+
+       return E_SUCCESS;
+}
+
+_ZipFileArchive::_ZipFileArchive(void)
+       : __pUnZipArchive(null)
+{
+}
+
+_ZipFileArchive::~_ZipFileArchive(void)
+{
+}
+
+result
+_ZipFileArchive::Construct(const String& zipFilePath)
+{
+       SysAssertf(__pUnZipArchive == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysTryReturnResult(NID_IO, zipFilePath.GetLength() > 0 && zipFilePath.GetLength() <= PATH_MAX, E_INVALID_ARG,
+                       "Given zipFilePath length is invalid.");
+
+       std::unique_ptr< char[] > pZipFilePath(_StringConverter::CopyToCharArrayN(zipFilePath));
+       SysTryReturnResult(NID_IO, pZipFilePath != null, E_INVALID_ARG, "Invalid zip file archive path.");
+
+       std::unique_ptr< void, CloseUnzipFile > pUnzipFile(unzOpen(pZipFilePath.get()));
+       SysTryReturnResult(NID_IO, pUnzipFile != null, E_IO, "Failed to open [%s].", pZipFilePath.get());
+
+       __pUnZipArchive = pUnzipFile.release();
+
+       return E_SUCCESS;
+}
+
+File*
+_ZipFileArchive::GetFileN(const String& relativePath)
+{
+       SysLog(NID_IO, "Enter");
+
+       SysAssertf(__pUnZipArchive != null, "Not yet constructed. Construct() should be called before use.\n");
+       SysTryReturn(NID_IO, relativePath.GetLength() > 0 && relativePath.GetLength() <= PATH_MAX, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input path.");
+       SysTryReturn(NID_IO, relativePath.StartsWith(L"/", 0) == false || relativePath.EndsWith(L"/") == false, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input path.");
+
+       char unzFileEntryName[PATH_MAX + 1] = { 0, };
+       unz_file_info unzfileInfo = { 0, };
+       bool fileEntryFound = false;
+       String tempFilePath;
+       result r = E_SUCCESS;
+
+       int err = unzGoToFirstFile(__pUnZipArchive);
+       SysTryReturn(NID_IO, err == UNZ_OK, null, E_IO, "[E_IO] Failed to get the first file entry in the zip file.");
+
+       do
+       {
+               err = unzGetCurrentFileInfo(__pUnZipArchive, &unzfileInfo, unzFileEntryName, PATH_MAX, null, 0, null, 0);               
+               SysTryReturn(NID_IO, err == UNZ_OK, null, E_IO, "[E_IO] Failed to get file entry info from the zip file.");
+
+               String filePath(unzFileEntryName);
+               if (filePath.StartsWith(relativePath, 0))
+               {
+                       fileEntryFound = true;
+                       break;
+               }
+               err = unzGoToNextFile(__pUnZipArchive);
+               SysTryReturn(NID_IO,
+                               (err == UNZ_OK) || (err == UNZ_END_OF_LIST_OF_FILE), null, E_IO, "[E_IO] Failed to get the next entry in the zip file.");
+
+       } while (err != UNZ_END_OF_LIST_OF_FILE);
+       SysTryReturn(NID_IO, fileEntryFound == true, null, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] The specified file is not found in the archive.");
+
+       tempFilePath.Append(String(_ZIP_ARCHIVE_DIR) + _AppInfo::GetApplicationId());
+       tempFilePath.Append(String(L"/") + String(unzFileEntryName));
+       r = _ZipFileArchive::UnzipCurrentFileTo(__pUnZipArchive, tempFilePath);
+       SysTryReturn(NID_IO, !IsFailed(r), null, r, "[%s] File could not be decompressed.", GetErrorMessage(r));
+
+       std::unique_ptr<File> pFile(new (std::nothrow) File());
+       SysTryReturn(NID_IO, pFile != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pFile->Construct(tempFilePath, L"r");
+       SysTryReturn(NID_IO, !IsFailed(r), null, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return pFile.release();
+}
+
+DirEnumerator* 
+_ZipFileArchive::GetDirEnumeratorN(const String& subDirName)
+{
+       SysAssertf(__pUnZipArchive != null, "Not yet constructed. Construct() should be called before use.\n");
+       SysTryReturn(NID_IO, subDirName.GetLength() > 0 && subDirName.GetLength() <= PATH_MAX, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input path.");
+       SysTryReturn(NID_IO, subDirName.StartsWith(L"/", 0) == false, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input path.");
+
+       char unzFileEntryName[PATH_MAX + 1] = {0};
+       unz_file_info unzfileInfo = {0};
+       bool dirEntryFound = false;
+       String relativePath = subDirName;
+       String tempRootDirPath(L"");
+       result r = E_SUCCESS;
+
+       if (relativePath.EndsWith(L'/') == false)
+       {
+               relativePath.Append(L'/');
+       }
+
+       int err = unzGoToFirstFile(__pUnZipArchive);
+       SysTryReturn(NID_IO, err == UNZ_OK, null, E_IO, "[E_IO] Failed to get the first file entry in the zip file.");
+
+       do
+       {
+               err = unzGetCurrentFileInfo(__pUnZipArchive, &unzfileInfo, unzFileEntryName, PATH_MAX, null, 0, null, 0);               
+               SysTryReturn(NID_IO, err == UNZ_OK, null, E_IO, "[E_IO] Failed to get file entry info from the zip file.");
+
+               String filePath(unzFileEntryName);
+               if (filePath.EndsWith(relativePath))
+               {
+                       dirEntryFound = true;
+                       tempRootDirPath.Append(unzFileEntryName);
+               }
+
+               if (dirEntryFound == true)
+               {
+                       String tempPath;
+                       tempPath.Append(unzFileEntryName);
+                       if (tempPath.StartsWith(tempRootDirPath, 0) == true)
+                       {
+                               String absoluteDirPath(String(_ZIP_ARCHIVE_DIR) + _AppInfo::GetApplicationId());
+                               absoluteDirPath.Append(String(L"/") + String(unzFileEntryName));
+                               r = _ZipFileArchive::UnzipCurrentFileTo(__pUnZipArchive, absoluteDirPath);
+                               SysTryReturn(NID_IO, !IsFailed(r), null, r, "[%s] Propogating to caller...", GetErrorMessage(r));                                       
+                       }
+               }
+               err = unzGoToNextFile(__pUnZipArchive);
+               SysTryReturn(NID_IO,
+                               (err == UNZ_OK) || (err == UNZ_END_OF_LIST_OF_FILE), null, E_IO, "[E_IO] Failed to get the next entry in the zip file.");
+
+       } while (err != UNZ_END_OF_LIST_OF_FILE);
+
+       SysTryReturn(NID_IO, dirEntryFound == true, null, E_IO, "[E_IO] The specified subDirName is not found in the archive.");
+
+       String absoluteDirPath(String(_ZIP_ARCHIVE_DIR) + _AppInfo::GetApplicationId());
+       absoluteDirPath.Append(String(L"/") + tempRootDirPath);
+
+       unique_ptr<DirEnumerator> pDirEnum(_DirEnumeratorImpl::CreateDirEnumeratorInstanceN(absoluteDirPath));
+       SysTryReturn(NID_IO, pDirEnum != null, null, E_OUT_OF_MEMORY,
+                          "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       SysLog(NID_IO, "Exit");
+
+       return pDirEnum.release();
+}
+
+result
+_ZipFileArchive::UnzipCurrentFileTo(void* pUnZipArchive, const String& filePath)
+{
+       SysLog(NID_IO, "Enter with filePath(%ls))", filePath.GetPointer());
+
+       std::unique_ptr< char[] > pOutPath(_StringConverter::CopyToCharArrayN(filePath));
+       SysTryReturn(NID_IO, pOutPath != null, GetLastResult(), GetLastResult(), "[%s] Failed to create Directory [%s]", GetErrorMessage(GetLastResult()), pOutPath.get());
+       
+       result r = _ZipFileArchive::CreateDirectories(pOutPath.get());
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to create Directory [%s]", pOutPath.get());
+
+       if(pOutPath[strlen(pOutPath.get()) - 1] != '/')
+       {
+               std::unique_ptr< FILE, CloseFile > pFile(fopen(pOutPath.get(), "w"));
+               r = __ConvertNativeErrorToResult(errno);
+               SysTryReturnResult(NID_IO, pFile != null, r, "Failed to open file [name: %s, errorno: %d].", pOutPath.get(), errno);
+
+               int err = unzOpenCurrentFile(pUnZipArchive);
+               SysTryReturnResult(NID_IO, err == UNZ_OK, E_IO, "Failed to open current zip file.");
+
+               int writeCnt = 0;
+               int readLen = 1;
+               char writeBuf[MAX_WRITE_BUF_LEN] = {0};
+               while (readLen > 0)
+               {
+                       readLen = unzReadCurrentFile(pUnZipArchive, writeBuf, sizeof(writeBuf));
+                       r = (readLen < 0) ? E_IO : E_SUCCESS;
+                       SysTryCatch(NID_IO, r == E_SUCCESS, unzCloseCurrentFile(pUnZipArchive), r,
+                                                       "[%s] Failed to read from zip file (%s).", GetErrorMessage(E_IO), pOutPath.get());
+
+                       if (readLen > 0)
+                       {
+                               writeCnt = fwrite(writeBuf, 1, readLen, pFile.get());
+                               if (writeCnt < readLen)
+                               {
+                                       int ret = ferror(pFile.get());
+                                       r = __ConvertNativeErrorToResult(ret);
+                                       SysTryCatch(NID_IO, ret != 0, unzCloseCurrentFile(pUnZipArchive), r,
+                                                               "[%s] Failed to perform write operation.", GetErrorMessage(r));
+                               }
+                       }
+               }
+
+               unzCloseCurrentFile(pUnZipArchive);
+       }
+
+CATCH:
+       return r;
+}
+
+}}
diff --git a/src/io/inc/FIo_ChannelCAppStub.h b/src/io/inc/FIo_ChannelCAppStub.h
deleted file mode 100644 (file)
index 585c6ed..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// 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       FIo_ChannelCAppStub.h
- * @brief      This is the header file for the _ChannelCAppStub class.
- *
- * This file contains the declarations of _ChannelCAppStub.
- */
-
-#ifndef _FIO_INTERNAL_CHANNEL_CAPP_STUB_H_
-#define _FIO_INTERNAL_CHANNEL_CAPP_STUB_H_
-
-#include <string>
-#include <pthread.h>
-#include <map>
-#include <glib.h>
-
-#include <FOspConfig.h>
-#include <FBaseObject.h>
-#include <FBaseString.h>
-#include <FBaseResult.h>
-#include <FBaseColArrayList.h>
-#include <FIo_ChannelService.h>
-
-namespace Tizen { namespace Base { namespace Runtime
-{
-class _EventDispatcher;
-}}}
-
-namespace Tizen { namespace Io
-{
-
-class _IIpcServerEventListener;
-class _ChannelServiceStub;
-
-/**
- * @class _ChannelCAppStub
- * @brief This class provides methods to handle c-application request messages.
- * @since 2.1
- *
- */
-class _OSP_EXPORT_ _ChannelCAppStub
-       : public Tizen::Base::Object
-{
-public:
-       /**
-        * This is the default constructor for this class.
-        * @since 2.1
-        */
-       _ChannelCAppStub(void);
-
-       /**
-        * This is the destructor for this class.
-        * @since 2.1
-        */
-       virtual ~_ChannelCAppStub(void);
-
-       result Construct(void);
-
-       void SetChannelService(_ChannelService& service);
-
-       static bool SendResponse(int requestId, void* pGIOChannel, const Tizen::Base::Collection::ArrayList& args);
-
-private:
-       _ChannelCAppStub(const _ChannelCAppStub& rhs);
-
-       _ChannelCAppStub& operator =(const _ChannelCAppStub& rhs);
-
-       static gboolean OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpointer data);
-
-       static gboolean OnReadMessage(GIOChannel* source, GIOCondition condition, gpointer data);
-
-       gboolean HandleReceivedMessage(GIOChannel* source, GIOCondition condition, gpointer data);
-
-       _ChannelService* __pChannelService;
-
-       struct  _ClientInfo;
-
-       struct  _ChannelInfo
-       {
-               _ChannelInfo(void);
-               ~_ChannelInfo(void);
-
-               struct _ClientInfo* pClientInfo;
-               GIOChannel* pGIOChannel;
-               GSource* pGSource;
-               bool destroySource;
-       };
-
-       struct  _ClientInfo
-       {
-               _ClientInfo(void);
-               ~_ClientInfo(void);
-
-               int clientId;                              /**< the client id */
-               _ChannelCAppStub* pChannelStub;                    /**< the pointer to an _ChannelCAppStub */
-               std::vector <struct _ChannelInfo*> channels;   /**< the set of channels associated with a client */
-               Tizen::Base::String appId;
-               //Tizen::Base::String appExecutableName;
-       };
-
-       GMainContext* __pGMainContext;
-
-       GSource* __pConnectGSource;
-
-       std::map <int, _ClientInfo*> __clients;   // pid of client is used for key
-
-}; // _ChannelCAppStub
-
-}} // Tizen::Io
-
-#endif // _FIO_INTERNAL_CHANNEL_CAPP_STUB_H_
-
diff --git a/src/io/inc/FIo_ChannelService.h b/src/io/inc/FIo_ChannelService.h
deleted file mode 100644 (file)
index d04cf30..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-//
-// 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       FIo_ChannelService.h
- * @brief      This is the header file for the _ChannelService class.
- *
- * This file contains the declarations of _ChannelService.
- */
-
-#ifndef _FIO_INTERNAL_CHANNEL_SERVICE_H_
-#define _FIO_INTERNAL_CHANNEL_SERVICE_H_
-
-#include <vector>
-
-#include <FBaseResult.h>
-#include <FBaseObject.h>
-#include <FBaseColIList.h>
-#include <FBaseColHashMapT.h>
-#include <FOspConfig.h>
-#include "FIo_IChannelService.h"
-#include "FIo_IChannelServiceEventListener.h"
-
-namespace IPC
-{
-class Message;
-}
-
-namespace Tizen { namespace Io
-{
-class _IChannelServiceStub;
-class _ChannelCAppStub;
-
-enum _ChannelType
-{
-       OSPAPP_CHANNEL = 0,
-       CAPP_CHANNEL,
-       WEBAPP_CHANNEL
-};
-
-class _OSP_EXPORT_ _ChannelService
-       : public Tizen::Base::Object
-       , public Tizen::Io::_IChannelService
-{
-public:
-       _ChannelService(void);
-
-       virtual ~_ChannelService(void);
-
-       virtual result Construct(_IChannelServiceStub& stub);
-
-       // _IChannelService
-       virtual result RegisterChannel(const Tizen::Base::String& channelId, const _IChannelServiceEventListener& listener);
-       virtual result UnregisterChannel(const Tizen::Base::String& channelId);
-
-       virtual result SendRequest(const Tizen::Base::String& src, const Tizen::Base::String& dest, const Tizen::Base::Collection::ArrayList& args, int messageId);
-       virtual result SendNullRequest(const Tizen::Base::String& src, const Tizen::Base::String& dest, int messageId);
-
-       virtual result SendResponse(const Tizen::Base::String& src, const Tizen::Base::String& dest, const Tizen::Base::Collection::ArrayList& args, int messageId);
-       virtual result SendNullResponse(const Tizen::Base::String& src, const Tizen::Base::String& dest, int messageId);
-
-
-       bool IsChannelRegistered(const Tizen::Base::String& channelId);
-
-       result RegisterChannel(const Tizen::Base::String& channelId, int clientId, unsigned int type = OSPAPP_CHANNEL);
-
-       result RegisterChannel(const Tizen::Base::String& channelId, int clientId, void* pGIOChannel);
-
-       result UnregisterChannel(int clientId);
-
-private:
-
-       struct _ChannelInfo
-       {
-               Tizen::Base::String channelId;
-               int clientId;
-               void* pGIOChannel;
-               unsigned int type;
-       };
-
-       class _StringHashProvider
-               : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
-       {
-       public:
-               virtual int GetHashCode(const Tizen::Base::String& value) const
-               {
-                       return value.GetHashCode();
-               }
-       };
-
-       class _StringComparer
-               : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
-       {
-       public:
-               virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
-               {
-                       cmp = string1.CompareTo(string2);
-                       return E_SUCCESS;
-               }
-       };
-private:
-       _IChannelServiceStub* __pIChannelServiceStub;
-       Tizen::Base::Collection::HashMapT <Tizen::Base::String, _ChannelInfo*> __channels;
-
-}; // _ChannelService
-
-
-} } // Tizen::Io
-
-#endif // _FIO_INTERNAL_CHANNEL_SERVICE_STUB_H_
diff --git a/src/io/inc/FIo_ChannelServiceStub.h b/src/io/inc/FIo_ChannelServiceStub.h
deleted file mode 100644 (file)
index 7dd1339..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// 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       FIo_ChannelServiceStub.h
- * @brief      This is the header file for the _ChannelServiceStub class.
- *
- * This file contains the declarations of _ChannelServiceStub.
- */
-
-
-#ifndef _FIO_INTERNAL_CHANNEL_SERVICE_STUB_H_
-#define _FIO_INTERNAL_CHANNEL_SERVICE_STUB_H_
-
-#include <FOspConfig.h>
-#include <FBaseResult.h>
-#include <FBaseObject.h>
-#include <FBaseColArrayList.h>
-#include <FBaseRt_ITask.h>
-#include "FIo_IIpcServerEventListener.h"
-#include "FIo_IChannelServiceStub.h"
-
-namespace IPC
-{
-class Message;
-}
-
-namespace Tizen { namespace Io
-{
-
-class _IpcServer;
-class _ChannelService;
-
-class _OSP_EXPORT_ _ChannelServiceStub
-       : public _IIpcServerEventListener
-       , public _IChannelServiceStub
-       , public Tizen::Base::Object
-{
-public:
-       _ChannelServiceStub(void);
-
-       virtual ~_ChannelServiceStub(void);
-
-       virtual result Construct(void);
-
-       // _IChannelServiceStub
-       virtual result SendRequest(int clientId, const Tizen::Base::String& src,
-                                                          const Tizen::Base::String& dest,
-                                                          const Tizen::Base::Collection::ArrayList& args,
-                                                          int requestId);
-
-       virtual result SendNullRequest(int clientId, const Tizen::Base::String& src,
-                                                          const Tizen::Base::String& dest,
-                                                          int requestId);
-
-       virtual result SendResponse(int clientId, const Tizen::Base::String& src,
-                                                               const Tizen::Base::String& dest,
-                                                               const Tizen::Base::Collection::ArrayList& args,
-                                                               int requestId);
-
-       virtual result SendNullResponse(int clientId, const Tizen::Base::String& src,
-                                                               const Tizen::Base::String& dest,
-                                                               int requestId);
-
-       virtual void SetChannelService(_ChannelService& service);
-
-
-private:
-       bool OnRegisterChannelMessage(const Tizen::Base::String& appId, int* pResult);
-
-       bool OnSendRequestMessage(const Tizen::Base::String& src,
-                                                         const Tizen::Base::String& dest,
-                                                         const Tizen::Base::Collection::ArrayList& args,
-                                                         int requestId,
-                                                         int* pResult);
-
-       bool OnSendNullRequestMessage(const Tizen::Base::String& src,
-                                                         const Tizen::Base::String& dest,
-                                                         int requestId,
-                                                         int* pResult);
-
-       bool OnSendResponseMessage(const Tizen::Base::String& src,
-                                                          const Tizen::Base::String& dest,
-                                                          const Tizen::Base::Collection::ArrayList& args,
-                                                          int requestId,
-                                                          int* pResult);
-
-       bool OnSendNullResponseMessage(const Tizen::Base::String& src,
-                                                          const Tizen::Base::String& dest,
-                                                          int requestId,
-                                                          int* pResult);
-
-       virtual void OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message);
-
-       virtual void OnIpcServerStarted(const _IpcServer& server);
-
-       virtual void OnIpcServerStopped(const _IpcServer& server);
-
-       virtual void OnIpcClientConnected(const _IpcServer& server, int clientId);
-
-       virtual void OnIpcClientDisconnected(const _IpcServer& server, int clientId);
-
-       _ChannelServiceStub(const _ChannelServiceStub& value);
-       _ChannelServiceStub& operator = (const _ChannelServiceStub& value);
-private:
-       _IpcServer* __pIpcServer;
-       _ChannelService* __pChannelService;
-
-}; // _ChannelServiceStub
-
-} } // Tizen::Io
-
-#endif // _FIO_INTERNAL_CHANNEL_SERVICE_STUB_H_
-
diff --git a/src/io/inc/FIo_ChannelWebAppStub.h b/src/io/inc/FIo_ChannelWebAppStub.h
deleted file mode 100644 (file)
index b882bf9..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-//
-// 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       FIo_ChannelWebAppStub.h
- * @brief      This is the header file for the _ChannelWebAppStub class.
- *
- * This file contains the declarations of _ChannelWebAppStub.
- */
-
-#ifndef _FIO_INTERNAL_CHANNEL_WEBAPP_STUB_H_
-#define _FIO_INTERNAL_CHANNEL_WEBAPP_STUB_H_
-
-#include <string>
-#include <pthread.h>
-#include <map>
-#include <glib.h>
-#include <libsoup/soup.h>
-
-#include <FOspConfig.h>
-#include <FBaseObject.h>
-#include <FBaseString.h>
-#include <FBaseResult.h>
-#include <FBaseColArrayList.h>
-#include <FBaseColHashMap.h>
-#include <FAppTypes.h>
-#include <FIo_ChannelService.h>
-
-namespace Tizen { namespace Base { namespace Runtime
-{
-class _EventDispatcher;
-}}}
-
-namespace Tizen { namespace Io
-{
-
-enum WebSocketType
-{
-       WS_NONE,
-       WS_HYBI00,
-       WS_HYBI10
-};
-
-class _IIpcServerEventListener;
-class _ChannelServiceStub;
-
-/**
- * @class _ChannelWebAppStub
- * @brief This class provides methods to handle web-application request messages.
- * @since 2.1
- *
- */
-class _OSP_EXPORT_ _ChannelWebAppStub
-       : public Tizen::Base::Object
-{
-public:
-       /**
-        * This is the default constructor for this class.
-        * @since 2.1
-        */
-       _ChannelWebAppStub(void);
-
-       /**
-        * This is the destructor for this class.
-        * @since 2.1
-        */
-       virtual ~_ChannelWebAppStub(void);
-
-       result Construct(void);
-
-       void SetChannelService(_ChannelService& service);
-
-       static bool SendResponse(int clientId, const Tizen::Base::Collection::ArrayList& args);
-
-private:
-       _ChannelWebAppStub(const _ChannelWebAppStub& rhs);
-
-       _ChannelWebAppStub& operator =(const _ChannelWebAppStub& rhs);
-
-       static gboolean OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpointer data);
-
-       static gboolean OnReadMessage(GIOChannel* source, GIOCondition condition, gpointer data);
-
-       gboolean HandleReceivedMessage(GIOChannel* source, GIOCondition condition, gpointer data);
-
-       static std::string CreateResponseHeader(int appSocket, SoupMessageHeaders *header, const std::string& response);
-
-       static WebSocketType VerifyHttpHeaderType(std::string header, int headerLength);
-       static std::string MakeHybi00Response(uint32_t first, uint32_t second, unsigned char* third);
-       static std::string MakeHybi10Response(std::string& secureAccept);
-
-       static bool AppendChallengeNumber(uint32_t number, unsigned char *response);
-       static unsigned int ExtractChallengeNumber(const char* keyString);
-       static char* EncodeBase64(unsigned char *string, int len);
-
-
-//     struct  _ClientInfo;
-//
-//     struct  _ChannelInfo
-//     {
-//             _ChannelInfo(void);
-//             ~_ChannelInfo(void);
-//
-//             struct _ClientInfo* pClientInfo;
-//             GIOChannel* pGIOChannel;
-//             GSource* pGSource;
-//             bool destroySource;
-//     };
-//
-//     struct  _ClientInfo
-//     {
-//             _ClientInfo(void);
-//             ~_ClientInfo(void);
-//
-//             int clientId;                              // the client id
-//             _ChannelWebAppStub* pChannelStub;                   // the pointer to an _ChannelWebAppStub
-//             //GIOChannel* pReverseChannel;               // the channel for sending reverse message
-//             std::vector <struct _ChannelInfo*> channels;   // the set of channels associated with a client
-//             //Tizen::Base::String appId;
-//             //Tizen::Base::String appExecutableName;
-//     };
-
-       class _ClientInfo;
-
-       class _ChannelInfo
-       {
-       public:
-               _ChannelInfo(void);
-               ~_ChannelInfo(void);
-
-               _ClientInfo* pClientInfo;
-
-               Tizen::App::AppId destAppId;
-
-               GIOChannel* pGIOChannel;
-               GSource* pGSource;
-               bool destroySource;
-       };
-
-       class _ClientInfo
-               : public Tizen::Base::Object
-       {
-       public:
-               _ClientInfo(void);
-               ~_ClientInfo(void);
-
-               Tizen::App::AppId srcAppId;
-
-               //int clientId;
-               Tizen::Base::String key; // key = srcAppId + srcAppExecName
-               _ChannelWebAppStub* pChannelStub;
-               std::vector <struct _ChannelInfo*> channels;   /**< the set of channels associated with a client */
-       };
-
-       class _WebSocketMessage
-       {
-               public:
-                       _WebSocketMessage(void);
-                       ~_WebSocketMessage(void);
-
-
-                       typedef union
-                       {
-                               struct
-                               {
-                                       unsigned int opcode : 4;
-                                       unsigned int rsv3 : 1;
-                                       unsigned int rsv2 : 1;
-                                       unsigned int rsv1 : 1;
-                                       unsigned int fin : 1;
-                                       unsigned int payloadLen : 7;
-                                       unsigned int masked : 1;
-                               } factors;
-                               uint16_t header;
-                       } MiniHeader;
-
-                       int ParseHeader(uint8_t* header, int messageLen);
-                       int ParsePayload(uint8_t* payload, int messageLen);
-                       void ConsoleMessage() const;
-                       static size_t CreateMessage(std::string& payload, std::string& message);
-
-                       MiniHeader m_header;
-                       uint8_t m_payloadOffset;
-                       uint8_t m_maskingKey[4];
-                       uint64_t m_payloadLen;
-                       bool m_headerParsed;
-                       uint8_t* m_payload;
-
-               private:
-                       _WebSocketMessage(_WebSocketMessage& webSocketMessage);
-
-                       _WebSocketMessage& operator =(const _WebSocketMessage& webSocketMessage);
-
-       };
-
-       _ChannelService* __pChannelService;
-
-       GMainContext* __pGMainContext;
-       GSource* __pServerGSource;
-       GSource* __pClientGSource;
-
-       Tizen::Base::Collection::HashMap* __pClients;
-
-}; // _ChannelWebAppStub
-
-}} // Tizen::Io
-
-#endif // _FIO_INTERNAL_CHANNEL_WEBAPP_STUB_H_
-
index 91565b8..99e92a7 100644 (file)
@@ -57,8 +57,9 @@ private:
        _DataRouter();
        ~_DataRouter();
 
+private:
        _IDataRouterEventListener*      __pDataRouterEventListener;
-       bool    __initialized;
+       bool                            __initialized;
 }; // _DataRouter
 
 }} // Tizen::Io
index bba297e..e042c06 100644 (file)
@@ -44,6 +44,7 @@ class FileAttributes;
 class _NormalFile;
 class _SecureFile;
 class _IFileCore;
+class _FileLockImpl;
 
 #define MAX_FILEPATH_APP    18
 #define MAX_FILEPATH_MEDIA  2
@@ -63,6 +64,19 @@ enum _FilePathType
        FILEPATH_TYPE_SYSTEM // for paths like /SystemRw, /Tmp etc.
 };
 
+/**
+ * @enum       _FileLockMode
+ * Defines various file lock modes supported.
+ *
+ * @since 2.1
+ */
+enum _FileLockMode
+{
+       FILE_LOCK_MODE_INVALID, // invalid case
+       FILE_LOCK_MODE_BLOCKING, // blocking mode
+       FILE_LOCK_MODE_NON_BLOCKING // non blocking mode
+};
+
 class _OSP_EXPORT_ _FileImpl
        : public Tizen::Base::Object
 {
@@ -102,6 +116,14 @@ public:
 
        FILE* GetFilePointer(void) const;
 
+       FileLock* LockN(FileLockType lockType);
+
+       FileLock* LockN(FileLockType lockType, int offset, int length);
+
+       FileLock* TryToLockN(FileLockType lockType);
+
+       FileLock* TryToLockN(FileLockType lockType, int offset, int length);
+
        static result Remove(const Tizen::Base::String& filePath);
 
        static result Move(const Tizen::Base::String& oldFilePath, const Tizen::Base::String& newFilePath);
@@ -179,6 +201,8 @@ private:
 
        bool VerifyFileOpenMode(const char* pOpenMode);
 
+       FileLock* LockN(FileLockType lockType, _FileLockMode lockMode, int offset, int length);
+
        static bool VerifyFilePath(const Tizen::Base::String& filePath, _FilePathType pathType);
 
        static bool CreateOspInternalDirectories(const Tizen::Base::String& pkgId);
@@ -196,8 +220,10 @@ private:
        bool __write;
        bool __truncate;
        bool __append;
+       _FileLockImpl* __pFileLockImpl;
 
        friend class File;
+       friend class _FileLockImpl;
 
 }; // _FileImpl
 
diff --git a/src/io/inc/FIo_FileLockImpl.h b/src/io/inc/FIo_FileLockImpl.h
new file mode 100644 (file)
index 0000000..058227d
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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            FIo_FileLockImpl.h
+* @brief          This is the header file for the %_FileLockImpl class.
+*
+* This header file contains the declarations of the %FileLockImpl class.
+*/
+
+#ifndef _FIO_INTERNAL_FILE_LOCK_IMPL_H_
+#define _FIO_INTERNAL_FILE_LOCK_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseInternalTypes.h>
+#include <FOspConfig.h>
+#include <FIoFileLock.h>
+
+namespace Tizen { namespace Io
+{
+
+class _FileImpl;
+
+class _OSP_EXPORT_ _FileLockImpl
+       : public Tizen::Base::Object
+{
+public:
+
+       _FileLockImpl(void);
+
+       virtual ~_FileLockImpl(void);
+
+       static _FileLockImpl* GetInstance(FileLock& fileLock);
+
+       static const _FileLockImpl* GetInstance(const FileLock& fileLock);
+
+       /**
+       * Checks whether the file lock is shared.
+       *
+       * @since          2.1
+       *
+       * @return         @c true if the file lock is shared, @n
+       *                    else @c false
+       */
+       bool IsShared(void) const;
+
+       /**
+       * Checks whether the file lock is exclusive.
+       *
+       * @since          2.1
+       *
+       * @return         @c true if the file lock is exclusive, @n
+       *                    else @c false
+       */
+       bool IsExclusive(void) const;
+
+       /**
+       * Checks whether the file lock is valid. @n
+       * The lock is valid unless the associated %File has been closed.
+       *
+       * @since          2.1
+       *
+       * @return         @c true if the file lock is valid, @n
+       *                    else @c false
+       */
+       bool IsValid(void) const;
+
+       result Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid);
+
+       static FileLock* CreateFileLockInstanceN(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid);
+
+private:
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       _FileLockImpl(const _FileLockImpl& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       _FileLockImpl& operator =(const _FileLockImpl& rhs);
+
+       _FileImpl* __pFileImpl;
+       FileLockType __lockType;
+       int __offset;
+       int __size;
+       int __pid;
+
+       friend class _FileImpl;
+
+}; // _FileLockImpl
+
+}} // Tizen::Io
+
+#endif // _FIO_INTERNAL_FILE_LOCK_IMPL_H_
index 431e278..7cb8edf 100644 (file)
@@ -20,8 +20,8 @@
  * @brief      This is the header file for the _IMmcStorageServiceEventListener class.
  */
 
-#ifndef _FIO_INTERNAL_IIO_MMC_STORAGE_SERVICE_EVENT_LISTENER_H_
-#define _FIO_INTERNAL_IIO_MMC_STORAGE_SERVICE_EVENT_LISTENER_H_
+#ifndef _FIO_INTERNAL_IMMC_STORAGE_SERVICE_EVENT_LISTENER_H_
+#define _FIO_INTERNAL_IMMC_STORAGE_SERVICE_EVENT_LISTENER_H_
 
 #include <FBaseResult.h>
 #include <FBaseRtIEventListener.h>
@@ -43,13 +43,13 @@ public:
 
        ~_IMmcStorageServiceEventListener(void) {}
 
-       virtual result OnMmcMountResponseReceived(result r) = 0;
+       virtual void OnMmcMountResponseReceived(result r) = 0;
 
-       virtual result OnMmcUnmountResponseReceived(result r) = 0;
+       virtual void OnMmcUnmountResponseReceived(result r) = 0;
 
-       virtual result OnMmcFormatResponseReceived(result r) = 0;
+       virtual void OnMmcFormatResponseReceived(result r) = 0;
 }; // _MmcStorageServiceEventListener
 
 } } // Tizen::Io
 
-#endif // _FIO_INTERNAL_IIO_MMC_STORAGE_SERVICE_EVENT_LISTENER_H_
+#endif // _FIO_INTERNAL_IMMC_STORAGE_SERVICE_EVENT_LISTENER_H_
index 4503a47..cde5d39 100644 (file)
@@ -51,30 +51,19 @@ class _IIpcClientEventListener;
 /**
  * @class _IpcClient
  * @brief This class provides methods for sending a message to an IPC server.
- * @since 2.1
  *
  */
 class _OSP_EXPORT_ _IpcClient
        : Tizen::Base::Object
 {
 public:
-       /**
-        * This is the default constructor for this class.
-        * @since 2.1
-        */
        _IpcClient(void);
 
-       /**
-        * This is the destructor for this class.
-        * @since 2.1
-        */
        virtual ~_IpcClient(void);
 
        /**
         * Constructs the instance of this class.
         *
-        * @since 2.1
-        *
         * @return An error code
         * @param[in] serverName        The name of the server
         * @param[in] pListener Set if the client want to handle a message from the IPC server.
@@ -89,10 +78,8 @@ public:
        /**
         * Sends a request message to an IPC server.
         *
-        * @since 2.1
         * @code
         *
-        *
         * int
         * CalculatorProxy::Add(int a , int b)
         * {
old mode 100644 (file)
new mode 100755 (executable)
index 1eafe5e..8d30aae
@@ -318,8 +318,8 @@ struct ParamTraits <Tizen::Io::_IpcBuffer>
                m->ReadBytes(iter, &pBuffer, len);
 
                r->size = len;
-               r->pBuffer = (void*) pBuffer;
-
+               r->pBuffer = malloc(len);
+               memcpy(r->pBuffer, pBuffer, len);
 
                return true;
        }
index 47d5d13..98db492 100644 (file)
@@ -40,7 +40,9 @@ enum IpcMessageStart {
     ConnectivityWifiServiceMsgStart,
     ConnectivityBluetoothServiceMsgStart,
     ConnectivityNfcServiceMsgStart,
-    ConnectivityTelephonyServiceMsgStart
+    ConnectivityTelephonyServiceMsgStart,
+       UiManagerServiceStart,
+       TrustZoneServiceStart
        //LastIPCMsgStart      // Must come last.
 };
 
diff --git a/src/io/inc/FIo_MessagePortMessages.h b/src/io/inc/FIo_MessagePortMessages.h
deleted file mode 100644 (file)
index 9c641d3..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// 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        FIo_MessagePortMessages.h
- * @brief              This is the header file for the message port message types.
- */
-
-#ifndef _FIO_MESSAGE_PORT_MESSAGES_H_
-#define _FIO_MESSAGE_PORT_MESSAGES_H_
-
-#include "ipc/ipc_message_macros.h"
-#include "FIo_IpcCommonParamTraits.h"
-#include "FIo_IpcMessageStart.h"
-
-#define IPC_MESSAGE_START MessagePortServiceStart
-
-IPC_SYNC_MESSAGE_CONTROL3_1(MessagePortService_register, Tizen::Base::String, Tizen::Base::String, bool, int)
-IPC_SYNC_MESSAGE_CONTROL3_1(MessagePortService_requestRemotePort, Tizen::Base::String, Tizen::Base::String, bool, int)
-IPC_SYNC_MESSAGE_CONTROL4_1(MessagePortService_sendMessage, Tizen::Base::String, Tizen::Base::String, bool, Tizen::Base::Collection::HashMap, int)
-IPC_SYNC_MESSAGE_CONTROL6_1(MessagePortService_sendBidirMessage, Tizen::Base::String, Tizen::Base::String, bool, Tizen::Base::String, Tizen::Base::String, Tizen::Base::Collection::HashMap, int)
-IPC_SYNC_MESSAGE_CONTROL6_1(MessagePortService_sendTrustedBidirMessage, Tizen::Base::String, Tizen::Base::String, bool, Tizen::Base::String, Tizen::Base::String, Tizen::Base::Collection::HashMap, int)
-IPC_MESSAGE_CONTROL3(MessagePortService_sendMessageAsync, Tizen::Base::String, bool, Tizen::Base::Collection::HashMap)
-IPC_MESSAGE_CONTROL6(MessagePortService_sendBidirMessageAsync, Tizen::Base::String, bool, Tizen::Base::String, Tizen::Base::String, bool, Tizen::Base::Collection::HashMap)
-
-#endif
index c65a873..50af7ce 100644 (file)
 #ifndef _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_
 #define _FIO_INTERNAL_MESSAGE_PORT_PROXY_H_
 
+#include <bundle.h>
+
 #include <FBaseResult.h>
 #include <FBaseObject.h>
 #include <FBaseString.h>
 #include <FBaseColHashMap.h>
 #include <FBaseColHashMapT.h>
 #include <FAppTypes.h>
-#include "FIo_IMessagePortListener.h"
-#include "FIo_IIpcClientEventListener.h"
 
-namespace IPC { class Message; }
+#include "FIo_IMessagePortListener.h"
 
 namespace Tizen { namespace Io
 {
 
-class _IpcClient;
-
 class _MessagePortProxy
        : public Tizen::Base::Object
-       , public _IIpcClientEventListener
 {
 public:
        _MessagePortProxy(void);
@@ -53,9 +50,6 @@ public:
 
        virtual result Construct(void);
 
-       virtual void OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message);
-
-
        virtual result RegisterMessagePort(const Tizen::Base::String& localPort,
                                                                       bool isTrusted,
                                                                       const _IMessagePortListener& listener);
@@ -78,19 +72,11 @@ public:
 
        static _MessagePortProxy* GetProxy(void);
 
-private:
-       bool OnSendMessage(const Tizen::Base::String& localPort,
-                                       bool isTrusted,
-                                       const Tizen::Base::Collection::HashMap& map);
-
-       bool OnSendBidirMessage(const Tizen::Base::String& localPort,
-                                                       bool isTrustedLocal,
-                                                       const Tizen::App::AppId& remoteAppId,
-                                                       const Tizen::Base::String& remotePort,
-                                                       bool isTrustedRemote,
-                                                       const Tizen::Base::Collection::HashMap& map);
+       bundle* ConvertMapToBundleN(const Tizen::Base::Collection::HashMap* pMap);
 
 private:
+       result ConvertToResult(int error);
+
        class _StringHashProvider
                : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
        {
@@ -112,11 +98,13 @@ private:
                }
        };
 
-private:
+public:
        Tizen::App::AppId __appId;
-       _IpcClient* __pIpcClient;
+
        Tizen::Base::Collection::HashMapT <Tizen::Base::String, _IMessagePortListener*> __listeners;
        Tizen::Base::Collection::HashMapT <Tizen::Base::String, _IMessagePortListener*> __trustedListeners;
+       Tizen::Base::Collection::HashMapT <Tizen::Base::String, int> __ids;
+       Tizen::Base::Collection::HashMapT <Tizen::Base::String, int> __trustedIds;
 }; // _MessagePortProxy
 
 
index ad376c3..a11f092 100644 (file)
 #include <FBaseObject.h>
 #include <FBaseInternalTypes.h>
 #include <FBaseColLinkedListT.h>
+#include <FBaseRtEvent.h>
 
 #include <FIoMmcStorageManager.h>
 
-#include <FIo_IMmcStorageServiceEventListener.h>
-
-/*namespace Tizen { namespace Base
-{
-namespace Collection
-{
-class LinkedListT;
-}
-}}*/
+#include "FIo_IMmcStorageServiceEventListener.h"
 
 namespace Tizen { namespace Io
 {
@@ -50,17 +43,12 @@ class IMmcStorageMountListener;
 class IMmcStorageFormatListener;
 
 class _OSP_EXPORT_ _MmcStorageManagerImpl
-       : public Tizen::Base::Object
-       , public Tizen::Io::_IMmcStorageServiceEventListener
+       : public _IMmcStorageServiceEventListener
 {
 
 public:
-       _MmcStorageManagerImpl(void);
-
        ~_MmcStorageManagerImpl(void);
 
-       result Construct(void);
-
        static _MmcStorageManagerImpl* GetInstance(void);
 
        result Mount(void);
@@ -77,21 +65,23 @@ public:
 
        result RemoveMmcStorageFormatListener(IMmcStorageFormatListener& listener);
 
-       virtual result OnMmcMountResponseReceived(result r);
+       virtual void OnMmcMountResponseReceived(result r);
 
-       virtual result OnMmcUnmountResponseReceived(result r);
+       virtual void OnMmcUnmountResponseReceived(result r);
 
-       virtual result OnMmcFormatResponseReceived(result r);
+       virtual void OnMmcFormatResponseReceived(result r);
 
 private:
-       _MmcStorageManagerImpl& operator =(const _MmcStorageManagerImpl& source);
+       _MmcStorageManagerImpl(void);
+       result Construct(void);
 
        _MmcStorageManagerImpl(const _MmcStorageManagerImpl& source);
+       _MmcStorageManagerImpl& operator =(const _MmcStorageManagerImpl& source);
 
 private:
        _MmcStorageManagerProxy* __pMmcStorageManagerProxy;
-       Tizen::Base::Collection::LinkedListT<IMmcStorageMountListener*> __pMmcMountListener;
-       Tizen::Base::Collection::LinkedListT<IMmcStorageFormatListener*> __pMmcFormatListener;
+       Tizen::Base::Runtime::Event* __pMountEvent;
+       Tizen::Base::Runtime::Event* __pFormatEvent;
 
 }; // _MmcStorageManagerImpl
 
index e2606d6..337d8f6 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <FBaseObject.h>
 #include <FBaseString.h>
-#include <FIoMmcStorageManager.h>
 
 #include <FIo_IIpcClientEventListener.h>
 
@@ -35,11 +34,6 @@ namespace Tizen { namespace Io
 class _IMmcStorageServiceEventListener;
 class _IpcClient;
 
-/**
- * @class       _MmcStorageManagerProxy
- * @brief
- * @since 2.1
- */
 class _MmcStorageManagerProxy
        : public Tizen::Io::_IIpcClientEventListener
        , public Tizen::Base::Object
@@ -48,7 +42,7 @@ public:
        _MmcStorageManagerProxy(void);
        virtual ~_MmcStorageManagerProxy(void);
 
-       result Construct(_IMmcStorageServiceEventListener* pImpl);
+       result Construct(_IMmcStorageServiceEventListener* pListener);
 
        result Mount(void);
        result Unmount(void);
@@ -67,7 +61,7 @@ private:
 
 private:
        _IpcClient* __pIpcClient;
-       static _IMmcStorageServiceEventListener* __pImpl;
+       _IMmcStorageServiceEventListener* __pListener;
 
 }; // _MmcStorageManagerProxy
 
index ca20a1c..f0e3e1c 100644 (file)
 #include <FBaseColHashMap.h>
 #include <FBaseColIMap.h>
 #include <FBaseResult.h>
+#include <FIoFileLock.h>
+
 
 namespace Tizen { namespace Io
 {
 
+class _FileImpl;
+
 class _RegistryCore
        : public Tizen::Base::Object
 {
@@ -101,6 +105,10 @@ public:
 
        static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer* key = null);
 
+       FileLock* LockN(FileLockType lockType);
+
+       FileLock* TryToLockN(FileLockType lockType);
+
 protected:
        static result AddSection(Tizen::Base::Collection::LinkedList& sectionList, const Tizen::Base::String& sectionName);
 
@@ -126,10 +134,14 @@ protected:
     bool _write;
     bool _truncate;
     bool _append;
+    bool _update;
        Tizen::Base::Collection::LinkedList _sectionList; // <section_name, list<section_val_name, val>>
        byte* _pBuffer;
        int _length;
 
+private:
+       _FileImpl* __pFileImpl;
+
 }; // _RegistryCore
 
 }} // Tizen::Io
index 986ba7c..98db3fc 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <FOspConfig.h>
 #include <FBaseObject.h>
+#include <FIoFileLock.h>
 
 namespace Tizen {namespace Base
 {
@@ -135,6 +136,10 @@ public:
 
        void ModifyEntryValue(int sectionIndex, int entryIndex, _RegValueType type, const void* pValue, int size);
 
+       FileLock* LockN(FileLockType lockType);
+
+       FileLock* TryToLockN(FileLockType lockType);
+
        static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer* key = null);
 
        static _RegistryImpl* GetInstance(Registry& registry);
diff --git a/src/io/inc/FIo_ZipFileArchive.h b/src/io/inc/FIo_ZipFileArchive.h
new file mode 100644 (file)
index 0000000..e639237
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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       FIo_ZipFileArchive.h
+ * @brief      This is the header file for _ZipFileArchive class.
+ *
+ * This header file contains the declarations of the _ZipFileArchive class.
+ */
+
+#ifndef _FIO_INTERNAL_ZIP_FILE_ARCHIVE_H_
+#define _FIO_INTERNAL_ZIP_FILE_ARCHIVE_H_
+
+#include <limits.h>
+#include <unique_ptr.h>
+
+#include <FBaseString.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+}}
+
+namespace Tizen { namespace Io
+{
+
+class File;
+class DirEnumerator;
+
+class _OSP_EXPORT_ _ZipFileArchive
+       : public Tizen::Base::Object
+{
+public:
+       _ZipFileArchive(void);
+
+       virtual ~_ZipFileArchive(void);
+
+       result Construct(const Tizen::Base::String& zipFilePath);
+
+       File* GetFileN(const Tizen::Base::String& entryFilePath);
+
+       DirEnumerator* GetDirEnumeratorN(const Tizen::Base::String& entryDirPath);
+
+private:
+       static result CreateDirectories(char* pFilePath);
+
+       static result UnzipCurrentFileTo(void* pUnZipArchive, const Tizen::Base::String& filePath);
+
+private:
+       void* __pUnZipArchive;
+}; // _ZipFileArchive
+
+}} // Tizen::Io
+
+#endif // _FIO_INTERNAL_ZIP_FILE_ARCHIVE_H_
+
index 3768edc..5def2d3 100644 (file)
@@ -27,6 +27,7 @@
 #include <FLclTimeZone.h>
 
 #include "FLcl_CalendarImpl.h"
+#include "FLcl_LocaleImpl.h"
 
 using namespace Tizen::Base;
 
@@ -92,17 +93,12 @@ Calendar::Construct(const TimeZone& timezone, const Locale& locale)
                "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
 
        result r = E_INVALID_ARG;
+    if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
+    {
+            r = E_UNSUPPORTED_OPERATION;
+    }
 
-        if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
-        {
-                r = E_UNSUPPORTED_OPERATION;
-        }
-
-       SysTryReturnResult(NID_LCL, locale.GetLanguageCode() != LANGUAGE_INVALID,
-                               r, "Invalid argument is used. Language code is invalid. Given locale is not supported");
-
-       SysTryReturnResult(NID_LCL, locale.GetCountryCode() != COUNTRY_INVALID,
-                               r, "Invalid argument is used. Country code is invalid. Given locale is not supported");
+       SysTryReturnResult(NID_LCL, _LocaleImpl::IsSupported(locale), r, "Given locale is not supported");
 
        _timeZone = timezone;
        _nextStamp = MINIMUM_USER_STAMP;
index ddf2eaf..d42a3e4 100644 (file)
@@ -227,13 +227,6 @@ DateTimeSymbols::SetTimeZoneName(const Tizen::Base::String& timeZoneId, const Ti
        return __pDateTimeSymbolsImpl->SetTimeZoneName(timeZoneId, concatenatedTimeZoneName);
 }
 
-WcharBuffer*
-DateTimeSymbols::GetNonLocalizedDateTimePatternN(void)
-{
-       ClearLastResult();
-       return _DateTimeSymbolsImpl::GetNonLocalizedDateTimePatternN();   // Get Non Localized DateTime Pattern, fixed pattern
-}
-
 };
 };      // Tizen::Locales
 
index c96814a..e2604fa 100644 (file)
@@ -253,9 +253,7 @@ GregorianCalendar::SetGregorianChange(long long change)
        _CalendarImpl* pCalImpl = dynamic_cast< _CalendarImpl* >(pCalendar.get());
        if (pCalImpl != null)
        {
-               DateTime dt;
-               dt.SetValue(change);
-               pCalImpl->SetTime(dt);
+               pCalImpl->SetTimeInMillisec(change);
 
                __cutoverJulianDay = pCalImpl->GetJulianDay();
                //        __normalizedGregorianCutover = change * Calendar::ONE_DAY_IN_MILLISEC;
index be3ced3..226ed11 100644 (file)
 #include <unique_ptr.h>
 
 #include <FBaseSysLog.h>
-#include "FBase_StringConverter.h"
 #include <FLclLocale.h>
+#include <FApp_AppInfo.h>
 
+#include "FBase_StringConverter.h"
 #include "FLcl_LocaleImpl.h"
 
 using namespace Tizen::Base;
@@ -33,7 +34,10 @@ using namespace Tizen::Base;
 namespace Tizen { namespace Locales
 {
 
-static const char* LanguageCodeString3LetterArray[LANGUAGE_MAX] =
+static const LanguageCode LanguageMaxReserved = static_cast <LanguageCode> (LANGUAGE_INVALID_RESERVED - 1);
+static const CountryCode CountryMaxReserved = static_cast <CountryCode> (COUNTRY_INVALID_RESERVED - 1);
+
+static const char* LanguageCodeString3LetterArray[LANGUAGE_MAX+2] =
 {
        "aar", /**< Afar */
        "abk", /**< Abkhazian */
@@ -73,8 +77,8 @@ static const char* LanguageCodeString3LetterArray[LANGUAGE_MAX] =
        "aym", /**< Aymara */
        "aze", /**< Azerbaijani */
        "aze-arab", /**< Azerbaijani (Arabic) */
-        "aze-cyrl", /**< Azerbaijani (Cyrillic) */
-        "aze-latn", /**< Azerbaijani (Latin) */
+       "aze-cyrl", /**< Azerbaijani (Cyrillic) */
+       "aze-latn", /**< Azerbaijani (Latin) */
        "bad", /**< Banda languages */
        "bai", /**< Bamileke languages */
        "bak", /**< Bashkir */
@@ -540,7 +544,7 @@ static const char* LanguageCodeString3LetterArray[LANGUAGE_MAX] =
 };
 
 
-static const char CountryCodeString2LetterArray[COUNTRY_MAX][4] =
+static const char* CountryCodeString2LetterArray[COUNTRY_MAX] =
 {
        "AF", /**< AFGHANISTAN  */
        "AX", /**< ALAND ISLANDS */
@@ -782,7 +786,10 @@ static const char CountryCodeString2LetterArray[COUNTRY_MAX][4] =
        "ZM", /**< ZAMBIA */
        "ZW", /**< ZIMBABWE */
        "RS", /**< SERBIA */
-       "ME" /**< MONTENEGRO */
+       "ME", /**< MONTENEGRO */
+       "BL", /**< SAINT BARTHELEMY @b Since: @b 2.1  */
+       "MF", /**< SAINT MARTIN (FRENCH PART) @b Since: @b 2.1 */
+    "419" /**< Latin America and the Caribbean @b Since: @b 2.1  */
 };
 
 
@@ -799,13 +806,26 @@ Locale::Locale(const Locale& other)
 
 
 Locale::Locale(LanguageCode languageCode, CountryCode countryCode, const String* pVariantCodeString)
-       : __languageCode((languageCode < LANGUAGE_MAX)? languageCode : LANGUAGE_INVALID)
-       , __countryCode((countryCode < COUNTRY_MAX) ? countryCode : COUNTRY_INVALID)
+       : __languageCode((languageCode < LANGUAGE_MAX && languageCode >= LANGUAGE_AAR) ? languageCode : LANGUAGE_INVALID)
+       , __countryCode((countryCode < COUNTRY_MAX && countryCode >= COUNTRY_AF) ? countryCode : COUNTRY_INVALID)
        , __pLocaleImpl(null)
 {
-       const char* pLanguage = (languageCode != LANGUAGE_INVALID) ? LanguageCodeString3LetterArray[__languageCode] : null;
-       const char* pCountry = (countryCode != COUNTRY_INVALID) ? CountryCodeString2LetterArray[__countryCode] : null;
-       
+       if (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+       {
+               // LANGUAGE_INVALID_RESERVED-1 is LANGUAGE_MAX of tizen 2.0
+               if (__languageCode >= LanguageMaxReserved)
+               {
+                       __languageCode = LANGUAGE_INVALID;
+               }
+               // COUNTRY_INVALID_RESERVED-1 is COUNTRY_MAX of tizen 2.0
+               if (__countryCode >= CountryMaxReserved)
+               {
+                       __countryCode = COUNTRY_INVALID;
+               }
+       }
+       const char* pLanguage = (__languageCode != LANGUAGE_INVALID) ? LanguageCodeString3LetterArray[__languageCode] : null;
+       const char* pCountry = (__countryCode != COUNTRY_INVALID) ? CountryCodeString2LetterArray[__countryCode] : null;
+
        std::unique_ptr<char[]> pVariantCode (null);
        if (pVariantCodeString)
        {
@@ -855,6 +875,10 @@ Locale::SetVariantCodeString(const String* pVariantCode)
 LanguageCode
 Locale::GetLanguageCode(void) const
 {
+    if ((__languageCode == LANGUAGE_INVALID) && (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1))
+       {
+        return LANGUAGE_INVALID_RESERVED;
+    }
        return __languageCode;
 }
 
@@ -862,6 +886,10 @@ Locale::GetLanguageCode(void) const
 CountryCode
 Locale::GetCountryCode(void) const
 {
+    if ((__countryCode == COUNTRY_INVALID) && (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1))
+       {
+        return COUNTRY_INVALID_RESERVED;
+    }
        return __countryCode;
 }
 
@@ -875,7 +903,7 @@ Locale::GetLanguageCodeString(void) const
 
 String
 Locale::GetCountryCodeString(void) const
-{      
+{
        return __pLocaleImpl->Get2LetterCountryCodeString();
 }
 
@@ -970,37 +998,76 @@ Locale::GetHashCode(void) const
 LanguageCode
 Locale::StringToLanguageCode(const String& languageCodeString)
 {
-       for (int i = 0; i < LANGUAGE_MAX; i++)
+       LanguageCode invalidLanguageCode = LANGUAGE_INVALID;
+       LanguageCode maxLangageCode = LANGUAGE_MAX;
+
+       if (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+       {
+               invalidLanguageCode =  LANGUAGE_INVALID_RESERVED;
+               maxLangageCode = LanguageMaxReserved;
+       }
+
+       if (!languageCodeString.IsEmpty())
        {
-               if (languageCodeString == LanguageCodeString3LetterArray[i])
+               for (int i = 0; i < maxLangageCode; i++)
                {
-                       return (LanguageCode) i;
+                       if (languageCodeString == LanguageCodeString3LetterArray[i])
+                       {
+                               return (LanguageCode) i;
+                       }
                }
        }
-       SysTryReturn(NID_LCL, false,LANGUAGE_INVALID, E_INVALID_ARG, "languageCodeStirng [%ls] is invalid", languageCodeString.GetPointer());
-       return LANGUAGE_INVALID;
+       else
+       {
+               SysLog(NID_LCL,"languageCodeString is empty string");
+       }
+
+       return invalidLanguageCode;
 }
 
 
 CountryCode
 Locale::StringToCountryCode(const String& countryCodeString)
 {
-       for (int i = 0; i < COUNTRY_MAX; i++)
+       CountryCode invalidCountryCode = COUNTRY_INVALID;
+       CountryCode maxCountryCode = COUNTRY_MAX;
+
+       if (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+       {
+               invalidCountryCode = COUNTRY_INVALID_RESERVED;
+               maxCountryCode = CountryMaxReserved;
+       }
+
+       if(!countryCodeString.IsEmpty())
        {
-               if (countryCodeString == CountryCodeString2LetterArray[i])
+               for (int i = 0; i < maxCountryCode; i++)
                {
-                       return (CountryCode) i;
+                       if (countryCodeString == CountryCodeString2LetterArray[i])
+                       {
+                               return (CountryCode) i;
+                       }
                }
        }
-       SysTryReturn (NID_LCL, false, COUNTRY_INVALID, E_INVALID_ARG , "countryCodeString [%ls] is invalid", countryCodeString.GetPointer());
-       return COUNTRY_INVALID;
+       else
+       {
+               SysLog(NID_LCL,"countryCodeString is empty string");
+       }
+
+       return invalidCountryCode;
 }
 
 
 String
 Locale::LanguageCodeToString(LanguageCode languageCode)
 {
-       return (languageCode < LANGUAGE_MAX)
+    if (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+    {
+        return ((languageCode >= LANGUAGE_AAR) && (languageCode < LanguageMaxReserved))
+                ? LanguageCodeString3LetterArray[languageCode]
+                : String();
+    }
+
+       return ((languageCode > LANGUAGE_INVALID) && (languageCode < LANGUAGE_MAX))
                        ? LanguageCodeString3LetterArray[languageCode]
                        : String();
 }
@@ -1009,7 +1076,14 @@ Locale::LanguageCodeToString(LanguageCode languageCode)
 String
 Locale::CountryCodeToString(CountryCode countryCode)
 {
-       return (countryCode < COUNTRY_MAX)
+    if (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+    {
+        return ((countryCode >= COUNTRY_AF) && (countryCode < CountryMaxReserved))
+                ? CountryCodeString2LetterArray[countryCode]
+                : String();
+    }
+
+       return ((countryCode > COUNTRY_INVALID) && (countryCode < COUNTRY_MAX))
                   ? CountryCodeString2LetterArray[countryCode]
                   : String();
 }
@@ -1018,9 +1092,16 @@ Locale::CountryCodeToString(CountryCode countryCode)
 String
 Locale::LanguageCodeToTwoLetterLanguageCodeString(LanguageCode languageCode)
 {
-       return (languageCode < LANGUAGE_MAX)
-                       ? _LocaleImpl::Get2LetterLanguageCodeString(LanguageCodeString3LetterArray[languageCode])
-                       : String();
+    if (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+    {
+        return ((languageCode >= LANGUAGE_AAR) && (languageCode < LanguageMaxReserved))
+                ? _LocaleImpl::Get2LetterLanguageCodeString(LanguageCodeString3LetterArray[languageCode])
+                : String();
+    }
+
+    return ((languageCode > LANGUAGE_INVALID) && (languageCode < LANGUAGE_MAX))
+        ? _LocaleImpl::Get2LetterLanguageCodeString(LanguageCodeString3LetterArray[languageCode])
+        : String();
 }
 
 
@@ -1036,16 +1117,23 @@ Locale::TwoLetterLanguageCodeStringToLanguageCode(const String& languageCodeStri
                std::unique_ptr<char[]> pLangStr (_StringConverter::CopyToCharArrayN(languageCodeString));
                return StringToLanguageCode(_LocaleImpl::Get3LetterLanguageCodeString(pLangStr.get()));
        }
-       return LANGUAGE_INVALID;
+       return (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1) ? LANGUAGE_INVALID_RESERVED : LANGUAGE_INVALID;
 }
 
 
 String
 Locale::CountryCodeToThreeLetterCountryCodeString(CountryCode countryCode)
 {
-       return (countryCode < COUNTRY_MAX)
-                  ? _LocaleImpl::Get3LetterCountryCodeString(CountryCodeString2LetterArray[countryCode])
-                  : String();
+    if (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+    {
+        return ((countryCode >= COUNTRY_AF) && (countryCode < CountryMaxReserved))
+                ? _LocaleImpl::Get3LetterCountryCodeString(CountryCodeString2LetterArray[countryCode])
+                : String();
+    }
+
+    return ((countryCode > COUNTRY_INVALID) && (countryCode < COUNTRY_MAX))
+            ? _LocaleImpl::Get3LetterCountryCodeString(CountryCodeString2LetterArray[countryCode])
+            : String();
 }
 
 
@@ -1054,7 +1142,11 @@ Locale::ThreeLetterCountryCodeStringToCountryCode(const String& countryCodeStrin
 {
        if (countryCodeString.GetLength() == 3)
        {
-               for (int i = 0; i < COUNTRY_MAX; i++)
+               CountryCode maxCountryCode = (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+                                        ? (CountryCode)(COUNTRY_INVALID_RESERVED - 1)
+                                        : COUNTRY_MAX;
+
+               for (int i = 0; i < maxCountryCode; i++)
                {
                        String countryCode(_LocaleImpl::Get3LetterCountryCodeString(CountryCodeString2LetterArray[i]));
                        if (countryCodeString.Equals(countryCode, false))
@@ -1064,7 +1156,7 @@ Locale::ThreeLetterCountryCodeStringToCountryCode(const String& countryCodeStrin
                }
        }
 
-       return COUNTRY_INVALID;
+       return (Tizen::App::_AppInfo::GetApiVersion() < _API_VERSION_2_1) ? COUNTRY_INVALID_RESERVED : COUNTRY_INVALID;
 }
 
 
index dca4052..984ea6f 100644 (file)
@@ -27,6 +27,7 @@
 #include <FApp_AppInfo.h>
 #include <FLclNumberSymbols.h>
 #include "FLcl_NumberSymbolsImpl.h"
+#include "FLcl_LocaleImpl.h"
 
 
 using namespace Tizen::Base;
@@ -63,10 +64,7 @@ NumberSymbols::Construct(const Locale& locale)
                r = E_UNSUPPORTED_OPERATION;
        }
        // validating locale
-       TryReturn(locale.GetCountryCode() != COUNTRY_INVALID, r,
-                       "[%s] Country code is invalid. Given locale is not supported", GetErrorMessage(r));
-       TryReturn(locale.GetLanguageCode() != LANGUAGE_INVALID, r,
-                       "[%s] Language code is invalid. Given locale is not supported", GetErrorMessage(r));
+       SysTryReturnResult(NID_LCL, _LocaleImpl::IsSupported(locale), r, "Given locale is not supported");
 
        __pNumberSymbolsImpl = new (std::nothrow) _NumberSymbolsImpl;
        SysTryReturnResult(NID_LCL, __pNumberSymbolsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
index 08f0bf3..2c55ae3 100644 (file)
@@ -31,6 +31,8 @@
 #include "FLcl_CalendarImpl.h"
 #include "FLcl_IcuCalendarImpl.h"
 #include "FLcl_LocaleData.h"
+#include "FLcl_LocaleImpl.h"
+#include "FLcl_LocaleManagerImpl.h"
 
 using namespace Tizen::Base;
 
@@ -63,7 +65,7 @@ _CalendarImpl::CreateCalendarInstanceN(CalendarType calendarType)
 Calendar*
 _CalendarImpl::CreateCalendarInstanceN(const TimeZone& timeZone, CalendarType calendarType)
 {
-       return CreateInstanceN(timeZone, _LocaleData::GetOspSystemLocale(), calendarType);
+       return CreateInstanceN(timeZone, _LocaleManagerImpl::GetSystemLocale(), calendarType);
 }
 
 Calendar*
@@ -129,14 +131,14 @@ _CalendarImpl::CloneN(void) const
 result
 _CalendarImpl::Construct(CalendarType calendarType)
 {
-       Locale defaultLocale = _LocaleData::GetOspSystemLocale();
+       Locale defaultLocale = _LocaleManagerImpl::GetSystemLocale();
        return Construct( TimeZone::GetGmtTimeZone(), defaultLocale, calendarType);
 }
 
 result
 _CalendarImpl::Construct(const TimeZone& timezone, CalendarType calendarType)
 {
-       Locale defaultLocale = _LocaleData::GetOspSystemLocale();
+       Locale defaultLocale = _LocaleManagerImpl::GetSystemLocale();
        return Construct(timezone, defaultLocale, calendarType);
 }
 
@@ -154,11 +156,7 @@ _CalendarImpl::Construct(const TimeZone& timeZone, const Locale& locale, Calenda
        SysAssertf(__pCalendar == null,
                           "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
 
-       SysTryReturnResult(NID_LCL, locale.GetLanguageCode() != LANGUAGE_INVALID,
-                       E_INVALID_ARG, "Invalid argument is used. Language code is invalid. Given locale is not supported");
-
-       SysTryReturnResult(NID_LCL, locale.GetCountryCode() != COUNTRY_INVALID,
-                       E_INVALID_ARG, "Invalid argument is used. Country code is invalid. Given locale is not supported");
+       SysTryReturnResult(NID_LCL, _LocaleImpl::IsSupported(locale), E_INVALID_ARG, "Given locale is not supported");
 
        std::unique_ptr< _IcuCalendarImpl > pCalendar(new (std::nothrow) _IcuCalendarImpl);
        SysTryReturnResult(NID_LCL, pCalendar != null, E_OUT_OF_MEMORY, "Memory allocation failed");
@@ -234,13 +232,6 @@ result
 _CalendarImpl::SetTimeImpl(int year, int month, int day, int hour, int minute, int second)
 {
        SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
-       SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_YEAR, year), E_OUT_OF_RANGE, "year(%d) is out of range.", year);
-       SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_MONTH, month), E_OUT_OF_RANGE, "month(%d) is out of range.", month);
-       SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_DAY_OF_MONTH, day), E_OUT_OF_RANGE, "day(%d) is out of range.", day);
-       SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_HOUR_OF_DAY, hour),E_OUT_OF_RANGE, "hour(%d) is out of range.", hour);
-       SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_MINUTE, minute), E_OUT_OF_RANGE, "minute(%d) is out of range.", minute);
-       SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_SECOND, second), E_OUT_OF_RANGE, "second(%d) is out of range.", second);
-
        return __pCalendar->SetTime(year, month, day, hour, minute, second);
 }
 
index 681e513..158de6f 100644 (file)
@@ -38,7 +38,7 @@ result
 _CurrencyImpl::GetCurrencyCodeSymbol(const Locale& locale, Tizen::Base::String& currencyCodeSymbol)
 {
        const _LocaleImpl* pLclImpl = _LocaleImpl::GetLocaleImpl(locale);
-       SysTryReturnResult(NID_LCL, pLclImpl != null && pLclImpl->IsLocaleSupported(),
+       SysTryReturnResult(NID_LCL, pLclImpl != null && pLclImpl->IsSupported(),
                                        E_INVALID_ARG, "Invalid argument is used. Given locale is not supported");
 
        UErrorCode ec = U_ZERO_ERROR;
index 79ef05f..65033ee 100644 (file)
@@ -26,7 +26,8 @@
 #include <FLclDateTimeSymbols.h>
 #include "FLcl_DateTimeSymbolsImpl.h"
 #include "FLcl_LocaleData.h"
-
+#include "FLcl_LocaleImpl.h"
+#include "FLcl_LocaleManagerImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -35,17 +36,6 @@ using namespace Tizen::Base::Utility;
 namespace Tizen { namespace Locales
 {
 
-// This will be used to define non localized pattern string.
-static const wchar_t PATTERN_CHARS[] =
-{
-       // GyMdkHmsSEDFwWahKzYeugAZ
-       0x47, 0x79, 0x4D, 0x64, 0x6B, 0x48, 0x6D, 0x73, 0x53, 0x45, 0x44,
-       0x46, 0x77, 0x57, 0x61, 0x68, 0x4B, 0x7A, 0x59, 0x65, 0x75, 0x67,
-       0x41, 0x5A, 0    // Should be ended with 0 as we are not setting null at the end of the pattern
-};
-
-static const int PATTERN_LENGTH = 24 + 1;       // 24 Char and one null (0)
-
 static const int ERAS_COUNT = 2;
 static const int MONTH_COUNT = 12;
 static const int WEEKDAYS_COUNT = 7;
@@ -53,26 +43,6 @@ static const int AM_PM_COUNT =2;
 
 static const int MAX_TIMEZONE_NAME = 4;
 
-WcharBuffer*
-_DateTimeSymbolsImpl::GetNonLocalizedDateTimePatternN(void)
-{
-       ClearLastResult();
-       std::unique_ptr< WcharBuffer > pChars(new (std::nothrow) WcharBuffer());
-       SysTryReturn(NID_TEXT, pChars, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-
-       result r = pChars->Construct(PATTERN_LENGTH);
-       SysTryCatch(NID_LCL, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
-
-       r = pChars->SetArray(PATTERN_CHARS, 0, PATTERN_LENGTH);     // Setting value from PATTERN_CHARS defined above
-       SysTryCatch(NID_LCL, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
-
-       pChars->Flip();
-       return pChars.release();
-
-CATCH:
-       return null;
-}
-
 _DateTimeSymbolsImpl::_DateTimeSymbolsImpl(void)
        : __pErasList(null)
        , __pMonthsList(null)
@@ -98,16 +68,13 @@ _DateTimeSymbolsImpl::~_DateTimeSymbolsImpl(void)
 result
 _DateTimeSymbolsImpl::Initialize(CalendarType calendarType)
 {
-       return Initialize(_LocaleData::GetOspSystemLocale(), calendarType);
+       return Initialize(_LocaleManagerImpl::GetSystemLocale(), calendarType);
 }
 
 result
 _DateTimeSymbolsImpl::Initialize(const Locale& locale, CalendarType calendarType)
 {
-       SysTryReturnResult(NID_LCL, locale.GetCountryCode() != COUNTRY_INVALID, E_INVALID_ARG,
-                               "Invalid argument is used. Country code is invalid. Given locale is not supported");
-       SysTryReturnResult(NID_LCL, locale.GetLanguageCode() != LANGUAGE_INVALID, E_INVALID_ARG,
-                               "Invalid argument is used. Language code is invalid. Given locale is not supported");
+       SysTryReturnResult(NID_LCL, _LocaleImpl::IsSupported(locale), E_INVALID_ARG, "Given locale is not supported");
 
        _LocaleData localeData;
        result r = localeData.SetDateFormatSymbols(locale);   // this will set ICU DateTimeSymbol in _LocaleData object for future use
@@ -159,10 +126,10 @@ _DateTimeSymbolsImpl::AddTimeZoneName(const String& timeZoneId, const String& co
 
        if (!isOverwrite)
        {
-               String tzName(timeZoneId);    
-               GetTimeZoneName(tzName, 0); 
+               String tzName(timeZoneId);
+               GetTimeZoneName(tzName, 0);
 
-               r = GetLastResult();    
+               r = GetLastResult();
                SysTryReturnResult(NID_LCL, r != E_SUCCESS, E_OBJ_ALREADY_EXIST, "The timeZoneId already exists.");
        }
 
@@ -171,7 +138,7 @@ _DateTimeSymbolsImpl::AddTimeZoneName(const String& timeZoneId, const String& co
                MultiHashMap* pMultiHashMap = new (std::nothrow) MultiHashMap();
                SysTryReturnResult(NID_LCL, pMultiHashMap, E_OUT_OF_MEMORY, "Memory allocation failed.");
                pMultiHashMap->Construct();
-               
+
                __pTimeZonesMap = (IMultiMap*) pMultiHashMap;
        }
 
@@ -381,11 +348,11 @@ _DateTimeSymbolsImpl::GetTimeZoneName(Tizen::Base::String& timeZoneId, int timeZ
                         "[%s] Invalid argument is used. timeZoneStyle(%d) is grater than MAX_TIMEZONE_NAME", GetErrorMessage(E_INVALID_ARG), timeZoneStyle);
 
        ClearLastResult();
-       
+
        if (__pTimeZonesMap && __pTimeZonesMap->GetValuesN(timeZoneId))
        {
                std::unique_ptr< IEnumerator >pValueEnum(__pTimeZonesMap->GetValuesN(timeZoneId));
-       
+
                int i = 0;
                String timeZoneName;
                while(pValueEnum->MoveNext() == E_SUCCESS)
@@ -413,8 +380,8 @@ _DateTimeSymbolsImpl::GetTimeZoneName(Tizen::Base::String& timeZoneId, int timeZ
                        {
                                SetLastResult(E_SUCCESS);
                                return _LocaleData::GetOspString(pIcuMap[rc][timeZoneStyle+1]);
-                       }                       
-               }               
+                       }
+               }
        }
        SetLastResult(E_OBJ_NOT_FOUND);
        return String();
@@ -432,19 +399,19 @@ _DateTimeSymbolsImpl::SetTimeZoneName(const Tizen::Base::String& timeZoneId, con
        {
                bool check = true;
                __pTimeZonesMap->ContainsKey(timeZoneId, check);                           // checking if Time zone is already exist
-               
+
                if (check)
                {
                        __pTimeZonesMap->Remove(timeZoneId, true);
                        return AddTimeZoneName(timeZoneId, concatenatedTimeZoneName, true);
                }
        }
-       
-       String tzName(timeZoneId);      
+
+       String tzName(timeZoneId);
        GetTimeZoneName(tzName, 0);
-       
-       result r = GetLastResult();     
-       
+
+       result r = GetLastResult();
+
        if(!IsFailed(r))
        {
                return AddTimeZoneName(timeZoneId, concatenatedTimeZoneName, true);
index a4a2b9a..c252633 100644 (file)
@@ -85,7 +85,6 @@ public:
        Tizen::Base::String GetTimeZoneName(Tizen::Base::String& timeZoneId, int timeZoneStyle = 0);
        result SetTimeZoneName(const Tizen::Base::String& timeZoneId, const Tizen::Base::String& concatenatedTimeZoneName);
 
-       static Tizen::Base::WcharBuffer* GetNonLocalizedDateTimePatternN(void);
        Tizen::Base::Collection::IList* CloneArrayListN(const Tizen::Base::Collection::IList* pList) const;
        Tizen::Base::Collection::IMultiMap* CloneMultiHashMapN(const Tizen::Base::Collection::IMultiMap* pMap) const;
        result SetList(Tizen::Base::Collection::ArrayList* pArraylist, int tokenCount, const Tizen::Base::String& stringWillBeTokenized);
index d8468e7..f3c29b1 100644 (file)
@@ -196,13 +196,7 @@ _IcuCalendarImpl::Equals(const _IcuCalendarImpl& otherInstance)
        SysAssertf(__pIcuCalendar != null, "Not yet constructed! Construct() should be called before use.");
        if (otherInstance.__pIcuCalendar != null)
        {
-               IcuErrorCode err;
-               bool isEqual = __pIcuCalendar->equals(*(otherInstance.__pIcuCalendar), err);
-               if (err.isSuccess())
-               {
-                       return isEqual;
-               }
-               return false;
+               return *__pIcuCalendar == *otherInstance.__pIcuCalendar;
        }
        return false;
 }
@@ -497,8 +491,19 @@ result
 _IcuCalendarImpl::SetTime(int year, int month, int day, int hour, int minute, int second)
 {
        SysAssertf(__pIcuCalendar != null, "Not yet constructed! Construct() should be called before use.");
-
+       UErrorCode ec = U_ZERO_ERROR;
+       UDate old = __pIcuCalendar->getTime(ec);
        __pIcuCalendar->set(year, month - 1, day, hour, minute, second);
+
+       ec = U_ZERO_ERROR;
+       __pIcuCalendar->getTime(ec);
+       if (U_FAILURE(ec))
+       {
+               ec = U_ZERO_ERROR;
+               __pIcuCalendar->setTime(old, ec);
+               return E_OUT_OF_RANGE;
+       }
+
        return E_SUCCESS;
 }
 
index 20c8187..f4a6a43 100644 (file)
@@ -36,6 +36,7 @@
 #include "FLcl_CalendarImpl.h"
 #include "FLcl_IcuCalendarImpl.h"
 #include "FLcl_LocaleData.h"
+#include "FLcl_LocaleImpl.h"
 
 
 // Other defines
@@ -191,41 +192,6 @@ _LocaleData::ConvertOspArrayToIcuStringArrayN(const Tizen::Base::Collection::ILi
        return null;                                                                // return null in case of failure
 }
 
-// This function convert ICU locale to OSP Locale
-Locale
-_LocaleData::GetOspLocale(const IcuLocale& icuLocale)
-{
-       SysTryReturn(NID_LCL, !icuLocale.isBogus(), Locale(LANGUAGE_INVALID, COUNTRY_INVALID, null), E_SYSTEM,
-                "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
-
-       LanguageCode langCode = LANGUAGE_INVALID;
-       CountryCode countryCode = COUNTRY_INVALID;
-       const char* pIcuStr = icuLocale.getLanguage();
-       langCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(pIcuStr);
-
-       if (langCode == LANGUAGE_INVALID)
-       {
-               langCode = Tizen::Locales::Locale::StringToLanguageCode(pIcuStr);
-               SysTryReturn(NID_LCL, langCode != LANGUAGE_INVALID, Locale(LANGUAGE_INVALID, COUNTRY_INVALID, null), E_SYSTEM,
-                       "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
-       }
-
-       pIcuStr = icuLocale.getCountry();
-       countryCode = Tizen::Locales::Locale::StringToCountryCode(pIcuStr);
-
-       SysTryReturn(NID_LCL, countryCode != COUNTRY_INVALID, Locale(LANGUAGE_INVALID, COUNTRY_INVALID, null), E_SYSTEM,
-               "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
-
-       String variantCodeString = icuLocale.getVariant();
-       SetLastResult(E_SUCCESS);
-
-       if (variantCodeString.IsEmpty())
-       {
-               return Locale(langCode, countryCode, null);
-       }
-
-       return Locale(langCode, countryCode, &variantCodeString);
-}
 
 IcuLocale
 _LocaleData::GetIcuLocale(const Locale& ospLocale)
@@ -258,22 +224,6 @@ _LocaleData::GetIcuLocale(const Locale& ospLocale)
        return icuLocale;
 }
 
-Locale
-_LocaleData::GetOspSystemLocale(void)
-{
-       char* pRegion = null;
-       int ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &pRegion);
-       if (ret == RUNTIME_INFO_ERROR_NONE)
-       {
-               IcuLocale icuLcl(pRegion);
-               free(pRegion);
-               SetLastResult(E_SUCCESS);
-               return _LocaleData::GetOspLocale(icuLcl);
-       }
-
-       SetLastResult(E_SYSTEM);
-       return Locale(LANGUAGE_INVALID, COUNTRY_INVALID, null);
-}
 
 const IcuLocale&
 _LocaleData::GetIcuLocale(void)
@@ -290,14 +240,11 @@ _LocaleData::IsLocaleSupported(void)
 result
 _LocaleData::SetLocale(const Locale& ospLocale)
 {
-       if (ospLocale.GetCountryCode() != COUNTRY_INVALID)
-       {
-               if (ospLocale.GetLanguageCode() != LANGUAGE_INVALID)
-               {
-                       __icuLocale = GetIcuLocale(ospLocale);
-                       return E_SUCCESS;
-               }
-       }
+       if (_LocaleImpl::IsSupported(ospLocale))
+    {
+        __icuLocale = GetIcuLocale(ospLocale);
+        return E_SUCCESS;
+    }
 
        __icuLocale.setToBogus();
        return (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) ? E_UNSUPPORTED_OPERATION : E_INVALID_ARG;
@@ -1246,7 +1193,7 @@ _LocaleData::GetDateTimeSymbolsN(DateTimeSymbols* pDateTimeSymbols)
                pDateTimeSymbolsImpl->__pWeekdaysList = GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_WEEKDAY_LIST);
                pDateTimeSymbolsImpl->__pShortWeekdaysList = GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_SHORT_WEEKDAY_LIST);
                pDateTimeSymbolsImpl->__pAmPmList = GetDateFormatSymbolAttrArrayN(DATE_FORMAT_SYM_AM_PM_LIST);
-               
+
                return pDateTimeSymbols;
        }
 
index 521632d..e3ae717 100644 (file)
@@ -138,8 +138,6 @@ public:
 
        // Methods to support Locale
        bool IsLocaleSupported();
-       static Locale GetOspSystemLocale(void);
-       static Locale GetOspLocale(const IcuLocale& icuLocale);
        result SetLocale(const Locale& ospLocale);
 
        // Methods to support NumberSymbols
index b87f81b..b5f0bb5 100644 (file)
@@ -51,7 +51,7 @@ _LocaleImpl::_LocaleImpl(const char* pLocaleCode)
 _LocaleImpl::_LocaleImpl(const char* pLanguage, const char* pCountry, const char* pVariant)
        : __icuLocale(pLanguage, pCountry, pVariant)
 {
-       if (pLanguage == null || pCountry == null)
+       if (pLanguage == null || *pLanguage == '\0' || pCountry == null || *pCountry == '\0')
        {
                __icuLocale.setToBogus();
        }
@@ -118,17 +118,17 @@ _LocaleImpl::GetHashCode(void) const
 
 String
 _LocaleImpl::GetLanguageCodeString(bool isTwoLetter)
-{      
+{
        String languageCode((isTwoLetter ? __icuLocale.getLanguage() : __icuLocale.getISO3Language()));
        String languageScriptTmp(__icuLocale.getScript());
-       
+
        if (!languageScriptTmp.IsEmpty())
        {
                String languageScript;
                languageScriptTmp.ToLowerCase(languageScript);
                languageCode.Append(L"-");
                languageCode.Append(languageScript);
-       }               
+       }
        return languageCode;
 }
 
@@ -140,10 +140,10 @@ _LocaleImpl::GetLanguageName(String& languageName) const
        if (!languageName.IsEmpty())
        {
                String languageScriptTmp(__icuLocale.getScript());
-               
+
                if (!languageScriptTmp.IsEmpty())
-               {       
-                       U_ICU_NAMESPACE::UnicodeString icuScriptStr;                    
+               {
+                       U_ICU_NAMESPACE::UnicodeString icuScriptStr;
                        String languageScriptName = _LocaleData::GetOspString(__icuLocale.getDisplayScript(icuScriptStr));
                        languageName.Append(L" (");
                        languageName.Append(languageScriptName);
@@ -162,15 +162,15 @@ _LocaleImpl::GetLanguageName(const _LocaleImpl& otherLocale, String& languageNam
        if (!languageName.IsEmpty())
        {
                String languageScriptTmp(__icuLocale.getScript());
-                    
+
                 if (!languageScriptTmp.IsEmpty())
-                {    
-                        U_ICU_NAMESPACE::UnicodeString icuScriptStr;    
+                {
+                        U_ICU_NAMESPACE::UnicodeString icuScriptStr;
                         String languageScriptName = _LocaleData::GetOspString(__icuLocale.getDisplayScript(otherLocale.__icuLocale, icuScriptStr));
                         languageName.Append(L" (");
                         languageName.Append(languageScriptName);
                         languageName.Append(L")");
-                }      
+                }
                return E_SUCCESS;
        }
        return E_UNSUPPORTED_OPERATION;
@@ -232,11 +232,17 @@ _LocaleImpl::GetLocaleCodeString(void) const
 }
 
 bool
-_LocaleImpl::IsLocaleSupported(void) const
+_LocaleImpl::IsSupported(void) const
 {
        return !__icuLocale.isBogus();
 }
 
+bool
+_LocaleImpl::IsSupported(const Locale& ospLocale)
+{
+    return !ospLocale.__pLocaleImpl->__icuLocale.isBogus();
+}
+
 const _LocaleImpl*
 _LocaleImpl::GetLocaleImpl(const Locale& ospLocale)
 {
index 6d30f81..ba4f9a2 100644 (file)
@@ -69,11 +69,12 @@ public:
 
        const char* GetLocaleCodeString(void) const;
 
-       bool IsLocaleSupported(void) const;
+       bool IsSupported(void) const;
 
        U_ICU_NAMESPACE::Locale GetIcuLocale (void) const;
        Locale GetOspLocale(void);
 
+       static bool IsSupported(const Locale& ospLocale);
        static const _LocaleImpl* GetLocaleImpl(const Locale& ospLocale);
 
        static String Get2LetterLanguageCodeString(const char* pLanguageCodeString);
index f84272c..724b89c 100644 (file)
@@ -305,8 +305,8 @@ _LocaleManagerImpl::GetAvailableLocalesN(void)
                                        "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
 
                Locale ospLocale = _LocaleImpl(*(pIcuLocaleList + i)).GetOspLocale();
-               if (ospLocale.GetLanguageCode() != LANGUAGE_INVALID && ospLocale.GetCountryCode() != COUNTRY_INVALID)
-               {                       
+               if (_LocaleImpl::IsSupported(ospLocale))
+               {
                        Locale* pLocale = new (std::nothrow) Locale(ospLocale);
                        SysTryReturn(NID_LCL, pLocale, null, E_OUT_OF_MEMORY,
                                                "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
@@ -343,21 +343,21 @@ _LocaleManagerImpl::GetSelectedLanguage(void)
 
 IList*
 _LocaleManagerImpl::GetAvailableLanguagesN(void)
-{      
+{
        result r = E_SUCCESS;
        std::unique_ptr<IList, AllElementsDeleter> pLocaleList (GetAvailableLocalesN());
        std::unique_ptr<HashMap> pLanguageMap(new (std::nothrow) HashMap());
 
         SysTryReturn(NID_LCL, pLanguageMap, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-       
+
        pLanguageMap->Construct();
 
        for (int i = 0; i < pLocaleList->GetCount() ; i++)
-       {       
+       {
                Locale* pLocale = (Locale*)pLocaleList->GetAt(i);
                std::unique_ptr<String> pLanguageCode(new (std::nothrow) String(pLocale->GetLanguageCodeString()));
-               SysTryReturn(NID_LCL, pLanguageCode, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));  
-               
+               SysTryReturn(NID_LCL, pLanguageCode, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+
                if (!pLanguageMap->ContainsKey(*pLanguageCode))
                {
                        std::unique_ptr<String> pDummyValue(new (std::nothrow) String());
@@ -368,7 +368,7 @@ _LocaleManagerImpl::GetAvailableLanguagesN(void)
                        if (IsFailed(r))
                        {
                                SetLastResult(E_UNSUPPORTED_OPERATION);
-                               return null;                            
+                               return null;
                        }
                        pLanguageCode.release();
                        pDummyValue.release();
@@ -399,7 +399,7 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(U_ICU_NAMESPACE::StringEnumeration* p
        UErrorCode ec = U_ZERO_ERROR;
        const char* pIcuTZStr = pIcuTZStrList->next(&resultLength, ec);
        IMap* pTZMap = GetAvailableTimeZonesN();
-       
+
        r = GetLastResult();
        SysTryReturn(NID_LCL, pTZMap, null, r, "[%s] Fail to get available time zone list", GetErrorMessage(r));
 
@@ -439,28 +439,28 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(void)
 
        result r = E_SUCCESS;
        int index = 0;
-       
+
        pTimeZoneMap->Construct();
 
        do
-       {   
+       {
                String* pTimeZone = new (std::nothrow) String(TimeZoneList[index++]);
                SysTryReturn(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
                                "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                if (!pTimeZoneMap->ContainsKey(*pTimeZone))
-               {                       
+               {
                        String* pDummyValue = new  (std::nothrow) String();
 
                        r = pTimeZoneMap->Add(*pTimeZone, *pDummyValue);
                        if (IsFailed(r))
-                       {   
+                       {
                                delete pTimeZone;
                                delete pDummyValue;
                                SetLastResult(E_SYSTEM);
                                return null;
-                       }  
-               } 
+                       }
+               }
        }while (index < TIMEZONE_MAX);
 
        SetLastResult(E_SUCCESS);
@@ -479,30 +479,21 @@ _LocaleManagerImpl::GetSystemTimeZone(void)
 {
        char tz[PATH_MAX + 1];
        int len = readlink("/opt/etc/localtime", tz, PATH_MAX);
-       std::unique_ptr<U_ICU_NAMESPACE::TimeZone> pTzICU(null);
-       if (len > 20)
-       {
-               tz[len] = '\0';
-               pTzICU.reset(U_ICU_NAMESPACE::TimeZone::createTimeZone(tz + 20));
-       }
-       else
-       {
-               pTzICU.reset(U_ICU_NAMESPACE::TimeZone::createDefault());
-       }
-
-       if (pTzICU.get())
-       {
-               _TimeZoneImpl tzImpl(*pTzICU.get(), U_ICU_NAMESPACE::Calendar::getNow());
-               return tzImpl.GetOspTimeZone();
-       }
-
-       return TimeZone(-1, "");
+       tz[len] = '\0';
+       SysTryReturn(NID_LCL, len > 20, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
+
+       String tzId(tz + 20);
+       SysLog(NID_LCL, "System TimeZone id [%ls]", tzId.GetPointer());
+       TimeZone timeZone;
+       result r = Tizen::Locales::TimeZone::GetTimeZone(tzId, timeZone);
+       SysTryReturn(NID_LCL, r == E_SUCCESS, TimeZone(-1, ""), r, "[%s] error occurs.", GetErrorMessage(r));
+       return timeZone;
 }
 
 result
 _LocaleManagerImpl::IsSupportedLocale(const Tizen::Locales::Locale& locale, bool& isSupportedLocale)
 {
-       isSupportedLocale = _LocaleImpl::GetLocaleImpl(locale)->IsLocaleSupported();
+       isSupportedLocale = _LocaleImpl::IsSupported(locale);
        return E_SUCCESS;
 }
 
index d618860..3ee1f5d 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "FLcl_LocaleData.h"
 #include "FLcl_LocaleImpl.h"
+#include "FLcl_LocaleManagerImpl.h"
 #include "FLcl_NumberFormatterImpl.h"
 
 
@@ -49,7 +50,7 @@ _NumberFormatterImpl::~_NumberFormatterImpl(void)
 NumberFormatter*
 _NumberFormatterImpl::CreateNumberFormatterN(NumberFormatterStyle style)
 {
-       return CreateNumberFormatterN(_LocaleData::GetOspSystemLocale(), style);
+       return CreateNumberFormatterN(_LocaleManagerImpl::GetSystemLocale(), style);
 }
 
 NumberFormatter*
index c3658f0..ab1f8ab 100644 (file)
@@ -151,14 +151,6 @@ _TimeZoneImpl::GetIcuTimeZone(void) const
        return __icuTimeZone;
 }
 
-TimeZone
-_TimeZoneImpl::GetOspTimeZone(void)
-{
-       TimeZone ospTimeZone;
-       ospTimeZone.__pTimeZoneImpl = new (std::nothrow) _TimeZoneImpl(*this);
-       SysAssert(ospTimeZone.__pTimeZoneImpl);
-       return ospTimeZone;
-}
 
 bool
 _TimeZoneImpl::operator ==(const _TimeZoneImpl& otherTimeZone) const
@@ -264,7 +256,9 @@ _TimeZoneImpl::SetDstStartingRule(const TimeRule& startRule)
 
        UErrorCode ec = U_ZERO_ERROR;
        GetIcuTimeRuleValue(startRule, month, dayOfWeekInMonth, dayOfWeek, time, mode);
-       __icuTimeZone.setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, mode, ec);
+
+       U_ICU_NAMESPACE::SimpleTimeZone::TimeMode timeMode = static_cast<U_ICU_NAMESPACE::SimpleTimeZone::TimeMode> (mode);
+       __icuTimeZone.setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, timeMode, ec);
        __startingRule = startRule;
 }
 
@@ -285,7 +279,9 @@ _TimeZoneImpl::SetDstEndingRule(const TimeRule& endRule)
 
        UErrorCode ec = U_ZERO_ERROR;
        GetIcuTimeRuleValue(endRule, month, dayOfWeekInMonth, dayOfWeek, time, mode);
-       __icuTimeZone.setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, mode, ec);
+
+       U_ICU_NAMESPACE::SimpleTimeZone::TimeMode timeMode = static_cast<U_ICU_NAMESPACE::SimpleTimeZone::TimeMode> (mode);
+       __icuTimeZone.setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, timeMode, ec);
        __endingRule = endRule;
 }
 
index 1a69565..9c98d98 100644 (file)
@@ -84,7 +84,6 @@ public:
        bool IsDstUsed(void) const;
 
        U_ICU_NAMESPACE::SimpleTimeZone GetIcuTimeZone(void) const;
-       TimeZone GetOspTimeZone(void);
 
        static const _TimeZoneImpl* GetTimeZoneImpl(const TimeZone& ospTimeZone);
        static result GetTimeZone(const Tizen::Base::String& id, Tizen::Locales::TimeZone& timeZone);
index 082a630..8f6cc12 100755 (executable)
@@ -36,22 +36,37 @@ SET (${this_target}_SOURCE_FILES
   crypto/FSecCryptoSkipJackCipher.cpp
   crypto/FSecCryptoRsaCipher.cpp
   crypto/FSecCryptoRsaSignature.cpp
+  crypto/FSecCrypto_TrustZoneService.cpp
+  crypto/FSecCrypto_TrustZoneServiceMessage.cpp
   cert/FSecCertX509Certificate.cpp
   cert/FSecCertX509CertificatePath.cpp
   cert/FSecCertX509CertificateSelector.cpp
   cert/FSecCertX509CertificateStore.cpp
   cert/FSecCert_X509CertificateStoreImpl.cpp
   cert/FSecCert_CertServiceProxy.cpp
-  #pkcs/FSecPkcsAlgorithmIdentifier.cpp 
-  #pkcs/FSecPkcsInitialVector.cpp 
-  #pkcs/FSecPkcsPkcs05PbMacParameters.cpp 
-  #pkcs/FSecPkcsRc2CbcParameters.cpp
-  #pkcs/FSecPkcs_PkcsUtility.cpp
-  #pkcs/FSecPkcsPkcs05PbKdf2Parameters.cpp 
-  #pkcs/FSecPkcsPkcs05PbEs2Parameters.cpp  
-  #pkcs/FSecPkcsPkcs05Schemes.cpp
-  #pkcs/FSecPkcsPkcs08PrivateKeyInfo.cpp
-  #pkcs/FSecPkcsPkcs08EncryptedPrivateKeyInfo.cpp  
+  pkcs/FSecPkcsAlgorithmIdentifier.cpp
+  pkcs/FSecPkcs_AlgorithmIdentifierImpl.cpp 
+  pkcs/FSecPkcsInitialVector.cpp
+  pkcs/FSecPkcs_InitialVectorImpl.cpp 
+  pkcs/FSecPkcsPkcs05PbEs2Parameters.cpp
+  pkcs/FSecPkcs_Pkcs05PbEs2ParametersImpl.cpp
+  pkcs/FSecPkcsPkcs05PbKdf2Parameters.cpp
+  pkcs/FSecPkcs_Pkcs05PbKdf2ParametersImpl.cpp
+  pkcs/FSecPkcsPkcs05PbMacParameters.cpp
+  pkcs/FSecPkcs_Pkcs05PbMacParametersImpl.cpp 
+  pkcs/FSecPkcsPkcs05Schemes.cpp
+  pkcs/FSecPkcs_Pkcs05SchemesImpl.cpp 
+  pkcs/FSecPkcsPkcs08Attribute.cpp
+  pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp
+  pkcs/FSecPkcsPkcs08AttributeValue.cpp
+  pkcs/FSecPkcs_Pkcs08AttributeValueImpl.cpp
+  pkcs/FSecPkcsPkcs08EncryptedPrivateKeyInfo.cpp
+  pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp 
+  pkcs/FSecPkcsPkcs08PrivateKeyInfo.cpp
+  pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp 
+  pkcs/FSecPkcsRc2CbcParameters.cpp
+  pkcs/FSecPkcs_Rc2CbcParametersImpl.cpp  
+  pkcs/FSecPkcs_PkcsUtility.cpp
   FSecSecretKey.cpp
   FSecSecretKeyGenerator.cpp
   FSecAesSecureRandom.cpp
@@ -63,6 +78,7 @@ SET (${this_target}_SOURCE_FILES
   FSecDesEdeSecureRandom.cpp
   FSecDhKeyParameters.cpp
   FSecKeaKeyParameters.cpp
+  FSecRsaKeyConverter.cpp
   FSec_DeviceKeyGenerator.cpp
   #FSec_DeviceKeyGeneratorMessage.cpp
   FSecAccessController.cpp
@@ -70,9 +86,15 @@ SET (${this_target}_SOURCE_FILES
   FSec_PrivilegeCache.cpp
   FSec_PrivilegeManager.cpp
   FSec_PrivilegeInfo.cpp  
+  FSec_PrivilegeInfoImpl.cpp  
+  FSecPrivilegeInfo.cpp  
   FSec_PrivilegeManagerMessage.cpp
   FSec_Prng.cpp
   FSec_GenerateParameters.cpp
+  FSec_PrivacyInfoImpl.cpp
+  FSecPrivacyInfo.cpp
+  FSec_PrivacyManagerImpl.cpp
+  FSecPrivacyManager.cpp
 )
 
 INCLUDE(${CMAKE_SOURCE_DIR}/src/security/cert/CMakeLists.txt)
index 383e397..ff8ba49 100644 (file)
 #include <FAppApplication.h>
 #include <FApp_AppInfo.h>
 #include <FApp_AppManagerImpl.h>
+#include <FAppPkg_PackageInfoImpl.h>
 #include <FBaseSysLog.h>
 #include <FBaseString.h>
 #include <FBaseColArrayList.h>
 #include <FIoFile.h>
 #include <FIo_IpcClient.h>
 #include <FSecAccessController.h>
+#include <FSec_AccessController.h>
 #include "FSec_AccessControlTypes.h"
 #include "FSec_PrivilegeManager.h"
 #include "FSec_PrivilegeManagerMessage.h"
@@ -38,6 +40,7 @@
 
 
 using namespace Tizen::App;
+using namespace Tizen::App::Package;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
@@ -74,9 +77,7 @@ AccessController::Initialize(void)
 
        std::unique_ptr<IPC::Message> pCipherPrivilegeMessage(null);
        std::unique_ptr<IPC::Message> pCipherVisibilityMessage(null);
-
-
-       SysLog(NID_SEC, "Enter");
+       std::unique_ptr<ArrayList> pPrivilegeList(null);
 
        r = ipcClient.Construct(L"osp.security.ipcserver.privilegemanager", null);
        SysTryReturnVoidResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "Failed to construct the instance of IPC.");
@@ -87,7 +88,12 @@ AccessController::Initialize(void)
        pChecksum.reset(new (std::nothrow) String());
        SysTryReturnVoidResult(NID_SEC, pChecksum != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
-       pCipherPrivilegeMessage.reset(new (std::nothrow) PrivilegeManagerMsg_retrieve(pEncryptedPrivileges.get(), pChecksum.get(), &r));
+       pPrivilegeList.reset(new ArrayList());
+       SysTryReturnVoidResult(NID_SEC, pPrivilegeList != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       pPrivilegeList->Construct();
+
+       pCipherPrivilegeMessage.reset(new (std::nothrow) PrivilegeManagerMsg_retrieve(pEncryptedPrivileges.get(), pChecksum.get(), pPrivilegeList.get(), &r));
        SysTryReturnVoidResult(NID_SEC, pCipherPrivilegeMessage != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
        ipcResult = ipcClient.SendRequest(pCipherPrivilegeMessage.get());
@@ -107,14 +113,14 @@ AccessController::Initialize(void)
        SysTryReturnVoidResult(NID_SEC, ipcResult == E_SUCCESS, E_SYSTEM, "Failed to send IPC message.");
        SysTryReturnVoidResult(NID_SEC, r == E_SUCCESS, r, "Failed to retrieve privilege information");
 
-       const PackageId& packageId = _AppInfo::GetPackageId();
+       PackageId packageId = _AppInfo::GetPackageId();
+       packageId[0] = packageId[0];
 
-       r = privilegeInfo.Construct(packageId, *(pEncryptedPrivileges.get()), *(pChecksum.get()), *(pEncryptedVisibility.get()), *(pVisibilityChecksum.get()));
+       r = privilegeInfo.Construct(packageId, *(pEncryptedPrivileges.get()), *(pChecksum.get()), *(pEncryptedVisibility.get()), *(pVisibilityChecksum.get()), pPrivilegeList.get());
        SysTryReturnVoidResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
+       pPrivilegeList->RemoveAll(true);
        isConstructed = true;
-
-    SysLog(NID_SEC, "Exit");
        return;
 }
 
@@ -126,7 +132,6 @@ AccessController::CheckPrivilege(int privilege)
 
        bool ret = false;
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
        SysTryReturnResult(NID_SEC, privilege < _MAX_PRIVILEGE_ENUM, E_INVALID_ARG, "The privilege enumerator is invalid");
@@ -169,20 +174,134 @@ AccessController::CheckPrivilege(int privilege)
                goto CATCH;
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 
+CATCH:
+
+       SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+       return r;
+}
+
+result
+AccessController::CheckPrivilege(const String& privilege)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       bool ret = false;
+
+       ClearLastResult();
+
+       if (!isConstructed)
+       {
+               pthread_once(&onceBlock, Initialize);
+               r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       if (r == E_DATA_NOT_FOUND)
+                       {
+                               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+                               goto CATCH;
+                       }
+                       else
+                       {
+                               onceBlock = PTHREAD_ONCE_INIT;
+                               SysLogException(NID_SEC, r, "[%s] Propagated.", GetErrorMessage(r));
+                       }
+                       return r;
+               }
+       }
+
+       if (privilegeInfo.GetAppId().IsEmpty())
+       {
+               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+               r = E_DATA_NOT_FOUND;
+               goto CATCH;
+       }
+       else
+       {
+               SysLog(NID_SEC, "%ls is in the cache [client]", privilegeInfo.GetAppId().GetPointer());
+       }
+
+       ret = privilegeInfo.HasPrivilege(privilege);
+       if (!ret)
+       {
+               r = E_PRIVILEGE_DENIED;
+               goto CATCH;
+       }
+
+       return r;
 
 CATCH:
 
        SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-       SysLog(NID_SEC, "Exit.");
+       return r;
+}
+
+_PrivilegeManager* AccessController::__pPrivilegeManager = null;
+
+result
+AccessController::CheckPrivilege(const PackageId& packageId, const String& privilege)
+{
+       result r = E_SUCCESS;
+
+       bool ret = false;
+       std::unique_ptr<_PrivilegeInfo> pPrivilegeInfo(null);
+       String subAppId;
+       _PackageInfoImpl infoImpl;
+       String appType;
+       String webAppType(L"wgt");
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PRIVILEGEMANAGER_READ);
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       packageId.SubString(0, MAX_APP_ID_SIZE, subAppId);
+
+       r = infoImpl.Construct(subAppId);
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
+       appType = infoImpl.GetAppType();
+       if (appType.Equals(webAppType, true))
+       {
+               return E_SUCCESS;
+       }
+
+       if (__pPrivilegeManager == null)
+       {
+               __pPrivilegeManager = _PrivilegeManager::GetInstance();
+       }
+       SysTryReturnResult(NID_SEC, __pPrivilegeManager != null, E_SYSTEM, "An unexpected system error occurred.");
+
+       pPrivilegeInfo.reset(__pPrivilegeManager->RetrievePrivilegeInfoN(subAppId));
+       r = GetLastResult();
+
+       if (r == E_SUCCESS)
+       {
+               // nothing to do.
+       }
+       else if (r == E_DATA_NOT_FOUND)
+       {
+               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+               goto CATCH;
+       }
+       else
+       {
+               SysLogException(NID_SEC, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               return E_SYSTEM;
+       }
+
+       ret = pPrivilegeInfo->HasPrivilege(privilege);
+       if (!ret)
+       {
+               r = E_PRIVILEGE_DENIED;
+               goto CATCH;
+       }
 
-       const PackageId& packageId = _AppInfo::GetPackageId();
+       return r;
 
-       _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
-       pAppManagerImpl->TerminateApplications(packageId);
+CATCH:
 
+       SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
        return r;
 }
 
index c44037b..7485ba7 100644 (file)
@@ -24,6 +24,7 @@
 #include <openssl/evp.h>
 #include <openssl/dh.h>
 #include <openssl/rsa.h>
+#include <openssl/x509.h>
 #include <FBaseResult.h>
 #include <FBaseErrors.h>
 #include <FSecKeyPairGenerator.h>
@@ -102,7 +103,7 @@ KeyPairGenerator::GenerateKeyParametersN(int lInBits, int nInBits) const
        SysTryReturn(NID_SEC, (__algorithm.CompareTo(L"DH") == 0) || (__algorithm.CompareTo(L"KEA") == 0), null, E_INVALID_ARG, "[E_INVALID_ARG] The requested algorithm is not supported.");
 
        pDh = DH_new();
-       SysTryReturn(NID_SEC, pDh != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+       SysTryReturn(NID_SEC, pDh != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        r = _GenerateParameters::GenerateParametersX186(pDh, static_cast< long >(lInBits), static_cast< long >(nInBits),
                                                                                                        seedLenInBytes);
@@ -113,13 +114,13 @@ KeyPairGenerator::GenerateKeyParametersN(int lInBits, int nInBits) const
        memset(temp, 0, _PUBLIC_KEY_LENGTH);
 
        size = BN_bn2bin(pDh->p, temp);
-       SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
        r = dhp.Construct(size);
-       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        r = dhp.SetArray(temp, 0, size);
-       SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
        dhp.Flip();
 
@@ -127,13 +128,13 @@ KeyPairGenerator::GenerateKeyParametersN(int lInBits, int nInBits) const
        size = 0;
 
        size = BN_bn2bin(pDh->g, temp);
-       SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
        r = dhg.Construct(size);
-       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        r = dhg.SetArray(temp, 0, size);
-       SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
        dhg.Flip();
 
@@ -142,7 +143,7 @@ KeyPairGenerator::GenerateKeyParametersN(int lInBits, int nInBits) const
        if (__algorithm.CompareTo(L"DH") == 0)
        {
                DhKeyParameters* pDHParams = new (std::nothrow) DhKeyParameters();
-               SysTryCatch(NID_SEC, pDHParams != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, pDHParams != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                r = pDHParams->Construct(dhp, dhg, static_cast< int >(dheSize));
                if (IsFailed(r))
@@ -156,7 +157,7 @@ KeyPairGenerator::GenerateKeyParametersN(int lInBits, int nInBits) const
        else if (__algorithm.CompareTo(L"KEA") == 0)
        {
                KeaKeyParameters* pKeaParams = new (std::nothrow) KeaKeyParameters();
-               SysTryCatch(NID_SEC, pKeaParams != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, pKeaParams != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                r = pKeaParams->Construct(dhp, dhg, static_cast< int >(dheSize));
                if (IsFailed(r))
@@ -196,10 +197,10 @@ KeyPairGenerator::GenerateKeyPairN(Tizen::Security::IKeyParameters* pKeyParams)
        RSA* pRsa = null;
        BIGNUM* pE = null;
        EVP_PKEY* pEvpKey = null;
-       std::unique_ptr<ByteBuffer> pDHp(null);
-       std::unique_ptr<ByteBuffer> pDHg(null);
-       std::unique_ptr<IPublicKey> pPubKey(null);
-       std::unique_ptr<IPrivateKey> pPriKey(null);
+       std::unique_ptr< ByteBuffer > pDHp(null);
+       std::unique_ptr< ByteBuffer > pDHg(null);
+       std::unique_ptr< IPublicKey > pPubKey(null);
+       std::unique_ptr< IPrivateKey > pPriKey(null);
 
        ClearLastResult();
 
@@ -214,10 +215,10 @@ KeyPairGenerator::GenerateKeyPairN(Tizen::Security::IKeyParameters* pKeyParams)
                        DhKeyParameters* pDHParams = dynamic_cast< DhKeyParameters* >(pKeyParams);
                        SysTryReturn(NID_SEC, pDHParams != null, null, E_INVALID_ARG, " [E_INVALID_ARG] dh parameters value is not valid.");
 
-                       pDHp = std::unique_ptr<ByteBuffer> (pDHParams->GetParameterValueN(KEY_PARAMETER_DH_P));
+                       pDHp = std::unique_ptr< ByteBuffer >(pDHParams->GetParameterValueN(KEY_PARAMETER_DH_P));
                        SysTryReturn(NID_SEC, pDHp != null, null, GetLastResult(), " [%s] Dh prime value is not valid.", GetErrorMessage(GetLastResult()));
 
-                       pDHg = std::unique_ptr<ByteBuffer> (pDHParams->GetParameterValueN(KEY_PARAMETER_DH_G));
+                       pDHg = std::unique_ptr< ByteBuffer >(pDHParams->GetParameterValueN(KEY_PARAMETER_DH_G));
                        SysTryCatch(NID_SEC, pDHg != null, r = GetLastResult(), GetLastResult(), " [%s] Dh generator value is not valid.", GetErrorMessage(GetLastResult()));
 
                        paramSize = pDHParams->GetParameterSize(KEY_PARAMETER_DH_PRIVATE_KEY_SIZE);
@@ -228,10 +229,10 @@ KeyPairGenerator::GenerateKeyPairN(Tizen::Security::IKeyParameters* pKeyParams)
                        KeaKeyParameters* pKeaParams = dynamic_cast< KeaKeyParameters* >(pKeyParams);
                        SysTryReturn(NID_SEC, pKeaParams != null, null, E_INVALID_ARG, " [E_INVALID_ARG] kea parameters value is not valid.");
 
-                       pDHp = std::unique_ptr<ByteBuffer> (pKeaParams->GetParameterValueN(KEY_PARAMETER_KEA_P));
+                       pDHp = std::unique_ptr< ByteBuffer >(pKeaParams->GetParameterValueN(KEY_PARAMETER_KEA_P));
                        SysTryReturn(NID_SEC, pDHp != null, null, GetLastResult(), " [%s] Kea prime value is not valid.", GetErrorMessage(GetLastResult()));
 
-                       pDHg = std::unique_ptr<ByteBuffer> (pKeaParams->GetParameterValueN(KEY_PARAMETER_KEA_G));
+                       pDHg = std::unique_ptr< ByteBuffer >(pKeaParams->GetParameterValueN(KEY_PARAMETER_KEA_G));
                        SysTryCatch(NID_SEC, pDHg != null, r = GetLastResult(), GetLastResult(), " [%s] Kea generator value is not valid.", GetErrorMessage(GetLastResult()));
 
                        paramSize = pKeaParams->GetParameterSize(KEY_PARAMETER_KEA_PRIVATE_KEY_SIZE);
@@ -239,29 +240,29 @@ KeyPairGenerator::GenerateKeyPairN(Tizen::Security::IKeyParameters* pKeyParams)
                }
 
                pDh = DH_new();
-               SysTryCatch(NID_SEC, pDh != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Failed to allocate memory.");
+               SysTryCatch(NID_SEC, pDh != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
                pDh->p = BN_bin2bn(pDHp->GetPointer(), pDHp->GetRemaining(), null);
-               SysTryCatch(NID_SEC, pDh->p != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, pDh->p != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                pDh->g = BN_bin2bn(pDHg->GetPointer(), pDHg->GetRemaining(), null);
-               SysTryCatch(NID_SEC, pDh->g != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, pDh->g != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                pDh->length = paramSize * _BITS_IN_BYTE;
 
                ret = DH_generate_key(pDh);
-               SysTryCatch(NID_SEC, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                memset(temp, 0, _PUBLIC_KEY_LENGTH);
 
                size = BN_bn2bin(pDh->priv_key, temp);
-               SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                r = privKey.Construct(size);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                r = privKey.SetArray(temp, 0, size);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                privKey.Flip();
 
@@ -269,23 +270,23 @@ KeyPairGenerator::GenerateKeyPairN(Tizen::Security::IKeyParameters* pKeyParams)
                size = 0;
 
                size = BN_bn2bin(pDh->pub_key, temp);
-               SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, size > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                r = pubKey.Construct(size);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                r = pubKey.SetArray(temp, 0, size);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                pubKey.Flip();
 
-               pPubKey = std::unique_ptr<IPublicKey> (new (std::nothrow) PublicKey());
-               SysTryCatch(NID_SEC, pPubKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               pPubKey = std::unique_ptr< IPublicKey >(new (std::nothrow) PublicKey());
+               SysTryCatch(NID_SEC, pPubKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                pPubKey->SetKey(pubKey);
 
-               pPriKey = std::unique_ptr<IPrivateKey> (new (std::nothrow) PrivateKey());
-               SysTryCatch(NID_SEC, pPriKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               pPriKey = std::unique_ptr< IPrivateKey >(new (std::nothrow) PrivateKey());
+               SysTryCatch(NID_SEC, pPriKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                pPriKey->SetKey(privKey);
 
@@ -293,67 +294,67 @@ KeyPairGenerator::GenerateKeyPairN(Tizen::Security::IKeyParameters* pKeyParams)
        else if (__algorithm.CompareTo(L"RSA") == 0)
        {
                pCtx = BN_CTX_new();
-               SysTryReturn(NID_SEC, pCtx != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryReturn(NID_SEC, pCtx != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                BN_CTX_start(pCtx);
 
                pRsa = RSA_new();
-               SysTryCatch(NID_SEC, pRsa != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, pRsa != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                pE = BN_CTX_get(pCtx);
-               SysTryCatch(NID_SEC, pE != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, pE != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                ret = BN_dec2bn(&pE, _MAX_SECRET_E_VAL);
-               SysTryCatch(NID_SEC, ret != 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, ret != 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                ret = RSA_generate_key_ex(pRsa, __modulusBitSize, pE, null);
-               SysTryCatch(NID_SEC, ret != 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, ret != 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                pEvpKey = EVP_PKEY_new();
-               SysTryCatch(NID_SEC, pEvpKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                ret = EVP_PKEY_set1_RSA(pEvpKey, pRsa);
-               SysTryCatch(NID_SEC, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                ret = i2d_PrivateKey(pEvpKey, &pBuffer);
-               SysTryCatch(NID_SEC, ret != -1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, ret != -1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                r = privKey.Construct(ret);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                r = privKey.SetArray(pBuffer, 0, ret);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                privKey.Flip();
 
                OPENSSL_free(pBuffer);
                pBuffer = null;
 
-               ret = i2d_PublicKey(pEvpKey, &pBuffer);
-               SysTryCatch(NID_SEC, ret != -1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               ret = i2d_PUBKEY(pEvpKey, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                r = pubKey.Construct(ret);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                r = pubKey.SetArray(pBuffer, 0, ret);
-               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
 
                pubKey.Flip();
 
-               pPubKey = std::unique_ptr<IPublicKey> (new (std::nothrow) PublicKey());
-               SysTryCatch(NID_SEC, pPubKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               pPubKey = std::unique_ptr< IPublicKey >(new (std::nothrow) PublicKey());
+               SysTryCatch(NID_SEC, pPubKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                pPubKey->SetKey(pubKey);
 
-               pPriKey = std::unique_ptr<IPrivateKey> (new (std::nothrow) PrivateKey());
-               SysTryCatch(NID_SEC, pPriKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+               pPriKey = std::unique_ptr< IPrivateKey >(new (std::nothrow) PrivateKey());
+               SysTryCatch(NID_SEC, pPriKey != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
                pPriKey->SetKey(privKey);
 
        }
 
        pKeyPair = new (std::nothrow) KeyPair();
-       SysTryCatch(NID_SEC, pKeyPair != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+       SysTryCatch(NID_SEC, pKeyPair != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        r = pKeyPair->SetPrivateKey(privKey);
        SysTryCatch(NID_SEC, !IsFailed(r), , r, "[%s] Failed to do set private key operation.", GetErrorMessage(r));
diff --git a/src/security/FSecPrivacyInfo.cpp b/src/security/FSecPrivacyInfo.cpp
new file mode 100755 (executable)
index 0000000..6d97c8c
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// 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       FSecPrivacyInfo.cpp
+ * @brief      This is the implementation for the PrivacyInfo class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <FSecPrivacyInfo.h>
+#include <FBaseSysLog.h>
+#include "FSec_PrivacyInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Security
+{
+
+PrivacyInfo::PrivacyInfo(void)
+       : __pImpl(null)
+{
+
+}
+
+PrivacyInfo::~PrivacyInfo(void)
+{
+
+}
+
+result
+PrivacyInfo::Construct(const Tizen::Base::String& privacyId, bool enable)
+{
+       SysAssertf(__pImpl == null,
+               "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
+
+       std::unique_ptr< _PrivacyInfoImpl > pImpl(new (std::nothrow) _PrivacyInfoImpl);
+       SysTryReturnResult(NID_SEC, pImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
+
+       result r = pImpl->Construct(privacyId, enable);
+       if (!IsFailed(r))
+       {
+               __pImpl = pImpl.release();
+               return E_SUCCESS;
+       }
+
+       return r;
+
+}
+
+String
+PrivacyInfo::GetId(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->GetId();
+}
+
+bool
+PrivacyInfo::IsEnabled(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->IsEnabled();
+}
+
+void
+PrivacyInfo::SetEnabled(bool enable)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       __pImpl->SetEnabled(enable);
+}
+
+String
+PrivacyInfo::GetDisplayName(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->GetDisplayName();
+}
+
+String
+PrivacyInfo::GetDescription(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->GetDescription();
+}
+
+}} // Tizen::Security
diff --git a/src/security/FSecPrivacyManager.cpp b/src/security/FSecPrivacyManager.cpp
new file mode 100755 (executable)
index 0000000..f2f484d
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// 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       FSecPrivacyInfo.cpp
+ * @brief      This is the implementation for the PrivacyInfo class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <FSecPrivacyManager.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIList.h>
+#include "FSec_PrivacyManagerImpl.h"
+#include <FSec_AccessController.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Security
+{
+
+PrivacyManager::PrivacyManager(void)
+       : __pPrivacyManagerImpl(null)
+{
+
+}
+
+PrivacyManager::~PrivacyManager(void)
+{
+       if (__pPrivacyManagerImpl)
+               delete __pPrivacyManagerImpl;
+}
+
+PrivacyManager*
+PrivacyManager::GetInstance(void)
+{
+       static PrivacyManager* pInstance = null;
+       
+       if (pInstance)
+       {
+               return pInstance;
+       }
+
+       std::unique_ptr< _PrivacyManagerImpl > pImpl(new (std::nothrow) _PrivacyManagerImpl);
+       pInstance  = new (std::nothrow) PrivacyManager;
+
+       pInstance->__pPrivacyManagerImpl = pImpl.release();
+
+       return pInstance;
+}
+
+Tizen::Base::Collection::IList*
+PrivacyManager::GetPrivacyAppPackageListN(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PRIVACYMANAGER_READ);
+       SysTryReturn(NID_SEC, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       return __pPrivacyManagerImpl->GetPrivacyAppPackageListN();
+
+}
+
+Tizen::Base::Collection::IList*
+PrivacyManager::GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PRIVACYMANAGER_READ);
+       SysTryReturn(NID_SEC, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       return __pPrivacyManagerImpl->GetPrivacyInfoListN(packageId);
+}
+
+result
+PrivacyManager::SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_PRIVACYMANAGER_WRITE);
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       r = __pPrivacyManagerImpl->SetAppPackagePrivacy(packageId, privacyInfo);
+
+       return r;
+}
+
+}} // Tizen::Security
diff --git a/src/security/FSecPrivilegeInfo.cpp b/src/security/FSecPrivilegeInfo.cpp
new file mode 100755 (executable)
index 0000000..c48b1fe
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// 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       FSecPrivilegeInfo.cpp
+ * @brief      This is the implementation for the PrivilegeInfo class.
+ */
+
+#include <new>
+
+#include <FSecPrivilegeInfo.h>
+
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FSec_PrivilegeInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Security
+{
+
+_PrivilegeInfoImpl* PrivilegeInfo::__pPrivilegeInfoImpl = null;
+
+PrivilegeInfo::PrivilegeInfo(void)
+       : __pImpl(null)
+{
+
+}
+
+PrivilegeInfo::~PrivilegeInfo(void)
+{
+
+}
+
+result
+PrivilegeInfo::Construct(const Tizen::Base::String& privilegeId)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl == null,
+                   "Already constructed. Calling Construct() twice or more on a same in stance is not allowed for this class.");
+
+       __pImpl = new (std::nothrow) _PrivilegeInfoImpl;
+    SysTryReturnResult(NID_SEC, __pImpl != null, E_OUT_OF_MEMORY, "");
+
+    r = __pImpl->Construct(privilegeId);
+    SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+    return r;
+
+CATCH:
+    delete __pImpl;
+    __pImpl = null;
+
+    return r;
+
+}
+
+String
+PrivilegeInfo::GetId(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetId();
+}
+
+
+String
+PrivilegeInfo::GetDisplayName(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetDisplayName();
+}
+
+String
+PrivilegeInfo::GetDescription(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetDescription();
+}
+
+
+
+String
+PrivilegeInfo::GetName(const String& privilege)
+{
+       String name;
+
+       if (__pPrivilegeInfoImpl == null)
+       {
+               __pPrivilegeInfoImpl = _PrivilegeInfoImpl::GetInstance();
+       }
+       SysTryReturn(NID_SEC, __pPrivilegeInfoImpl != null, name, E_SYSTEM, "An unexpected system error occurred.");
+
+       name = __pPrivilegeInfoImpl->GetName(privilege);
+
+       return name;
+}
+
+String
+PrivilegeInfo::GetDescription(const String& privilege)
+{
+       String description;
+
+       if (__pPrivilegeInfoImpl == null)
+       {
+               __pPrivilegeInfoImpl = _PrivilegeInfoImpl::GetInstance();
+       }
+       SysTryReturn(NID_SEC, __pPrivilegeInfoImpl != null, description, E_SYSTEM, "An unexpected system error occurred.");
+
+       description = __pPrivilegeInfoImpl->GetDescription(privilege);
+
+       return description;
+}
+
+}} // Tizen::Security
diff --git a/src/security/FSecRsaKeyConverter.cpp b/src/security/FSecRsaKeyConverter.cpp
new file mode 100644 (file)
index 0000000..0c8fa82
--- /dev/null
@@ -0,0 +1,508 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecRsaKeyConverter.cpp
+ * @brief              This is the implementation file for RsaKeyConverter class.
+ */
+
+#include <unique_ptr.h>
+#include <openssl/bn.h>
+#include <openssl/evp.h>
+#include <openssl/dh.h>
+#include <openssl/rsa.h>
+#include <openssl/x509.h>
+#include <openssl/pem.h>
+#include <FBaseResult.h>
+#include <FBaseErrors.h>
+#include <FSecIPublicKey.h>
+#include <FSecIPrivateKey.h>
+#include <FSecPrivateKey.h>
+#include <FSecPublicKey.h>
+#include <FBaseSysLog.h>
+#include <FSecRsaKeyConverter.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+
+namespace Tizen { namespace Security
+{
+
+RsaKeyConverter::RsaKeyConverter(void)
+{
+
+}
+
+RsaKeyConverter::~RsaKeyConverter(void)
+{
+}
+
+ByteBuffer*
+RsaKeyConverter::ConvertPrivateKeyFormatN(RsaKeyFormat format, const IPrivateKey& key)
+{
+       result r = E_SUCCESS;
+       byte* pBuffer = null;
+       const byte* pKey = null;
+       std::unique_ptr< ByteBuffer > pOutBuffer;
+       BIO* pBio = null;
+       EVP_PKEY* pEvpKey = null;
+       int ret = 0;
+       int keyLen = 0;
+       bool isPemFormat = false;
+
+       SysTryReturn(NID_SEC, format != RSA_KEY_FORMAT_UNKNOWN, null, E_INVALID_ARG, " [E_INVALID_ARG] The specified input parameter is invalid.");
+
+       std::unique_ptr< ByteBuffer > pPrivateKey(key.GetEncodedN());
+       SysTryReturn(NID_SEC, pPrivateKey != null, null, r, "[%s] Failed to get the public key", GetErrorMessage(r));
+
+       pKey = pPrivateKey->GetPointer();
+       SysTryReturn(NID_SEC, pKey != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyLen = pPrivateKey->GetRemaining();
+       SysTryReturn(NID_SEC, keyLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pEvpKey = d2i_PrivateKey(EVP_PKEY_RSA, null, &pKey, keyLen);
+
+       if (pEvpKey == null)
+       {
+               PKCS8_PRIV_KEY_INFO* pPrivKeyInfo = d2i_PKCS8_PRIV_KEY_INFO(null, &pKey, keyLen);
+               if (pPrivKeyInfo != null)
+               {
+                       pEvpKey = EVP_PKCS82PKEY(pPrivKeyInfo);
+                       PKCS8_PRIV_KEY_INFO_free(pPrivKeyInfo);
+               }
+
+       }
+       if (pEvpKey == null)
+       {
+               pBio = BIO_new(BIO_s_mem());
+               SysTryReturn(NID_SEC, pBio != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               int readCount = BIO_write(pBio, (const void*) pKey, keyLen);
+               SysTryCatch(NID_SEC, readCount > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pEvpKey = PEM_read_bio_PrivateKey(pBio, null, 0, null);
+               if (pEvpKey != null)
+               {
+                       isPemFormat = true;
+               }
+       }
+
+       SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       switch (format)
+       {
+       case RSA_KEY_FORMAT_PKCS01_PRIVATE_KEY:
+       {
+               ret = i2d_PrivateKey(pEvpKey, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       case RSA_KEY_FORMAT_PKCS08_PRIVATE_KEY:
+       {
+               PKCS8_PRIV_KEY_INFO* pPrivKeyInfo = EVP_PKEY2PKCS8(pEvpKey);
+               SysTryCatch(NID_SEC, pPrivKeyInfo != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               ret = i2d_PKCS8_PRIV_KEY_INFO(pPrivKeyInfo, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       default:
+               SysTryCatch(NID_SEC, false, r = E_INVALID_ARG, E_INVALID_ARG, " [E_INVALID_ARG] The specified input parameter is invalid.");
+
+       }
+
+       pOutBuffer = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC, pOutBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->Construct(ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->SetArray(pBuffer, 0, ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       pOutBuffer->Flip();
+
+       if (isPemFormat == true)
+       {
+               PrivateKey key;
+               r = key.SetKey(*pOutBuffer.get());
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+               pOutBuffer = std::unique_ptr< ByteBuffer >(ConvertDerToPemN(format, key));
+               SysTryCatch(NID_SEC, pOutBuffer != null, r = GetLastResult(), GetLastResult(), "[%s] Failed to convert der to pem encoded byte buffer");
+       }
+
+       OPENSSL_free(pBuffer);
+       pBuffer = null;
+
+CATCH:
+
+       if (pEvpKey != null)
+       {
+               EVP_PKEY_free(pEvpKey);
+       }
+
+       if (pBio != null)
+       {
+               BIO_free(pBio);
+       }
+
+       return pOutBuffer.release();
+}
+
+ByteBuffer*
+RsaKeyConverter::ConvertPublicKeyFormatN(RsaKeyFormat format, const IPublicKey& key)
+{
+       result r = E_SUCCESS;
+       byte* pBuffer = null;
+       const byte* pKey = null;
+       std::unique_ptr< ByteBuffer > pOutBuffer;
+       BIO* pBio = null;
+       EVP_PKEY* pEvpKey = null;
+       int ret = 0;
+       int keyLen = 0;
+       bool isPemFormat = false;
+
+       SysTryReturn(NID_SEC, format != RSA_KEY_FORMAT_UNKNOWN, null, E_INVALID_ARG, " [E_INVALID_ARG] The specified input parameter is invalid.");
+
+       std::unique_ptr< ByteBuffer > pPublicKey(key.GetEncodedN());
+       SysTryReturn(NID_SEC, pPublicKey, null, r, "[%s] Failed to get the public key", GetErrorMessage(r));
+
+       pKey = pPublicKey->GetPointer();
+       SysTryReturn(NID_SEC, pKey != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyLen = pPublicKey->GetRemaining();
+       SysTryReturn(NID_SEC, keyLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pEvpKey = d2i_PUBKEY(null, &pKey, keyLen);
+
+       if (pEvpKey == null)
+       {
+               pEvpKey = d2i_PublicKey(EVP_PKEY_RSA, null, &pKey, keyLen);
+
+       }
+       if (pEvpKey == null)
+       {
+               pBio = BIO_new(BIO_s_mem());
+               SysTryReturn(NID_SEC, pBio != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               int readCount = BIO_write(pBio, (const void*) pKey, keyLen);
+               if (readCount > 0)
+               {
+                       pEvpKey = PEM_read_bio_PUBKEY(pBio, null, 0, null);
+               }
+               if (pEvpKey != null)
+               {
+                       isPemFormat = true;
+               }
+       }
+
+       SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       switch (format)
+       {
+       case RSA_KEY_FORMAT_PKCS01_PUBLIC_KEY:
+       {
+               ret = i2d_PublicKey(pEvpKey, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       case RSA_KEY_FORMAT_X509_PUBLIC_KEY:
+       {
+               ret = i2d_PUBKEY(pEvpKey, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       default:
+               SysTryCatch(NID_SEC, false, r = E_INVALID_ARG, E_INVALID_ARG, " [E_INVALID_ARG] The specified input parameter is invalid.");
+
+       }
+
+       pOutBuffer = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC, pOutBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->Construct(ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->SetArray(pBuffer, 0, ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pOutBuffer->Flip();
+
+       if (isPemFormat == true)
+       {
+               PublicKey key;
+               r = key.SetKey(*pOutBuffer.get());
+               SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+               pOutBuffer = std::unique_ptr< ByteBuffer >(ConvertDerToPemN(format, key));
+               SysTryCatch(NID_SEC, pOutBuffer != null, r = GetLastResult(), GetLastResult(), "[%s] Failed to convert der to pem encoded byte buffer");
+       }
+
+       OPENSSL_free(pBuffer);
+       pBuffer = null;
+
+CATCH:
+
+       if (pEvpKey != null)
+       {
+               EVP_PKEY_free(pEvpKey);
+       }
+
+       if (pBio != null)
+       {
+               BIO_free(pBio);
+       }
+
+       return pOutBuffer.release();
+}
+
+
+ByteBuffer*
+RsaKeyConverter::ConvertDerToPemN(RsaKeyFormat format, const IKey& key)
+{
+       result r = E_SUCCESS;
+       const byte* pKey = null;
+       BIO* pBio = null;
+       EVP_PKEY* pEvpKey = null;
+       std::unique_ptr< byte[] > pData;
+       std::unique_ptr< ByteBuffer > pOutBuffer;
+       std::unique_ptr< ByteBuffer > pEncodedInputBuffer;
+       int ret = 0;
+       int keyLen = 0;
+       int dataLen = 0;
+
+       pEncodedInputBuffer = std::unique_ptr< ByteBuffer >(key.GetEncodedN());
+       SysTryReturn(NID_SEC, pEncodedInputBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pKey = pEncodedInputBuffer->GetPointer();
+       SysTryReturn(NID_SEC, pKey != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyLen = pEncodedInputBuffer->GetRemaining();
+       SysTryReturn(NID_SEC, keyLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       switch (format)
+       {
+       case RSA_KEY_FORMAT_PKCS01_PRIVATE_KEY:
+       {
+               pEvpKey = d2i_PrivateKey(EVP_PKEY_RSA, null, &pKey, keyLen);
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pBio = BIO_new(BIO_s_mem());
+               SysTryCatch(NID_SEC, pBio != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ret = PEM_write_bio_PrivateKey(pBio, pEvpKey, null, null, 0, null, null);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       }
+       break;
+
+       case RSA_KEY_FORMAT_PKCS01_PUBLIC_KEY:
+       {
+               pEvpKey = d2i_PublicKey(EVP_PKEY_RSA, null, &pKey, keyLen);
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pBio = BIO_new(BIO_s_mem());
+               SysTryCatch(NID_SEC, pBio != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ret = PEM_write_bio_PUBKEY(pBio, pEvpKey);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       }
+       break;
+
+       case RSA_KEY_FORMAT_X509_PUBLIC_KEY:
+       {
+               pEvpKey = d2i_PUBKEY(null, &pKey, keyLen);
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pBio = BIO_new(BIO_s_mem());
+               SysTryCatch(NID_SEC, pBio != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ret = PEM_write_bio_PUBKEY(pBio, pEvpKey);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       case RSA_KEY_FORMAT_PKCS08_PRIVATE_KEY:
+       {
+               PKCS8_PRIV_KEY_INFO* pPrivKeyInfo = d2i_PKCS8_PRIV_KEY_INFO(null, &pKey, keyLen);
+               if (pPrivKeyInfo != null)
+               {
+                       pEvpKey = EVP_PKCS82PKEY(pPrivKeyInfo);
+                       PKCS8_PRIV_KEY_INFO_free(pPrivKeyInfo);
+               }
+               pBio = BIO_new(BIO_s_mem());
+               SysTryCatch(NID_SEC, pBio != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ret = PEM_write_bio_PrivateKey(pBio, pEvpKey, null, null, 0, null, null);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+
+       break;
+
+       default:
+
+               SysTryCatch(NID_SEC, false, r = E_INVALID_ARG, E_INVALID_ARG, " [E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+
+       dataLen = BIO_get_mem_data(pBio, null);
+       SysTryCatch(NID_SEC, dataLen > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pData = std::unique_ptr< byte[] >(new (std::nothrow) byte[dataLen]);
+       SysTryCatch(NID_SEC, pData != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       ret = BIO_read(pBio, pData.get(), dataLen);
+       SysTryCatch(NID_SEC, ret > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pOutBuffer = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC, pOutBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->Construct(ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->SetArray(pData.get(), 0, ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pOutBuffer->Flip();
+
+CATCH:
+       if (pEvpKey != null)
+       {
+
+               EVP_PKEY_free(pEvpKey);
+       }
+
+       if (pBio != null)
+       {
+               BIO_free(pBio);
+       }
+
+       return pOutBuffer.release();
+}
+
+ByteBuffer*
+RsaKeyConverter::ConvertPemToDerN(RsaKeyFormat format, const IKey& key)
+{
+       result r = E_SUCCESS;
+       int keyLen = 0;
+       int ret = 0;
+       const byte* pKey = null;
+       byte* pBuffer = null;
+       BIO* pBio = null;
+       EVP_PKEY* pEvpKey = null;
+       std::unique_ptr< ByteBuffer > pOutBuffer;
+       std::unique_ptr< ByteBuffer > pEncodedInputBuffer;
+
+       pEncodedInputBuffer = std::unique_ptr< ByteBuffer >(key.GetEncodedN());
+       SysTryReturn(NID_SEC, pEncodedInputBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pKey = pEncodedInputBuffer->GetPointer();
+       SysTryReturn(NID_SEC, pKey != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyLen = pEncodedInputBuffer->GetRemaining();
+       SysTryReturn(NID_SEC, keyLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pBio = BIO_new(BIO_s_mem());
+       SysTryReturn(NID_SEC, pBio != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       int readCount = BIO_write(pBio, (const void*) pKey, keyLen);
+       SysTryCatch(NID_SEC, readCount > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       switch (format)
+       {
+       case RSA_KEY_FORMAT_PKCS01_PRIVATE_KEY:
+       {
+               pEvpKey = PEM_read_bio_PrivateKey(pBio, null, 0, null);
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               ret = i2d_PrivateKey(pEvpKey, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       case RSA_KEY_FORMAT_PKCS01_PUBLIC_KEY:
+       {
+               pEvpKey = PEM_read_bio_PUBKEY(pBio, null, 0, null);
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               ret = i2d_PublicKey(pEvpKey, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       case RSA_KEY_FORMAT_X509_PUBLIC_KEY:
+       {
+               pEvpKey = PEM_read_bio_PUBKEY(pBio, null, 0, null);
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               ret = i2d_PUBKEY(pEvpKey, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       case RSA_KEY_FORMAT_PKCS08_PRIVATE_KEY:
+       {
+               pEvpKey = PEM_read_bio_PrivateKey(pBio, null, 0, null);
+               SysTryCatch(NID_SEC, pEvpKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               PKCS8_PRIV_KEY_INFO* pPrivKeyInfo = EVP_PKEY2PKCS8(pEvpKey);
+               SysTryCatch(NID_SEC, pPrivKeyInfo != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               ret = i2d_PKCS8_PRIV_KEY_INFO(pPrivKeyInfo, &pBuffer);
+               SysTryCatch(NID_SEC, ret != -1, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       }
+       break;
+
+       default:
+               SysTryCatch(NID_SEC, false, r = E_INVALID_ARG, E_INVALID_ARG, " [E_INVALID_ARG] The specified input parameter is invalid.");
+
+       }
+
+       pOutBuffer = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC, pOutBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->Construct(ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->SetArray(pBuffer, 0, ret);
+       SysTryCatch(NID_SEC, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pOutBuffer->Flip();
+
+       OPENSSL_free(pBuffer);
+       pBuffer = null;
+
+CATCH:
+
+       if (pEvpKey != null)
+       {
+               EVP_PKEY_free(pEvpKey);
+       }
+
+       if (pBio != null)
+       {
+               BIO_free(pBio);
+       }
+
+       return pOutBuffer.release();
+
+}
+
+} } //Tizen::Security
index cd41a20..83afac4 100644 (file)
@@ -50,6 +50,12 @@ namespace Tizen { namespace Security
 
 _PrivilegeManager* _AccessController::__pPrivilegeManager = null;
 
+static std::unique_ptr<String> pEncryptedPrivileges(null);
+static std::unique_ptr<String> pChecksum(null);
+static std::unique_ptr<String> pEncryptedVisibility(null);
+static std::unique_ptr<String> pVisibilityChecksum(null);
+static std::unique_ptr<ArrayList> pPrivilegeList(null);
+
 _AccessController::_AccessController(void)
 {
 
@@ -57,11 +63,14 @@ _AccessController::_AccessController(void)
 
 _AccessController::~_AccessController(void)
 {
-
+       if (pPrivilegeList != null)
+       {
+               pPrivilegeList->RemoveAll(true);
+       }
 }
 
 result
-_AccessController::CheckSystemPrivilege(const AppId& appId, _Privilege privilege)
+_AccessController::CheckSystemPrivilege(const PackageId& packageId, _Privilege privilege)
 {
        result r = E_SUCCESS;
 
@@ -72,23 +81,153 @@ _AccessController::CheckSystemPrivilege(const AppId& appId, _Privilege privilege
        String appType;
        String webAppType(L"wgt");
 
-       SysLog(NID_SEC, "Enter.");
        SysTryReturnResult(NID_SEC, privilege < _MAX_PRIVILEGE_ENUM, E_INVALID_ARG, "The privilege enumerator is invalid");
 
-       appId.SubString(0, MAX_APP_ID_SIZE, subAppId);
+       packageId.SubString(0, MAX_APP_ID_SIZE, subAppId);
 
        r = infoImpl.Construct(subAppId);
-       if (r == E_APP_NOT_INSTALLED)
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
+       appType = infoImpl.GetAppType();
+       if (appType.Equals(webAppType, true))
+       {
+               return E_SUCCESS;
+       }
+
+       if (__pPrivilegeManager == null)
+       {
+               __pPrivilegeManager = _PrivilegeManager::GetInstance();
+       }
+       SysTryReturnResult(NID_SEC, __pPrivilegeManager != null, E_SYSTEM, "An unexpected system error occurred.");
+
+       pPrivilegeInfo.reset(__pPrivilegeManager->RetrievePrivilegeInfoN(subAppId));
+       r = GetLastResult();
+
+       if (r == E_SUCCESS)
+       {
+               // nothing to do.
+       }
+       else if (r == E_DATA_NOT_FOUND)
+       {
+               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+               goto CATCH;
+       }
+       else
+       {
+               SysLogException(NID_SEC, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               return E_SYSTEM;
+       }
+
+       ret = pPrivilegeInfo->HasPrivilege(privilege);
+       if (!ret)
        {
-               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The package information does not exist.");
-               r = E_DATA_NOT_FOUND;
+               r = E_PRIVILEGE_DENIED;
                goto CATCH;
        }
 
+       return r;
+
+CATCH:
+
+       SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
+       pAppManagerImpl->TerminateApplications(packageId);
+
+       return r;
+}
+
+result
+_AccessController::CheckSystemPrivilege(const PackageId& packageId, _Privilege privilege1, _Privilege privilege2)
+{
+       result r = E_SUCCESS;
+
+       bool ret = false;
+       std::unique_ptr<_PrivilegeInfo> pPrivilegeInfo(null);
+       String subAppId;
+       _PackageInfoImpl infoImpl;
+       String appType;
+       String webAppType(L"wgt");
+
+       SysTryReturnResult(NID_SEC, privilege1 < _MAX_PRIVILEGE_ENUM, E_INVALID_ARG, "The privilege enumerator is invalid");
+       SysTryReturnResult(NID_SEC, privilege2 < _MAX_PRIVILEGE_ENUM, E_INVALID_ARG, "The privilege enumerator is invalid");
+
+       packageId.SubString(0, MAX_APP_ID_SIZE, subAppId);
+
+       r = infoImpl.Construct(subAppId);
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
        appType = infoImpl.GetAppType();
+       if (appType.Equals(webAppType, true))
+       {
+               return E_SUCCESS;
+       }
+
+       if (__pPrivilegeManager == null)
+       {
+               __pPrivilegeManager = _PrivilegeManager::GetInstance();
+       }
+       SysTryReturnResult(NID_SEC, __pPrivilegeManager != null, E_SYSTEM, "An unexpected system error occurred.");
+
+       pPrivilegeInfo.reset(__pPrivilegeManager->RetrievePrivilegeInfoN(subAppId));
        r = GetLastResult();
+
+       if (r == E_SUCCESS)
+       {
+               // nothing to do.
+       }
+       else if (r == E_DATA_NOT_FOUND)
+       {
+               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+               goto CATCH;
+       }
+       else
+       {
+               SysLogException(NID_SEC, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+               return E_SYSTEM;
+       }
+
+       ret = pPrivilegeInfo->HasPrivilegeEx(privilege1);
+       if (!ret)
+       {
+               ret = pPrivilegeInfo->HasPrivilege(privilege2);
+               if (!ret)
+               {
+                       r = E_PRIVILEGE_DENIED;
+                       goto CATCH;
+               }
+       }
+
+       return r;
+
+CATCH:
+
+       SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
+       pAppManagerImpl->TerminateApplications(packageId);
+
+       return r;
+}
+
+result
+_AccessController::CheckPrivilege(const PackageId& packageId, const String& privilege)
+{
+       result r = E_SUCCESS;
+
+       bool ret = false;
+       std::unique_ptr<_PrivilegeInfo> pPrivilegeInfo(null);
+       String subAppId;
+       _PackageInfoImpl infoImpl;
+       String appType;
+       String webAppType(L"wgt");
+
+       packageId.SubString(0, MAX_APP_ID_SIZE, subAppId);
+
+       r = infoImpl.Construct(subAppId);
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
+       appType = infoImpl.GetAppType();
        if (appType.Equals(webAppType, true))
        {
                return E_SUCCESS;
@@ -125,25 +264,18 @@ _AccessController::CheckSystemPrivilege(const AppId& appId, _Privilege privilege
                goto CATCH;
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 
 CATCH:
 
        SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-       SysLog(NID_SEC, "Exit.");
 
        _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
-       pAppManagerImpl->TerminateApplications(appId);
+       pAppManagerImpl->TerminateApplications(packageId);
 
        return r;
 }
 
-static std::unique_ptr<String> pEncryptedPrivileges(null);
-static std::unique_ptr<String> pChecksum(null);
-static std::unique_ptr<String> pEncryptedVisibility(null);
-static std::unique_ptr<String> pVisibilityChecksum(null);
-
 void
 _AccessController::Initialize(void)
 {
@@ -153,8 +285,6 @@ _AccessController::Initialize(void)
        std::unique_ptr<IPC::Message> pCipherPrivilegeMessage(null);
        std::unique_ptr<IPC::Message> pCipherVisibilityMessage(null);
 
-       SysLog(NID_SEC, "Enter");
-
        r = ipcClient.Construct(L"osp.security.ipcserver.privilegemanager", null);
        SysTryReturnVoidResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "Failed to construct the instance of IPC.");
 
@@ -164,7 +294,12 @@ _AccessController::Initialize(void)
        pChecksum.reset(new (std::nothrow) String());
        SysTryReturnVoidResult(NID_SEC, pChecksum != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
-       pCipherPrivilegeMessage.reset(new (std::nothrow) PrivilegeManagerMsg_retrieve(pEncryptedPrivileges.get(), pChecksum.get(), &r));
+       pPrivilegeList.reset(new ArrayList());
+       SysTryReturnVoidResult(NID_SEC, pPrivilegeList != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       pPrivilegeList->Construct();
+
+       pCipherPrivilegeMessage.reset(new (std::nothrow) PrivilegeManagerMsg_retrieve(pEncryptedPrivileges.get(), pChecksum.get(), pPrivilegeList.get(), &r));
        SysTryReturnVoidResult(NID_SEC, pCipherPrivilegeMessage != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
        ipcResult = ipcClient.SendRequest(pCipherPrivilegeMessage.get());
@@ -186,7 +321,6 @@ _AccessController::Initialize(void)
 
        isConstructed = true;
 
-    SysLog(NID_SEC, "Exit");
        return;
 }
 
@@ -198,17 +332,16 @@ _AccessController::CheckUserPrivilege(_Privilege privilege)
 
        bool ret = false;
 
-       _AppType appType = _APP_TYPE_UI_APP;
        _PrivilegeInfo privilegeInfo;
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
        SysTryReturnResult(NID_SEC, privilege < _MAX_PRIVILEGE_ENUM, E_INVALID_ARG, "The privilege enumerator is invalid");
        //SysAssertf(privilegeLevelListTable[privilege][_PRV_API_VER_2_0] == _PRV_LEVEL_USER, "System-level privilege is passed to CheckUserPrivilege.");
 
-       appType = _AppInfo::GetAppType();
-       const PackageId& packageId = _AppInfo::GetPackageId();
+       int appType = _AppInfo::GetAppType();
+       PackageId packageId = _AppInfo::GetPackageId();
+       packageId[0] = packageId[0];
 
        if ((appType & _APP_TYPE_WEB_APP) != _APP_TYPE_WEB_APP)
        {
@@ -234,7 +367,7 @@ _AccessController::CheckUserPrivilege(_Privilege privilege)
 
                if ((pEncryptedPrivileges != null) && (pChecksum != null) && (pEncryptedVisibility != null) && (pVisibilityChecksum != null))
                {
-                       r = privilegeInfo.Construct(packageId, *(pEncryptedPrivileges.get()), *(pChecksum.get()), *(pEncryptedVisibility.get()), *(pVisibilityChecksum.get()));
+                       r = privilegeInfo.Construct(packageId, *(pEncryptedPrivileges.get()), *(pChecksum.get()), *(pEncryptedVisibility.get()), *(pVisibilityChecksum.get()), pPrivilegeList.get());
                        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred. %ls", packageId.GetPointer());
 
                        SysLog(NID_SEC, "%ls is in the cache [client]", privilegeInfo.GetAppId().GetPointer());
@@ -254,13 +387,11 @@ _AccessController::CheckUserPrivilege(_Privilege privilege)
                }
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 
 CATCH:
 
        SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-       SysLog(NID_SEC, "Exit.");
 
        _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
        pAppManagerImpl->TerminateApplications(packageId);
@@ -269,4 +400,161 @@ CATCH:
 
 }
 
+result
+_AccessController::CheckUserPrivilege(_Privilege privilege1, _Privilege privilege2)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       bool ret = false;
+
+       _PrivilegeInfo privilegeInfo;
+
+       ClearLastResult();
+
+       SysTryReturnResult(NID_SEC, privilege1 < _MAX_PRIVILEGE_ENUM, E_INVALID_ARG, "The privilege enumerator is invalid");
+       SysTryReturnResult(NID_SEC, privilege2 < _MAX_PRIVILEGE_ENUM, E_INVALID_ARG, "The privilege enumerator is invalid");
+       //SysAssertf(privilegeLevelListTable[privilege][_PRV_API_VER_2_0] == _PRV_LEVEL_USER, "System-level privilege is passed to CheckUserPrivilege.");
+
+       int appType = _AppInfo::GetAppType();
+       PackageId packageId = _AppInfo::GetPackageId();
+       packageId[0] = packageId[0];
+
+       if ((appType & _APP_TYPE_WEB_APP) != _APP_TYPE_WEB_APP)
+       {
+           if (isConstructed != true)
+           {
+               pthread_once(&onceBlock, Initialize);
+               r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       if (r == E_DATA_NOT_FOUND)
+                       {
+                               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+                               goto CATCH;
+                       }
+                       else
+                       {
+                               onceBlock = PTHREAD_ONCE_INIT;
+                                       SysLogException(NID_SEC, r, "[%s] Propagated.", GetErrorMessage(r));
+                       }
+                               return r;
+               }
+           }
+
+               if ((pEncryptedPrivileges != null) && (pChecksum != null) && (pEncryptedVisibility != null) && (pVisibilityChecksum != null))
+               {
+                       r = privilegeInfo.Construct(packageId, *(pEncryptedPrivileges.get()), *(pChecksum.get()), *(pEncryptedVisibility.get()), *(pVisibilityChecksum.get()), pPrivilegeList.get());
+                       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred. %ls", packageId.GetPointer());
+
+                       SysLog(NID_SEC, "%ls is in the cache [client]", privilegeInfo.GetAppId().GetPointer());
+               }
+               else
+               {
+                       SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+                       r =  E_DATA_NOT_FOUND;
+                       goto CATCH;
+               }
+
+               ret = privilegeInfo.HasPrivilegeEx(privilege1);
+               if (!ret)
+               {
+                       ret = privilegeInfo.HasPrivilege(privilege2);
+                       if (!ret)
+                       {
+                               r = E_PRIVILEGE_DENIED;
+                               goto CATCH;
+                       }
+               }
+       }
+
+       return r;
+
+CATCH:
+
+       SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
+       pAppManagerImpl->TerminateApplications(packageId);
+
+       return r;
+
+}
+
+
+result
+_AccessController::CheckPrivilege(const String& privilege)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       bool ret = false;
+
+       _PrivilegeInfo privilegeInfo;
+
+       ClearLastResult();
+
+       int appType = _AppInfo::GetAppType();
+       PackageId packageId = _AppInfo::GetPackageId();
+       packageId[0] = packageId[0];
+
+       if ((appType & _APP_TYPE_WEB_APP) != _APP_TYPE_WEB_APP)
+       {
+               if (isConstructed != true)
+               {
+                       pthread_once(&onceBlock, Initialize);
+                       r = GetLastResult();
+                       if (IsFailed(r))
+                       {
+                               if (r == E_DATA_NOT_FOUND)
+                               {
+                                       SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+                                       goto CATCH;
+                               }
+                               else
+                               {
+                                       onceBlock = PTHREAD_ONCE_INIT;
+                                       SysLogException(NID_SEC, r, "[%s] Propagated.", GetErrorMessage(r));
+                               }
+                               return r;
+                       }
+               }
+
+               std::unique_ptr<IEnumerator> pEnum(null);
+               pEnum.reset(pPrivilegeList->GetEnumeratorN());
+
+               if ((pEncryptedPrivileges != null) && (pChecksum != null) && (pEncryptedVisibility != null) && (pVisibilityChecksum != null))
+               {
+                       r = privilegeInfo.Construct(packageId, *(pEncryptedPrivileges.get()), *(pChecksum.get()), *(pEncryptedVisibility.get()), *(pVisibilityChecksum.get()), pPrivilegeList.get());
+                       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred. %ls", packageId.GetPointer());
+
+                       SysLog(NID_SEC, "%ls is in the cache [client]", privilegeInfo.GetAppId().GetPointer());
+               }
+               else
+               {
+                       SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
+                       r =  E_DATA_NOT_FOUND;
+                       goto CATCH;
+               }
+
+               ret = privilegeInfo.HasPrivilege(privilege);
+               if (!ret)
+               {
+                       r = E_PRIVILEGE_DENIED;
+                       goto CATCH;
+               }
+       }
+
+       return r;
+
+CATCH:
+
+       SysLogException(NID_SEC,  r, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
+       pAppManagerImpl->TerminateApplications(packageId);
+
+       return r;
+}
+
 }} //Tizen::Security
diff --git a/src/security/FSec_PrivacyInfoImpl.cpp b/src/security/FSec_PrivacyInfoImpl.cpp
new file mode 100755 (executable)
index 0000000..b445db8
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// 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       FSec_PrivacyInfoImpl.cpp
+ * @brief      This is the implementation for the _PrivacyInfoImpl class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <FSecPrivacyInfo.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FSec_PrivacyInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Security
+{
+
+_PrivacyInfoImpl::_PrivacyInfoImpl(void)
+       : __enabled(false)
+{
+
+}
+
+_PrivacyInfoImpl::~_PrivacyInfoImpl(void)
+{
+
+}
+
+result
+_PrivacyInfoImpl::Construct(const Tizen::Base::String& privacyId, bool enable)
+{
+       result r = E_SUCCESS;
+       __privacyId = privacyId;
+       __enabled = enable;
+       
+       return r;
+}
+
+String
+_PrivacyInfoImpl::GetId(void) const
+{
+       return __privacyId;
+}
+
+bool
+_PrivacyInfoImpl::IsEnabled(void) const
+{
+       return __enabled;
+}
+
+void
+_PrivacyInfoImpl::SetEnabled(bool enable)
+{
+       __enabled = enable;
+}
+
+String
+_PrivacyInfoImpl::GetDisplayName(void) const
+{
+       return __privacyId;
+}
+
+String
+_PrivacyInfoImpl::GetDescription(void) const
+{
+       String description("undefined");
+       return description;
+}
+
+}} // Tizen::Security
diff --git a/src/security/FSec_PrivacyManagerImpl.cpp b/src/security/FSec_PrivacyManagerImpl.cpp
new file mode 100755 (executable)
index 0000000..a15f317
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// 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       FSec_PrivacyManagerImpl.cpp
+ * @brief      This is the implementation for the _PrivacyManagerImpl class.
+ */
+
+#include <new>
+#include <FSecPrivacyManager.h>
+#include <FBaseSysLog.h>
+#include "FSec_PrivacyManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Security
+{
+
+_PrivacyManagerImpl::_PrivacyManagerImpl(void)
+{
+
+}
+
+_PrivacyManagerImpl::~_PrivacyManagerImpl(void)
+{
+
+}
+
+const _PrivacyManagerImpl*
+_PrivacyManagerImpl::GetInstance(PrivacyManager& privacyManager)
+{
+       return privacyManager.__pPrivacyManagerImpl;
+}
+
+Tizen::Base::Collection::IList*
+_PrivacyManagerImpl::GetPrivacyAppPackageListN(void) const
+{
+       return null;
+
+}
+
+Tizen::Base::Collection::IList*
+_PrivacyManagerImpl::GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const
+{
+       return null;
+}
+
+result
+_PrivacyManagerImpl::SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo)
+{
+       result r = E_SUCCESS;
+
+       return r;
+}
+
+}} // Tizen::Security
index b760451..5427f40 100644 (file)
@@ -61,8 +61,6 @@ _PrivilegeCache::Construct(void)
 {
        result r = E_SUCCESS;
 
-       SysLog(NID_SEC, "Enter.");
-
        std::unique_ptr<HashMap> pPrivilegeList(new (std::nothrow) HashMap());
        SysTryReturnResult(NID_SEC, pPrivilegeList != null, E_OUT_OF_MEMORY, "Memory allocation is failed.");
 
@@ -78,7 +76,6 @@ _PrivilegeCache::Construct(void)
        __pPrivilegeList = std::move(pPrivilegeList);
        __pMutex = std::move(pMutex);
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -91,8 +88,6 @@ _PrivilegeCache::AddPrivilegeInfo(const _PrivilegeInfo& privilegeInfo)
        std::unique_ptr<_PrivilegeInfo> pPrivilegeInfo(null);
        std::unique_ptr<String> pKey(null);
 
-       SysLog(NID_SEC, "Enter.");
-
        SysTryReturnResult(NID_SEC, privilegeInfo.GetAppId().GetLength() == MAX_APP_ID_SIZE, E_INVALID_ARG, "The argument is invalid.");
 
        pPrivilegeInfo.reset(privilegeInfo.CloneN());
@@ -110,7 +105,6 @@ _PrivilegeCache::AddPrivilegeInfo(const _PrivilegeInfo& privilegeInfo)
        mutexResult = __pMutex->Release();
        SysTryCatch(NID_SEC, mutexResult == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 
 CATCH2:
@@ -118,13 +112,9 @@ CATCH2:
        mutexResult = __pMutex->Release();
        SysTryCatch(NID_SEC, mutexResult == E_SUCCESS, mutexResult = E_SYSTEM, E_SYSTEM, "An unexpected system error occurred.");
 
-
-       SysLog(NID_SEC, "Exit.");
        return r;
 
 CATCH:
-
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -134,8 +124,6 @@ _PrivilegeCache::RemovePrivilegeInfo(const AppId& appId)
        result r = E_SUCCESS;
        result mutextResult = E_SUCCESS;
 
-       SysLog(NID_SEC, "Enter.");
-
        mutextResult = __pMutex->Acquire();
        SysTryReturnResult(NID_SEC, mutextResult == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
@@ -154,7 +142,6 @@ _PrivilegeCache::RemovePrivilegeInfo(const AppId& appId)
        mutextResult = __pMutex->Release();
        SysTryReturnResult(NID_SEC, mutextResult == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -166,7 +153,6 @@ _PrivilegeCache::GetPrivilegeInfoN(const AppId& appId) const
 
        std::unique_ptr<_PrivilegeInfo> pPrivilegeInfo(null);
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
        mutexResult = __pMutex->Acquire();
@@ -197,7 +183,6 @@ _PrivilegeCache::GetPrivilegeInfoN(const AppId& appId) const
                SysLogException(NID_SEC, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
        }
 
-       SysLog(NID_SEC, "Exit.");
        return pPrivilegeInfo.release();
 }
 
index 08a4ec6..24868c1 100644 (file)
@@ -29,6 +29,7 @@
 #include <FSecCryptoAesCipher.h>
 #include <FSecCryptoSha1Hmac.h>
 #include <FSecCryptoSha1Hash.h>
+#include <FBaseColArrayList.h>
 
 #include "FSec_DeviceKeyGenerator.h"
 #include "FSec_PrivilegeInfo.h"
@@ -36,6 +37,7 @@
 using namespace Tizen::App;
 using namespace Tizen::App::Package;
 using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::Security::Crypto;
 using namespace Tizen::Text;
@@ -52,11 +54,11 @@ _PrivilegeInfo::_PrivilegeInfo(void)
 
 _PrivilegeInfo::~_PrivilegeInfo(void)
 {
-
+       __privilegeList.RemoveAll(true);
 }
 
 result
-_PrivilegeInfo::Construct(const AppId& appId, const byte* pBitwisePrivilege)
+_PrivilegeInfo::Construct(const AppId& appId, const byte* pBitwisePrivilege, const ArrayList* pPrivilegeList)
 {
        result r = E_SUCCESS;
 
@@ -71,11 +73,25 @@ _PrivilegeInfo::Construct(const AppId& appId, const byte* pBitwisePrivilege)
        __appId = appId;
        memcpy(__bitwisePrivilege, pBitwisePrivilege, __bitwiseLength);
 
+
+       std::unique_ptr<IEnumerator> pEnum(null);
+       r = __privilegeList.Construct();
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
+       pEnum.reset(pPrivilegeList->GetEnumeratorN());
+       SysTryReturnResult(NID_SEC, pEnum != null, E_SYSTEM, "An unexpected system error occurred.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* tempString = static_cast< String* >(pEnum->GetCurrent());
+               __privilegeList.Add(new String(*tempString));
+       }
+
        return r;
 }
 
 result
-_PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges, const String& checksum)
+_PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges, const String& checksum, const ArrayList* pPrivilegeList)
 {
        result r = E_SUCCESS;
        byte* pDecrytpedBitwisePrivilege = null;
@@ -83,8 +99,6 @@ _PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges,
        std::unique_ptr<ByteBuffer> pBitwisePrivilege(null);
        _PackageInfoImpl infoImpl;
 
-       SysLog(NID_SEC, "Enter.");
-
        SysTryReturnResult(NID_SEC,
                                          appId.GetLength() > 0 && appId.GetLength() == MAX_APP_ID_SIZE, E_INVALID_ARG,
                                          "One of the argument is invalid.");
@@ -117,12 +131,24 @@ _PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges,
        __apiVisibility = infoImpl.GetApiVisibility();
        SysTryReturnResult(NID_SEC, __apiVisibility >= 0, E_SYSTEM, "An unexpected system error occurred.");
 
-       SysLog(NID_SEC, "Exit.");
+       std::unique_ptr<IEnumerator> pEnum(null);
+       r = __privilegeList.Construct();
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
+       pEnum.reset(pPrivilegeList->GetEnumeratorN());
+       SysTryReturnResult(NID_SEC, pEnum != null, E_SYSTEM, "An unexpected system error occurred.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* tempString = static_cast< String* >(pEnum->GetCurrent());
+               __privilegeList.Add(new String(*tempString));
+       }
+
        return r;
 }
 
 result
-_PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges, const String& checksum, const String& encryptedVisibiliity, const String& visibilityChecksum)
+_PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges, const String& checksum, const String& encryptedVisibiliity, const String& visibilityChecksum, const ArrayList* pPrivilegeList)
 {
        result r = E_SUCCESS;
        byte* pDecrytpedBitwisePrivilege = null;
@@ -142,8 +168,6 @@ _PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges,
                0x08, 0x9D, 0x9F, 0x57, 0x3B, 0x63, 0xEF, 0x4B
        };
 
-       SysLog(NID_SEC, "Enter.");
-
        SysTryReturnResult(NID_SEC,
                                          appId.GetLength() > 0 && appId.GetLength() == MAX_APP_ID_SIZE, E_INVALID_ARG,
                                          "One of the argument is invalid.");
@@ -197,14 +221,28 @@ _PrivilegeInfo::Construct(const AppId& appId, const String& encryptedPrivileges,
 
        __apiVisibility = visibility;
 
-       SysLog(NID_SEC, "Exit.");
+       std::unique_ptr<IEnumerator> pEnum(null);
+       r = __privilegeList.Construct();
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
+       pEnum.reset(pPrivilegeList->GetEnumeratorN());
+       SysTryReturnResult(NID_SEC, pEnum != null, E_SYSTEM, "An unexpected system error occurred.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* tempString = static_cast< String* >(pEnum->GetCurrent());
+               __privilegeList.Add(new String(*tempString));
+       }
+
        return r;
 }
 
+
 _PrivilegeInfo*
 _PrivilegeInfo::CloneN(void) const
 {
        _PrivilegeInfo* pPrivilegeInfo = null;
+       result r = E_SUCCESS;
 
        ClearLastResult();
 
@@ -217,6 +255,19 @@ _PrivilegeInfo::CloneN(void) const
        pPrivilegeInfo->__appId.Append(this->__appId);
        memcpy(pPrivilegeInfo->__bitwisePrivilege, this->__bitwisePrivilege, pPrivilegeInfo->__bitwiseLength);
 
+       std::unique_ptr<IEnumerator> pEnum(null);
+       r = pPrivilegeInfo->__privilegeList.Construct();
+       SysTryReturn(NID_SEC, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       pEnum.reset(this->__privilegeList.GetEnumeratorN());
+       SysTryReturn(NID_SEC, pEnum != null, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* tempString = static_cast< String* >(pEnum->GetCurrent());
+               pPrivilegeInfo->__privilegeList.Add(new String(*tempString));
+       }
+
        return pPrivilegeInfo;
 }
 
@@ -234,6 +285,16 @@ _PrivilegeInfo::Construct(const _PrivilegeInfo& privilegeInfo)
 
        __apiVisibility = privilegeInfo.__apiVisibility;
 
+       __privilegeList.Construct();
+
+       IEnumerator* pEnum = privilegeInfo.__privilegeList.GetEnumeratorN();
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* tempString = static_cast< String* >(pEnum->GetCurrent());
+               __privilegeList.Add(new String(*tempString));
+       }
+
+       delete pEnum;
        return r;
 }
 
@@ -249,15 +310,12 @@ _PrivilegeInfo::GetBitwisePrivilegeN(byte*& pBitwisePrivilege) const
        byte* pReturn = null;
        result r = E_SUCCESS;
 
-       SysLog(NID_SEC, "Enter.");
-
        pReturn = (byte*) malloc(sizeof(byte) * MAX_BITWISE_PRIV_SIZE);
        SysTryReturnResult(NID_SEC, pReturn != null, E_OUT_OF_MEMORY, "Memory allocation is failed.");
        memcpy(pReturn, __bitwisePrivilege, MAX_BITWISE_PRIV_SIZE);
 
        pBitwisePrivilege = pReturn;
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -272,8 +330,6 @@ _PrivilegeInfo::GetEncryptedBitwise(String& encryptedPrivileges) const
        AesCipher cipherEnc;
        const byte ivector[_IV_LEN] = { 0x3E, 0xB5, 0x01, 0x45, 0xE4, 0xF8, 0x75, 0x3F, 0x08, 0x9D, 0x9F, 0x57, 0x3B, 0x63, 0xEF, 0x4B};
 
-       SysLog(NID_SEC, "Enter.");
-
        pBitwisePrivilege.reset(new (std::nothrow) ByteBuffer());
        SysTryReturnResult(NID_SEC, pBitwisePrivilege != null, E_OUT_OF_MEMORY, "Memory allocation is failed.");
 
@@ -309,7 +365,6 @@ _PrivilegeInfo::GetEncryptedBitwise(String& encryptedPrivileges) const
        r = StringUtil::EncodeToBase64String(*(pEncryptedBitwisePrivilege.get()), encryptedPrivileges);
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -324,7 +379,7 @@ _PrivilegeInfo::GetChecksum(String& checksum) const
        std::unique_ptr<ISecretKey> pKey(null);
        std::unique_ptr<IHmac> pHmac(null);
        std::unique_ptr<ByteBuffer> pChecksumByteBuffer(null);
-       std::unique_ptr<char> pAppId(null);
+       std::unique_ptr<char[]> pAppId(null);
 
        pAppId.reset(_StringConverter::CopyToCharArrayN(__appId));
        SysTryReturnResult(NID_SEC, pAppId != null, E_SYSTEM, "An unexpected system error occurred.");
@@ -393,6 +448,83 @@ _PrivilegeInfo::HasPrivilege(_Privilege privilege) const
        return ret;
 }
 
+bool
+_PrivilegeInfo::HasPrivilegeEx(_Privilege privilege) const
+{
+       bool ret = false;
+       int targetIndex = static_cast< int >(privilege) / _BITS_IN_BYTE;
+       byte privilegeBit = (byte) (static_cast< int >(privilege) % _BITS_IN_BYTE);
+       byte bitwiseTargetPrivilege = 0;
+       byte tempBitwisePrivilege = 0;
+
+       if (__apiVisibility != _API_VISIBILITY_NONE) // To be removed
+       {
+               if (visibilityLevelListTable[privilege][_PRV_API_VER_2_0] > __apiVisibility)
+               {
+                       return ret;
+               }
+       }
+
+       bitwiseTargetPrivilege = bitwiseTargetPrivilege | (1 << privilegeBit);
+       tempBitwisePrivilege = __bitwisePrivilege[targetIndex] & bitwiseTargetPrivilege;
+
+       if (bitwiseTargetPrivilege == tempBitwisePrivilege)
+       {
+               SysLog(NID_SEC, "Result : TRUE");
+               ret = true;
+       }
+
+       return ret;
+}
+
+bool
+_PrivilegeInfo::HasPrivilege(const String& privilege) const
+{
+    bool ret = false;
+    bool validStringFlag = false;
+    int privilegeEnum = -1;
+    int index = 0;
+
+       String privilegeURI = L"http://tizen.org/privilege/";
+    String privilegeSubString;
+    String privilegeSubStringURI;
+    privilege.SubString(0, privilegeURI.GetLength(), privilegeSubStringURI);
+
+    if (privilegeSubStringURI.Equals(privilegeURI, true))
+    {
+               privilege.SubString(privilegeURI.GetLength(), privilege.GetLength() - privilegeURI.GetLength(), privilegeSubString);
+       for (index = 0; index < _MAX_PRIVILEGE_ENUM; index++)
+               {
+                       if (wcscmp(privilegeListTable[index].privilegeString, privilegeSubString.GetPointer()) == 0)
+                       {
+                               validStringFlag = true;
+                               privilegeEnum = index;
+                               break;
+                       }
+               }
+    }
+
+    if (validStringFlag)
+    {
+       ret = HasPrivilege(privilegeListTable[index].privilege);
+
+    }
+    else
+    {
+       ret = __privilegeList.Contains(privilege);
+       if (ret)
+               {
+                       SysLog(NID_SEC, "Result : TRUE");
+               }
+               else
+               {
+                       SysLogException(NID_SEC, E_PRIVILEGE_DENIED, "Result : FALSE [%ls, %ls]", __appId.GetPointer(), privilege.GetPointer());
+               }
+    }
+
+       return ret;
+}
+
 result
 _PrivilegeInfo::VerifyIntegrity(const AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length)
 {
@@ -405,8 +537,6 @@ _PrivilegeInfo::VerifyIntegrity(const AppId& appId, const byte* targetBitwisePri
        std::unique_ptr<ByteBuffer> pChecksumByteBuffer(null);
        std::unique_ptr<char> pAppId(null);
 
-       SysLog(NID_SEC, "Enter.");
-
        SysTryReturnResult(NID_SEC, length <= MAX_BITWISE_PRIV_SIZE, E_INVALID_ARG, "The privilege information of %ls is invalid.", appId.GetPointer());
 
        pAppId.reset(_StringConverter::CopyToCharArrayN(appId));
@@ -439,7 +569,6 @@ _PrivilegeInfo::VerifyIntegrity(const AppId& appId, const byte* targetBitwisePri
                r = E_INVALID_ARG;
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -455,9 +584,8 @@ _PrivilegeInfo::VerifyIntegrityEx(const AppId& appId, const byte* targetBitwiseP
        std::unique_ptr<IHmac> pHmac(null);
        std::unique_ptr<ByteBuffer> pChecksumByteBuffer(null);
        std::unique_ptr<ISecretKey> pKey(null);
-       std::unique_ptr<char> pAppId(null);
+       std::unique_ptr<char[]> pAppId(null);
 
-       SysLog(NID_SEC, "Enter.");
        SysTryReturnResult(NID_SEC, length <= MAX_BITWISE_PRIV_SIZE, E_INVALID_ARG, "The privilege information of [%ls] is invalid.", appId.GetPointer());
 
        pAppId.reset(_StringConverter::CopyToCharArrayN(appId));
@@ -496,7 +624,6 @@ _PrivilegeInfo::VerifyIntegrityEx(const AppId& appId, const byte* targetBitwiseP
                r = E_INVALID_ARG;
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -516,9 +643,8 @@ _PrivilegeInfo::VerifyIntegrity(const AppId& appId, const byte* targetBitwisePri
        std::unique_ptr<ByteBuffer> pChecksumByteBuffer(null);
        std::unique_ptr<ByteBuffer> pVisibilityChecksumByteBuffer(null);
        std::unique_ptr<ISecretKey> pKey(null);
-       std::unique_ptr<char> pAppId(null);
+       std::unique_ptr<char[]> pAppId(null);
 
-       SysLog(NID_SEC, "Enter.");
        SysTryReturnResult(NID_SEC, length <= MAX_BITWISE_PRIV_SIZE, E_INVALID_ARG, "The privilege information of [%ls] is invalid.", appId.GetPointer());
 
        pAppId.reset(_StringConverter::CopyToCharArrayN(appId));
@@ -579,7 +705,6 @@ _PrivilegeInfo::VerifyIntegrity(const AppId& appId, const byte* targetBitwisePri
                r = E_INVALID_ARG;
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
index 1c33b70..f6256a7 100644 (file)
@@ -68,10 +68,10 @@ public:
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_INVALID_ARG           A specified input parameter is invalid.
         */
-       result Construct(const Tizen::App::AppId& appId, const byte* pBitwisePrivilege);
+       result Construct(const Tizen::App::AppId& appId, const byte* pBitwisePrivilege, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
 
        /**
-        * Initializes an instance of _PrivilegeInfo and sets its base information using stored information.
+        * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege information.
         *
         * @since               2.0
         * @return              An error code
@@ -81,8 +81,22 @@ public:
         * @exception   E_SUCCESS                               The method is successful.
         * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
         */
-       result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum);
-       result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum, const Tizen::Base::String& encryptedVisibiliity, const Tizen::Base::String& visibilityChecksum);
+       result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
+                       const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
+
+       /**
+        * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege and visibility information.
+        *
+        * @since               2.0
+        * @return              An error code
+        * @param[in]   appId                                   The application ID.
+        * @param[in]   encryptedPrivileges             A string containing encrypted privilege information.
+        * @param[in]   checksum                                A string containing checksum of privilege information.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
+        */
+       result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
+                       const Tizen::Base::String& encryptedVisibiliity, const Tizen::Base::String& visibilityChecksum, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
 
        /**
         * Initializes an instance of _PrivilegeInfo and sets its base information using _PrivilegeInfo instance.
@@ -152,28 +166,34 @@ public:
         *
         * @since               2.0
         * @return              A boolean value of the result
-        * @param[int]  privilege               A value of enumerator of the specified privilege group.
+        * @param[int]  privilege               A value of enumerator of the specified privilege.
         */
        bool HasPrivilege(_Privilege privilege) const;
 
-private:
        /**
-        * Verify the checksum string.
+        * Checks whether the application has a privilege to invoke. @n
+        * Unlike HasPrivilege, HasPrivilegeEx does not print the log.
         *
-        * @since               2.0
-        * @return              E_SUCCESS if the checksum is normal
-        * @param[in]   appId                                   The application ID.
-        * @param[int]  targetBitwisePrivilege  The bitwise privilege information.
-        * @param[in]   storedChecksum                  The stored checksum.
-        * @param[out]  pResult                                 A boolean value of the result.
-        * @exception   E_SUCCESS                               The method is successful.
-        * @exception   E_INVALID_ARG                   The checksum is abnormal.
-        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
-        * @exception   E_SYSTEM                                An unexpected system error occurred.
+        * @since               2.1
+        * @return              A boolean value of the result
+        * @param[int]  privilege               A value of enumerator of the specified privilege.
         */
+       bool HasPrivilegeEx(_Privilege privilege) const;
+
+       /**
+        * Checks whether the application has a privilege to invoke.
+        *
+        * @since               2.1
+        * @return              A boolean value of the result
+        * @param[in]   privilege               A string of the specified privilege.
+        */
+       bool HasPrivilege(const Tizen::Base::String& privilege) const;
+
+private:
+
        result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
-       result VerifyIntegrityEx(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
        result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length, int visibility, const Tizen::Base::String& storedVisibilityChecksum);
+       result VerifyIntegrityEx(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
 
        _PrivilegeInfo(const _PrivilegeInfo& rhs);
        _PrivilegeInfo& operator =(const _PrivilegeInfo& rhs);
@@ -183,6 +203,7 @@ private:
        int __apiVisibility;
        byte __bitwisePrivilege[MAX_BITWISE_PRIV_SIZE];
        int __bitwiseLength;
+       Tizen::Base::Collection::ArrayList __privilegeList;
 
 };  // _PrivilegeInfo
 
diff --git a/src/security/FSec_PrivilegeInfoImpl.cpp b/src/security/FSec_PrivilegeInfoImpl.cpp
new file mode 100755 (executable)
index 0000000..e0f712e
--- /dev/null
@@ -0,0 +1,333 @@
+//
+// 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       FSec_PrivilegeInfoImpl.cpp
+ * @brief      This is the implementation for the _PrivilegeInfoImpl class.
+ */
+
+#include <new>
+#include <cstdio>
+#include <cstdlib>
+#include <unistd.h>
+#include <unique_ptr.h>
+
+#include <FSysSystemTime.h>
+#include <FSecPrivilegeInfo.h>
+#include <FBaseSysLog.h>
+#include <FIo.h>
+#include <FBase_StringConverter.h>
+#include <FSec_AccessControlTypes.h>
+
+#include "FSec_PrivilegeInfoImpl.h"
+
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Security
+{
+
+_PrivilegeInfoImpl* _PrivilegeInfoImpl::__pPrivilegeInfoImplInstance  = null;
+
+_PrivilegeInfoImpl::_PrivilegeInfoImpl(void)
+: __pDb(null)
+{
+}
+
+_PrivilegeInfoImpl::~_PrivilegeInfoImpl(void)
+{
+       delete __pDb;
+       return;
+}
+
+result
+_PrivilegeInfoImpl::Construct(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       r = CheckDatabase();
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
+       Database* pDb = new Database;
+       SysTryReturnResult(NID_SEC, pDb != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       r = pDb->Construct(PRIVILEGE_DESCRIPTION_DATABASE_FILE_NAME, false);
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
+       __pDb = pDb;
+
+       return E_SUCCESS;
+}
+
+result
+_PrivilegeInfoImpl::CheckDatabase(void)
+{
+       if (File::IsFileExist(PRIVILEGE_DESCRIPTION_DATABASE_FILE_NAME) != true)
+       {
+               SysLogException(NID_SEC, E_SYSTEM, "[E_SYSTEM] Privilege information DB is not exist.");
+               return E_SYSTEM;
+       }
+
+       return E_SUCCESS;
+}
+
+
+void
+_PrivilegeInfoImpl::InitInstance(void)
+{
+       result r = E_SUCCESS;
+       static _PrivilegeInfoImpl instance;
+
+       ClearLastResult();
+
+       r = instance.Construct();
+       SysTryReturnVoidResult(NID_SEC, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pPrivilegeInfoImplInstance = &instance;
+}
+
+_PrivilegeInfoImpl*
+_PrivilegeInfoImpl::GetInstance(void)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       ClearLastResult();
+
+    if (__pPrivilegeInfoImplInstance == null)
+    {
+        pthread_once(&onceBlock, InitInstance);
+
+        r = GetLastResult();
+        if (IsFailed(r))
+        {
+            onceBlock = PTHREAD_ONCE_INIT;
+            __pPrivilegeInfoImplInstance = null;
+            SysLogException(NID_SEC, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+        }
+    }
+
+       return __pPrivilegeInfoImplInstance;
+}
+
+String
+_PrivilegeInfoImpl::GetName(const String& privilege) const
+{
+       String name;
+       result r = E_SUCCESS;
+       DbStatement* pStmt = null;
+       DbEnumerator* pEnum = null;
+       String query;
+
+       String privilegeURI = L"http://tizen.org/privilege/";
+       String uriString;
+       String privilegeString;
+
+       SysTryCatch(NID_SEC, (privilege.GetLength()) > (privilegeURI.GetLength()), ,E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", privilege.GetPointer());
+
+
+       privilege.SubString(0, privilegeURI.GetLength(), uriString);
+       SysTryCatch(NID_SEC, uriString.Equals(privilegeURI, true), ,E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", privilege.GetPointer());
+
+       privilege.SubString(privilegeURI.GetLength(), privilege.GetLength()-privilegeURI.GetLength(), privilegeString);
+       query.Format(1024, L"SELECT NAME FROM Privileges WHERE PRIVILEGE = '%ls'", privilegeString.GetPointer());
+
+       pStmt = CreateStatementN(*__pDb, query);
+       SysTryCatch(NID_SEC, pStmt != null, , E_DATABASE, "[E_DATABASE] An error occurs while creating a database statement.");
+
+       pEnum = ExecuteStatementN(*__pDb, pStmt);
+       if (pEnum != null)
+       {
+               if (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       r = pEnum->GetStringAt(0, name);
+               }
+
+               delete pEnum;
+               pEnum = null;
+       }
+       else
+       {
+               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] Privilege information is not found. [%ls]", privilegeString.GetPointer());
+       }
+
+CATCH:
+       delete pStmt;
+       pStmt = null;
+
+       return name;
+}
+
+String
+_PrivilegeInfoImpl::GetDescription(const String& privilege) const
+{
+       String description;
+       result r = E_SUCCESS;
+       DbStatement* pStmt = null;
+       DbEnumerator* pEnum = null;
+       String query;
+
+       String privilegeURI = L"http://tizen.org/privilege/";
+       String uriString;
+       String privilegeString;
+
+       SysTryCatch(NID_SEC, (privilege.GetLength()) > (privilegeURI.GetLength()), ,E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", privilege.GetPointer());
+
+       privilege.SubString(0, privilegeURI.GetLength(), uriString);
+       SysTryCatch(NID_SEC, uriString.Equals(privilegeURI, true), ,E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", privilege.GetPointer());
+
+       privilege.SubString(privilegeURI.GetLength(), privilege.GetLength()-privilegeURI.GetLength(), privilegeString);
+       query.Format(1024, L"SELECT DESCRIPTION FROM Privileges WHERE PRIVILEGE = '%ls'", privilegeString.GetPointer());
+
+       pStmt = CreateStatementN(*__pDb, query);
+       SysTryCatch(NID_SEC, pStmt != null, , E_DATABASE, "[E_DATABASE] An error occurs while creating a database statement.");
+
+       pEnum = ExecuteStatementN(*__pDb, pStmt);
+       if (pEnum != null)
+       {
+               if (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       r = pEnum->GetStringAt(0, description);
+               }
+
+               delete pEnum;
+               pEnum = null;
+       }
+       else
+       {
+               SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] Privilege information is not found. [%ls]", privilegeString.GetPointer());
+       }
+
+CATCH:
+       delete pStmt;
+       pStmt = null;
+
+       return description;
+}
+
+DbStatement*
+_PrivilegeInfoImpl::CreateStatementN(Database& db, const String& query)
+{
+       result r = E_SUCCESS;
+       DbStatement* pStmt = null;
+
+       for (int i = 0; i < MAX_DATABASE_RETRY_COUNT; i++)
+       {
+               pStmt = db.CreateStatementN(query);
+               r = GetLastResult();
+
+               if (r != E_OBJECT_LOCKED)
+               {
+                       break;
+               }
+               else
+               {
+                       SysLog(NID_SEC, "RetryCount[%d] CreateStatementN - E_OBJECT_LOCKED", i);
+                       delete pStmt;
+                       pStmt = null;
+                       usleep(50000);
+               }
+       }
+
+       return pStmt;
+}
+
+DbEnumerator*
+_PrivilegeInfoImpl::ExecuteStatementN(Database& db, const DbStatement* pStmt)
+{
+       result r = E_SUCCESS;
+       DbEnumerator* pEnum = null;
+
+       for (int i = 0; i < MAX_DATABASE_RETRY_COUNT; i++)
+       {
+               pEnum = db.ExecuteStatementN(*pStmt);
+               r = GetLastResult();
+
+               if (r != E_OBJECT_LOCKED)
+               {
+                       break;
+               }
+               else
+               {
+                       SysLog(NID_SEC, "RetryCount[%d] ExecuteStatementN - E_OBJECT_LOCKED", i);
+                       delete pEnum;
+                       pEnum = null;
+                       usleep(50000);
+               }
+       }
+
+       return pEnum;
+}
+
+result
+_PrivilegeInfoImpl::Construct(const Tizen::Base::String& privilegeId)
+{
+       result r = E_SUCCESS;
+
+       String privilegeURI = L"http://tizen.org/privilege/";
+       String privilegeSubStringURI;
+       String privilegeSubString;
+       int index = 0;
+
+       privilegeId.SubString(0, privilegeURI.GetLength(), privilegeSubStringURI);
+       bool validStringFlag = false;
+
+       if (privilegeSubStringURI.Equals(privilegeURI, true))
+       {
+               privilegeId.SubString(privilegeURI.GetLength(), privilegeId.GetLength() - privilegeURI.GetLength(), privilegeSubString);
+               for (index = 0; index < _MAX_PRIVILEGE_ENUM; index++)
+               {
+                       if (wcscmp(privilegeListTable[index].privilegeString, privilegeSubString.GetPointer()) == 0)
+                       {
+                               validStringFlag = true;
+                               break;
+                       }
+               }
+       }
+
+       SysTryReturnResult(NID_SEC, validStringFlag == true, E_INVALID_ARG, "Invalid privilege ID [%ls]", privilegeId.GetPointer());
+
+       r = Construct();
+       SysTryReturnResult(NID_SEC, validStringFlag == true, E_SYSTEM, "The method cannot proceed due to a severe system error.");
+
+       __privilegeId = privilegeId;
+
+       return r;
+}
+
+String
+_PrivilegeInfoImpl::GetId(void) const
+{
+       return __privilegeId; 
+}
+
+String
+_PrivilegeInfoImpl::GetDisplayName(void) const
+{
+       return GetName(__privilegeId);
+}
+
+String
+_PrivilegeInfoImpl::GetDescription(void) const
+{
+       return GetDescription(__privilegeId);
+}
+
+} } // Tizen::Security
index c92d947..a59f0b3 100644 (file)
@@ -34,7 +34,6 @@
 #include "FSec_PrivilegeCache.h"
 #include "FSec_PrivilegeInfo.h"
 
-
 using namespace Tizen::App;
 using namespace Tizen::App::Package;
 using namespace Tizen::Base;
@@ -63,8 +62,6 @@ _PrivilegeManager::Construct(void)
 {
        result r = E_SUCCESS;
 
-       SysLog(NID_SEC, "Enter.");
-
        _PackageManagerImpl* pPackageManagerImpl = null;
 
        pPackageManagerImpl = _PackageManagerImpl::GetInstance();
@@ -80,14 +77,11 @@ _PrivilegeManager::Construct(void)
        r = __pPrivilegeCache->Construct();
        SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 
 CATCH:
 
        delete __pPrivilegeCache;
-
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -97,7 +91,6 @@ _PrivilegeManager::InitInstance(void)
        result r = E_SUCCESS;
        static _PrivilegeManager instance;
 
-       SysLog(NID_SEC, "Enter");
        ClearLastResult();
 
        r = instance.Construct();
@@ -105,7 +98,7 @@ _PrivilegeManager::InitInstance(void)
 
        __pPrivilegeManagerInstance = &instance;
 
-    SysLog(NID_SEC, "Exit");
+       return;
 }
 
 _PrivilegeManager*
@@ -114,7 +107,6 @@ _PrivilegeManager::GetInstance(void)
        result r = E_SUCCESS;
        static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
 
-       SysLog(NID_SEC, "Enter");
        ClearLastResult();
 
     if (__pPrivilegeManagerInstance == null)
@@ -128,9 +120,7 @@ _PrivilegeManager::GetInstance(void)
         }
     }
 
-    SysLog(NID_SEC, "Exit");
-
-       return __pPrivilegeManagerInstance;
+    return __pPrivilegeManagerInstance;
 }
 
 
@@ -140,14 +130,14 @@ _PrivilegeManager::GetPrivilegeListN(const AppId& appId)
        result r = E_SUCCESS;
        _PrivilegeInfo privilegeInfo;
        byte* pTargetBitwisePrivilege = null;
-       IList* pPrivilegeList = null;
+       IList* pReturnPrivilegeList = null;
        String encryptedPrivileges;
        String checksum;
+       ArrayList* pPrivilegeList = null;
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
-       r = RetrieveCipherPrivilege(appId, encryptedPrivileges, checksum);
+       r = RetrieveCipherPrivilegeN(appId, encryptedPrivileges, checksum, pPrivilegeList);
        if (r == E_DATA_NOT_FOUND)
        {
                SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
@@ -155,39 +145,46 @@ _PrivilegeManager::GetPrivilegeListN(const AppId& appId)
        }
        SysTryReturn(NID_SEC, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
-       r = privilegeInfo.Construct(appId, encryptedPrivileges, checksum);
+       r = privilegeInfo.Construct(appId, encryptedPrivileges, checksum, pPrivilegeList);
        SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        r = privilegeInfo.GetBitwisePrivilegeN(pTargetBitwisePrivilege);
        SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
-       pPrivilegeList = UnpackPrivilegeN(pTargetBitwisePrivilege);
-       SysTryCatch(NID_SEC,  pPrivilegeList != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       pReturnPrivilegeList = UnpackPrivilegeN(pTargetBitwisePrivilege);
+       SysTryCatch(NID_SEC,  pReturnPrivilegeList != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        // fall through
 
 CATCH:
 
+       if (pPrivilegeList != null)
+       {
+               pPrivilegeList->RemoveAll(true);
+               delete pPrivilegeList;
+       }
+
        if (pTargetBitwisePrivilege)
        {
                free(pTargetBitwisePrivilege);
                pTargetBitwisePrivilege = null;
        }
 
-       SysLog(NID_SEC, "Exit.");
-       return pPrivilegeList;
+       return pReturnPrivilegeList;
 }
 
 result
-_PrivilegeManager::RetrieveCipherPrivilege(const AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum)
+_PrivilegeManager::RetrieveCipherPrivilegeN(const AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, ArrayList*& pPrivilegeList)
 {
        result r = E_SUCCESS;
-
-       SysLog(NID_SEC, "Enter.");
+       ArrayList tempPrivilegeList;
 
        encryptedPrivileges.Clear();
        checksum.Clear();
 
+       r = tempPrivilegeList.Construct();
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
+
        _PackageInfoImpl infoImpl;
        r = infoImpl.Construct(appId);
        if (r == E_APP_NOT_INSTALLED)
@@ -197,27 +194,39 @@ _PrivilegeManager::RetrieveCipherPrivilege(const AppId& appId, Tizen::Base::Stri
        }
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
-       r = infoImpl.GetPrivileges(encryptedPrivileges, checksum);
+       r = infoImpl.GetPrivileges(encryptedPrivileges, checksum, tempPrivilegeList);
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
        SysTryReturnResult(NID_SEC, encryptedPrivileges.IsEmpty() != true, E_DATA_NOT_FOUND, "The privilege information does not exist.");
        SysTryReturnResult(NID_SEC, checksum.IsEmpty() != true, E_SYSTEM, "An unexpected system error occurred.");
 
-       SysLog(NID_SEC, "Exit.");
+       pPrivilegeList = new ArrayList;
+       r = pPrivilegeList->Construct();
+
+       IEnumerator* pEnum = tempPrivilegeList.GetEnumeratorN();
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* tempString = static_cast< String* >(pEnum->GetCurrent());
+               pPrivilegeList->Add(new String(*tempString));
+       }
+
+       tempPrivilegeList.RemoveAll(true);
        return r;
 }
 
 result
-_PrivilegeManager::RetrieveCipherPrivilegeEx(const AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum)
+_PrivilegeManager::RetrieveCipherPrivilegeExN(const AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, ArrayList*& pPrivilegeList)
 {
        result r = E_SUCCESS;
 
-       SysLog(NID_SEC, "Enter.");
-
        encryptedPrivileges.Clear();
        checksum.Clear();
 
        String tempEncryptedPrivileges;
        String tempChecksum;
+       ArrayList tempPrivilegeList;
+
+       r = tempPrivilegeList.Construct();
+       SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
        _PackageInfoImpl infoImpl;
        r = infoImpl.Construct(appId);
@@ -228,14 +237,14 @@ _PrivilegeManager::RetrieveCipherPrivilegeEx(const AppId& appId, Tizen::Base::St
        }
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
-       r = infoImpl.GetPrivileges(tempEncryptedPrivileges, tempChecksum);
+       r = infoImpl.GetPrivileges(tempEncryptedPrivileges, tempChecksum, tempPrivilegeList);
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
        SysTryReturnResult(NID_SEC, tempEncryptedPrivileges.IsEmpty() != true, E_DATA_NOT_FOUND, "The privilege information does not exist.");
        SysTryReturnResult(NID_SEC, tempChecksum.IsEmpty() != true, E_SYSTEM, "An unexpected system error occurred.");
 
        _PrivilegeInfo privilegeInfo;
 
-       r = privilegeInfo.Construct(appId, tempEncryptedPrivileges, tempChecksum);
+       r = privilegeInfo.Construct(appId, tempEncryptedPrivileges, tempChecksum, &tempPrivilegeList);
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
        r = privilegeInfo.GetEncryptedBitwise(encryptedPrivileges);
@@ -244,7 +253,17 @@ _PrivilegeManager::RetrieveCipherPrivilegeEx(const AppId& appId, Tizen::Base::St
        r = privilegeInfo.GetChecksum(checksum);
        SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
 
-       SysLog(NID_SEC, "Exit.");
+       pPrivilegeList = new ArrayList;
+       r = pPrivilegeList->Construct();
+
+       IEnumerator* pEnum = tempPrivilegeList.GetEnumeratorN();
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* tempString = static_cast< String* >(pEnum->GetCurrent());
+               pPrivilegeList->Add(new String(*tempString));
+       }
+
+       tempPrivilegeList.RemoveAll(true);
        return r;
 }
 
@@ -257,8 +276,8 @@ _PrivilegeManager::RetrievePrivilegeInfoN(const AppId& appId) const
        String checksum;
        std::unique_ptr<_PrivilegeInfo> pPrivilegeInfo(null);
        _PackageInfoImpl infoImpl;
+       ArrayList* pPrivilegeList = null;
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
        pPrivilegeInfo.reset(__pPrivilegeCache->GetPrivilegeInfoN(appId));
@@ -270,7 +289,7 @@ _PrivilegeManager::RetrievePrivilegeInfoN(const AppId& appId) const
        }
        else if (r == E_DATA_NOT_FOUND)
        {
-               r = RetrieveCipherPrivilege(appId, encryptedPrivileges, checksum);
+               r = RetrieveCipherPrivilegeN(appId, encryptedPrivileges, checksum, pPrivilegeList);
                if (r == E_DATA_NOT_FOUND)
                {
                        SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] The privilege information does not exist.");
@@ -281,11 +300,17 @@ _PrivilegeManager::RetrievePrivilegeInfoN(const AppId& appId) const
                pPrivilegeInfo.reset(new (std::nothrow) _PrivilegeInfo());
                SysTryReturn(NID_SEC, pPrivilegeInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-               r = pPrivilegeInfo->Construct(appId, encryptedPrivileges, checksum);
+               r = pPrivilegeInfo->Construct(appId, encryptedPrivileges, checksum, pPrivilegeList);
                SysTryReturn(NID_SEC, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
                r = __pPrivilegeCache->AddPrivilegeInfo(*(pPrivilegeInfo.get()));
                SysTryReturn(NID_SEC, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+               if (pPrivilegeList != null)
+               {
+                       pPrivilegeList->RemoveAll(true);
+                       delete pPrivilegeList;
+               }
        }
        else
        {
@@ -294,7 +319,6 @@ _PrivilegeManager::RetrievePrivilegeInfoN(const AppId& appId) const
                return null;
        }
 
-       SysLog(NID_SEC, "Exit.");
        return pPrivilegeInfo.release();
 }
 
@@ -311,7 +335,6 @@ _PrivilegeManager::UnpackPrivilegeN(const byte* pBitwisePrivilege)
        int privilegeEnum = 0;
        std::unique_ptr<ArrayList> pPrivilegeList(null);
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
        SysTryReturn(NID_SEC, pBitwisePrivilege != null, null, E_INVALID_ARG, "One of the argument is invalid.");
@@ -362,7 +385,6 @@ _PrivilegeManager::UnpackPrivilegeN(const byte* pBitwisePrivilege)
                }
        }
 
-       SysLog(NID_SEC, "Exit.");
        return pPrivilegeList.release();
 
 CATCH:
@@ -374,13 +396,9 @@ CATCH:
 void
 _PrivilegeManager::OnPackageInstallationCompleted(const PackageId& packageId, PackageInstallationResult installationResult)
 {
-       SysLog(NID_SEC, "Enter.");
-
        __pPrivilegeCache->RemovePrivilegeInfo(packageId);
        SysLog(NID_SEC, "%ls is removed.", packageId.GetPointer());
 
-       SysLog(NID_SEC, "Exit.");
-
        return;
 }
 
index e9834b2..5d94919 100755 (executable)
@@ -28,6 +28,6 @@ LIST (APPEND ${this_target}_SOURCE_FILES
   ${MODULE_DIR}/FSecCert_CertExtension.cpp
   ${MODULE_DIR}/FSecCert_CertTime.cpp
   ${MODULE_DIR}/FSecCert_CertMgrMessages.cpp
-  ${MODULE_DIR}/FSecCert_CertServiceStub.cpp
+#  ${MODULE_DIR}/FSecCert_CertServiceStub.cpp
 )
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 7087aac..9df2375 100755 (executable)
@@ -151,27 +151,6 @@ _CertDbManager::RemoveCaCertificateByType(_CaCertType certType)
 }
 
 result
-_CertDbManager::RemoveUserCertificateByCertId(int certId)
-{
-       result r = E_SUCCESS;
-       _CertFileStore fileStore;
-       String certFileName;
-       String keyName;
-
-       r = __userCertDbStore.RemoveCertificateById(certId);
-       SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_SYSTEM, "Failed to delete user certificate in database.");
-
-       //Delete File
-
-    fileStore.GetFileNameFromHandle(certId, _CERT_PATH_USER_CERT, certFileName);
-    Tizen::Io::File::Remove(certFileName);
-    fileStore.GetFileNameFromHandle(certId, _CERT_PATH_PRIVATE_KEY, keyName);
-    Tizen::Io::File::Remove(keyName);
-
-       return E_SUCCESS;
-}
-
-result
 _CertDbManager::RemoveUserCaCertificateByCertId(int certId)
 {
        result r = E_SUCCESS;
@@ -1450,6 +1429,12 @@ _CertDbManager::InsertCertificateChain(_CertFormat certFormat, _CertChain* pCert
                        return r;
                }
 
+               if (pUserCert->IsSelfSigned())
+               {
+                       __userCertDbStore.UpdateParentCa(curDevCertId, curDevCertId);
+                       return r;
+               }
+
                //Insert certificate chain in CA certificate store
                while (pCertChain->MoveNext() == E_SUCCESS)
                {
old mode 100755 (executable)
new mode 100644 (file)
index 173fcd4..b72dcd2
@@ -44,8 +44,6 @@ public:
 
        result RemoveUserCaCertificateByCertId(int certId);
 
-       result RemoveUserCertificateByCertId(int certId);
-
        result RemoveAllUserCertificate(void);
 
        result CreateCertificateTables(void);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index ab49fbc..0ae2a73 100644 (file)
@@ -763,275 +763,66 @@ _CertManager::GetCertificateType(CertificateHandle certHandle, _CaCertType* pCer
 }
 
 result
-_CertManager::ParseCertTitle(char* pSubject, char* pTitle)
+_CertManager::ParseCertTitle(char subject[_MAX_ISSUER_SUBJECT_NAME_SIZE + 1], char title[_MAX_ISSUER_SUBJECT_NAME_SIZE + 1])
 {
-       char* pCNHeader = null;
-       char* pOUHeader = null;
-       char* pEailHeader = null;
-       char* pTrailer = null;
-       std::unique_ptr<char[]> pOutputBuf(null);
-       int outputBufLen = 0;
-
        ClearLastResult();
 
-       SysTryReturn(NID_SEC_CERT, pSubject != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input parameter.");
+       SysTryReturn(NID_SEC_CERT, subject[0] != '\0', E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input parameter.");
+       
+       SysAssertf(strlen(subject) <= _MAX_ISSUER_SUBJECT_NAME_SIZE, "The buffer size of source is too big.");
 
-       pCNHeader = strstr(pSubject, _CERT_COMMON_NAME);
-       pOUHeader = strstr(pSubject, _CERT_ORG_UNIT_NAME);
-       pEailHeader = strstr(pSubject, _CERT_EMAIL_ADDRESS);
-       if (pCNHeader != null)
-       {
-               pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_COMMON_NAME);
-               if (pTrailer != null)
-               {
-                       outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-               }
-               else
-               {
-                       pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_ORG_UNIT_NAME);
-                       if (pTrailer != null)
-                       {
-                               outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                       }
-                       else
-                       {
-                               pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_ORG_NAME);
-                               if (pTrailer != null)
-                               {
-                                       outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                               }
-                               else
-                               {
-                                       pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_STATE_OR_PROVINCE_NAME);
-                                       if (pTrailer != null)
-                                       {
-                                               outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                                       }
-                                       else
-                                       {
-                                               pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_STATE_OF_PROVINCE);
-                                               if (pTrailer != null)
-                                               {
-                                                       outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                                               }
-                                               else
-                                               {
-                                                       pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_LOCALITY_NAME);
-                                                       if (pTrailer != null)
-                                                       {
-                                                               outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                                                       }
-                                                       else
-                                                       {
-                                                               pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_COUNTRY_NAME);
-                                                               if (pTrailer != null)
-                                                               {
-                                                                       outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                                                               }
-                                                               else
-                                                               {
-                                                                       pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_EMAIL_ADDRESS);
-                                                                       if (pTrailer != null)
-                                                                       {
-                                                                               outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               pTrailer = strstr(pCNHeader + strlen(_CERT_COMMON_NAME), _CERT_DC);
-                                                                               if (pTrailer != null)
-                                                                               {
-                                                                                       outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME) - _MAX_GAP;
-                                                                               }
-                                                                               else
-                                                                               {
-                                                                                       pTrailer = pCNHeader + strlen(pCNHeader);
-                                                                                       outputBufLen = pTrailer - pCNHeader - strlen(_CERT_COMMON_NAME);
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-               pOutputBuf = std::unique_ptr<char[]> (new (std::nothrow) char[outputBufLen + 1]);
-               SysTryReturnResult(NID_SEC_CERT, pOutputBuf != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
+       bool done = false;
+    char* pPivotPtr = null;
+    char* pSavePtr = null;
+    char* pSubStr = null;
+    char tempSubject[_MAX_ISSUER_SUBJECT_NAME_SIZE + 1] = {0, };
 
-               memset(pOutputBuf.get(), 0, outputBufLen + 1);
-               memcpy(pOutputBuf.get(), pCNHeader + strlen(_CERT_COMMON_NAME), outputBufLen);
-       }
-       else if (pOUHeader != null)
-       {
-               pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_COMMON_NAME);
-               if (pTrailer != null)
+       strncpy(tempSubject, subject, strlen(subject));
+       pPivotPtr = tempSubject;
+    for (int count = 0; ; pSubStr = null)
+    {
+        pSubStr = strtok_r(pPivotPtr, "/", &pSavePtr);
+
+               if (strncmp(pSubStr, _CERT_COMMON_NAME, strlen(_CERT_COMMON_NAME)) == 0)
                {
-                       outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
+                       pSubStr = pSubStr + strlen(_CERT_COMMON_NAME);
+                       done = true;
+                       break;
                }
-               else
+               else if (strncmp(pSubStr, _CERT_ORG_NAME, strlen(_CERT_ORG_NAME)) == 0)
                {
-                       pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_ORG_UNIT_NAME);
-                       if (pTrailer != null)
-                       {
-                               outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                       }
-                       else
-                       {
-                               pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_ORG_NAME);
-                               if (pTrailer != null)
-                               {
-                                       outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                               }
-                               else
-                               {
-                                       pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_STATE_OR_PROVINCE_NAME);
-                                       if (pTrailer != null)
-                                       {
-                                               outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                                       }
-                                       else
-                                       {
-                                               pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_STATE_OF_PROVINCE);
-                                               if (pTrailer != null)
-                                               {
-                                                       outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                                               }
-                                               else
-                                               {
-                                                       pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_LOCALITY_NAME);
-                                                       if (pTrailer != null)
-                                                       {
-                                                               outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                                                       }
-                                                       else
-                                                       {
-                                                               pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_COUNTRY_NAME);
-                                                               if (pTrailer != null)
-                                                               {
-                                                                       outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                                                               }
-                                                               else
-                                                               {
-                                                                       pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_EMAIL_ADDRESS);
-                                                                       if (pTrailer != null)
-                                                                       {
-                                                                               outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               pTrailer = strstr(pOUHeader + strlen(_CERT_ORG_UNIT_NAME), _CERT_DC);
-                                                                               if (pTrailer != null)
-                                                                               {
-                                                                                       outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME) - _MAX_GAP;
-                                                                               }
-                                                                               else
-                                                                               {
-                                                                                       pTrailer = pOUHeader + strlen(pOUHeader);
-                                                                                       outputBufLen = pTrailer - pOUHeader - strlen(_CERT_ORG_UNIT_NAME);
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
+                       pSubStr = pSubStr + strlen(_CERT_ORG_NAME);
+                       done = true;
+                       break;
                }
-               pOutputBuf = std::unique_ptr<char[]> (new (std::nothrow) char[outputBufLen + 1]);
-               SysTryReturnResult(NID_SEC_CERT, pOutputBuf != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
-
-               memcpy(pOutputBuf.get(), pOUHeader + strlen(_CERT_ORG_UNIT_NAME), outputBufLen);
-
-       }
-       else if (pEailHeader != null)
-       {
-               pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_COMMON_NAME);
-               if (pTrailer != null)
+               else if (strncmp(pSubStr, _CERT_ORG_UNIT_NAME, strlen(_CERT_ORG_UNIT_NAME)) == 0)
                {
-                       outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
+                       pSubStr = pSubStr + strlen(_CERT_ORG_UNIT_NAME);
+                       done = true;
+                       break;
                }
-               else
+               else if (strncmp(pSubStr, _CERT_EMAIL_ADDRESS, strlen(_CERT_EMAIL_ADDRESS)) == 0)
                {
-                       pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_ORG_UNIT_NAME);
-                       if (pTrailer != null)
-                       {
-                               outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                       }
-                       else
-                       {
-                               pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_ORG_NAME);
-                               if (pTrailer != null)
-                               {
-                                       outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                               }
-                               else
-                               {
-                                       pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_STATE_OR_PROVINCE_NAME);
-                                       if (pTrailer != null)
-                                       {
-                                               outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                                       }
-                                       else
-                                       {
-                                               pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_STATE_OF_PROVINCE);
-                                               if (pTrailer != null)
-                                               {
-                                                       outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                                               }
-                                               else
-                                               {
-                                                       pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_LOCALITY_NAME);
-                                                       if (pTrailer != null)
-                                                       {
-                                                               outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                                                       }
-                                                       else
-                                                       {
-                                                               pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_COUNTRY_NAME);
-                                                               if (pTrailer != null)
-                                                               {
-                                                                       outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                                                               }
-                                                               else
-                                                               {
-                                                                       pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_EMAIL_ADDRESS);
-                                                                       if (pTrailer != null)
-                                                                       {
-                                                                               outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               pTrailer = strstr(pEailHeader + strlen(_CERT_EMAIL_ADDRESS), _CERT_DC);
-                                                                               if (pTrailer != null)
-                                                                               {
-                                                                                       outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS) - _MAX_GAP;
-                                                                               }
-                                                                               else
-                                                                               {
-                                                                                       pTrailer = pEailHeader + strlen(pEailHeader);
-                                                                                       outputBufLen = pTrailer - pEailHeader - strlen(_CERT_EMAIL_ADDRESS);
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
+                       pSubStr = pSubStr + strlen(_CERT_EMAIL_ADDRESS);
+                       done = true;
+                       break;
                }
-               pOutputBuf = std::unique_ptr<char[]> (new (std::nothrow) char[outputBufLen + 1]);
-               SysTryReturnResult(NID_SEC_CERT, pOutputBuf != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
 
-               memset(pOutputBuf.get(), 0, outputBufLen + 1);
-               memcpy(pOutputBuf.get(), pEailHeader + strlen(_CERT_EMAIL_ADDRESS), outputBufLen);
+               pPivotPtr = pSavePtr;
+               pSubStr = null;
        }
-       else
+
+       SysTryReturn(NID_SEC_CERT, done, E_PARSING_FAILED, E_SYSTEM, "[%s] Failed to parse Certificate title.", GetErrorMessage(E_PARSING_FAILED));
+
+       // initialize buffer
+       for (int index = 0; index < _MAX_ISSUER_SUBJECT_NAME_SIZE + 1; index++)
        {
-               SysLogException(NID_SEC_CERT, E_PARSING_FAILED, "[E_PARSING_FAILED] Failed to parse Certificate title.");
-               return E_SYSTEM;
+               title[index] = '\0';
        }
-       strcpy(pTitle, pOutputBuf.get());
 
+       // copy title into out param
+       strncpy(title, pSubStr, strlen(pSubStr));
+               
        return E_SUCCESS;
 }
 
old mode 100755 (executable)
new mode 100644 (file)
index e5951ee..f61c4e5
@@ -87,7 +87,7 @@ public:
        static CertificateStoreCtx OpenRootCaStore(_CaCertType type, int& count);
 
 private:
-       static result ParseCertTitle(char* pSubject, char* pTitle);
+       static result ParseCertTitle(char subject[_MAX_ISSUER_SUBJECT_NAME_SIZE], char title[_MAX_ISSUER_SUBJECT_NAME_SIZE]);
 
        _CertManager(const _CertManager& rhs);
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 39afb91..24474b9 100644 (file)
@@ -81,7 +81,7 @@ const char* _CERT_ORG_NAME = "O=";
 const char* _CERT_LOCALITY_NAME = "L=";
 const char* _CERT_STATE_OR_PROVINCE_NAME = "S=";
 const char* _CERT_COUNTRY_NAME = "C=";
-const char* _CERT_EMAIL_ADDRESS = "EmailAddress=";
+const char* _CERT_EMAIL_ADDRESS = "emailAddress=";
 const char* _CERT_SERIAL_NUM = "SN=";
 const char* _CERT_GIVEN_NAME = "GN=";
 const char* _CERT_SUR_NAME = "SUN=";
@@ -1702,26 +1702,8 @@ CATCH:
        FreeRootCertList(pCertChainHead);
        return r;
 
-
-}
-result
-_CertService::RemoveUserCertificateByCertId(int certId)
-{
-       result r = E_SUCCESS;
-       _CertDbManager* pCertDb = null;
-
-       SysTryReturnResult(NID_SEC_CERT, certId > 0, E_INVALID_ARG, "Invalid certificate id.");
-
-       pCertDb = _CertDbManager::GetInstance();
-       SysTryReturnResult(NID_SEC_CERT, pCertDb != null, E_SYSTEM, "Failed to get instance of certificate database manager.");
-
-       r = pCertDb->RemoveUserCertificateByCertId(certId);
-       SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_SYSTEM, "Failed to delete root ca certificate.");
-
-       return r;
 }
 
-
 result
 _CertService::RemoveUserCertChainByCertId(int certId)
 {
old mode 100755 (executable)
new mode 100644 (file)
index f62207e..6c29242
@@ -421,26 +421,6 @@ _CertServiceProxy::InsertPkcs12Content(char* pPkcs12FilePath, char* pPkcs12Impor
 
        return r;
 }
-result
-_CertServiceProxy::RemoveUserCertificateByCertId(int certId)
-{
-       result r = E_SUCCESS;
-       result ret = E_SUCCESS;
-
-       ClearLastResult();
-
-       SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "Instance is not constructed.");
-       SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
-
-       std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_DeleteUserCertificateByCertId(certId, &ret));
-       SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
-
-       r = __pIpcClient->SendRequest(pMessage.get());
-       SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
-       SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
-
-       return r;
-}
 
 result
 _CertServiceProxy::RemoveUserCertChainByCertId(int certId)
diff --git a/src/security/cert/FSecCert_CertServiceStub.cpp b/src/security/cert/FSecCert_CertServiceStub.cpp
deleted file mode 100755 (executable)
index 4c43688..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-//
-// 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       FSecCert_CertServiceStub.cpp
-// @brief      This is the implementation file for the  _CertServiceStub class.
-//
-
-#include <unique_ptr.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <error.h>
-#include <memory.h>
-#include <new>
-#include <sys/stat.h>
-#include <assert.h>
-#include <dirent.h>
-#include <FBaseByteBuffer.h>
-#include <FBaseResult.h>
-#include <FBaseSysLog.h>
-#include <FBaseRt_EventDispatcher.h>
-#include <FIo_IpcServer.h>
-#include <FSec_AccessController.h>
-#include <FSec_AccessControlTypes.h>
-#include <FApp_AppInfo.h>
-#include "FSecCert_CertServiceStub.h"
-#include "FSecCert_CertMgrMessages.h"
-#include "FSecCert_CertService.h"
-
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
-using namespace Tizen::App;
-using namespace Tizen::Io;
-
-namespace Tizen { namespace Security { namespace Cert
-{
-
-_CertServiceStub::_CertServiceStub(void)
-       : __pIpcServer(null)
-{
-
-}
-
-_CertServiceStub::~_CertServiceStub(void)
-{
-       if (__pIpcServer != null)
-       {
-               __pIpcServer->Stop();
-               delete __pIpcServer;
-       }
-}
-
-result
-_CertServiceStub::Construct(void)
-{
-       result r = E_SUCCESS;
-
-       std::unique_ptr<_IpcServer> pIpcServer(new (std::nothrow) _IpcServer());
-       SysTryReturnResult(NID_SEC_CERT, pIpcServer != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
-
-       r = pIpcServer->Construct(L"osp.security.ipcserver.certmanager", *this);
-       SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to create IPC server(%s)", GetErrorMessage(r), "CertService");
-
-       __pIpcServer = pIpcServer.release();
-
-       _CertService::InitializeDb();
-
-       return r;
-}
-
-bool
-_CertServiceStub::OnUpdateRootCa(int type, Tizen::Io::_IpcBuffer certOldBufferIpc, Tizen::Io::_IpcBuffer certNewBufferIpc, result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_WRITE);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = _CertService::UpdateCaCertificate(static_cast< _CaCertType >(type), static_cast< char* >(certOldBufferIpc.pBuffer), certOldBufferIpc.size,
-                                                                                         static_cast< char* >(certNewBufferIpc.pBuffer), certNewBufferIpc.size);
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnRemoveRootCa(int type, Tizen::Io::_IpcBuffer certBufferIpc, int bufLen, result* pRet)
-{
-
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_WRITE);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = _CertService::RemoveCaCertificate(static_cast< _CaCertType >(type), static_cast< char* >(certBufferIpc.pBuffer), bufLen);
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnInsertCaCertificate(int type, int format, Tizen::Io::_IpcBuffer pCert, long certLen, result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_WRITE);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = _CertService::InsertCaCertificate(static_cast< _CaCertType >(type), static_cast< _CertFormat >(format), static_cast< byte* >(pCert.pBuffer), certLen);
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnInsertUserCaCertificate(int format, Tizen::Io::_IpcBuffer pCert, int certLen, result* pRet)
-{
-       *pRet = _CertService::InsertUserCaCertificate(static_cast< _CertFormat >(format), static_cast< char* >(pCert.pBuffer), certLen);
-
-       return true;
-}
-
-bool
-_CertServiceStub::OnInstallUserRootCertificate(Tizen::Io::_IpcBuffer filePath, result* pRet)
-{
-       *pRet = _CertService::InsertUserCaCertificate(static_cast< byte* >(filePath.pBuffer));
-
-       return true;
-}
-
-//User Certificate APIs
-bool
-_CertServiceStub::OnInsertUserCertChainPrivateKey(Tizen::Io::_IpcBuffer certChainBufferIpc, int certSize, Tizen::Io::_IpcBuffer privateKeyBufferIpc, int userPriKeyLen, result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_WRITE);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = _CertService::InsertUserCertChainPrivateKey(static_cast< char* >(certChainBufferIpc.pBuffer), certSize, static_cast< char* >(privateKeyBufferIpc.pBuffer), userPriKeyLen);
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnInsertCertificateChainWithPrivateKey(Tizen::Io::_IpcBuffer certChainPrivateKeyBufferIpc, int certChainPrivateKeyLength, result* pRet)
-{
-       *pRet = _CertService::InsertCertificateChainWithPrivateKey(static_cast< char* >(certChainPrivateKeyBufferIpc.pBuffer), certChainPrivateKeyLength);
-
-       return true;
-}
-
-bool
-_CertServiceStub::OnInstallPkcs12Content(Tizen::Io::_IpcBuffer pkcs12FilePath, Tizen::Io::_IpcBuffer pkcs12ImportPassword, result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_WRITE);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = _CertService::InsertPkcs12Content(static_cast< char* >(pkcs12FilePath.pBuffer), static_cast< char* >(pkcs12ImportPassword.pBuffer));
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnDeleteUserCertificateByCertId(int certId, result* pRet)
-{
-       *pRet = _CertService::RemoveUserCertificateByCertId(certId);
-
-       return true;
-}
-
-bool
-_CertServiceStub::OnDeleteUserCertChainByCertId(int certId, result* pRet)
-{
-       *pRet = _CertService::RemoveUserCertChainByCertId(certId);
-
-       return true;
-}
-
-bool
-_CertServiceStub::OnUninstallUserRootCertificateByCertId(int certId, result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_WRITE);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = _CertService::RemoveUserCaCertificateByCertId(certId);
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnGetUserCertChainByIssuerAndSubjectNameN(Tizen::Io::_IpcBuffer issuerBufferIpc, int issuerNameLen, Tizen::Io::_IpcBuffer subjectBufferIpc, int subNameLen, _CertificateListInfo* pCertList, result* pRet)
-{
-       _CertificateListInfo* pCertListIpc = null;
-
-       *pRet = _CertService::GetUserCertChainByIssuerAndSubjectNameN(static_cast< char* >(issuerBufferIpc.pBuffer), issuerNameLen, static_cast< char* >(subjectBufferIpc.pBuffer), subNameLen, pCertListIpc);
-
-       if (pCertListIpc != null)
-       {
-               std::unique_ptr<_CertificateListInfo> pCertListAuto(pCertListIpc);
-
-               pCertList->certFileId = pCertListIpc->certFileId;
-
-               pCertList->format = pCertListIpc->format;
-               pCertList->certType = pCertListIpc->certType;
-               pCertList->length = pCertListIpc->length;
-               pCertList->priKeyLen = pCertListIpc->priKeyLen;
-
-               memcpy(pCertList->certificate, pCertListIpc->certificate, _MAX_CERTIFICATE_SIZE);
-               memcpy(pCertList->privatekey, pCertListIpc->privatekey, _MAX_CERT_PRIVATE_KEY_SIZE);
-
-               pCertList->pNext = pCertListIpc->pNext;
-       }
-       else
-       {
-               memset(pCertList, 0, sizeof(*pCertList));
-       }
-
-       return true;
-}
-
-bool
-_CertServiceStub::OnGetUserCertificateByCertIdN(int certId, int encodingType, _CertInfo* pUserCertificateList, result* pRet)
-{
-       _CertInfo* pUserCertificateInfoIpc = null;
-
-       *pRet = _CertService::GetUserCertificateByCertIdN(certId, static_cast< _CertEncodingType >(encodingType), pUserCertificateInfoIpc);
-
-       if (pUserCertificateInfoIpc != null)
-       {
-               std::unique_ptr<_CertInfo> pCertInfoAuto(pUserCertificateInfoIpc);
-
-               pUserCertificateList->certId = pUserCertificateInfoIpc->certId;
-               pUserCertificateList->certFormat = pUserCertificateInfoIpc->certFormat;
-               pUserCertificateList->certType = pUserCertificateInfoIpc->certType;
-               pUserCertificateList->certLength = pUserCertificateInfoIpc->certLength;
-               pUserCertificateList->privateKeyLen = pUserCertificateInfoIpc->privateKeyLen;
-
-               memcpy(pUserCertificateList->certificate, pUserCertificateInfoIpc->certificate, _MAX_CERTIFICATE_SIZE);
-               memcpy(pUserCertificateList->privatekey, pUserCertificateInfoIpc->privatekey, _MAX_CERT_PRIVATE_KEY_SIZE);
-       }
-       else
-       {
-               memset(pUserCertificateList, 0, sizeof(*pUserCertificateList));
-       }
-       return true;
-}
-
-bool
-_CertServiceStub::OnGetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertInfoBufferIpc, result* pRet)
-{
-       _CertFieldInfos certInfo;
-
-       *pRet = _CertService::GetUserCertFieldInfoByCertId(certId, &certInfo);
-
-       if (!IsFailed(*pRet))
-       {
-               pCertInfoBufferIpc->certType = certInfo.certType;
-               pCertInfoBufferIpc->certFileId = certInfo.certFileId;
-
-               memcpy(pCertInfoBufferIpc->serialNo, certInfo.serialNo, _MAX_SERIAL_NUMBER_SIZE + 1);
-               memcpy(pCertInfoBufferIpc->sigAlgorithm, certInfo.sigAlgorithm, _MAX_CERT_ALGORITHM_SIZE + 1);
-               memcpy(pCertInfoBufferIpc->validityFrom, certInfo.validityFrom, _MAX_CERT_VALIDITY_SIZE + 1);
-               memcpy(pCertInfoBufferIpc->validityTo, certInfo.validityTo, _MAX_CERT_VALIDITY_SIZE + 1);
-               memcpy(pCertInfoBufferIpc->subjectName, certInfo.subjectName, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
-               memcpy(pCertInfoBufferIpc->issuerName, certInfo.issuerName, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
-               memcpy(pCertInfoBufferIpc->fingerPrint, certInfo.fingerPrint, _MAX_CERT_FINGERPRINT_SIZE + 1);
-
-               pCertInfoBufferIpc->fingerPrintLen = certInfo.fingerPrintLen;
-
-               memcpy(pCertInfoBufferIpc->publicKey, certInfo.publicKey, _MAX_CERT_PUBLIC_KEY_SIZE + 1);
-               memcpy(static_cast< void* >(pCertInfoBufferIpc->certTypeFormat), static_cast< const void* >(certInfo.certTypeFormat), _MAX_CERT_TYPE_SIZE + 1);
-
-               pCertInfoBufferIpc->certVersion = certInfo.certVersion;
-
-               memcpy(pCertInfoBufferIpc->certTitle, certInfo.certTitle, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
-               memcpy(pCertInfoBufferIpc->certSubTitle, certInfo.certSubTitle, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
-
-       }
-       else
-       {
-               memset(pCertInfoBufferIpc, 0, sizeof(*pCertInfoBufferIpc));
-       }
-       return true;
-}
-
-
-bool
-_CertServiceStub::OnGetName(result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_READ);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = E_SUCCESS;
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnCloseCertificateStore(int certificateStoreCtx, result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_READ);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pRet = _CertService::CloseCertificateStore(reinterpret_cast< CertificateStoreCtx >(certificateStoreCtx));
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnOpenCertificateStoreByType(int type, int* pCount, int* pCertCtx, result* pRet)
-{
-       void* pCertList = null;
-
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_READ);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       pCertList = _CertService::OpenCertificateStoreByType(static_cast< _CaCertType >(type), pCount);
-
-       *pCertCtx = reinterpret_cast< int >(pCertList);
-
-       *pRet = E_SUCCESS;
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnGetCertificateCount(int certificateStoreCtx, int* pCertCount, result* pRet)
-{
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_READ);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       *pCertCount = _CertService::GetCertificateCount(reinterpret_cast< CertificateStoreCtx >(certificateStoreCtx));
-
-       *pRet = E_SUCCESS;
-
-CATCH:
-       return true;
-}
-
-bool
-_CertServiceStub::OnGetNextCertificate(int certificateStoreCtx, int length, Tizen::Io::_IpcBuffer* pCertBufferIpc, result* pRet)
-{
-       char* pBuffer = null;
-
-       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_CERTIFICATE_READ);
-       SysTryCatch(NID_SEC_CERT, !IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
-
-       pBuffer = new (std::nothrow) char[length];
-       SysTryCatch(NID_SEC_CERT, pBuffer, *pRet = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]Allocation failed");
-
-       *pRet = _CertService::GetNextCertificate(reinterpret_cast< CertificateStoreCtx >(certificateStoreCtx), pBuffer, &length);
-
-CATCH:
-       if (!IsFailed(*pRet))
-       {
-               pCertBufferIpc->size = length;
-               pCertBufferIpc->pBuffer = pBuffer;
-       }
-       else
-       {
-               pCertBufferIpc->size = 0;
-               pCertBufferIpc->pBuffer = null;
-       }
-
-       return true;
-}
-
-void
-_CertServiceStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
-{
-       IPC_BEGIN_MESSAGE_MAP(_CertServiceStub, message)
-       IPC_MESSAGE_HANDLER_EX(CertService_GetName, &server, OnGetName)
-       IPC_MESSAGE_HANDLER_EX(CertService_CloseCertificateStore, &server, OnCloseCertificateStore)
-       IPC_MESSAGE_HANDLER_EX(CertService_OpenCertificateStoreByType, &server, OnOpenCertificateStoreByType)
-       IPC_MESSAGE_HANDLER_EX(CertService_GetCertificateCount, &server, OnGetCertificateCount)
-       IPC_MESSAGE_HANDLER_EX(CertService_GetNextCertificate, &server, OnGetNextCertificate)
-       IPC_MESSAGE_HANDLER_EX(CertService_UpdateRootCa, &server, OnUpdateRootCa)
-       IPC_MESSAGE_HANDLER_EX(CertService_RemoveRootCa, &server, OnRemoveRootCa)
-       IPC_MESSAGE_HANDLER_EX(CertService_UninstallUserRootCertificateByCertId, &server, OnUninstallUserRootCertificateByCertId)
-       IPC_MESSAGE_HANDLER_EX(CertService_InsertCaCertificate, &server, OnInsertCaCertificate)
-       IPC_MESSAGE_HANDLER_EX(CertService_InsertUserCaCertificate, &server, OnInsertUserCaCertificate)
-       IPC_MESSAGE_HANDLER_EX(CertService_InstallUserRootCertificate, &server, OnInstallUserRootCertificate)
-
-       //User Certificates API
-       IPC_MESSAGE_HANDLER_EX(CertService_InsertUserCertChainPrivateKey, &server, OnInsertUserCertChainPrivateKey)
-       IPC_MESSAGE_HANDLER_EX(CertService_InsertCertificateChainWithPrivateKey, &server, OnInsertCertificateChainWithPrivateKey)
-       IPC_MESSAGE_HANDLER_EX(CertService_InstallPkcs12Content, &server, OnInstallPkcs12Content)
-       IPC_MESSAGE_HANDLER_EX(CertService_DeleteUserCertChainByCertId, &server, OnDeleteUserCertChainByCertId)
-       IPC_MESSAGE_HANDLER_EX(CertService_DeleteUserCertificateByCertId, &server, OnDeleteUserCertificateByCertId)
-       IPC_MESSAGE_HANDLER_EX(CertService_GetUserCertChainByIssuerAndSubjectNameN, &server, OnGetUserCertChainByIssuerAndSubjectNameN)
-       IPC_MESSAGE_HANDLER_EX(CertService_GetUserCertificateByCertIdN, &server, OnGetUserCertificateByCertIdN)
-       IPC_MESSAGE_HANDLER_EX(CertService_GetUserCertFieldInfoByCertId, &server, OnGetUserCertFieldInfoByCertId)
-
-       IPC_END_MESSAGE_MAP_EX();
-}
-
-
-void
-_CertServiceStub::OnIpcServerStarted(const _IpcServer& server)
-{
-
-}
-
-void
-_CertServiceStub::OnIpcServerStopped(const _IpcServer& server)
-{
-
-}
-
-void
-_CertServiceStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
-{
-
-}
-
-void
-_CertServiceStub::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
-{
-
-}
-
-} } }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index b787943..3ceca2a 100755 (executable)
@@ -305,7 +305,7 @@ _X509CertificateStoreImpl::Update(CertificateType certificateType, const Tizen::
                _CertService::CloseCertificate(&certHandle);
                SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s]Failed to find user certificates in store.", GetErrorMessage(r));
 
-               r = __pCertServiceProxy->RemoveUserCaCertificateByCertId(certId);
+               r = __pCertServiceProxy->RemoveUserCertChainByCertId(certId);
                SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s]Failed to remove/update user certificates from store.", GetErrorMessage(r));
 
                r = __pCertServiceProxy->InsertUserCertChainPrivateKey(reinterpret_cast< char* >(pNewBuffer), newBufferLen, null, 0);
@@ -373,10 +373,11 @@ _X509CertificateStoreImpl::Remove(CertificateType certificateType, const Tizen::
                SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s]Failed to open certificates.", GetErrorMessage(r));
 
                r = _CertService::GetUserCertificateId(certHandle, certId);
+
                _CertService::CloseCertificate(&certHandle);
                SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s]Failed to find user certificates in store.", GetErrorMessage(r));
 
-               r = __pCertServiceProxy->RemoveUserCertificateByCertId(certId);
+               r = __pCertServiceProxy->RemoveUserCertChainByCertId(certId);
                SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s]Failed to remove user certificates.", GetErrorMessage(r));
        }
        else
index ad8e158..f5d4c10 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include <openssl/rsa.h>
 #include <openssl/evp.h>
+#include <openssl/pem.h>
 #include <openssl/x509.h>
 #include <FBaseResult.h>
 #include <FBaseErrors.h>
@@ -93,6 +94,7 @@ RsaCipher::EncryptN(const Tizen::Base::ByteBuffer& input)
        ByteBuffer* pOutput = null;
        EVP_PKEY* pEvpKey = null;
        RSA* pRsa = null;
+       BIO* pBio = null;
 
        ClearLastResult();
 
@@ -109,7 +111,25 @@ RsaCipher::EncryptN(const Tizen::Base::ByteBuffer& input)
        SysTryReturn(NID_SEC_CRYPTO, keyLen > 0, null, E_KEY_NOT_FOUND, "[E_KEY_NOT_FOUND] Key length should be positive.");
 
        pEvpKey = d2i_PublicKey(EVP_PKEY_RSA, null, &pKey, keyLen);
-       SysTryReturn(NID_SEC_CRYPTO, pEvpKey != null, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       if (pEvpKey == null)
+       {
+               pEvpKey = d2i_PUBKEY(null, &pKey, keyLen);
+       }
+
+       if (pEvpKey == null)
+       {
+               pBio = BIO_new(BIO_s_mem());
+               SysTryReturn(NID_SEC_CRYPTO, pBio != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               int readCount = BIO_write(pBio, (const void*) pKey, keyLen);
+               if (readCount > 0)
+               {
+                       pEvpKey = PEM_read_bio_PUBKEY(pBio, null, 0, null);
+               }
+       }
+
+       SysTryCatch(NID_SEC_CRYPTO, pEvpKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        pRsa = EVP_PKEY_get1_RSA(pEvpKey);
        SysTryCatch(NID_SEC_CRYPTO, pRsa != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
@@ -149,7 +169,14 @@ CATCH:
        {
                RSA_free(pRsa);
        }
-       EVP_PKEY_free(pEvpKey);
+       if (pBio)
+       {
+               BIO_free(pBio);
+       }
+       if (pEvpKey)
+       {
+               EVP_PKEY_free(pEvpKey);
+       }
 
        delete[] pTempBuf;
        return pOutput;
@@ -170,6 +197,7 @@ RsaCipher::DecryptN(const Tizen::Base::ByteBuffer& input)
        ByteBuffer* pOutput = null;
        EVP_PKEY* pEvpKey = null;
        RSA* pRsa = null;
+       BIO* pBio = null;
 
        ClearLastResult();
 
@@ -187,7 +215,29 @@ RsaCipher::DecryptN(const Tizen::Base::ByteBuffer& input)
 
        //res = __SecCrDecodeRSAPrivateKey(&pPriKey, (CrUINT8 *)pKey, (CrUINT32)keyLen);
        pEvpKey = d2i_PrivateKey(EVP_PKEY_RSA, null, &pKey, keyLen);
-       SysTryReturn(NID_SEC_CRYPTO, pEvpKey != null, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       if (pEvpKey == null)
+       {
+               PKCS8_PRIV_KEY_INFO* pPrivKeyInfo = d2i_PKCS8_PRIV_KEY_INFO(null, &pKey, keyLen);
+               if (pPrivKeyInfo != null)
+               {
+                       pEvpKey = EVP_PKCS82PKEY(pPrivKeyInfo);
+                       PKCS8_PRIV_KEY_INFO_free(pPrivKeyInfo);
+               }
+       }
+       if (pEvpKey == null)
+       {
+               pBio = BIO_new(BIO_s_mem());
+               SysTryReturn(NID_SEC_CRYPTO, pBio != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               int readCount = BIO_write(pBio, (const void*) pKey, keyLen);
+               if (readCount > 0)
+               {
+                       pEvpKey = PEM_read_bio_PrivateKey(pBio, null, 0, null);
+               }
+       }
+
+       SysTryCatch(NID_SEC_CRYPTO, pEvpKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        pRsa = EVP_PKEY_get1_RSA(pEvpKey);
        SysTryCatch(NID_SEC_CRYPTO, pRsa != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
@@ -226,7 +276,14 @@ CATCH:
        {
                RSA_free(pRsa);
        }
-       EVP_PKEY_free(pEvpKey);
+       if (pEvpKey)
+       {
+               EVP_PKEY_free(pEvpKey);
+       }
+       if (pBio)
+       {
+               BIO_free(pBio);
+       }
 
        delete[] pTempBuf;
        return pOutput;
index d0da511..23b65a4 100644 (file)
@@ -22,6 +22,8 @@
  */
 #include <openssl/rsa.h>
 #include <openssl/evp.h>
+#include <openssl/pem.h>
+#include <openssl/x509.h>
 #include <FBaseResult.h>
 #include <FBaseErrors.h>
 #include <FSecCryptoRsaSignature.h>
@@ -80,6 +82,12 @@ CATCH:
 ByteBuffer*
 RsaSignature::SignN(const ByteBuffer& input)
 {
+       return SignN(input, L"SHA1");
+}
+
+ByteBuffer*
+RsaSignature::SignN(const ByteBuffer& input, const Tizen::Base::String& algorithm)
+{
        result r = E_SUCCESS;
        int ret = 0;
        int keyLen = 0;
@@ -92,6 +100,8 @@ RsaSignature::SignN(const ByteBuffer& input)
        ByteBuffer* pOutput = null;
        EVP_PKEY* pEvpKey = null;
        RSA* pRsa = null;
+       BIO* pBio = null;
+       int localNid = NID_sha1;
 
        ClearLastResult();
 
@@ -108,7 +118,29 @@ RsaSignature::SignN(const ByteBuffer& input)
        SysTryReturn(NID_SEC_CRYPTO, keyLen > 0, null, E_KEY_NOT_FOUND, "[E_KEY_NOT_FOUND] Key length should be positive.");
 
        pEvpKey = d2i_PrivateKey(EVP_PKEY_RSA, null, &pKey, keyLen);
-       SysTryReturn(NID_SEC_CRYPTO, pEvpKey != null, null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       if (pEvpKey == null)
+       {
+               PKCS8_PRIV_KEY_INFO* pPrivKeyInfo = d2i_PKCS8_PRIV_KEY_INFO(null, &pKey, keyLen);
+               if (pPrivKeyInfo != null)
+               {
+                       pEvpKey = EVP_PKCS82PKEY(pPrivKeyInfo);
+                       PKCS8_PRIV_KEY_INFO_free(pPrivKeyInfo);
+               }
+
+       }
+       if (pEvpKey == null)
+       {
+               pBio = BIO_new(BIO_s_mem());
+               SysTryReturn(NID_SEC_CRYPTO, pBio != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+               int readCount = BIO_write(pBio, (const void*) pKey, keyLen);
+               SysTryCatch(NID_SEC_CRYPTO, readCount > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+               pEvpKey = PEM_read_bio_PrivateKey(pBio, null, 0, null);
+       }
+
+       SysTryCatch(NID_SEC_CRYPTO, pEvpKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        pRsa = EVP_PKEY_get1_RSA(pEvpKey);
        SysTryCatch(NID_SEC_CRYPTO, pRsa != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
@@ -121,7 +153,40 @@ RsaSignature::SignN(const ByteBuffer& input)
 
        memset(pTempBuf, 0, outLen);
 
-       ret = RSA_sign(NID_sha1, pData, dataLen, pTempBuf, &outLen, pRsa);
+       if (algorithm.CompareTo(L"MD5WITHSHA1") == 0) //for ssl padding
+       {
+               localNid = NID_md5_sha1;
+       }
+       else if (algorithm.CompareTo(L"MD5") == 0)
+       {
+               localNid = NID_md5;
+       }
+       else if (algorithm.CompareTo(L"SHA1") == 0)
+       {
+               localNid = NID_sha1;
+       }
+       else if (algorithm.CompareTo(L"SHA2/224") == 0)
+       {
+               localNid = NID_sha224;
+       }
+       else if (algorithm.CompareTo(L"SHA2/256") == 0)
+       {
+               localNid = NID_sha256;
+       }
+       else if (algorithm.CompareTo(L"SHA2/384") == 0)
+       {
+               localNid = NID_sha384;
+       }
+       else if (algorithm.CompareTo(L"SHA2/512") == 0)
+       {
+               localNid = NID_sha512;
+       }
+       else
+       {
+               SysTryCatch(NID_SEC_CRYPTO, false, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] An unsupported algorithm.");
+       }
+
+       ret = RSA_sign(localNid, pData, dataLen, pTempBuf, &outLen, pRsa);
        SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
        SysTryCatch(NID_SEC_CRYPTO, outLen > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Output length should be positive.");
 
@@ -147,7 +212,14 @@ CATCH:
        {
                RSA_free(pRsa);
        }
-       EVP_PKEY_free(pEvpKey);
+       if (pEvpKey)
+       {
+               EVP_PKEY_free(pEvpKey);
+       }
+       if (pBio)
+       {
+               BIO_free(pBio);
+       }
 
        delete[] pTempBuf;
        return pOutput;
@@ -156,6 +228,12 @@ CATCH:
 bool
 RsaSignature::Verify(const Tizen::Base::ByteBuffer& data, const Tizen::Base::ByteBuffer& signedData)
 {
+       return Verify(data, signedData, L"SHA1");
+}
+
+bool
+RsaSignature::Verify(const Tizen::Base::ByteBuffer& data, const Tizen::Base::ByteBuffer& signedData, const Tizen::Base::String& algorithm)
+{
        result r = E_SUCCESS;
        int ret = 0;
        int keyLen = 0;
@@ -166,6 +244,8 @@ RsaSignature::Verify(const Tizen::Base::ByteBuffer& data, const Tizen::Base::Byt
        const byte* pKey = null;
        EVP_PKEY* pEvpKey = null;
        RSA* pRsa = null;
+       BIO* pBio = null;
+       int localNid = NID_sha1;
 
        ClearLastResult();
 
@@ -188,12 +268,63 @@ RsaSignature::Verify(const Tizen::Base::ByteBuffer& data, const Tizen::Base::Byt
        SysTryReturn(NID_SEC_CRYPTO, keyLen > 0, false, E_KEY_NOT_FOUND, "[E_KEY_NOT_FOUND] Key length should be positive.");
 
        pEvpKey = d2i_PublicKey(EVP_PKEY_RSA, null, &pKey, keyLen);
-       SysTryReturn(NID_SEC_CRYPTO, pEvpKey != null, false, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       if (pEvpKey == null)
+       {
+               pEvpKey = d2i_PUBKEY(null, &pKey, keyLen);
+       }
+
+       if (pEvpKey == null)
+       {
+               pBio = BIO_new(BIO_s_mem());
+               SysTryReturn(NID_SEC_CRYPTO, pBio != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               int readCount = BIO_write(pBio, (const void*) pKey, keyLen);
+               if (readCount > 0)
+               {
+                       pEvpKey = PEM_read_bio_PUBKEY(pBio, null, 0, null);
+               }
+       }
+
+       SysTryCatch(NID_SEC_CRYPTO, pEvpKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        pRsa = EVP_PKEY_get1_RSA(pEvpKey);
        SysTryCatch(NID_SEC_CRYPTO, pRsa != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
-       ret = RSA_verify(NID_sha1, pData, dataLen, pSignedData, signedDataLen, pRsa);
+       if (algorithm.CompareTo(L"MD5WITHSHA1") == 0) //for ssl padding
+       {
+               localNid = NID_md5_sha1;
+       }
+       else if (algorithm.CompareTo(L"MD5") == 0)
+       {
+               localNid = NID_md5;
+       }
+       else if (algorithm.CompareTo(L"SHA1") == 0)
+       {
+               localNid = NID_sha1;
+       }
+       else if (algorithm.CompareTo(L"SHA2/224") == 0)
+       {
+               localNid = NID_sha224;
+       }
+       else if (algorithm.CompareTo(L"SHA2/256") == 0)
+       {
+               localNid = NID_sha256;
+       }
+       else if (algorithm.CompareTo(L"SHA2/384") == 0)
+       {
+               localNid = NID_sha384;
+       }
+       else if (algorithm.CompareTo(L"SHA2/512") == 0)
+       {
+               localNid = NID_sha512;
+       }
+       else
+       {
+               SysTryCatch(NID_SEC_CRYPTO, false, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] An unsupported algorithm.");
+       }
+
+       ret = RSA_verify(localNid, pData, dataLen, pSignedData, signedDataLen, pRsa);
        SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
 CATCH:
@@ -202,8 +333,14 @@ CATCH:
        {
                RSA_free(pRsa);
        }
-       EVP_PKEY_free(pEvpKey);
-
+       if (pEvpKey)
+       {
+               EVP_PKEY_free(pEvpKey);
+       }
+       if (pBio)
+       {
+               BIO_free(pBio);
+       }
        if (IsFailed(r))
        {
                return false;
diff --git a/src/security/crypto/FSecCrypto_TrustZoneService.cpp b/src/security/crypto/FSecCrypto_TrustZoneService.cpp
new file mode 100755 (executable)
index 0000000..c8a323b
--- /dev/null
@@ -0,0 +1,173 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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       FSec_TrustZoneService.cpp
+ * @brief      This is the implementation for the _AccessController class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseString.h>
+#include <FBaseColArrayList.h>
+#include <FIoFile.h>
+#include <FIo_IpcClient.h>
+#include <FBase.h>
+#include <FIo_IpcCommonParamTraits.h>
+#include <FSecCryptoAesCipher.h>
+#include <FSec_DeviceKeyGenerator.h>
+#include "FSecCrypto_TrustZoneService.h"
+#include "FSecCrypto_TrustZoneServiceMessage.h"
+
+
+using namespace Tizen::Io;
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Security { namespace Crypto
+{
+
+_TrustZoneService* _TrustZoneService::__pTrustZoneService = null;
+_IpcClient* _TrustZoneService::__pIpcClient = null;
+unsigned int _TrustZoneService::__refCount = 0;
+
+_TrustZoneService::_TrustZoneService(void)
+{
+
+}
+
+_TrustZoneService::~_TrustZoneService(void)
+{
+
+}
+
+_TrustZoneService*
+_TrustZoneService::GetInstance(void)
+{
+       static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+       if(!__pTrustZoneService)
+       {
+               pthread_once(&once_block, Initialize);
+       }
+
+       if(!__pIpcClient && __refCount == 0)
+       {
+               std::unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient());
+               SysTryReturn(NID_SEC_CRYPTO, pIpcClient != null, null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+               __pIpcClient = pIpcClient.release();
+
+               result r = __pIpcClient->Construct("osp.security.ipcserver.trustzoneservice");
+               SysTryReturn(NID_SEC_CRYPTO, r == E_SUCCESS, null, E_SYSTEM, "Failed to construct the instance of IPC.");
+       }
+       __refCount++;
+
+       return __pTrustZoneService;
+}
+
+ByteBuffer*
+_TrustZoneService::EncryptN(const ByteBuffer& appInfo, const ByteBuffer& plainBuffer)
+{
+       
+       result ret = E_SUCCESS;
+       std::unique_ptr<IPC::Message> pMessage(null);
+       ByteBuffer* pEncryptedBuffer = null;
+
+       _IpcBuffer ipcBuffer;
+       ipcBuffer.size = 0;
+       ipcBuffer.pBuffer = null;
+
+       pMessage.reset(new (std::nothrow) TrustZoneService_Encrypt(appInfo, plainBuffer, &ipcBuffer, &ret));
+       TryReturnResult(pMessage != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       result r = __pIpcClient->SendRequest(pMessage.get());
+       TryReturnResult(r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Failed to send IPC message.");
+       TryReturnResult(ret == E_SUCCESS, null, ret, "[%s] Failed to encrypt", GetErrorMessage(ret));
+
+       byte* pBuffer = static_cast<byte*>(ipcBuffer.pBuffer);
+       TryReturnResult(pBuffer != null && ipcBuffer.size != 0, null, E_SYSTEM, "[E_SYSTEM] Failed to get encrypted data(%d).", ipcBuffer.size);
+
+       pEncryptedBuffer = new (std::nothrow) ByteBuffer();
+       TryReturnResult(pEncryptedBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncryptedBuffer->Construct(ipcBuffer.size);
+       r = pEncryptedBuffer->SetArray(pBuffer, 0, ipcBuffer.size);
+       TryReturnResult(r == E_SUCCESS, null, r, "[%s] propagating.", r);
+       pEncryptedBuffer->Flip();
+
+       free(pBuffer); 
+
+       return pEncryptedBuffer;
+}
+
+ByteBuffer*
+_TrustZoneService::DecryptN(const ByteBuffer& appInfo, const ByteBuffer& encryptedBuffer)
+{
+       
+       result ret = E_SUCCESS;
+       std::unique_ptr<IPC::Message> pMessage(null);
+       ByteBuffer* pPlainBuffer = null;
+
+       _IpcBuffer ipcBuffer;
+       ipcBuffer.size = 0;
+       ipcBuffer.pBuffer = null;
+
+       pMessage.reset(new (std::nothrow) TrustZoneService_Decrypt(appInfo, encryptedBuffer, &ipcBuffer, &ret));
+       TryReturnResult(pMessage != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       result r = __pIpcClient->SendRequest(pMessage.get());
+       TryReturnResult(r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Failed to send IPC message.");
+       TryReturnResult(ret == E_SUCCESS, null, ret, "[%s] Failed to Decrypt", GetErrorMessage(ret));
+
+       byte* pBuffer = static_cast<byte*>(ipcBuffer.pBuffer);
+       TryReturnResult(pBuffer != null && ipcBuffer.size != 0, null, E_SYSTEM, "[E_SYSTEM] Failed to Decrtype");
+
+       pPlainBuffer = new (std::nothrow) ByteBuffer();
+       TryReturnResult(pPlainBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pPlainBuffer->Construct(ipcBuffer.size);
+       r = pPlainBuffer->SetArray(pBuffer, 0, ipcBuffer.size);
+       TryReturnResult(r == E_SUCCESS, null, r, "[%s] propagating.", r);
+       pPlainBuffer->Flip();
+
+       free(pBuffer);
+
+       return pPlainBuffer;
+}
+
+
+void
+_TrustZoneService::Initialize(void)
+{
+
+       static _TrustZoneService trustZoneService;
+       _TrustZoneService::__pTrustZoneService = &trustZoneService;
+
+}
+
+void
+_TrustZoneService::Release()
+{
+       if(--(__refCount) == 0)
+       {
+               SysLog(NID_SEC_CRYPTO, "Close IPC connection");
+               delete __pIpcClient;
+               __pIpcClient = null;
+       }
+}
+
+}}} // Tizen::Security::Crypto
 //
 
 /**
- * @file       FApp_NotificationManagerIpcMessages.cpp
- * @brief      This file contains IPC message class generated by macros.
+ * @file       FSec_TrustZoneService.cpp
+ * @brief      This is the message type of the IPC communication of _TrustZoneService daemon.
  */
 
 #define IPC_MESSAGE_IMPL
-#include "FApp_NotificationManagerIpcMessages.h"
+#include "FSecCrypto_TrustZoneServiceMessage.h"
 
 // Generate constructors.
-#include "ipc/struct_constructor_macros.h"
-#include "FApp_NotificationManagerIpcMessages.h"
+#include <ipc/struct_constructor_macros.h>
+#include "FSecCrypto_TrustZoneServiceMessage.h"
 // Generate destructors.
 
-#include "ipc/struct_destructor_macros.h"
-#include "FApp_NotificationManagerIpcMessages.h"
+#include <ipc/struct_destructor_macros.h>
+#include "FSecCrypto_TrustZoneServiceMessage.h"
 
 // Generate param traits write methods.
-#include "ipc/param_traits_write_macros.h"
+#include <ipc/param_traits_write_macros.h>
 namespace IPC
 {
-#include "FApp_NotificationManagerIpcMessages.h"
+#include "FSecCrypto_TrustZoneServiceMessage.h"
 }  // namespace IPC
 
 // Generate param traits read methods.
-#include "ipc/param_traits_read_macros.h"
+#include <ipc/param_traits_read_macros.h>
 namespace IPC
 {
-#include "FApp_NotificationManagerIpcMessages.h"
+#include "FSecCrypto_TrustZoneServiceMessage.h"
 }  // namespace IPC
old mode 100755 (executable)
new mode 100644 (file)
similarity index 99%
rename from src/security/cert/FSecCert_CertMgrMessages.h
rename to src/security/inc/FSecCert_CertMgrMessages.h
index 43e46d5..dd507a8
@@ -300,7 +300,6 @@ IPC_SYNC_MESSAGE_CONTROL1_1(CertService_InstallUserRootCertificate, Tizen::Io::_
 IPC_SYNC_MESSAGE_CONTROL4_1(CertService_InsertUserCertChainPrivateKey, Tizen::Io::_IpcBuffer, int, Tizen::Io::_IpcBuffer, int, result);
 IPC_SYNC_MESSAGE_CONTROL2_1(CertService_InsertCertificateChainWithPrivateKey, Tizen::Io::_IpcBuffer, int, result);
 IPC_SYNC_MESSAGE_CONTROL2_1(CertService_InstallPkcs12Content, Tizen::Io::_IpcBuffer, Tizen::Io::_IpcBuffer, result);
-IPC_SYNC_MESSAGE_CONTROL1_1(CertService_DeleteUserCertificateByCertId, int, result);
 IPC_SYNC_MESSAGE_CONTROL1_1(CertService_DeleteUserCertChainByCertId, int, result);
 IPC_SYNC_MESSAGE_CONTROL4_2(CertService_GetUserCertChainByIssuerAndSubjectNameN, Tizen::Io::_IpcBuffer, int, Tizen::Io::_IpcBuffer, int, Tizen::Security::Cert::_CertificateListInfo, result);
 IPC_SYNC_MESSAGE_CONTROL2_2(CertService_GetUserCertificateByCertIdN, int, int, Tizen::Security::Cert::_CertInfo, result);
index b2a69d0..30ba364 100644 (file)
@@ -357,22 +357,6 @@ public:
         *                                                                              - DB operation error.
         */
        static result RemoveUserCaCertificateByCertId(int certId);
-       
-       /**
-        *       This function un-installs User Certificate given by a certificate ID.
-        *
-        * @since 2.1
-        * @return                      An error code.
-        * @param[in]           certId                          Certificate Id.
-        * @exception           E_SUCCESS                       The method is successful.
-        * @exception           E_INVALID_ARG           The specified input parameter is invalid.
-        * @exception           E_OUT_OF_MEMORY     The memory is insufficient.
-        * @exception           E_SYSTEM                        A system error has occurred.
-        *                                                                              - File operation error.
-        *                                                                              - DB operation error.
-        */
-       static result RemoveUserCertificateByCertId(int certId);
-
 
        /**
         * This function removes the Default user CA certificates from the storage identified.
index 54230a6..3184470 100644 (file)
@@ -192,22 +192,6 @@ public:
         *                                                                                              - DB operation failed.
         */
        result RemoveUserCaCertificateByCertId(int certId);
-       
-       /**
-        *       This function uninstalls User Certificate given by a certificate ID.
-        *
-        * @since 2.1
-        * @return                      An error code.
-        * @param[in]           certId                                          Certificate Id.
-        * @exception           E_SUCCESS                                       The method is successful.
-        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
-        * @exception           E_OUT_OF_MEMORY                         The memory is insufficient.
-        * @exception           E_SYSTEM                                        A system error has occurred.
-        *                                                                                              - IPC operation failed.
-        *                                                                                              - File operation failed.
-        *                                                                                              - DB operation failed.
-        */
-       result RemoveUserCertificateByCertId(int certId);
 
        /**
         * This function installs the root certificate from pBuffer into Db table identified by type and format of the certificate.
diff --git a/src/security/inc/FSecCert_CertServiceStub.h b/src/security/inc/FSecCert_CertServiceStub.h
deleted file mode 100644 (file)
index 32b5f67..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// 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       FSecCert_CertServiceStub.h
- * @brief      This is the header file for the _CertServiceStub class.
- *
- * This file contains the declarations of _CertServiceStub.
- */
-
-#ifndef _FSEC_CERT_INTERNAL_CERT_SERVICE_STUB_H_
-#define _FSEC_CERT_INTERNAL_CERT_SERVICE_STUB_H_
-
-#include <FBaseByteBuffer.h>
-#include <FBaseResult.h>
-#include <FBaseObject.h>
-#include <FBaseString.h>
-
-#include "FIo_IIpcServerEventListener.h"
-#include "FIo_IpcCommonParamTraits.h"
-#include "FSecCert_CertTypes.h"
-
-namespace Tizen { namespace Io
-{
-class _IpcServer;
-} }
-
-namespace Tizen { namespace Security { namespace Cert
-{
-
-class _OSP_EXPORT_ _CertServiceStub
-       : public Tizen::Io::_IIpcServerEventListener
-       , public Tizen::Base::Object
-{
-public:
-       _CertServiceStub(void);
-
-       virtual ~_CertServiceStub(void);
-
-public:
-       // __IIPcServerEventListener interfaces
-       virtual result Construct(void);
-
-       virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
-
-       virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
-
-       virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
-
-       virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer& server, int clientId);
-
-       virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
-
-       //CertService handler method
-
-       bool OnGetName(result* pRet);
-
-       bool OnCloseCertificateStore(int certificateStoreCtx, result* pRet);
-
-       bool OnOpenCertificateStoreByType(int type, int* pCount, int* pRootHandle, result* pRet);
-
-       bool OnGetCertificateCount(int certificateStoreCtx, int* pRootHandle, result* pRet);
-
-       bool OnGetNextCertificate(int certificateStoreCtx, int length, Tizen::Io::_IpcBuffer* pCertBufferIpc, result* pRet);
-
-       bool OnUpdateRootCa(int type, Tizen::Io::_IpcBuffer certOldBufferIpc, Tizen::Io::_IpcBuffer certNewBufferIpc, result* pRet);
-
-       bool OnRemoveRootCa(int type, Tizen::Io::_IpcBuffer certBufferIpc, int bufLen, result* pRet);
-
-       bool OnUninstallUserRootCertificateByCertId(int certId, result* pRet);
-
-       bool OnInsertCaCertificate(int type, int format, Tizen::Io::_IpcBuffer certBuffer, long certLen, result* pRet);
-
-       bool OnInsertUserCaCertificate(int format, Tizen::Io::_IpcBuffer certBuffer, int certLen, result* pRet);
-
-       bool OnInstallUserRootCertificate(Tizen::Io::_IpcBuffer filePath, result* pRet);
-
-       bool OnInsertUserCertChainPrivateKey(Tizen::Io::_IpcBuffer certChainBufferIpc, int certSize, Tizen::Io::_IpcBuffer privateKeyBufferIpc, int userPriKeyLen, result* pRet);
-
-       bool OnInsertCertificateChainWithPrivateKey(Tizen::Io::_IpcBuffer certChainPrivateKeyBufferIpc, int certChainPrivateKeyLength, result* pRet);
-
-       bool OnInstallPkcs12Content(Tizen::Io::_IpcBuffer pkcs12FilePath, Tizen::Io::_IpcBuffer pkcs12ImportPassword, result* pRet);
-
-       bool OnDeleteUserCertChainByCertId(int certID, result* pRet);
-
-       bool OnDeleteUserCertificateByCertId(int certID, result* pRet);
-
-       bool OnGetUserCertChainByIssuerAndSubjectNameN(Tizen::Io::_IpcBuffer issuerBufferIpc, int issuerNameLen, Tizen::Io::_IpcBuffer subjectBufferIpc, int subNameLen, _CertificateListInfo* pCertList, result* pRet);
-
-       bool OnGetUserCertificateByCertIdN(int certId, int encodingType, _CertInfo* pUserCertificateList, result* pRet);
-
-       bool OnGetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertFieldInfos, result* pRet);
-
-private:
-       _CertServiceStub(const _CertServiceStub& rhs);
-
-       _CertServiceStub& operator =(const _CertServiceStub& rhs);
-
-private:
-       Tizen::Io::_IpcServer* __pIpcServer;
-}; // _CertServiceStub
-
-} } } // Tizen::Security::Cert
-
-#endif // _FSEC_CERT_INTERNAL_CERT_SERVICE_STUB_H_
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/src/security/inc/FSecCrypto_TrustZoneService.h b/src/security/inc/FSecCrypto_TrustZoneService.h
new file mode 100755 (executable)
index 0000000..3808e07
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// 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       FSecCrypto_TrustZoneService.h
+ * @brief      This is the header file for the _TrustZoneService class.
+ *
+ * This file contains the declarations of _TrustZoneService.
+ */
+
+#ifndef _FSEC_CRTYPTO_INTERNAL_TRUST_ZONE_SERVICE_H_
+#define _FSEC_CRTYPTO_INTERNAL_TRUST_ZONE_SERVICE_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Io
+{
+class _IpcClient;
+} }
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Mutex;
+} } }
+
+namespace Tizen { namespace Security { namespace Crypto
+{
+
+/**
+ * @class      _TrustZoneService
+ * @brief      This class is provide IPC API for TrustZone Management.
+ * @since 2.1
+ * /////
+ * The %_TrustZoneService class is used for to provide TrustZone Management's IPC API.
+ * /////
+ * For more information on the class features, see <a href="../com.osp.cppappprogramming.help/html/dev_guide/security/certificate_namespace.htm">Certificates</a>.
+ *
+ */
+class _OSP_EXPORT_ _TrustZoneService
+{
+
+public:
+       /**
+        * Creates and intialize the instance of _TrustZoneService class.
+        *
+        * @since 2.1
+        * @return                      An error code.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception           E_SYSTEM                                        A system error has occurred.
+        *                                                                                              - IPC operation failed.
+        */
+       static _TrustZoneService* GetInstance(void);
+
+       Tizen::Base::ByteBuffer* EncryptN(const Tizen::Base::ByteBuffer& appInfo, const Tizen::Base::ByteBuffer& plainBuffer);
+       Tizen::Base::ByteBuffer* DecryptN(const Tizen::Base::ByteBuffer& appInfo, const Tizen::Base::ByteBuffer& EncryptedBuffer);
+
+       static void Release(void);
+
+private:
+       // This default constructor is intentionally declared as private to
+       // implement the Singleton semantic.
+       _TrustZoneService(void);
+
+       // This destructor is intentionally declared as private to
+       // implement the Singleton semantic.
+       ~_TrustZoneService(void);
+
+       _TrustZoneService(const _TrustZoneService& rhs);
+
+       _TrustZoneService& operator =(const _TrustZoneService& rhs);
+
+       //This construct function initialises the _TrustZoneService instance
+       static void Construct(void);
+       static void Initialize(void);
+
+private:
+       static Tizen::Io::_IpcClient* __pIpcClient;
+       static _TrustZoneService* __pTrustZoneService;
+       static unsigned int __refCount;
+}; // _TrustZoneService
+
+
+}}} // Tizen::Security::TrustZoneService
+#endif //_FSEC_CRTYPTO_INTERNAL_TRUST_ZONE_SERVICE_H_
old mode 100644 (file)
new mode 100755 (executable)
similarity index 60%
rename from src/io/FIo_MessagePortMessages.cpp
rename to src/security/inc/FSecCrypto_TrustZoneServiceMessage.h
index 0fa5421..fa1926b
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
+#include <ipc/ipc_message_macros.h>
+#include <FIo_IpcCommonParamTraits.h>
+#include <FIo_IpcMessageStart.h>
 
-/**
- * @file       FIo_MessagePortMessages.cpp
- * @brief      This is the implementation file for the MessagePortMessages class.
- *
- */
+#define IPC_MESSAGE_START TrustZoneServiceStart
 
+IPC_SYNC_MESSAGE_CONTROL2_2(TrustZoneService_Encrypt, Tizen::Base::ByteBuffer, Tizen::Base::ByteBuffer, Tizen::Io::_IpcBuffer, result);
+IPC_SYNC_MESSAGE_CONTROL2_2(TrustZoneService_Decrypt, Tizen::Base::ByteBuffer, Tizen::Base::ByteBuffer, Tizen::Io::_IpcBuffer, result);
 
-#define IPC_MESSAGE_IMPL
-#include "FIo_MessagePortMessages.h"
index c4be9aa..878612d 100644 (file)
@@ -111,6 +111,25 @@ enum _Privilege
        _PRV_WIFI_WIFIDIRECT_ADMIN,
        _PRV_WIFI_WIFIDIRECT_READ,
        _PRV_WIFIMANAGER,
+       _PRV_APPWIDGET,
+       _PRV_ACCOUNT_READ,
+       _PRV_ACCOUNT_WRITE,
+       _PRV_USERPROFILE_READ,
+       _PRV_USERPROFILE_WRITE,
+       _PRV_TELEPHONY,
+       _PRV_NETSTATISTICSMANAGER,
+       _PRV_NETWORK_STATISTICS,
+       _PRV_NFCMANAGER,
+       _PRV_BOOKMARK_READ,
+       _PRV_BOOKMARK_WRITE,
+       _PRV_GEOLOCATIONPERMISSION_READ,
+       _PRV_GEOLOCATIONPERMISSION_WRITE,
+       _PRV_LOCKMANAGER,
+       _PRV_SHORTCUT,
+       _PRV_APPMANAGER_KILL,
+       _PRV_PRIVILEGEMANAGER_READ,
+       _PRV_PRIVACYMANAGER_READ,
+       _PRV_PRIVACYMANAGER_WRITE,
        _MAX_PRIVILEGE_ENUM
 };
 
@@ -202,6 +221,25 @@ const static _PrivilegeStringList privilegeListTable[_MAX_PRIVILEGE_ENUM] =
        {L"wifi.wifidirect.admin", _PRV_WIFI_WIFIDIRECT_ADMIN},
        {L"wifi.wifidirect.read", _PRV_WIFI_WIFIDIRECT_READ},
        {L"wifimanager", _PRV_WIFIMANAGER},
+       {L"appwidget", _PRV_APPWIDGET},
+       {L"account.read", _PRV_ACCOUNT_READ},
+       {L"account.write", _PRV_ACCOUNT_WRITE},
+       {L"userprofile.read", _PRV_USERPROFILE_READ},
+       {L"userprofile.write", _PRV_USERPROFILE_WRITE},
+       {L"telephony", _PRV_TELEPHONY},
+       {L"netstatisticsmanager", _PRV_NETSTATISTICSMANAGER},
+       {L"network.statistics", _PRV_NETWORK_STATISTICS},
+       {L"nfcmanager", _PRV_NFCMANAGER},
+       {L"bookmark.read", _PRV_BOOKMARK_READ},
+       {L"bookmark.write", _PRV_BOOKMARK_WRITE},
+       {L"geolocationpermission.read", _PRV_GEOLOCATIONPERMISSION_READ},
+       {L"geolocationpermission.write", _PRV_GEOLOCATIONPERMISSION_WRITE},
+       {L"lockmanager", _PRV_LOCKMANAGER},
+       {L"shortcut", _PRV_SHORTCUT},
+       {L"appmanager.kill", _PRV_APPMANAGER_KILL},
+       {L"privilegemanager.read", _PRV_PRIVILEGEMANAGER_READ},
+       {L"privacymanager.read", _PRV_PRIVACYMANAGER_READ},
+       {L"privacymanager.write", _PRV_PRIVACYMANAGER_WRITE},
 };
 
 enum _PrivilegeApiVersion
@@ -291,6 +329,25 @@ const static Tizen::Base::_ApiVisibility visibilityLevelListTable[_MAX_PRIVILEGE
        { Tizen::Base::_API_VISIBILITY_PUBLIC },        // wifi.wifidirect.admin
        { Tizen::Base::_API_VISIBILITY_PUBLIC },        // wifi.wifidirect.read
        { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // wifimanager
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // appwidget
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // account.read
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // account.write
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // userprofile.read
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // userprofile.write
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // telephony
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // netstatisticsmanager
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // network.statistics
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // nfcmanager
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // bookmark.read
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // bookmark.write
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // geolocationpermission.read
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // geolocationpermission.write
+       { Tizen::Base::_API_VISIBILITY_PARTNER },       // lockmanager
+       { Tizen::Base::_API_VISIBILITY_PUBLIC },        // shortcut
+       { Tizen::Base::_API_VISIBILITY_PARTNER },       // appmanager.kill
+       { Tizen::Base::_API_VISIBILITY_PARTNER },       // privilegemanager.read
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // privacymanager.read
+       { Tizen::Base::_API_VISIBILITY_PARTNER_MANUFACTURER },  // privacymanager.write
 };
 
 enum _PrivilegeLevel
@@ -380,6 +437,25 @@ const static _PrivilegeLevel privilegeLevelListTable[_MAX_PRIVILEGE_ENUM][_PRV_A
        { _PRV_LEVEL_USER },    // wifi.wifidirect.admin
        { _PRV_LEVEL_USER },    // wifi.wifidirect.read
        { _PRV_LEVEL_SYSTEM },  // wifimanager
+       { _PRV_LEVEL_USER },    // appwidget
+       { _PRV_LEVEL_USER },    // account.read
+       { _PRV_LEVEL_USER },    // account.write
+       { _PRV_LEVEL_USER },    // userprofile.read
+       { _PRV_LEVEL_USER },    // userprofile.write
+       { _PRV_LEVEL_USER },    // telephony
+       { _PRV_LEVEL_SYSTEM },  // netstatisticsmanager
+       { _PRV_LEVEL_USER },    // network.statistics
+       { _PRV_LEVEL_SYSTEM },  // nfcmanager
+       { _PRV_LEVEL_SYSTEM },  // bookmark.read
+       { _PRV_LEVEL_SYSTEM },  // bookmark.write
+       { _PRV_LEVEL_SYSTEM },  // geolocationpermission.read
+       { _PRV_LEVEL_SYSTEM },  // geolocationpermission.write
+       { _PRV_LEVEL_USER },    // lockmanager
+       { _PRV_LEVEL_USER },    // shortcut
+       { _PRV_LEVEL_SYSTEM },  // appmanager.kill
+       { _PRV_LEVEL_SYSTEM },  // privilegemanager.read
+       { _PRV_LEVEL_SYSTEM },  // privacymanager.read
+       { _PRV_LEVEL_SYSTEM },  // privacymanager.write
 };
 
 const int MAX_BITWISE_PRIV_SIZE = (((_MAX_PRIVILEGE_ENUM - 1) / 32) + 1) * 4;
index c08fff0..5199621 100644 (file)
@@ -49,30 +49,98 @@ public:
         *
         * @since               2.0
         * @return              An error code
-        * @param[in]   appId                           The application ID.
-        * @param[in]   privilege                       A value of enumerator of the specified privilege.
-        * @exception   E_SUCCESS                       The method is successful and request is granted.
-        * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
-        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
-        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege.
-        * @exception   E_SYSTEM                        An unexpected system error occurred.
+        * @param[in]   packageId                               The package ID.
+        * @param[in]   privilege                               A value of enumerator of the specified privilege.
+        * @exception   E_SUCCESS                               The method is successful and request is granted.
+        * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
+        * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
         */
-       static result CheckSystemPrivilege(const Tizen::App::AppId& appId, _Privilege privilege);
+       static result CheckSystemPrivilege(const Tizen::App::PackageId& packageId, _Privilege privilege);
+
+       /**
+        * Checks whether the application has either a privilege1 or a privilege2 and a visibility to invoke the API.
+        *
+        * @since               2.1
+        * @return              An error code
+        * @param[in]   packageId                               The package ID.
+        * @param[in]   privilege1                              A value of enumerator of the specified privilege.
+        * @param[in]   privilege2                              A value of enumerator of the specified privilege.
+        * @exception   E_SUCCESS                               The method is successful and request is granted.
+        * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
+        * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       static result CheckSystemPrivilege(const Tizen::App::PackageId& packageId, _Privilege privilege1, _Privilege privilege2);
+
+       /**
+        * Checks whether the application has a privilege to invoke the API.
+        *
+        * @since               2.1
+        * @return              An error code
+        * @param[in]   packageId                               The package ID.
+        * @param[in]   privilege                               A string of the specified privilege.
+        * @exception   E_SUCCESS                               The method is successful and request is granted.
+        * @exception   E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
+        * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
+        * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+        static result CheckPrivilege(const Tizen::App::PackageId& packageId, const Tizen::Base::String& privilege);
+
 
        /**
         * Checks whether the application has a privilege and a visibility to invoke the API.
         *
         * @since               2.0
         * @return              An error code
-        * @param[in]   privilege                       A value of enumerator of the specified privilege.
-        * @exception   E_SUCCESS                       The method is successful and request is granted.
-        * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
-        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
-        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege.
-        * @exception   E_SYSTEM                        An unexpected system error occurred.
+        * @param[in]   privilege                               A value of enumerator of the specified privilege.
+        * @exception   E_SUCCESS                               The method is successful and request is granted.
+        * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
+        * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+        * @exception   E_SYSTEM                                An unexpected system error occurred.
         */
        static result CheckUserPrivilege(_Privilege privilege);
 
+       /**
+        * Checks whether the application has either a privilege1 or a privilege2 and a visibility to invoke the API.
+        *
+        * @since               2.1
+        * @return              An error code
+        * @param[in]   privilege1                              A value of enumerator of the specified privilege.
+        * @param[in]   privilege2                              A value of enumerator of the specified privilege.
+        * @exception   E_SUCCESS                               The method is successful and request is granted.
+        * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
+        * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+        * @exception   E_SYSTEM                                An unexpected system error occurred.
+        */
+       static result CheckUserPrivilege(_Privilege privilege1, _Privilege privilege2);
+
+    /**
+     * Checks whether the application has a privilege to invoke the API.
+     *
+     * @since          2.1
+     * @return         An error code
+     * @param[in]      privilege                               A string of the specified privilege.
+     * @exception      E_SUCCESS                               The method is successful and request is granted.
+     * @exception      E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
+     * @exception      E_DATA_NOT_FOUND                The privilege information does not exist.
+     * @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
+     * @exception      E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
+     * @exception      E_SYSTEM                                The method cannot proceed due to a severe system error.
+     */
+    static result CheckPrivilege(const Tizen::Base::String& privilege);
+
+
 private:
 
        _AccessController(void);
diff --git a/src/security/inc/FSec_PrivacyInfoImpl.h b/src/security/inc/FSec_PrivacyInfoImpl.h
new file mode 100755 (executable)
index 0000000..b9fb8f9
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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    FSec_PrivacyInfoImpl.h
+* @brief  This is the header file for the %_PrivacyInfoImpl class.
+*
+* This header file contains the declarations of the %_PrivacyInfoImpl class.
+*/
+#ifndef _FSEC_INTERNAL_PRIVACY_INFO_H_
+#define _FSEC_INTERNAL_PRIVACY_INFO_H_
+#include <FBaseObject.h>
+namespace Tizen { namespace Security
+{
+/**
+* @class               _PrivacyInfoImpl
+* @brief               This class represents the privacy information.
+*
+* @since 2.1
+*
+* @final This class is not intended for extension.
+*
+* The %_PrivacyInfoImpl class represents the privacy information.
+* %_PrivacyInfoImpl provides methods to retrieve the name and description of privilege.
+*/
+class _OSP_EXPORT_ _PrivacyInfoImpl
+                        : public Tizen::Base::Object
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        *
+        * @remarks  After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       _PrivacyInfoImpl(void);
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.1
+        *
+        */
+       virtual ~_PrivacyInfoImpl(void);
+       /**
+        * Initializes this instance of %_PrivacyInfoImpl with the specified parameters.
+        *
+        * @since             2.1
+        *
+        * @return           An error code
+        * @param[in]       privacyId                  The privacy ID
+        * @param[in]       enable                      Set to @c true to enable the privacy setting, @n
+        *                                                    else @c false
+        * @exception       E_SUCCESS                The method is successful.
+        * @exception      E_INVALID_ARG          The specified @c privacyId is invalid or the @c privacyId is not exist.
+        *
+        */
+       result Construct(const Tizen::Base::String& privacyId, bool enable = false);
+       /**
+        * Gets a privacy ID.
+        *
+        * @since              2.1
+        *
+        * @return            The privacy ID.
+        *
+        */
+       Tizen::Base::String GetId(void) const;
+       /**
+        * Checks whether the privacy setting is enabled.
+        *
+        * @since       2.1
+        *
+        * @return      @c true if the privacy setting is enabled, @n
+        *                 else @c false
+        * @see         SetEnabled()
+        */
+       bool IsEnabled(void) const;
+       /**
+        * Enables or disables the privacy setting.
+        *
+        * @since       2.1
+        *
+        * @param[in]   enable                  A Boolean value indicating whether the privacy setting is enabled.
+        * @see          IsEnabled()
+        *
+        */
+       void SetEnabled(bool enable);
+       /**
+        * Gets the localized display name of privacy.
+        *
+        * @since              2.1
+        *
+        * @return             The display name of privacy, else an empty string is returned if there is no value.
+        *
+        */
+       Tizen::Base::String GetDisplayName(void) const;
+       /**
+        * Gets the localized description of privacy.
+        *
+        * @since              2.1
+        *
+        * @return             The description of privacy, else an empty string is returned if there is no value.
+        *
+        */
+       Tizen::Base::String GetDescription(void) const;
+private:
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @param[in]   rhs         An instance of %_PrivacyInfoImpl
+       //
+       _PrivacyInfoImpl(const _PrivacyInfoImpl& rhs);
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @param[in]   rhs          An instance of %_PrivacyInfoImpl
+       //
+       _PrivacyInfoImpl& operator =(const _PrivacyInfoImpl& rhs);
+
+private:
+       Tizen::Base::String __privacyId;
+       bool __enabled;
+}; // _PrivacyInfoImpl
+} } // Tizen::Security
+#endif // _FSEC_INTERNAL_PRIVACY_INFO_H_
diff --git a/src/security/inc/FSec_PrivacyManagerImpl.h b/src/security/inc/FSec_PrivacyManagerImpl.h
new file mode 100755 (executable)
index 0000000..fe1fb67
--- /dev/null
@@ -0,0 +1,151 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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                FSec_PrivacyManagerImpl.h
+* @brief       This is the header file for the %_PrivacyManagerImpl class.
+*
+* This header file contains the declarations of the %_PrivacyManagerImpl class.
+*/
+#ifndef _FSEC_INTERNAL_PRIVACY_MANAGER_H_
+#define _FSEC_INTERNAL_PRIVACY_MANAGER_H_
+#include <FBaseObject.h>
+#include <FBaseColIList.h>
+
+namespace Tizen { namespace Security
+{
+class _PrivacyManagerImpl;
+/**
+ * @class        _PrivacyManagerImpl
+ * @brief        This class gets the privacy information and manages an application's privacy settings.
+ *
+ * @since   2.1
+ *
+ * @final   This class is not intended for extension.
+ *
+ * The %_PrivacyManagerImpl class lets an application to get or save application's privacy settings.
+ */
+class _OSP_EXPORT_ _PrivacyManagerImpl
+       : public Tizen::Base::Object
+{
+public:
+       _PrivacyManagerImpl(void);
+
+       virtual ~_PrivacyManagerImpl(void);
+
+       /**
+        * Gets the privacy manager instance.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the %_PrivacyManagerImpl instance, @n
+        *                                      else @c null if it fails
+        *
+        * @exception   E_SUCCESS                 The method is successful.
+        * @exception   E_SYSTEM                   The method cannot proceed due to a severe system error.
+        *
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static const _PrivacyManagerImpl* GetInstance(PrivacyManager& privacyManager);
+       /**
+        * Gets a list of packages which access user's privacy information.
+        *
+        * @since       2.1
+        * @privlevel           platform
+        * @privilege           http://tizen.org/privilege/privacymanager.read
+        *
+        * @return                      A pointer to the list of application packages (PackageId) which access user's privacy information, @n
+        *                                              else @c null if an error occurs
+        *
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception           E_SYSTEM                                The method cannot proceed due to a severe system error.
+        *
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetPrivacyAppPackageListN(void) const;
+       /**
+       * Gets a list of privacy information of a package.
+       *
+       * @since        2.1
+       * @privlevel            platform
+       * @privilege            http://tizen.org/privilege/privacymanager.read
+       *
+       * @return                       A pointer to the privacy information list (_PrivacyManagerImpl), @n
+       *                                               else @c null if an error occurs
+       *
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @exception            E_SYSTEM                                The method cannot proceed due to a severe system error.
+       *
+       * @remarks                       The specific error code can be accessed using the GetLastResult() method.
+       */
+       Tizen::Base::Collection::IList* GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const;
+
+       /**
+       * Sets the specific privacy setting of a package
+       *
+       * @since        2.1
+       * @privlevel            platform
+       * @privilege            http://tizen.org/privilege/privacymanager.write
+       *
+       * @return                       An error code
+       * @param[in]            packageId                               The package ID
+       * @param[in]            _PrivacyManagerImpl                             The privacy setting to be set
+       *
+       * @exception       E_SUCCESS                            The method is successful.
+       * @exception       E_OBJ_NOT_FOUND                      The specified @c packageId is not found in privacy database or @n
+       *                                                                                               the package did not be defined to access to the privacy information.
+       * @exception       E_INVALID_ARG                        The specified @c packageId length is invalid. 
+       * @exception       E_PRIVILEGE_DENIED           The application does not have the privilege to call this method.
+       * @exception       E_SYSTEM                                     The method cannot proceed due to a severe system error.
+       *
+       */
+       result SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo);
+private:
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since                  2.1
+       //
+       _PrivacyManagerImpl(const _PrivacyManagerImpl& rhs);
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since                  2.1
+       //
+       _PrivacyManagerImpl& operator =(const _PrivacyManagerImpl& rhs);
+
+private:
+}; // _PrivacyManagerImpl
+}} // Tizen::Security
+#endif // _FSEC_INTERNAL_PRIVACY_MANAGER_H_
diff --git a/src/security/inc/FSec_PrivilegeInfoImpl.h b/src/security/inc/FSec_PrivilegeInfoImpl.h
new file mode 100755 (executable)
index 0000000..5c8b996
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// 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       FSec_PrivilegeInfoImpl.h
+ * @brief      This is the header file for the _PrivilegeInfoImpl class.
+ */
+
+#ifndef _FSEC_INTERNAL_PRIVILEGE_INFO_IMPL_H_
+#define _FSEC_INTERNAL_PRIVILEGE_INFO_IMPL_H_
+
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FOspConfig.h>
+#include <FBaseInternalTypes.h>
+
+namespace Tizen { namespace Io
+{
+class Database;
+class DbStatement;
+class DbEnumerator;
+}}
+
+namespace Tizen { namespace Security
+{
+
+class PrivilegeInfo;
+
+static const int MAX_DATABASE_RETRY_COUNT = 30;
+static const wchar_t PRIVILEGE_DESCRIPTION_DATABASE_FILE_NAME[] = L"/usr/share/osp/.privilege-description.db";
+
+class _OSP_EXPORT_ _PrivilegeInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       Tizen::Base::String GetDescription(const Tizen::Base::String& privilege) const;
+       Tizen::Base::String GetName(const Tizen::Base::String& privilege) const;
+
+       static _PrivilegeInfoImpl* GetInstance(void);
+
+       _PrivilegeInfoImpl(void);
+       virtual ~_PrivilegeInfoImpl(void);
+       result Construct(void);
+       result Construct(const Tizen::Base::String& privilegeId);
+       Tizen::Base::String GetId(void) const;
+       Tizen::Base::String GetDisplayName(void) const;
+       Tizen::Base::String GetDescription(void) const;
+
+private:
+
+       Tizen::Io::Database* __pDb;
+
+       static _PrivilegeInfoImpl* __pPrivilegeInfoImplInstance;
+
+       result CheckDatabase(void);
+       static void InitInstance(void);
+
+       static Tizen::Io::DbStatement* CreateStatementN(Tizen::Io::Database& db, const Tizen::Base::String& query);
+       static Tizen::Io::DbEnumerator* ExecuteStatementN(Tizen::Io::Database& db, const Tizen::Io::DbStatement* pStmt);
+
+       friend class PrivilegeInfo;
+
+private:
+       Tizen::Base::String __privilegeId;
+
+
+}; // _PrivilegeInfoImpl
+
+} } // Tizen::Security
+
+#endif // _FSEC_INTERNAL_PRIVILEGE_INFO_IMPL_H_
index 3123283..b25ddb9 100644 (file)
@@ -89,8 +89,8 @@ private:
        result Construct(void);
        static _PrivilegeManager* GetInstance(void);
 
-       static result RetrieveCipherPrivilege(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum);
-       static result RetrieveCipherPrivilegeEx(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum);
+       static result RetrieveCipherPrivilegeN(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::ArrayList*& pPrivilegeList);
+       static result RetrieveCipherPrivilegeExN(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::ArrayList*& pPrivilegeList);
        _PrivilegeInfo* RetrievePrivilegeInfoN(const Tizen::App::AppId& appId) const;
 
        static Tizen::Base::Collection::IList* UnpackPrivilegeN(const byte* pBitwisePrivilege);
@@ -107,6 +107,7 @@ private:
 
        friend class ::PrivilegeService;
        friend class _AccessController;
+       friend class AccessController;
 
 };  // _PrivilegeManager
 
index 8b34683..a0d0257 100644 (file)
@@ -26,5 +26,5 @@
 
 #define IPC_MESSAGE_START PrivilegeManagerMsgStart
 
-IPC_SYNC_MESSAGE_CONTROL0_3(PrivilegeManagerMsg_retrieve, Tizen::Base::String, Tizen::Base::String, result)
+IPC_SYNC_MESSAGE_CONTROL0_4(PrivilegeManagerMsg_retrieve, Tizen::Base::String, Tizen::Base::String, Tizen::Base::Collection::ArrayList, result)
 IPC_SYNC_MESSAGE_CONTROL0_3(PrivilegeManagerMsg_retrieveEx, Tizen::Base::String, Tizen::Base::String, result)
diff --git a/src/security/pkcs/FSecPkcsAlgorithmIdentifier.cpp b/src/security/pkcs/FSecPkcsAlgorithmIdentifier.cpp
new file mode 100644 (file)
index 0000000..d2cfdd6
--- /dev/null
@@ -0,0 +1,197 @@
+///
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsAlgorithmIdentifier.cpp
+ * @brief              This is the implementation file for AlgorithmIdentifier class.
+ *
+ * This header file contains the implementation of AlgorithmIdentifier class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+
+#include "FSecPkcs_AlgorithmIdentifierImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+const wchar_t OID_PKCS_05[] = L"1.2.840.113549.1.5";
+const wchar_t OID_PBKDF2[] = L"1.2.840.113549.1.5.12";
+const wchar_t OID_PBES2[] = L"1.2.840.113549.1.5.13";
+const wchar_t OID_PBMAC1[] = L"1.2.840.113549.1.5.14";
+const wchar_t OID_HMAC_SHA1[] = L"1.2.840.113549.2.7";
+const wchar_t OID_HMAC_SHA2_224[] = L"1.2.840.113549.2.8";
+const wchar_t OID_HMAC_SHA2_256[] = L"1.2.840.113549.2.9";
+const wchar_t OID_HMAC_SHA2_384[] = L"1.2.840.113549.2.10";
+const wchar_t OID_HMAC_SHA2_512[] = L"1.2.840.113549.2.11";
+const wchar_t OID_DES_CBC[] = L"1.3.14.3.2.7";
+const wchar_t OID_DES_CBC_EDE3[] = L"1.2.840.113549.3.7";
+const wchar_t OID_AES_128_CBC[] = L"2.16.840.1.101.3.4.1.2";
+const wchar_t OID_AES_192_CBC[] = L"2.16.840.1.101.3.4.1.22";
+const wchar_t OID_AES_256_CBC[] = L"2.16.840.1.101.3.4.1.42";
+const wchar_t OID_RC2_CBC[] = L"1.2.840.113549.3.2";
+const wchar_t OID_PKCS_08[] = L"1.2.840.113549.1.8";
+const wchar_t OID_RSA_ENCRYPTION[] = L"1.2.804.113549.1.1.1";
+const wchar_t OID_ATTR_NAME[] = L"2.5.4.41";
+const wchar_t OID_ATTR_SURNAME[] = L"2.5.4.4";
+const wchar_t OID_ATTR_GIVEN_NAME[] = L"2.5.4.42";
+const wchar_t OID_ATTR_INITIAL[] = L"2.5.4.43";
+const wchar_t OID_ATTR_GEN_QUALIFIER[] = L"2.5.4.44";
+const wchar_t OID_ATTR_COMMON_NAME[] = L"2.5.4.3";
+const wchar_t OID_ATTR_LOCALITY_NAME[] = L"2.5.4.7";
+const wchar_t OID_ATTR_STATE_OR_PROV_NAME[] = L"2.5.4.8";
+const wchar_t OID_ATTR_ORG_NAME[] = L"2.5.4.10";
+const wchar_t OID_ATTR_ORG_UNIT_NAME[] = L"2.5.4.11";
+const wchar_t OID_ATTR_TITLE[] = L"2.5.4.12";
+const wchar_t OID_ATTR_DN_QUALIFIER[] = L"2.5.4.46";
+const wchar_t OID_ATTR_COUNTRY_NAME[] = L"2.5.4.6";
+const wchar_t OID_ATTR_SERIAL_NUMBER[] = L"2.5.4.5";
+const wchar_t OID_ATTR_PSEUDONYM[] = L"2.5.4.65";
+const wchar_t OID_ATTR_DOMAIN_COMPONENT[] = L"0.9.2342.19200300.100.1.25";
+const wchar_t OID_ATTR_EMAIL_ADDRESS[] = L"1.2.840.113549.1.9.1";
+
+
+AlgorithmIdentifier::AlgorithmIdentifier(void)
+       : __pAlgorithmIdentifierImpl(null)
+{
+       __pAlgorithmIdentifierImpl = new (std::nothrow) _AlgorithmIdentifierImpl();
+       SysTryReturnVoidResult(NID_SEC_CERT, __pAlgorithmIdentifierImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+AlgorithmIdentifier::~AlgorithmIdentifier(void)
+{
+       delete __pAlgorithmIdentifierImpl;
+}
+
+result
+AlgorithmIdentifier::Construct(const Tizen::Base::String& algorithm, const IAlgorithmParameters* pAlgoParams)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pAlgorithmIdentifierImpl->Construct(algorithm, pAlgoParams);
+       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AlgorithmIdentifier::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pAlgorithmIdentifierImpl->Construct(encodedData);
+       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+AlgorithmIdentifier*
+AlgorithmIdentifier::CloneN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+       SysAssertf(__pAlgorithmIdentifierImpl->GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Reconstructor the object.");
+
+       std::unique_ptr< AlgorithmIdentifier > pObj(new (std::nothrow) AlgorithmIdentifier());
+       SysTryReturn(NID_SEC_CRYPTO, pObj, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pObj->Construct(__pAlgorithmIdentifierImpl->GetAlgorithmObjectId(), __pAlgorithmIdentifierImpl->GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return pObj.release();
+}
+
+String
+AlgorithmIdentifier::GetAlgorithmObjectId(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pAlgorithmIdentifierImpl->__algorithm;
+}
+
+IAlgorithmParameters*
+AlgorithmIdentifier::GetParametersN(void) const
+{
+       //Return the Algorithm Parameter
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< IAlgorithmParameters > pObj(__pAlgorithmIdentifierImpl->GetParametersN());
+       SysTryReturn(NID_IO, pObj != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pObj.release();
+
+}
+
+ByteBuffer*
+AlgorithmIdentifier::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncAlgoIdParam(__pAlgorithmIdentifierImpl->GetEncodedDataN());
+       SysTryReturn(NID_IO, pEncAlgoIdParam != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncAlgoIdParam.release();
+
+}
+
+bool
+AlgorithmIdentifier::Equals(const Object& obj) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       const AlgorithmIdentifier* pOther = dynamic_cast< const AlgorithmIdentifier* >(&obj);
+       if (pOther == null)
+       {
+               return false;
+       }
+
+       return __pAlgorithmIdentifierImpl->Equals(*pOther->__pAlgorithmIdentifierImpl);
+}
+
+int
+AlgorithmIdentifier::GetHashCode(void) const
+{
+       ClearLastResult();
+       SysAssertf(__pAlgorithmIdentifierImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pAlgorithmIdentifierImpl->GetHashCode();
+
+}
+
+} }}
diff --git a/src/security/pkcs/FSecPkcsInitialVector.cpp b/src/security/pkcs/FSecPkcsInitialVector.cpp
new file mode 100644 (file)
index 0000000..b6e446e
--- /dev/null
@@ -0,0 +1,143 @@
+///
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsInitialVector.cpp
+ * @brief              This is the implementation file for InitialVector class.
+ *
+ * This header file contains the implementation of InitialVector class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseErrors.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsInitialVector.h>
+#include "FSecPkcs_InitialVectorImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+InitialVector::InitialVector(void)
+       : __pInitialVectorImpl(null)
+{
+       __pInitialVectorImpl = new (std::nothrow) _InitialVectorImpl();
+       SysTryReturnVoidResult(NID_SEC_CERT, __pInitialVectorImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+InitialVector::~InitialVector(void)
+{
+       delete __pInitialVectorImpl;
+}
+
+result
+InitialVector::Construct(const Tizen::Base::ByteBuffer& initialVector)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pInitialVectorImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       r = __pInitialVectorImpl->Construct(initialVector);
+       SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+
+}
+
+IAlgorithmParameters*
+InitialVector::CloneN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pInitialVectorImpl != null, "Not yet constructed. Reconstructor the object.");
+       SysAssertf(__pInitialVectorImpl->GetInitialVector().GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       std::unique_ptr< InitialVector > pInitialVectorObj(new (std::nothrow) InitialVector());
+       SysTryReturn(NID_SEC_CRYPTO, pInitialVectorObj != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pInitialVectorObj->Construct(__pInitialVectorImpl->GetInitialVector());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return pInitialVectorObj.release();
+
+}
+
+PkcsAlgorithmParameterType
+InitialVector::GetType(void) const
+{
+       SysAssertf(__pInitialVectorImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       ClearLastResult();
+       return __pInitialVectorImpl->GetType();
+}
+
+const ByteBuffer&
+InitialVector::GetInitialVector(void) const
+{
+
+       ClearLastResult();
+
+       SysAssertf(__pInitialVectorImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pInitialVectorImpl->GetInitialVector();
+
+}
+
+bool
+InitialVector::Equals(const Object& obj) const
+{
+       SysAssertf(__pInitialVectorImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       const InitialVector* pOther = dynamic_cast< const InitialVector* >(&obj);
+       if (pOther == null)
+       {
+               return false;
+       }
+
+       return __pInitialVectorImpl->Equals(*pOther->__pInitialVectorImpl);
+}
+
+int
+InitialVector::GetHashCode(void) const
+{
+       SysAssertf(__pInitialVectorImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pInitialVectorImpl->GetHashCode();
+}
+
+ByteBuffer*
+InitialVector::GetEncodedDataN(void) const
+{
+       SysAssertf(__pInitialVectorImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       result r = E_SUCCESS;
+
+       std::unique_ptr< ByteBuffer > pEncInitialVector(__pInitialVectorImpl->GetEncodedDataN());
+       SysTryReturn(NID_IO, pEncInitialVector != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncInitialVector.release();
+
+}
+
+
+} } }
diff --git a/src/security/pkcs/FSecPkcsPkcs05PbEs2Parameters.cpp b/src/security/pkcs/FSecPkcsPkcs05PbEs2Parameters.cpp
new file mode 100644 (file)
index 0000000..a644ca0
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05PbEs2Parameters.cpp
+ * @brief              This is the implementation file for Pkcs05PbEs2Parameters class.
+ *
+ * This header file contains the implementation of Pkcs05PbEs2Parameters class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include "FSecPkcs_Pkcs05PbEs2ParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+Pkcs05PbEs2Parameters::Pkcs05PbEs2Parameters(void)
+       : __pPkcs05PbEs2ParametersImpl(null)
+{
+       __pPkcs05PbEs2ParametersImpl = new (std::nothrow) _Pkcs05PbEs2ParametersImpl();
+       SysTryReturnVoidResult(NID_SEC_CRYPTO, __pPkcs05PbEs2ParametersImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+Pkcs05PbEs2Parameters::~Pkcs05PbEs2Parameters(void)
+{
+       delete __pPkcs05PbEs2ParametersImpl;
+}
+
+result
+Pkcs05PbEs2Parameters::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05PbEs2ParametersImpl->Construct(encodedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+
+}
+
+result
+Pkcs05PbEs2Parameters::Construct(const AlgorithmIdentifier& keyDerivationFunction, const AlgorithmIdentifier& encryptionScheme)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05PbEs2ParametersImpl->Construct(keyDerivationFunction, encryptionScheme);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+
+}
+
+
+ByteBuffer*
+Pkcs05PbEs2Parameters::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncPbeParam(__pPkcs05PbEs2ParametersImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncPbeParam != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncPbeParam.release();
+}
+
+const AlgorithmIdentifier&
+Pkcs05PbEs2Parameters::GetKeyDerivationAlgorithm(void) const
+{
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbEs2ParametersImpl->GetKeyDerivationAlgorithm();
+}
+
+const AlgorithmIdentifier&
+Pkcs05PbEs2Parameters::GetEncryptionScheme(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbEs2ParametersImpl->GetEncryptionScheme();
+}
+
+
+IAlgorithmParameters*
+Pkcs05PbEs2Parameters::CloneN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       SysAssertf(__pPkcs05PbEs2ParametersImpl->GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__pPkcs05PbEs2ParametersImpl->GetEncryptionScheme().GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       std::unique_ptr< Pkcs05PbEs2Parameters > pbEs2Parameters(new (std::nothrow) Pkcs05PbEs2Parameters());
+       SysTryReturn(NID_SEC_CRYPTO, pbEs2Parameters, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pbEs2Parameters->Construct(__pPkcs05PbEs2ParametersImpl->GetKeyDerivationAlgorithm(), __pPkcs05PbEs2ParametersImpl->GetEncryptionScheme());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, r, "[%s] Failed to construct password based encryption parameters.", GetErrorMessage(r));
+
+       return pbEs2Parameters.release();
+
+}
+
+PkcsAlgorithmParameterType
+Pkcs05PbEs2Parameters::GetType(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       return __pPkcs05PbEs2ParametersImpl->GetType();
+}
+
+bool
+Pkcs05PbEs2Parameters::Equals(const Object& obj) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       const Pkcs05PbEs2Parameters* pOther = dynamic_cast< const Pkcs05PbEs2Parameters* >(&obj);
+       if (pOther == null)
+       {
+               return false;
+       }
+
+       return __pPkcs05PbEs2ParametersImpl->Equals(*pOther->__pPkcs05PbEs2ParametersImpl);
+}
+
+int
+Pkcs05PbEs2Parameters::GetHashCode(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbEs2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbEs2ParametersImpl->GetHashCode();
+}
+
+
+} } } // end of namespace Pkcs
diff --git a/src/security/pkcs/FSecPkcsPkcs05PbKdf2Parameters.cpp b/src/security/pkcs/FSecPkcsPkcs05PbKdf2Parameters.cpp
new file mode 100644 (file)
index 0000000..8eab89a
--- /dev/null
@@ -0,0 +1,205 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05PbKdf2Parameters.cpp
+ * @brief              This is the implementation file for Pkcs05PbKdf2Parameters class.
+ *
+ * This header file contains the implementation of Pkcs05PbKdf2Parameters class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseInteger.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+
+#include "FSecPkcs_Pkcs05PbKdf2ParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+Pkcs05PbKdf2Parameters::Pkcs05PbKdf2Parameters(void)
+       : __pPkcs05PbKdf2ParametersImpl(null)
+{
+       __pPkcs05PbKdf2ParametersImpl = new (std::nothrow) _Pkcs05PbKdf2ParametersImpl();
+       SysTryReturnVoidResult(NID_SEC_CRYPTO, __pPkcs05PbKdf2ParametersImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+Pkcs05PbKdf2Parameters::~Pkcs05PbKdf2Parameters(void)
+{
+       delete __pPkcs05PbKdf2ParametersImpl;
+}
+
+result
+Pkcs05PbKdf2Parameters::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05PbKdf2ParametersImpl->Construct(encodedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Pkcs05PbKdf2Parameters::Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, int derivedKeyLength)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05PbKdf2ParametersImpl->Construct(saltBuffer, iterationCount, derivedKeyLength);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+result
+Pkcs05PbKdf2Parameters::Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, const AlgorithmIdentifier& prf, int derivedKeyLength)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05PbKdf2ParametersImpl->Construct(saltBuffer, iterationCount, prf, derivedKeyLength);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+ByteBuffer*
+Pkcs05PbKdf2Parameters::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncKdfParam(__pPkcs05PbKdf2ParametersImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncKdfParam != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncKdfParam.release();
+
+}
+
+const ByteBuffer&
+Pkcs05PbKdf2Parameters::GetSaltValue(void) const
+{
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbKdf2ParametersImpl->GetSaltValue();
+}
+
+int
+Pkcs05PbKdf2Parameters::GetIterationCount(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbKdf2ParametersImpl->__iterationCount;
+}
+int
+Pkcs05PbKdf2Parameters::GetDerivedKeyLength(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbKdf2ParametersImpl->__derivedKeyLength;
+}
+
+const AlgorithmIdentifier&
+Pkcs05PbKdf2Parameters::GetPrf(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbKdf2ParametersImpl->GetPrf();
+}
+
+IAlgorithmParameters*
+Pkcs05PbKdf2Parameters::CloneN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl->GetSaltValue().GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKdf2Parameters(new (std::nothrow) Pkcs05PbKdf2Parameters());
+       SysTryReturn(NID_SEC_CRYPTO, pKdf2Parameters, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       if (__pPkcs05PbKdf2ParametersImpl->GetPrf().GetAlgorithmObjectId().GetLength() > 0)
+       {
+               r = pKdf2Parameters->Construct(__pPkcs05PbKdf2ParametersImpl->GetSaltValue(), __pPkcs05PbKdf2ParametersImpl->GetIterationCount(), __pPkcs05PbKdf2ParametersImpl->GetPrf(), __pPkcs05PbKdf2ParametersImpl->GetDerivedKeyLength());
+       }
+       else
+       {
+               r = pKdf2Parameters->Construct(__pPkcs05PbKdf2ParametersImpl->GetSaltValue(), __pPkcs05PbKdf2ParametersImpl->GetIterationCount(), __pPkcs05PbKdf2ParametersImpl->GetDerivedKeyLength());
+       }
+
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, r, "[%s] Failed to construct key derivation parameters.", GetErrorMessage(r));
+
+       return pKdf2Parameters.release();
+}
+
+PkcsAlgorithmParameterType
+Pkcs05PbKdf2Parameters::GetType(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbKdf2ParametersImpl->GetType();
+}
+
+
+bool
+Pkcs05PbKdf2Parameters::Equals(const Object& obj) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       const Pkcs05PbKdf2Parameters* pOther = dynamic_cast< const Pkcs05PbKdf2Parameters* >(&obj);
+       if (pOther == null)
+       {
+               return false;
+       }
+
+       return __pPkcs05PbKdf2ParametersImpl->Equals(*pOther->__pPkcs05PbKdf2ParametersImpl);
+
+}
+
+int
+Pkcs05PbKdf2Parameters::GetHashCode(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbKdf2ParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbKdf2ParametersImpl->GetHashCode();
+}
+
+} } } // end of namespace Pkcs
diff --git a/src/security/pkcs/FSecPkcsPkcs05PbMacParameters.cpp b/src/security/pkcs/FSecPkcsPkcs05PbMacParameters.cpp
new file mode 100644 (file)
index 0000000..8aade31
--- /dev/null
@@ -0,0 +1,166 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05PbMacParameters.cpp
+ * @brief              This is the implementation file for Pkcs05PbMacParameters class.
+ *
+ * This header file contains the implementation of Pkcs05PbMacParameters class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include "FSecPkcs_Pkcs05PbMacParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+
+Pkcs05PbMacParameters::Pkcs05PbMacParameters(void)
+       : __pPkcs05PbMacParametersImpl(null)
+{
+       __pPkcs05PbMacParametersImpl = new (std::nothrow) _Pkcs05PbMacParametersImpl();
+       SysTryReturnVoidResult(NID_SEC_CRYPTO, __pPkcs05PbMacParametersImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+Pkcs05PbMacParameters::~Pkcs05PbMacParameters(void)
+{
+       delete __pPkcs05PbMacParametersImpl;
+}
+
+result
+Pkcs05PbMacParameters::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05PbMacParametersImpl->Construct(encodedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Pkcs05PbMacParameters::Construct(const AlgorithmIdentifier& keyDerivationFunction, const AlgorithmIdentifier& messageAuthScheme)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05PbMacParametersImpl->Construct(keyDerivationFunction, messageAuthScheme);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+Tizen::Base::ByteBuffer*
+Pkcs05PbMacParameters::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncPbMacParam(__pPkcs05PbMacParametersImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncPbMacParam != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncPbMacParam.release();
+
+
+}
+
+const AlgorithmIdentifier&
+Pkcs05PbMacParameters::GetKeyDerivationAlgorithm(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbMacParametersImpl->GetKeyDerivationAlgorithm();
+}
+
+const AlgorithmIdentifier&
+Pkcs05PbMacParameters::GetMacAlgorithm(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs05PbMacParametersImpl->GetMacAlgorithm();
+}
+
+IAlgorithmParameters*
+Pkcs05PbMacParameters::CloneN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       SysAssertf(__pPkcs05PbMacParametersImpl->GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__pPkcs05PbMacParametersImpl->GetMacAlgorithm().GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       std::unique_ptr< Pkcs05PbMacParameters > pbMacParameters(new (std::nothrow) Pkcs05PbMacParameters());
+       SysTryReturn(NID_SEC_CRYPTO, pbMacParameters, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pbMacParameters->Construct(__pPkcs05PbMacParametersImpl->GetKeyDerivationAlgorithm(), __pPkcs05PbMacParametersImpl->GetMacAlgorithm());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, r, "[%s] Failed to construct mac parameters.", GetErrorMessage(r));
+
+       return pbMacParameters.release();
+}
+
+PkcsAlgorithmParameterType
+Pkcs05PbMacParameters::GetType(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       return __pPkcs05PbMacParametersImpl->GetType();
+}
+
+bool
+Pkcs05PbMacParameters::Equals(const Object& obj) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       const Pkcs05PbMacParameters* pOther = dynamic_cast< const Pkcs05PbMacParameters* >(&obj);
+       if (pOther == null)
+       {
+               return false;
+       }
+
+       return __pPkcs05PbMacParametersImpl->Equals(*pOther->__pPkcs05PbMacParametersImpl);
+
+}
+
+int
+Pkcs05PbMacParameters::GetHashCode(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05PbMacParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       return __pPkcs05PbMacParametersImpl->GetHashCode();
+}
+
+} } } // end of namespace Pkcs
diff --git a/src/security/pkcs/FSecPkcsPkcs05Schemes.cpp b/src/security/pkcs/FSecPkcsPkcs05Schemes.cpp
new file mode 100644 (file)
index 0000000..0898650
--- /dev/null
@@ -0,0 +1,138 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05Schemes.cpp
+ * @brief              This is the implementation file for Pkcs05Schemes class.
+ *
+ * This header file contains the implementation of Pkcs05Schemes class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs05Schemes.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include "FSecPkcs_Pkcs05SchemesImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+Pkcs05Schemes::Pkcs05Schemes(void)
+       : __pPkcs05SchemesImpl(null)
+{
+       __pPkcs05SchemesImpl = new (std::nothrow) _Pkcs05SchemesImpl();
+       SysTryReturnVoidResult(NID_SEC_CRYPTO, __pPkcs05SchemesImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+Pkcs05Schemes::~Pkcs05Schemes(void)
+{
+       delete __pPkcs05SchemesImpl;
+}
+
+result
+Pkcs05Schemes::Construct(const Tizen::Base::ByteBuffer& password, int derivedKeyLength)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05SchemesImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05SchemesImpl->Construct(password, derivedKeyLength);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+ByteBuffer*
+Pkcs05Schemes::GenerateKeyKdf2N(const Pkcs05PbKdf2Parameters& params)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05SchemesImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pOut(__pPkcs05SchemesImpl->GenerateKeyKdf2N(params));
+       SysTryReturn(NID_SEC_CRYPTO, pOut != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pOut.release();
+
+}
+
+ByteBuffer*
+Pkcs05Schemes::EncryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05SchemesImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pOutBuffer(__pPkcs05SchemesImpl->EncryptionScheme2N(params, message));
+       SysTryReturn(NID_SEC_CRYPTO, pOutBuffer != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pOutBuffer.release();
+}
+
+ByteBuffer*
+Pkcs05Schemes::DecryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05SchemesImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pOutBuffer(__pPkcs05SchemesImpl->DecryptionScheme2N(params, message));
+       SysTryReturn(NID_SEC_CRYPTO, pOutBuffer != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pOutBuffer.release();
+}
+
+ByteBuffer*
+Pkcs05Schemes::GetPbHMacN(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs05SchemesImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pOutput(__pPkcs05SchemesImpl->GetPbHMacN(params, message));
+       SysTryReturn(NID_SEC_CRYPTO, pOutput != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pOutput.release();
+
+}
+
+result
+Pkcs05Schemes::VerifyPbMac(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message, const Tizen::Base::ByteBuffer& mac)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs05SchemesImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs05SchemesImpl->VerifyPbMac(params, message, mac);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+
+}
+
+} } } // end of namespace Pkcs05
diff --git a/src/security/pkcs/FSecPkcsPkcs08Attribute.cpp b/src/security/pkcs/FSecPkcsPkcs08Attribute.cpp
new file mode 100644 (file)
index 0000000..786622c
--- /dev/null
@@ -0,0 +1,125 @@
+///
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08Attribute.cpp
+ * @brief              This is the implementation file for Pkcs08Attribute class.
+ *
+ * This header file contains the implementation of Pkcs08Attributer class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsPkcs08Attribute.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+#include "FSecPkcs_Pkcs08AttributeImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+Pkcs08Attribute::Pkcs08Attribute(void)
+       : __pPkcs08AttributeImpl(null)
+{
+       __pPkcs08AttributeImpl = new (std::nothrow) _Pkcs08AttributeImpl();
+       SysTryReturnVoidResult(NID_SEC_CERT, __pPkcs08AttributeImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+Pkcs08Attribute::~Pkcs08Attribute(void)
+{
+       delete __pPkcs08AttributeImpl;
+}
+
+result
+Pkcs08Attribute::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08AttributeImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08AttributeImpl->Construct(encodedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Pkcs08Attribute::Construct(const Tizen::Base::String& attrType)
+{
+       //Variables local to function
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08AttributeImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08AttributeImpl->Construct(attrType);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+result
+Pkcs08Attribute::AddAttributeValue(const Pkcs08AttributeValue& value)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08AttributeImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08AttributeImpl->AddAttributeValue(value);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Pkcs08Attribute::RemoveAttributeValue(const Pkcs08AttributeValue& value)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08AttributeImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08AttributeImpl->RemoveAttributeValue(value);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+const Tizen::Base::Collection::ArrayList&
+Pkcs08Attribute::GetAttributeValues(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08AttributeImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08AttributeImpl->GetAttributeValues();
+}
+
+ByteBuffer*
+Pkcs08Attribute::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08AttributeImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncodedBuffer(__pPkcs08AttributeImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncodedBuffer != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncodedBuffer.release();
+
+}
+} } }
diff --git a/src/security/pkcs/FSecPkcsPkcs08AttributeValue.cpp b/src/security/pkcs/FSecPkcsPkcs08AttributeValue.cpp
new file mode 100644 (file)
index 0000000..5006bbf
--- /dev/null
@@ -0,0 +1,114 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08AttributeValue.cpp
+ * @brief              This is the implementation file for Pkcs08AttributeValue class.
+ *
+ * This header file contains the implementation of Pkcs08AttributeValue class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+#include "FSecPkcs_Pkcs08AttributeValueImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+Pkcs08AttributeValue::Pkcs08AttributeValue(void)
+       : __pPkcs08AttributeValueImpl(null)
+{
+       __pPkcs08AttributeValueImpl = new (std::nothrow) _Pkcs08AttributeValueImpl();
+       SysTryReturnVoidResult(NID_SEC_CERT, __pPkcs08AttributeValueImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+Pkcs08AttributeValue::~Pkcs08AttributeValue(void)
+{
+       delete __pPkcs08AttributeValueImpl;
+}
+
+result
+Pkcs08AttributeValue::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08AttributeValueImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08AttributeValueImpl->Construct(encodedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Pkcs08AttributeValue::Construct(const Tizen::Base::ByteBuffer& value, const Pkcs08TagValue tag)
+{
+       //Variables local to function
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08AttributeValueImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08AttributeValueImpl->Construct(value, tag);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+const ByteBuffer&
+Pkcs08AttributeValue::GetValue(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08AttributeValueImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08AttributeValueImpl->GetValue();
+
+}
+
+Pkcs08TagValue
+Pkcs08AttributeValue::GetTag(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08AttributeValueImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08AttributeValueImpl->GetTag();
+}
+
+ByteBuffer*
+Pkcs08AttributeValue::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08AttributeValueImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       std::unique_ptr< ByteBuffer > pEncodedData(__pPkcs08AttributeValueImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncodedData != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncodedData.release();
+
+}
+} } }
diff --git a/src/security/pkcs/FSecPkcsPkcs08EncryptedPrivateKeyInfo.cpp b/src/security/pkcs/FSecPkcsPkcs08EncryptedPrivateKeyInfo.cpp
new file mode 100644 (file)
index 0000000..82923af
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08EncryptedPrivateKeyInfo.cpp
+ * @brief              This is the implementation file for Pkcs08EncryptedPrivateKeyInfo class.
+ *
+ * This header file contains the implementation of Pkcs08EncryptedPrivateKeyInfo class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs08EncryptedPrivateKeyInfo.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+
+#include "FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+//EncryptedPrivateKeyInfo Class Life cycle
+
+//Default Constructor
+Pkcs08EncryptedPrivateKeyInfo::Pkcs08EncryptedPrivateKeyInfo(void)
+       : __pPkcs08EncryptedPrivateKeyInfoImpl(null)
+{
+       __pPkcs08EncryptedPrivateKeyInfoImpl = new (std::nothrow) _Pkcs08EncryptedPrivateKeyInfoImpl();
+       SysTryReturnVoidResult(NID_SEC_CRYPTO, __pPkcs08EncryptedPrivateKeyInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+//Default Destructor
+Pkcs08EncryptedPrivateKeyInfo::~Pkcs08EncryptedPrivateKeyInfo(void)
+{
+       delete __pPkcs08EncryptedPrivateKeyInfoImpl;
+}
+
+result
+Pkcs08EncryptedPrivateKeyInfo::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08EncryptedPrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08EncryptedPrivateKeyInfoImpl->Construct(encodedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+// Encrypted Private Key Info Class Operations
+result
+Pkcs08EncryptedPrivateKeyInfo::Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08EncryptedPrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08EncryptedPrivateKeyInfoImpl->Construct(algorithmId, encryptedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+result
+Pkcs08EncryptedPrivateKeyInfo::Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfoBuffer)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08EncryptedPrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08EncryptedPrivateKeyInfoImpl->Construct(algorithmId, key, encodedPrivateKeyInfoBuffer);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+const AlgorithmIdentifier&
+Pkcs08EncryptedPrivateKeyInfo::GetAlgorithm(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08EncryptedPrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08EncryptedPrivateKeyInfoImpl->GetAlgorithm();
+}
+
+ByteBuffer*
+Pkcs08EncryptedPrivateKeyInfo::GetEncryptedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08EncryptedPrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncryptedData(__pPkcs08EncryptedPrivateKeyInfoImpl->GetEncryptedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncryptedData != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncryptedData.release();
+
+}
+
+ByteBuffer*
+Pkcs08EncryptedPrivateKeyInfo::DecryptN(const Tizen::Base::ByteBuffer& key)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08EncryptedPrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pDecryptedData(__pPkcs08EncryptedPrivateKeyInfoImpl->DecryptN(key));
+       SysTryReturn(NID_SEC_CRYPTO, pDecryptedData != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pDecryptedData.release();
+}
+
+ByteBuffer*
+Pkcs08EncryptedPrivateKeyInfo::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08EncryptedPrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncPrivKey(__pPkcs08EncryptedPrivateKeyInfoImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncPrivKey != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncPrivKey.release();
+
+}
+
+} } }
diff --git a/src/security/pkcs/FSecPkcsPkcs08PrivateKeyInfo.cpp b/src/security/pkcs/FSecPkcsPkcs08PrivateKeyInfo.cpp
new file mode 100644 (file)
index 0000000..5a3d4f0
--- /dev/null
@@ -0,0 +1,160 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs08PrivateKeyInfo.cpp
+ * @brief              This is the implementation file for Pkcs08PrivateKeyInfo class.
+ *
+ * This header file contains the implementation of Pkcs08PrivateKeyInfo class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs08PrivateKeyInfo.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include "FSecPkcs_Pkcs08PrivateKeyInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+Pkcs08PrivateKeyInfo::Pkcs08PrivateKeyInfo(void)
+       : __pPkcs08PrivateKeyInfoImpl(null)
+{
+       __pPkcs08PrivateKeyInfoImpl = new (std::nothrow) _Pkcs08PrivateKeyInfoImpl();
+       SysTryReturnVoidResult(NID_SEC_CRYPTO, __pPkcs08PrivateKeyInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+//Default Destructor
+Pkcs08PrivateKeyInfo::~Pkcs08PrivateKeyInfo(void)
+{
+       delete __pPkcs08PrivateKeyInfoImpl;
+}
+
+
+result
+Pkcs08PrivateKeyInfo::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08PrivateKeyInfoImpl->Construct(encodedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Pkcs08PrivateKeyInfo::Construct(const AlgorithmIdentifier& privAlgoId, const Tizen::Base::ByteBuffer& privKey)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08PrivateKeyInfoImpl->Construct(privAlgoId, privKey);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+Pkcs08PrivateKeyInfo::GetVersion(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08PrivateKeyInfoImpl->GetVersion();
+
+}
+
+const AlgorithmIdentifier&
+Pkcs08PrivateKeyInfo::GetPrivateKeyAlgorithm(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08PrivateKeyInfoImpl->GetPrivateKeyAlgorithm();
+}
+
+const ByteBuffer&
+Pkcs08PrivateKeyInfo::GetPrivateKey(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08PrivateKeyInfoImpl->GetPrivateKey();
+}
+
+const Tizen::Base::Collection::ArrayList&
+Pkcs08PrivateKeyInfo::GetAttributes(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       return __pPkcs08PrivateKeyInfoImpl->GetAttributes();
+
+}
+
+result
+Pkcs08PrivateKeyInfo::AddAttribute(const Pkcs08Attribute& attribute)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08PrivateKeyInfoImpl->AddAttribute(attribute);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Pkcs08PrivateKeyInfo::RemoveAttribute(const Pkcs08Attribute& attribute)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       r = __pPkcs08PrivateKeyInfoImpl->RemoveAttribute(attribute);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+ByteBuffer*
+Pkcs08PrivateKeyInfo::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08PrivateKeyInfoImpl != null, "Not yet constructed. Reconstructor the object.");
+       std::unique_ptr< ByteBuffer > pEncodedData(__pPkcs08PrivateKeyInfoImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncodedData != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncodedData.release();
+}
+
+} } }
diff --git a/src/security/pkcs/FSecPkcsRc2CbcParameters.cpp b/src/security/pkcs/FSecPkcsRc2CbcParameters.cpp
new file mode 100644 (file)
index 0000000..ef74078
--- /dev/null
@@ -0,0 +1,158 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsRc2CbcParameters.cpp
+ * @brief              This is the implementation file for Rc2CbcParameters class.
+ *
+ * This header file contains the implementation of Rc2CbcParameters class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseErrors.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseInteger.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsRc2CbcParameters.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+
+#include "FSecPkcs_Rc2CbcParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+Rc2CbcParameters::Rc2CbcParameters(void)
+       : __pRc2CbcParametersImpl(null)
+{
+       __pRc2CbcParametersImpl = new (std::nothrow) _Rc2CbcParametersImpl();
+       SysTryReturnVoidResult(NID_SEC_CERT, __pRc2CbcParametersImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory in insufficient.");
+}
+
+Rc2CbcParameters::~Rc2CbcParameters(void)
+{
+       delete __pRc2CbcParametersImpl;
+}
+
+result
+Rc2CbcParameters::Construct(const Tizen::Base::ByteBuffer& initialVector, int version)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       r = __pRc2CbcParametersImpl->Construct(initialVector, version);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return r;
+}
+
+IAlgorithmParameters*
+Rc2CbcParameters::CloneN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       SysAssertf(__pRc2CbcParametersImpl->GetInitialVector().GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       std::unique_ptr< Rc2CbcParameters > pObj(new (std::nothrow) Rc2CbcParameters());
+       SysTryReturn(NID_SEC_CRYPTO, pObj, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pObj->Construct(__pRc2CbcParametersImpl->GetInitialVector(), __pRc2CbcParametersImpl->GetVersion());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return pObj.release();
+
+}
+const ByteBuffer&
+Rc2CbcParameters::GetInitialVector(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pRc2CbcParametersImpl->GetInitialVector();
+}
+
+
+
+PkcsAlgorithmParameterType
+Rc2CbcParameters::GetType(void) const
+{
+       //Return the Parameter type
+       ClearLastResult();
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       return __pRc2CbcParametersImpl->GetType();
+}
+
+int
+Rc2CbcParameters::GetVersion(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pRc2CbcParametersImpl->GetVersion();
+}
+
+bool
+Rc2CbcParameters::Equals(const Object& obj) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       const Rc2CbcParameters* pOther = dynamic_cast< const Rc2CbcParameters* >(&obj);
+       if (pOther == null)
+       {
+               return false;
+       }
+
+       return __pRc2CbcParametersImpl->Equals(*pOther->__pRc2CbcParametersImpl);
+}
+
+int
+Rc2CbcParameters::GetHashCode(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+       return __pRc2CbcParametersImpl->GetHashCode();
+}
+
+ByteBuffer*
+Rc2CbcParameters::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pRc2CbcParametersImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       std::unique_ptr< ByteBuffer > pEncRc2CbcParam(__pRc2CbcParametersImpl->GetEncodedDataN());
+       SysTryReturn(NID_SEC_CRYPTO, pEncRc2CbcParam != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(r));
+
+       return pEncRc2CbcParam.release();
+
+}
+} } }
diff --git a/src/security/pkcs/FSecPkcs_AlgorithmIdentifierImpl.cpp b/src/security/pkcs/FSecPkcs_AlgorithmIdentifierImpl.cpp
new file mode 100644 (file)
index 0000000..07627d5
--- /dev/null
@@ -0,0 +1,422 @@
+///
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_AlgorithmIdentifierImpl.cpp
+ * @brief              This is the implementation file for _AlgorithmIdentifierImpl class.
+ *
+ * This header file contains the implementation of _AlgorithmIdentifierImpl class.
+ *
+ */
+
+#include <new>
+#include <openssl/x509.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <openssl/evp.h>
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsInitialVector.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsRc2CbcParameters.h>
+
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_AlgorithmIdentifierImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_AlgorithmIdentifierImpl::_AlgorithmIdentifierImpl(void)
+       : __pAlgoParams(null)
+{
+
+}
+_AlgorithmIdentifierImpl::~_AlgorithmIdentifierImpl(void)
+{
+       delete __pAlgoParams;
+}
+
+result
+_AlgorithmIdentifierImpl::Construct(const Tizen::Base::String& algorithm, const IAlgorithmParameters* pAlgoParams)
+{
+       result r = E_SUCCESS;
+       _OidType oidValue;
+       bool isParamSupported = false;
+
+       SysAssertf(__algorithm.GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, algorithm.GetLength() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       __algorithm = algorithm;
+       oidValue = _PkcsUtility::ConvertOidToEnum(algorithm);
+
+       r = GetLastResult();
+       SysTryReturnResult(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "The object id of the input algorithm is not supported.");
+
+       delete __pAlgoParams;
+       __pAlgoParams = null;
+
+       if (pAlgoParams != null)
+       {
+               __pAlgoParams = pAlgoParams->CloneN();
+               SysTryReturnResult(NID_SEC_CRYPTO, __pAlgoParams != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+       }
+
+       if (__pAlgoParams == null)
+       {
+               isParamSupported = _PkcsUtility::IsParameterSupported(algorithm);
+               SysTryReturnResult(NID_SEC_CRYPTO, !isParamSupported, E_INVALID_ARG, "The specified input parameter is invalid.");
+       }
+
+       return r;
+}
+
+result
+_AlgorithmIdentifierImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+       const byte* pBuffer = null;
+       int bufferLen = 0;
+       int algoNid = 0;
+       X509_ALGOR* pAlgoObj = null;
+       Tizen::Base::String algoOid = null;
+
+       SysAssertf(__algorithm.GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pAlgoObj = d2i_X509_ALGOR(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryReturnResult(NID_SEC_CRYPTO, pAlgoObj != null, E_SYSTEM, "The method cannot proceed due to a severe system error.");
+
+       algoNid = OBJ_obj2nid(pAlgoObj->algorithm);
+       algoOid = _PkcsUtility::ConvertToOid(algoNid);
+
+       r = GetLastResult();
+       SysTryCatch(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The object id of the algorithm identifier is not supported.");
+
+       __algorithm = algoOid;
+
+       delete __pAlgoParams;
+       __pAlgoParams = null;
+
+       __pAlgoParams = _PkcsUtility::GernerateParametersFromOidN(__algorithm, pAlgoObj);
+       SysTryCatch(NID_SEC_CRYPTO, __pAlgoParams != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+CATCH:
+
+       X509_ALGOR_free(pAlgoObj);
+       return r;
+}
+
+String
+_AlgorithmIdentifierImpl::GetAlgorithmObjectId(void) const
+{
+       ClearLastResult();
+       return __algorithm;
+}
+
+IAlgorithmParameters*
+_AlgorithmIdentifierImpl::GetParametersN(void) const
+{
+       //Return the Algorithm Parameter
+       ClearLastResult();
+
+       if (__pAlgoParams != null)
+       {
+               return __pAlgoParams->CloneN();
+       }
+       return null;
+}
+
+ByteBuffer*
+_AlgorithmIdentifierImpl::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+       byte* pOut = null;
+       X509_ALGOR* pAlgoObj = null;
+       std::unique_ptr< ByteBuffer > pEncAlgoIdParam;
+       int value = 0;
+
+
+       ClearLastResult();
+
+       SysAssertf(__algorithm.GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       pAlgoObj = _PkcsUtility::GenerateAlgorithmIdentifierStructureN(__algorithm, __pAlgoParams);
+       SysTryReturn(NID_SEC_CRYPTO, pAlgoObj != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       value = i2d_X509_ALGOR(pAlgoObj, &pOut);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncAlgoIdParam = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncAlgoIdParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncAlgoIdParam->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncAlgoIdParam->SetArray(pOut, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncAlgoIdParam->Flip();
+
+CATCH:
+
+       X509_ALGOR_free(pAlgoObj);
+       SetLastResult(r);
+       return pEncAlgoIdParam.release();
+
+}
+
+bool
+_AlgorithmIdentifierImpl::Equals(const Object& obj) const
+{
+       Tizen::Base::String algorithm;
+
+       const _AlgorithmIdentifierImpl* pOther = dynamic_cast< const _AlgorithmIdentifierImpl* >(&obj);
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       if (pOther == this)
+       {
+               return true;
+       }
+
+       algorithm = pOther->GetAlgorithmObjectId();
+
+       if (algorithm == __algorithm)
+       {
+
+               switch (_PkcsUtility::ConvertOidToEnum(algorithm))
+               {
+               case _OID_TYPE_DES_CBC:
+               // fall through
+               case _OID_TYPE_DES_CBC_EDE3:
+               // fall through
+               case _OID_TYPE_AES_128_CBC:
+               // fall through
+               case _OID_TYPE_AES_192_CBC:
+               // fall through
+               case _OID_TYPE_AES_256_CBC:
+               {
+                       std::unique_ptr< InitialVector > pIvObj(dynamic_cast< InitialVector* >(pOther->GetParametersN()));
+                       SysTryReturn(NID_SEC_CRYPTO, pIvObj, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       SysTryReturn(NID_SEC_CRYPTO, __pAlgoParams != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       if (pIvObj->Equals(*(dynamic_cast< InitialVector* >(__pAlgoParams))))
+                       {
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+               break;
+
+               case _OID_TYPE_RC2_CBC:
+               {
+                       std::unique_ptr< Rc2CbcParameters > pRcObj(dynamic_cast< Rc2CbcParameters* >(pOther->GetParametersN()));
+                       SysTryReturn(NID_SEC_CRYPTO, pRcObj, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       SysTryReturn(NID_SEC_CRYPTO, __pAlgoParams != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       if (pRcObj->Equals(*(dynamic_cast< Rc2CbcParameters* >(__pAlgoParams))))
+                       {
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+
+               }
+               break;
+
+               case _OID_TYPE_HMAC_SHA1:
+               // fall through
+               case _OID_TYPE_HMAC_SHA2_224:
+               // fall through
+               case _OID_TYPE_HMAC_SHA2_256:
+               // fall through
+               case _OID_TYPE_HMAC_SHA2_384:
+               // fall through
+               case _OID_TYPE_HMAC_SHA2_512:
+               // fall through
+               case _OID_TYPE_RSA_ENCRYPTION:
+               {
+                       return true;
+               }
+               break;
+
+               case _OID_TYPE_PBES2:
+               {
+                       std::unique_ptr< Pkcs05PbEs2Parameters > pEncObj(dynamic_cast< Pkcs05PbEs2Parameters* >(pOther->GetParametersN()));
+                       SysTryReturn(NID_SEC_CRYPTO, pEncObj, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       SysTryReturn(NID_SEC_CRYPTO, __pAlgoParams != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       if (pEncObj->GetKeyDerivationAlgorithm().Equals(((dynamic_cast< Pkcs05PbEs2Parameters* >(__pAlgoParams))->GetKeyDerivationAlgorithm())))
+                       {
+                               if (pEncObj->GetEncryptionScheme().Equals(((dynamic_cast< Pkcs05PbEs2Parameters* >(__pAlgoParams))->GetEncryptionScheme())))
+                               {
+                                       return true;
+
+                               }
+                               else
+                               {
+                                       return false;
+                               }
+
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+               break;
+
+               case _OID_TYPE_PBKDF2:
+               {
+                       std::unique_ptr< Pkcs05PbKdf2Parameters > pKdf2Obj(dynamic_cast< Pkcs05PbKdf2Parameters* >(pOther->GetParametersN()));
+                       SysTryReturn(NID_SEC_CRYPTO, pKdf2Obj, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       SysTryReturn(NID_SEC_CRYPTO, __pAlgoParams != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       if (pKdf2Obj->Equals(*((dynamic_cast< Pkcs05PbKdf2Parameters* >(__pAlgoParams)))))
+                       {
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+               break;
+
+               default:
+                       SetLastResult(E_INVALID_ARG);
+                       return false;
+
+               }
+
+       }
+
+       return false;
+}
+
+int
+_AlgorithmIdentifierImpl::GetHashCode(void) const
+{
+       InitialVector* pIvObj = null;
+       Rc2CbcParameters* pRcObj = null;
+       Pkcs05PbEs2Parameters* pEncObj = null;
+       Pkcs05PbKdf2Parameters* pKdf2Obj = null;
+       int hashCode = 0;
+
+       switch (_PkcsUtility::ConvertOidToEnum(__algorithm))
+       {
+       case _OID_TYPE_DES_CBC:
+       // fall through
+       case _OID_TYPE_DES_CBC_EDE3:
+       // fall through
+       case _OID_TYPE_AES_128_CBC:
+       // fall through
+       case _OID_TYPE_AES_192_CBC:
+       // fall through
+       case _OID_TYPE_AES_256_CBC:
+       {
+               pIvObj = dynamic_cast< InitialVector* >(__pAlgoParams);
+               hashCode = __algorithm.GetHashCode() + pIvObj->GetHashCode();
+
+               return hashCode;
+       }
+
+       case _OID_TYPE_RC2_CBC:
+       {
+               pRcObj = dynamic_cast< Rc2CbcParameters* >(__pAlgoParams);
+               hashCode = __algorithm.GetHashCode() + pRcObj->GetHashCode();
+
+               return hashCode;
+       }
+
+       case _OID_TYPE_HMAC_SHA1:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_224:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_256:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_384:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_512:
+       // fall through
+       case _OID_TYPE_RSA_ENCRYPTION:
+       {
+               return __algorithm.GetHashCode();
+       }
+
+       case _OID_TYPE_PBES2:
+       {
+               pEncObj = dynamic_cast< Pkcs05PbEs2Parameters* >(__pAlgoParams);
+
+               hashCode = pEncObj->GetKeyDerivationAlgorithm().GetHashCode() + pEncObj->GetEncryptionScheme().GetHashCode();
+
+               return hashCode;
+       }
+
+       case _OID_TYPE_PBKDF2:
+       {
+               pKdf2Obj = dynamic_cast< Pkcs05PbKdf2Parameters* >(__pAlgoParams);
+
+               hashCode = __algorithm.GetHashCode() + pKdf2Obj->GetHashCode();
+               return hashCode;
+
+       }
+
+       default:
+               return 0;
+
+       }
+
+       return 0;
+
+}
+
+_AlgorithmIdentifierImpl*
+_AlgorithmIdentifierImpl::GetInstance(AlgorithmIdentifier& algorithmIdentifier)
+{
+       return algorithmIdentifier.__pAlgorithmIdentifierImpl;
+}
+
+const _AlgorithmIdentifierImpl*
+_AlgorithmIdentifierImpl::GetInstance(const AlgorithmIdentifier& algorithmIdentifier)
+{
+       return algorithmIdentifier.__pAlgorithmIdentifierImpl;
+}
+
+} }}
diff --git a/src/security/pkcs/FSecPkcs_AlgorithmIdentifierImpl.h b/src/security/pkcs/FSecPkcs_AlgorithmIdentifierImpl.h
new file mode 100644 (file)
index 0000000..5fb41de
--- /dev/null
@@ -0,0 +1,188 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_AlgorithmIdentifierImpl.h
+ * @brief              This is the header file for the %_AlgorithmIdentifierImpl class.
+ *
+ * This header file contains the declarations of the %_AlgorithmIdentifierImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_ALGORITHM_IDENTIFIER_H_
+#define _FSEC_PKCS_INTERNAL_ALGORITHM_IDENTIFIER_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _AlgorithmIdentifierImpl
+ * @brief              This class implements the ASN.1 specified AlgorithmIdentifier, which is used for
+ *                             creating the standard AlgorithmIdentifier object.
+ *              AlgorithmIdentifier structure consist the OID value of the Algorithm
+ *              and the parameters of that algorithm.
+ *
+ *              It is defined in ASN.1 as
+ *
+ *              AlgorithmIdentifier { ALGORITHM-IDENTIFIER:InfoObjectSet }
+ *              ::=
+ *              SEQUENCE {
+ *              algorithm ALGORITHM-IDENTIFIER.&id({InfoObjectSet}),
+ *              parameters ALGORITHM-IDENTIFIER.&Type({InfoObjectSet}
+ *              {@algorithm}) OPTIONAL }
+ *              ALGORITHM-IDENTIFIER ::= TYPE-IDENTIFIER
+ * @since              2.1
+ *
+ */
+
+class _AlgorithmIdentifierImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       _AlgorithmIdentifierImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~_AlgorithmIdentifierImpl(void);
+
+public:
+       /**
+        * Initializes the %_AlgorithmIdentifierImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   objectId                                                This parameter specifies object Identifier of particular algorithm. Object IDs
+        *                                                                                                                              are defined by standard bodies for algorithms and other crypto objects.Object ID of AlgorithmIdentifier can be described in string format like 1.2.3.4
+        * @param[in]   pParams                                                 This parameter specifies a pointer to AlgorithmParameters object. This is an
+        *                                                                                                                              optional parameter and contains a list of user supplied input parameters for the specified algorithm.
+        *                                                                                                                              For example, for Symmetric algorithms Initial vector (IV) is required as input.
+        *                                                                                                                              The default value of this parameter is NULL.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_UNSUPPORTED_ALGORITHM         The object id of the input algorithm is not supported.
+        */
+       result Construct(const Tizen::Base::String& objectId, const IAlgorithmParameters* pParams = null);
+
+       /**
+        * Initializes this instance of %_AlgorithmIdentifierImpl with the DER encoded Bytebuffer that conatins @n
+        * the ASN.1 specified AlgorithmIdentifier structure.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     An instance of DER encoded ByteBuffer
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Checks whether the specified instance of %_AlgorithmIdentifierImpl equals the current instance.
+        *
+        * @since                       2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *            else @c false
+        * @param[in]   rhs                                                                     An instance of %_AlgorithmIdentifierImpl
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %_AlgorithmIdentifierImpl.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %_AlgorithmIdentifierImpl
+        */
+       int GetHashCode(void) const;
+
+       /**
+        * Gets the parameters of algorithm.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to IAlgorithmParameters, containing the parameter list of algorithm, @n
+        *                                              else @c null if an no parameters exist.
+        */
+       IAlgorithmParameters* GetParametersN(void) const;
+
+       /**
+        * Gets the object Id value of an algorithm in string format.
+        *
+        * @since                       2.1
+        *
+        * @return              Object ID of AlgorithmIdentifier in string format like 1.2.3.4.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::String GetAlgorithmObjectId(void) const;
+
+       /**
+        * Gets the encoded form of the AlgorithmIdentifier. @n
+        * It is assumed that each AlgorithmIdentifier type will have only a single form of encoding that is DER encoding.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to the DER encoded ByteBuffer, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       static _AlgorithmIdentifierImpl* GetInstance(AlgorithmIdentifier& algorithmIdentifier);
+       static const _AlgorithmIdentifierImpl* GetInstance(const AlgorithmIdentifier& algorithmIdentifier);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _AlgorithmIdentifierImpl(const _AlgorithmIdentifierImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       _AlgorithmIdentifierImpl& operator =(const _AlgorithmIdentifierImpl& rhs);
+
+private:
+       Tizen::Base::String __algorithm;
+       IAlgorithmParameters* __pAlgoParams;
+       friend class AlgorithmIdentifier;
+};   // _AlgorithmIdentifierImpl
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_INTERNAL_ALGORITHM_IDENTIFIER_H_
diff --git a/src/security/pkcs/FSecPkcs_InitialVectorImpl.cpp b/src/security/pkcs/FSecPkcs_InitialVectorImpl.cpp
new file mode 100644 (file)
index 0000000..80a23e0
--- /dev/null
@@ -0,0 +1,177 @@
+///
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_InitialVectorImpl.cpp
+ * @brief              This is the implementation file for _InitialVectorImpl class.
+ *
+ * This header file contains the implementation of _InitialVectorImpl class.
+ *
+ */
+
+#include <new>
+#include <openssl/x509.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <openssl/evp.h>
+#include <unique_ptr.h>
+#include <FBaseErrors.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include "FSecPkcs_InitialVectorImpl.h"
+
+using namespace Tizen::Base;
+
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_InitialVectorImpl::_InitialVectorImpl(void)
+{
+
+}
+
+_InitialVectorImpl::~_InitialVectorImpl(void)
+{
+
+}
+
+result
+_InitialVectorImpl::Construct(const Tizen::Base::ByteBuffer& initialVector)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__initialVector.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, initialVector.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       r = __initialVector.Construct(initialVector);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       return r;
+
+}
+
+PkcsAlgorithmParameterType
+_InitialVectorImpl::GetType(void) const
+{
+       ClearLastResult();
+       return PKCS_ALGO_PARAM_TYPE_IV;
+}
+
+const ByteBuffer&
+_InitialVectorImpl::GetInitialVector(void) const
+{
+
+       ClearLastResult();
+
+       SysAssertf(__initialVector.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __initialVector;
+
+}
+
+bool
+_InitialVectorImpl::Equals(const Object& obj) const
+{
+       result r = E_SUCCESS;
+       ByteBuffer initialVector;
+       const _InitialVectorImpl* pOther = dynamic_cast< const _InitialVectorImpl* >(&obj);
+       bool value = false;
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       if (pOther == this)
+       {
+               return true;
+       }
+
+       r = initialVector.Construct(pOther->GetInitialVector());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       value = (initialVector == __initialVector);
+
+       return value;
+}
+
+int
+_InitialVectorImpl::GetHashCode(void) const
+{
+       return __initialVector.GetHashCode();
+}
+
+ByteBuffer*
+_InitialVectorImpl::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+       ASN1_OCTET_STRING* pInitialVectorStr = null;
+       std::unique_ptr< ByteBuffer > pEncInitialVector;
+       byte* pTemp = {0, };
+       int value = 0;
+
+       ClearLastResult();
+
+       SysAssertf(__initialVector.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       pInitialVectorStr = M_ASN1_OCTET_STRING_new();
+       SysTryReturn(NID_SEC_CRYPTO, pInitialVectorStr != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pInitialVectorStr->data = static_cast< unsigned char* >(OPENSSL_malloc(__initialVector.GetRemaining()));
+       SysTryCatch(NID_SEC_CRYPTO, pInitialVectorStr->data != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pInitialVectorStr->length = __initialVector.GetRemaining();
+
+       memcpy(pInitialVectorStr->data, __initialVector.GetPointer(), __initialVector.GetRemaining());
+
+       value = i2d_ASN1_OCTET_STRING(pInitialVectorStr, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       SysTryCatch(NID_SEC_CRYPTO, pTemp != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncInitialVector = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncInitialVector, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncInitialVector->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncInitialVector->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncInitialVector->Flip();
+
+CATCH:
+
+       ASN1_OCTET_STRING_free(pInitialVectorStr);
+       OPENSSL_free(pTemp);
+       SetLastResult(r);
+       return pEncInitialVector.release();
+
+}
+
+_InitialVectorImpl*
+_InitialVectorImpl::GetInstance(InitialVector& initialVector)
+{
+       return initialVector.__pInitialVectorImpl;
+}
+
+const _InitialVectorImpl*
+_InitialVectorImpl::GetInstance(const InitialVector& initialVector)
+{
+       return initialVector.__pInitialVectorImpl;
+}
+
+} } }
diff --git a/src/security/pkcs/FSecPkcs_InitialVectorImpl.h b/src/security/pkcs/FSecPkcs_InitialVectorImpl.h
new file mode 100644 (file)
index 0000000..46da946
--- /dev/null
@@ -0,0 +1,161 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_InitialVectorImpl.h
+ * @brief              This is the header file for the %_InitialVectorImpl class.
+ *
+ * This header file contains the declarations of the %_InitialVectorImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_INITIAL_VECTOR_H_
+#define _FSEC_PKCS_INTERNAL_INITIAL_VECTOR_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsInitialVector.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _InitialVectorImpl
+ * @brief              This class implements the functionalities specified by the _InitialVectorImpl class.
+ *                                     This class represents the Initial Vector parameter for symmetric ciphers like DES, AES, DES_EDE.
+ *                                     This InitialVector Parameters will be used by both Pkcs05 and Pkcs08 related classes at the time of encryption.
+ * @since              2.1
+ *
+ *
+ */
+
+class _InitialVectorImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       _InitialVectorImpl(void);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since                2.1
+       */
+
+       virtual ~_InitialVectorImpl(void);
+
+       /**
+        * Initializes this instance of %_InitialVectorImpl with the specified input buffer.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        *
+        * @param[in]   initialVector           An instance of ByteBuffer, holding the initial vector data.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& initialVector);
+
+       /**
+        * Get the pkcs algorithm parameter type enum value for Initial Vector.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType              Enum value  containing the PKCS_ALGO_PARAM_TYPE_IV value for Initial vector parameter.
+        *
+        */
+       PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %_InitialVectorImpl equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                     An instance of %_InitialVectorImpl
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %_InitialVectorImpl.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %_InitialVectorImpl
+        */
+       int GetHashCode(void) const;
+
+       /**
+        * Get the instance of byte buffer that contains the Initial vector value.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to the ByteBuffer class that contains the output.
+        */
+       const Tizen::Base::ByteBuffer& GetInitialVector(void) const;
+
+       /**
+        * Gets the encoded form of the InitialVector. @n
+        * It is assumed that each InitialVector type will have only a single form of encoding that is DER encoding.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to the DER encoded ByteBuffer, @n
+        *                                                      else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       static _InitialVectorImpl* GetInstance(InitialVector& initialVector);
+       static const _InitialVectorImpl* GetInstance(const InitialVector& initialVector);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _InitialVectorImpl(const _InitialVectorImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       _InitialVectorImpl& operator =(const _InitialVectorImpl& rhs);
+
+private:
+       Tizen::Base::ByteBuffer __initialVector;
+       friend class InitialVector;
+
+}; // _InitialVectorImpl
+
+} } } //Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_INTERNAL_INITIAL_VECTOR_H_
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05PbEs2ParametersImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs05PbEs2ParametersImpl.cpp
new file mode 100644 (file)
index 0000000..a551d46
--- /dev/null
@@ -0,0 +1,285 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs05PbEs2ParametersImpl.cpp
+ * @brief              This is the implementation file for _Pkcs05PbEs2ParametersImpl class.
+ *
+ * This header file contains the implementation of _Pkcs05PbEs2ParametersImpl class.
+ *
+ */
+
+#include <openssl/evp.h>
+#include <openssl/crypto.h>
+#include <openssl/x509.h>
+#include <openssl/hmac.h>
+#include <openssl/bn.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <new>
+#include <FSecPkcsRc2CbcParameters.h>
+#include <FSecPkcsInitialVector.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_Pkcs05PbEs2ParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_Pkcs05PbEs2ParametersImpl::_Pkcs05PbEs2ParametersImpl(void)
+{
+
+}
+
+
+
+_Pkcs05PbEs2ParametersImpl::~_Pkcs05PbEs2ParametersImpl(void)
+{
+       //do nothing
+}
+
+result
+_Pkcs05PbEs2ParametersImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+       ASN1_TYPE* pParam = null;
+       PBE2PARAM* pPbes2 = null;
+       int nidEncAlgo = 0;
+       int bufferLen = 0;
+       Tizen::Base::String encOid = null;
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKdf2Parameters;
+       std::unique_ptr< IAlgorithmParameters > pEncParam;
+       const byte* pBuffer = null;
+
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysAssertf(__encryptionScheme.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pPbes2 = d2i_PBE2PARAM(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryReturnResult(NID_SEC_CRYPTO, pPbes2 != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       SysTryCatch(NID_SEC_CRYPTO, OBJ_obj2nid(pPbes2->keyfunc->algorithm) == NID_id_pbkdf2, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pKdf2Parameters = std::unique_ptr< Pkcs05PbKdf2Parameters >(dynamic_cast< Pkcs05PbKdf2Parameters* >(_PkcsUtility::GernerateParametersFromOidN(OID_PBKDF2, pPbes2->keyfunc)));
+       SysTryCatch(NID_SEC_CRYPTO, pKdf2Parameters, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __keyDerivationFunction.Construct(OID_PBKDF2, pKdf2Parameters.get());
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pParam = pPbes2->encryption->parameter;
+       SysTryCatch(NID_SEC_CRYPTO, pParam != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       nidEncAlgo = OBJ_obj2nid(pPbes2->encryption->algorithm);
+       encOid = _PkcsUtility::ConvertToOid(nidEncAlgo);
+
+       r = GetLastResult();
+       SysTryCatch(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+       pEncParam = std::unique_ptr< IAlgorithmParameters >(_PkcsUtility::GernerateParametersFromOidN(encOid, pPbes2->encryption));
+       SysTryCatch(NID_SEC_CRYPTO, pEncParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __encryptionScheme.Construct(encOid, pEncParam.get());
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), , r, "[%s] Failed to construct algorithm identifier.", GetErrorMessage(r));
+
+CATCH:
+
+       PBE2PARAM_free(pPbes2);
+       return r;
+
+}
+
+result
+_Pkcs05PbEs2ParametersImpl::Construct(const AlgorithmIdentifier& keyDerivationFunction, const AlgorithmIdentifier& encryptionScheme)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+       SysAssertf(__encryptionScheme.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       r = __keyDerivationFunction.Construct(keyDerivationFunction.GetAlgorithmObjectId(), keyDerivationFunction.GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier.", GetErrorMessage(r));
+
+       r = __encryptionScheme.Construct(encryptionScheme.GetAlgorithmObjectId(), encryptionScheme.GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier.", GetErrorMessage(r));
+
+       return r;
+
+}
+
+ByteBuffer*
+_Pkcs05PbEs2ParametersImpl::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+       PBE2PARAM* pPbes2 = null;
+       std::unique_ptr< ByteBuffer > pEncPbeParam;
+       std::unique_ptr< Tizen::Base::ByteBuffer > pSaltBuf;
+       Tizen::Base::String prfOid = null;
+       byte* pTemp = {0, };
+       int value = 0;
+       int prfNid = 0;
+
+       ClearLastResult();
+
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__encryptionScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       Tizen::Base::String objectId = __encryptionScheme.GetAlgorithmObjectId();
+
+       IAlgorithmParameters* pParams = __encryptionScheme.GetParametersN();
+       SysTryReturn(NID_SEC_CRYPTO, pParams != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       Pkcs05PbKdf2Parameters* pKeyParams = dynamic_cast< Pkcs05PbKdf2Parameters* >(__keyDerivationFunction.GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, pKeyParams != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pPbes2 = PBE2PARAM_new();
+       SysTryCatch(NID_SEC_CRYPTO, pPbes2 != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       // set up the keyfunc
+
+       pSaltBuf = std::unique_ptr< Tizen::Base::ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pSaltBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pSaltBuf->Construct(pKeyParams->GetSaltValue());
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       prfOid = (pKeyParams->GetPrf()).GetAlgorithmObjectId();
+       prfNid = _PkcsUtility::ConvertToNid(prfOid);
+
+       pPbes2->keyfunc = _PkcsUtility::GenerateKdfParametersN(pKeyParams->GetIterationCount(), const_cast< unsigned char* >(pSaltBuf->GetPointer()), pSaltBuf->GetRemaining(), prfNid, pKeyParams->GetDerivedKeyLength());
+       SysTryCatch(NID_SEC_CRYPTO, pPbes2->keyfunc != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       // set up the pPbes2->encryption
+       pPbes2->encryption = X509_ALGOR_new();
+       SysTryCatch(NID_SEC_CRYPTO, pPbes2->encryption != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pPbes2->encryption = _PkcsUtility::GenerateAlgorithmIdentifierStructureN(objectId, pParams);
+       SysTryCatch(NID_SEC_CRYPTO, pPbes2->encryption != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       // encode the PBE2PARAM structure
+
+       value = i2d_PBE2PARAM(pPbes2, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncPbeParam = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncPbeParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncPbeParam->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncPbeParam->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncPbeParam->Flip();
+
+CATCH:
+
+       if (IsFailed(r))
+       {
+               PBE2PARAM_free(pPbes2);
+       }
+
+       OPENSSL_free(pTemp);
+       SetLastResult(r);
+       return pEncPbeParam.release();
+
+}
+
+const AlgorithmIdentifier&
+_Pkcs05PbEs2ParametersImpl::GetKeyDerivationAlgorithm(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__encryptionScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __keyDerivationFunction;
+}
+
+const AlgorithmIdentifier&
+_Pkcs05PbEs2ParametersImpl::GetEncryptionScheme(void) const
+{
+       ClearLastResult();
+       return __encryptionScheme;
+}
+
+PkcsAlgorithmParameterType
+_Pkcs05PbEs2ParametersImpl::GetType(void) const
+{
+       ClearLastResult();
+       return PKCS_ALGO_PARAM_TYPE_PKCS05_PBES02;
+}
+
+bool
+_Pkcs05PbEs2ParametersImpl::Equals(const Object& obj) const
+{
+       bool value = false;
+
+       const _Pkcs05PbEs2ParametersImpl* pOther = dynamic_cast< const _Pkcs05PbEs2ParametersImpl* >(&obj);
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       if (pOther == this)
+       {
+               return true;
+       }
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther->GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       SysTryReturn(NID_SEC_CRYPTO, pOther->GetEncryptionScheme().GetAlgorithmObjectId().GetLength() > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       value = (__keyDerivationFunction.Equals(pOther->GetKeyDerivationAlgorithm())) && (__encryptionScheme.Equals(pOther->GetEncryptionScheme()));
+
+       return value;
+
+}
+
+int
+_Pkcs05PbEs2ParametersImpl::GetHashCode(void) const
+{
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__encryptionScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __keyDerivationFunction.GetHashCode() + __encryptionScheme.GetHashCode();
+}
+
+_Pkcs05PbEs2ParametersImpl*
+_Pkcs05PbEs2ParametersImpl::GetInstance(Pkcs05PbEs2Parameters& pkcs05PbEs2Parameters)
+{
+       return pkcs05PbEs2Parameters.__pPkcs05PbEs2ParametersImpl;
+}
+
+const _Pkcs05PbEs2ParametersImpl*
+_Pkcs05PbEs2ParametersImpl::GetInstance(const Pkcs05PbEs2Parameters& pkcs05PbEs2Parameters)
+{
+       return pkcs05PbEs2Parameters.__pPkcs05PbEs2ParametersImpl;
+}
+
+} } } // end of namespace Pkcs
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05PbEs2ParametersImpl.h b/src/security/pkcs/FSecPkcs_Pkcs05PbEs2ParametersImpl.h
new file mode 100644 (file)
index 0000000..459465b
--- /dev/null
@@ -0,0 +1,195 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs05PbEs2Parameters.h
+ * @brief              This is the header file for the %_Pkcs05PbEs2Parameters class.
+ *
+ * This header file contains the declarations of the %_Pkcs05PbEs2Parameters class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_05_PBES2_PARAMETERS_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_05_PBES2_PARAMETERS_H_
+
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Pkcs05PbEs2ParametersImpl
+ * @brief              This class implements the functionalities specified by the Pkcs05 encryption scheme 2.
+ *                                     PBES2 combines a password-based key derivation function, which shall be PBKDF2
+ *                                     for PKCS #5 version 2.1, with an underlying encryption scheme
+ *                                     The key length and any other parameters for the underlying encryption scheme depend on the scheme.
+ *
+ *              It is defined in ASN.1 as:
+ *
+ *              PBES2-params ::= SEQUENCE {
+ *              keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
+ *              encryptionScheme AlgorithmIdentifier {{PBES2-Encs}} }
+ * @since              2.1
+ *
+ */
+
+class _Pkcs05PbEs2ParametersImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       _Pkcs05PbEs2ParametersImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~_Pkcs05PbEs2ParametersImpl(void);
+
+       /**
+        * Initializes this instance of %_Pkcs05PbEs2ParametersImpl with the encoded Bytebuffer which contain Password based encryption @n
+        * parameters structure(PBES2) in ASN.1 DER format.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer contains Pkcs05PbEs2Parameters.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %_Pkcs05PbEs2ParametersImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   keyDerivationFunc               An instance of AlgorithmIdentifier, holding key derivation function.
+        * @param[in]   encryptionScheme                An instance of AlgorithmIdentifier, holding encryption scheme.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& keyDerivationFunction, const AlgorithmIdentifier& encryptionScheme);
+
+       /**
+        * Gets the encoded form of the _Pkcs05PbEs2ParametersImpl.
+        * It is assumed that each _Pkcs05PbEs2ParametersImpl will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       /**
+        * Get the reference to the AlgorithmIdentifier instance  which identifies the underlying key derivation function.
+        * It shall be an algorithm ID with an OID in the set PBES2-KDFs, which for this version of PKCS #5 shall consist of id-PBKDF2.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying key derivation function.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
+
+       /**
+        * Get the reference to the AlgorithmIdentifier instance  which identifies the underlying encryption algorithm.
+        * It shall be an OID in the set PBES2-Encs, whose definition is left to the application.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying encryption algorithm.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetEncryptionScheme(void) const;
+
+       /**
+        *
+        * Get the PkcsAlgorithmParameterType value.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType holding enum value PKCS_ALGO_PARAM_TYPE_PKCS05_PBES02 for PBES2 Parameters.
+        *
+        */
+       PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %_Pkcs05PbEs2ParametersImpl equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                                     An instance of %Pkcs05PbEs2Parameters
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %Pkcs05PbEs2Parameters.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbEs2Parameters
+        */
+       int GetHashCode(void) const;
+
+       static _Pkcs05PbEs2ParametersImpl* GetInstance(Pkcs05PbEs2Parameters& pkcs05PbEs2Parameters);
+       static const _Pkcs05PbEs2ParametersImpl* GetInstance(const Pkcs05PbEs2Parameters& pkcs05PbEs2Parameters);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs05PbEs2ParametersImpl(const _Pkcs05PbEs2ParametersImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       _Pkcs05PbEs2ParametersImpl& operator =(const _Pkcs05PbEs2ParametersImpl& rhs);
+
+private:
+       AlgorithmIdentifier __keyDerivationFunction;
+       AlgorithmIdentifier __encryptionScheme;
+       friend class Pkcs05PbEs2Parameters;
+};  //_Pkcs05PbEs2ParametersImpl
+
+} } } // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_INTERNAL_PKCS_05_PBES2_PARAMETERS_H_
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05PbKdf2ParametersImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs05PbKdf2ParametersImpl.cpp
new file mode 100644 (file)
index 0000000..450e09d
--- /dev/null
@@ -0,0 +1,376 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs05PbKdf2ParametersImpl.cpp
+ * @brief              This is the implementation file for _Pkcs05PbKdf2ParametersImpl class.
+ *
+ * This header file contains the implementation of _Pkcs05PbKdf2ParametersImpl class.
+ *
+ */
+
+#include <new>
+#include <openssl/evp.h>
+#include <openssl/crypto.h>
+#include <openssl/x509.h>
+#include <openssl/hmac.h>
+#include <openssl/asn1t.h>
+#include <openssl/asn1.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseInteger.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_Pkcs05PbKdf2ParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_Pkcs05PbKdf2ParametersImpl::_Pkcs05PbKdf2ParametersImpl(void)
+       : __derivedKeyLength(0)
+{
+
+}
+
+
+
+_Pkcs05PbKdf2ParametersImpl::~_Pkcs05PbKdf2ParametersImpl(void)
+{
+       //do nothing
+}
+
+result
+_Pkcs05PbKdf2ParametersImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+       byte* pSalt = null;
+       Tizen::Base::ByteBuffer saltBuffer;
+       Tizen::Base::String prfOid = null;
+       int iter = 0;
+       int derivedKeyLength = 0;
+       int prfNid = 0;
+       int saltLength = 0;
+       int bufferLen = 0;
+       PBKDF2PARAM* pKdf = null;
+
+       SysAssertf(__saltBuffer.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+
+       const byte* pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pKdf = d2i_PBKDF2PARAM(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryCatch(NID_SEC_CRYPTO, pKdf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       SysTryCatch(NID_SEC_CRYPTO, pKdf->salt->type == V_ASN1_OCTET_STRING, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pSalt = pKdf->salt->value.octet_string->data;
+       SysTryCatch(NID_SEC_CRYPTO, pSalt != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       saltLength = pKdf->salt->value.octet_string->length;
+       SysTryCatch(NID_SEC_CRYPTO, saltLength > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       r = saltBuffer.Construct(saltLength);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = saltBuffer.SetArray(pSalt, 0, saltLength);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       saltBuffer.Flip();
+
+       r = __saltBuffer.Construct(saltBuffer);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       iter = ASN1_INTEGER_get(pKdf->iter);
+       SysTryCatch(NID_SEC_CRYPTO, iter > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       __iterationCount = iter;
+
+       derivedKeyLength = ASN1_INTEGER_get(pKdf->keylength);
+
+       __derivedKeyLength = derivedKeyLength;
+
+       if (pKdf->prf)
+       {
+               prfNid = OBJ_obj2nid(pKdf->prf->algorithm);
+               prfOid = _PkcsUtility::ConvertToOid(prfNid);
+
+               r = GetLastResult();
+               SysTryCatch(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+               r = __oidPrf.Construct(prfOid, null);
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       }
+       else
+       {
+               r = __oidPrf.Construct(OID_HMAC_SHA1, null);
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+       }
+
+CATCH:
+
+       PBKDF2PARAM_free(pKdf);
+       return r;
+}
+
+result
+_Pkcs05PbKdf2ParametersImpl::Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, int derivedKeyLength)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__saltBuffer.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, saltBuffer.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+       SysTryReturnResult(NID_SEC_CRYPTO, iterationCount > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+       SysTryReturnResult(NID_SEC_CRYPTO, derivedKeyLength >= 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       r = __saltBuffer.Construct(saltBuffer);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       __iterationCount = iterationCount;
+
+       __derivedKeyLength = derivedKeyLength; // derivedKeyLength is an optional parameter so no need to check its length
+
+       r = __oidPrf.Construct(OID_HMAC_SHA1, null);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.")
+
+       return r;
+}
+
+
+result
+_Pkcs05PbKdf2ParametersImpl::Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, const AlgorithmIdentifier& prf, int derivedKeyLength)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__saltBuffer.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, saltBuffer.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+       SysTryReturnResult(NID_SEC_CRYPTO, derivedKeyLength >= 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       r = __saltBuffer.Construct(saltBuffer);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, iterationCount > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+       __iterationCount = iterationCount;
+
+
+       __derivedKeyLength = derivedKeyLength; // derivedKeyLength is an optional parameter
+
+       r = __oidPrf.Construct(prf.GetAlgorithmObjectId(), null); // prf is a default parameter.
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier", GetErrorMessage(r));
+
+       return r;
+}
+
+ByteBuffer*
+_Pkcs05PbKdf2ParametersImpl::GetEncodedDataN(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       PBKDF2PARAM* pKdf = null;
+       ASN1_OCTET_STRING* pSalt = null;
+       std::unique_ptr< ByteBuffer > pEncKdfParam;
+       int saltLength = 0;
+       int prfNid = 0;
+       int value = 0;
+       int ret = 0;
+       byte* pSaltData = null;
+       byte* pTemp = {0, };
+
+
+       SysAssertf(__saltBuffer.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       saltLength = __saltBuffer.GetRemaining();
+       SysTryReturn(NID_SEC_CRYPTO, saltLength > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pKdf = PBKDF2PARAM_new();
+       SysTryReturn(NID_SEC_CRYPTO, pKdf != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pSalt = M_ASN1_OCTET_STRING_new();
+       SysTryReturn(NID_SEC_CRYPTO, pSalt != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+
+       pKdf->salt->value.octet_string = pSalt;
+       pKdf->salt->type = V_ASN1_OCTET_STRING;
+
+       pSalt->data = static_cast< unsigned char* >(OPENSSL_malloc(saltLength));
+       SysTryCatch(NID_SEC_CRYPTO, pSalt->data != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pSalt->length = saltLength;
+
+       pSaltData = const_cast< byte* >(__saltBuffer.GetPointer());
+       SysTryCatch(NID_SEC_CRYPTO, pSaltData != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       memcpy(pSalt->data, pSaltData, saltLength);
+
+       ASN1_INTEGER_set(pKdf->iter, __iterationCount);
+
+       if (__derivedKeyLength != 0) //optional parameter
+       {
+               pKdf->keylength = M_ASN1_INTEGER_new();
+               SysTryCatch(NID_SEC_CRYPTO, pKdf->keylength != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ASN1_INTEGER_set(pKdf->keylength, __derivedKeyLength);
+       }
+
+       prfNid = _PkcsUtility::ConvertToNid(__oidPrf.GetAlgorithmObjectId());
+
+       if (prfNid != NID_hmacWithSHA1) // default : not required
+       {
+               pKdf->prf = X509_ALGOR_new();
+               SysTryCatch(NID_SEC_CRYPTO, (pKdf->prf != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ret = X509_ALGOR_set0(pKdf->prf, OBJ_nid2obj(prfNid), V_ASN1_NULL, NULL);
+               SysTryCatch(NID_SEC_CRYPTO, ret > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+
+       value = i2d_PBKDF2PARAM(pKdf, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       SysTryCatch(NID_SEC_CRYPTO, pTemp != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncKdfParam = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncKdfParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncKdfParam->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncKdfParam->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncKdfParam->Flip();
+
+CATCH:
+
+       PBKDF2PARAM_free(pKdf);
+       OPENSSL_free(pTemp);
+       SetLastResult(r);
+       return pEncKdfParam.release();
+
+}
+
+const ByteBuffer&
+_Pkcs05PbKdf2ParametersImpl::GetSaltValue(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__saltBuffer.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __saltBuffer;
+}
+
+int
+_Pkcs05PbKdf2ParametersImpl::GetIterationCount(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__saltBuffer.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __iterationCount;
+}
+int
+_Pkcs05PbKdf2ParametersImpl::GetDerivedKeyLength(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__saltBuffer.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __derivedKeyLength;
+}
+
+const AlgorithmIdentifier&
+_Pkcs05PbKdf2ParametersImpl::GetPrf(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__saltBuffer.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __oidPrf;
+}
+
+PkcsAlgorithmParameterType
+_Pkcs05PbKdf2ParametersImpl::GetType(void) const
+{
+       ClearLastResult();
+       return PKCS_ALGO_PARAM_TYPE_PKCS05_KDF02;
+}
+
+
+bool
+_Pkcs05PbKdf2ParametersImpl::Equals(const Object& obj) const
+{
+       bool value = false;
+       const _Pkcs05PbKdf2ParametersImpl* pOther = dynamic_cast< const _Pkcs05PbKdf2ParametersImpl* >(&obj);
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       if (pOther == this)
+       {
+               return true;
+       }
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther->GetSaltValue().GetRemaining() > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther->GetPrf().GetAlgorithmObjectId().GetLength() > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       value = (__saltBuffer == pOther->GetSaltValue()) && (__oidPrf.GetAlgorithmObjectId() == pOther->GetPrf().GetAlgorithmObjectId()) && (__derivedKeyLength == pOther->GetDerivedKeyLength())
+                       && (__iterationCount == pOther->GetIterationCount());
+
+       return value;
+
+}
+
+int
+_Pkcs05PbKdf2ParametersImpl::GetHashCode(void) const
+{
+       SysAssertf(__saltBuffer.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       if (__derivedKeyLength > 0)
+       {
+               return (__saltBuffer.GetHashCode() + __oidPrf.GetAlgorithmObjectId().GetHashCode() + Integer::GetHashCode(__derivedKeyLength) + Integer::GetHashCode(__iterationCount));
+       }
+       else
+       {
+               return (__saltBuffer.GetHashCode() + __oidPrf.GetAlgorithmObjectId().GetHashCode() + Integer::GetHashCode(__iterationCount));
+       }
+}
+
+_Pkcs05PbKdf2ParametersImpl*
+_Pkcs05PbKdf2ParametersImpl::GetInstance(Pkcs05PbKdf2Parameters& pkcs05PbKdf2Parameters)
+{
+       return pkcs05PbKdf2Parameters.__pPkcs05PbKdf2ParametersImpl;
+}
+
+const _Pkcs05PbKdf2ParametersImpl*
+_Pkcs05PbKdf2ParametersImpl::GetInstance(const Pkcs05PbKdf2Parameters& pkcs05PbKdf2Parameters)
+{
+       return pkcs05PbKdf2Parameters.__pPkcs05PbKdf2ParametersImpl;
+}
+
+} } } // end of namespace Pkcs
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05PbKdf2ParametersImpl.h b/src/security/pkcs/FSecPkcs_Pkcs05PbKdf2ParametersImpl.h
new file mode 100644 (file)
index 0000000..16b0b4c
--- /dev/null
@@ -0,0 +1,240 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs05PbKdf2ParametersImpl.h
+ * @brief              This is the header file for the %_Pkcs05PbKdf2ParametersImpl class.
+ *
+ * This header file contains the declarations of the %_Pkcs05PbKdf2ParametersImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_05_PBKDF2_PARAMETERS_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_05_PBKDF2_PARAMETERS_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Pkcs05PbKdf2ParametersImpl
+ * @brief              This class implements the functionalities specified by the Pkcs05 KDF2 scheme. PBKDF2 applies a pseudo random function to derive
+ *                                     keys. The length of the derived key is essentially unbounded. However, the maximum effective search space for the derived key may
+ *                                     be limited by the structure of the underlying pseudorandom function.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             PBKDF2-params ::= SEQUENCE {
+ *                             salt CHOICE {
+ *                             specified OCTET STRING,
+ *                             otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}
+ *                             },
+ *                             iterationCount INTEGER (1..MAX),
+ *                             keyLength INTEGER (1..MAX) OPTIONAL,
+ *                             prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT
+ *                             algid-hmacWithSHA1 }
+ * @since              2.1
+ *
+ */
+
+class _Pkcs05PbKdf2ParametersImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       _Pkcs05PbKdf2ParametersImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~_Pkcs05PbKdf2ParametersImpl(void);
+
+       /**
+        * Initializes this instance of %_Pkcs05PbKdf2ParametersImpl with the encoded Bytebuffer which contain password based @n
+        * key derivation function parameters structure(PBKDF2) in ASN.1 DER format.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     DER encoded ByteBuffer of _Pkcs05PbKdf2ParametersImpl.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %_Pkcs05PbKdf2ParametersImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   saltBuffer                                      An instance of ByteBuffer, holding salt value.
+        * @param[in]   iterationCount                  Integer value holding the positive integer specifying iteration count
+        *                                                                                                                              for generation of password based key.
+        * @param[in]   derivedKeyLength                Positive integer specifying length of password based key to be generated.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remark              In this case when pseudo random function algorithm is not passed then default HMAC-SHA1 will be used.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, int derivedKeyLength = 0);
+
+       /**
+        * Initializes the %_Pkcs05PbKdf2ParametersImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   saltBuffer                                      An instance of ByteBuffer, holding salt value.
+        * @param[in]   iterationCount                  Integer value holding the positive integer specifying iteration count
+        *                                                                                                                              for generation of password based key.
+        * @param[in]   prf                                                                     An instance of AlgorithIdentifier, holding the underlying pseudo-random function to use for
+        *                                                                                                                              generation of password based key.
+        * @param[in]   derivedKeyLength                Positive integer specifying length of password based key to be generated.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& saltBuffer, int iterationCount, const AlgorithmIdentifier& prf, int derivedKeyLength = 0);
+
+       /**
+        * Gets the encoded form of the _Pkcs05PbKdf2ParametersImpl.
+        * It is assumed that each _Pkcs05PbKdf2ParametersImpl  will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       /**
+        * Get the salt byte buffer.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to Salt ByteBuffer Containing the specified salt value.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const Tizen::Base::ByteBuffer& GetSaltValue(void) const;
+
+       /**
+        * Get the iteration count.
+        * The purpose of this count is to increase the cost of producing keys from a password, thereby also increasing the difficulty of attack.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value containing the iteration count for PBKDF2.
+        *
+        */
+       int GetIterationCount(void) const;
+
+       /**
+        * Get the derived key length.
+        * This API will return the length of the derived key that will be used for generating the password based key.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value containing the length of the derived key.
+        *
+        */
+       int GetDerivedKeyLength(void) const;
+
+       /**
+        * Get the reference to the Algorithm Identifier which identifies the underlying pseudo random function.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier Containing the algorithm identifier of underlying pseudo random function.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetPrf(void) const;
+
+       /**
+        * Get the AlgoritmParameters Type value.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType holding enum value PKCS_ALGO_PARAM_TYPE_PKCS05_KDF02 for KDF2 Parameters.
+        */
+       PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %_Pkcs05PbKdf2ParametersImpl equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                                     An instance of %_Pkcs05PbKdf2ParametersImpl
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %Pkcs05PbKdf2Parameters.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbKdf2Parameters
+        */
+       int GetHashCode(void) const;
+
+       static _Pkcs05PbKdf2ParametersImpl* GetInstance(Pkcs05PbKdf2Parameters& pkcs05PbKdf2Parameters);
+       static const _Pkcs05PbKdf2ParametersImpl* GetInstance(const Pkcs05PbKdf2Parameters& pkcs05PbKdf2Parameters);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs05PbKdf2ParametersImpl(const _Pkcs05PbKdf2ParametersImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       _Pkcs05PbKdf2ParametersImpl& operator =(const _Pkcs05PbKdf2ParametersImpl& rhs);
+
+private:
+       Tizen::Base::ByteBuffer __saltBuffer;
+       int __iterationCount;
+       int __derivedKeyLength;
+       int __prfNid;
+       AlgorithmIdentifier __oidPrf;
+       friend class Pkcs05PbKdf2Parameters;
+};    // _Pkcs05PbKdf2ParametersImpl
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_INTERNAL_PKCS_05_PBKDF2_PARAMETERS_H_
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05PbMacParametersImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs05PbMacParametersImpl.cpp
new file mode 100644 (file)
index 0000000..72f04ca
--- /dev/null
@@ -0,0 +1,301 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcsPkcs05PbMacParameters.cpp
+ * @brief              This is the implementation file for Pkcs05PbMacParameters class.
+ *
+ * This header file contains the implementation of Pkcs05PbMacParameters class.
+ *
+ */
+
+#include <new>
+#include <openssl/evp.h>
+#include <openssl/crypto.h>
+#include <openssl/x509.h>
+#include <openssl/hmac.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_Pkcs05PbMacParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+
+_Pkcs05PbMacParametersImpl::_Pkcs05PbMacParametersImpl(void)
+{
+
+}
+
+
+
+_Pkcs05PbMacParametersImpl::~_Pkcs05PbMacParametersImpl(void)
+{
+       //do nothing
+}
+
+result
+_Pkcs05PbMacParametersImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+       const byte* pBuffer = null;
+       const unsigned char* pBuf = null;
+       int bufferLen = 0;
+       int nidMacAlgo = 0;
+       int paramLen = 0;
+       PBE2PARAM* pMacObj = null;
+       std::unique_ptr< ByteBuffer > pKdfParam;
+       Tizen::Base::String macOid = null;
+       ASN1_TYPE* pParam = null;
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKdf2Parameters;
+
+
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+       SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+
+       pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pMacObj = d2i_PBE2PARAM(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryReturnResult(NID_SEC_CRYPTO, pMacObj != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       SysTryCatch(NID_SEC_CRYPTO, OBJ_obj2nid(pMacObj->keyfunc->algorithm) == NID_id_pbkdf2, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pParam = pMacObj->keyfunc->parameter;
+       SysTryReturn(NID_SEC_CRYPTO, !((!pParam) || (pParam->type != V_ASN1_SEQUENCE)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pBuf = pParam->value.sequence->data;
+       SysTryCatch(NID_SEC_CRYPTO, pBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       paramLen = pParam->value.sequence->length;
+       SysTryCatch(NID_SEC_CRYPTO, paramLen > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pKdfParam = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pKdfParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pKdfParam->Construct(paramLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pKdfParam->SetArray(pBuf, 0, paramLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pKdfParam->Flip();
+
+       pKdf2Parameters = std::unique_ptr< Pkcs05PbKdf2Parameters >(new (std::nothrow) Pkcs05PbKdf2Parameters());
+       SysTryCatch(NID_SEC_CRYPTO, pKdf2Parameters, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pKdf2Parameters->Construct(*pKdfParam);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       __keyDerivationFunction.Construct(OID_PBKDF2, pKdf2Parameters.get());
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       nidMacAlgo = OBJ_obj2nid(pMacObj->encryption->algorithm);
+       macOid = _PkcsUtility::ConvertToOid(nidMacAlgo);
+
+       r = GetLastResult();
+       SysTryCatch(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+       __messageAuthScheme.Construct(macOid, null);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       CATCH:
+
+       PBE2PARAM_free(pMacObj);
+       return r;
+}
+
+result
+_Pkcs05PbMacParametersImpl::Construct(const AlgorithmIdentifier& keyDerivationFunction, const AlgorithmIdentifier& messageAuthScheme)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+       SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+
+       r = __keyDerivationFunction.Construct(keyDerivationFunction.GetAlgorithmObjectId(), keyDerivationFunction.GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier.", GetErrorMessage(r));
+
+       r = __messageAuthScheme.Construct(messageAuthScheme.GetAlgorithmObjectId(), messageAuthScheme.GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+ByteBuffer*
+_Pkcs05PbMacParametersImpl::GetEncodedDataN(void) const
+{
+
+       result r = E_SUCCESS;
+       PBE2PARAM* pMacObj = null;
+       byte* pTemp = {0, };
+       int value = 0;
+       int algoNid = 0;
+       int prfNid = 0;
+       int ret = 0;
+       Tizen::Base::String keyOid = null;
+       Tizen::Base::String macAlgo = null;
+       Tizen::Base::String prfOid = null;
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKeyParams;
+       std::unique_ptr< ByteBuffer > pSalt;
+       std::unique_ptr< ByteBuffer > pEncMacParam;
+
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       keyOid = __keyDerivationFunction.GetAlgorithmObjectId();
+
+       macAlgo = __messageAuthScheme.GetAlgorithmObjectId();
+
+       pKeyParams = std::unique_ptr< Pkcs05PbKdf2Parameters >(dynamic_cast< Pkcs05PbKdf2Parameters* >(__keyDerivationFunction.GetParametersN()));
+       SysTryReturn(NID_SEC_CRYPTO, pKeyParams, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pSalt = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pSalt != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       SysTryCatch(NID_SEC_CRYPTO, pKeyParams->GetSaltValue().GetRemaining() > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       r = pSalt->Construct(pKeyParams->GetSaltValue());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pMacObj = PBE2PARAM_new();
+       SysTryReturn(NID_SEC_CRYPTO, pMacObj != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       prfOid = (pKeyParams->GetPrf()).GetAlgorithmObjectId();
+       prfNid = _PkcsUtility::ConvertToNid(prfOid);
+
+       pMacObj->keyfunc = _PkcsUtility::GenerateKdfParametersN(pKeyParams->GetIterationCount(), const_cast< unsigned char* >(pSalt->GetPointer()), pSalt->GetRemaining(), prfNid, pKeyParams->GetDerivedKeyLength());
+       SysTryCatch(NID_SEC_CRYPTO, pMacObj->keyfunc != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       algoNid = _PkcsUtility::ConvertToNid(macAlgo);
+
+       pMacObj->encryption = X509_ALGOR_new();
+       SysTryCatch(NID_SEC_CRYPTO, (pMacObj->encryption != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       ret = X509_ALGOR_set0(pMacObj->encryption, OBJ_nid2obj(algoNid), V_ASN1_NULL, NULL);
+       SysTryCatch(NID_SEC_CRYPTO, ret > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       // encode the PBE2PARAM structure
+
+       value = i2d_PBE2PARAM(pMacObj, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncMacParam = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncMacParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncMacParam->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncMacParam->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncMacParam->Flip();
+
+       CATCH:
+
+       PBE2PARAM_free(pMacObj);
+       OPENSSL_free(pTemp);
+       SetLastResult(r);
+       return pEncMacParam.release();
+
+}
+
+
+
+const AlgorithmIdentifier&
+_Pkcs05PbMacParametersImpl::GetKeyDerivationAlgorithm(void) const
+{
+       ClearLastResult();
+       return __keyDerivationFunction;
+}
+
+const AlgorithmIdentifier&
+_Pkcs05PbMacParametersImpl::GetMacAlgorithm(void) const
+{
+       ClearLastResult();
+       return __messageAuthScheme;
+}
+
+PkcsAlgorithmParameterType
+_Pkcs05PbMacParametersImpl::GetType(void) const
+{
+       ClearLastResult();
+       return PKCS_ALGO_PARAM_TYPE_PKCS05_MAC;
+}
+
+bool
+_Pkcs05PbMacParametersImpl::Equals(const Object& obj) const
+{
+       bool value = false;
+
+       const _Pkcs05PbMacParametersImpl* pOther = dynamic_cast< const _Pkcs05PbMacParametersImpl* >(&obj);
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       if (pOther == this)
+       {
+               return true;
+       }
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther->GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       SysTryReturn(NID_SEC_CRYPTO, pOther->GetMacAlgorithm().GetAlgorithmObjectId().GetLength() > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       value = (__keyDerivationFunction.Equals(pOther->GetKeyDerivationAlgorithm())) && (__messageAuthScheme.Equals(pOther->GetMacAlgorithm()));
+
+       return value;
+
+}
+
+int
+_Pkcs05PbMacParametersImpl::GetHashCode(void) const
+{
+       SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+
+       return __keyDerivationFunction.GetHashCode() + __messageAuthScheme.GetHashCode();
+}
+
+_Pkcs05PbMacParametersImpl*
+_Pkcs05PbMacParametersImpl::GetInstance(Pkcs05PbMacParameters& pkcs05PbMacParameters)
+{
+       return pkcs05PbMacParameters.__pPkcs05PbMacParametersImpl;
+}
+
+const _Pkcs05PbMacParametersImpl*
+_Pkcs05PbMacParametersImpl::GetInstance(const Pkcs05PbMacParameters& pkcs05PbMacParameters)
+{
+       return pkcs05PbMacParameters.__pPkcs05PbMacParametersImpl;
+}
+
+} } } // end of namespace Pkcs
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05PbMacParametersImpl.h b/src/security/pkcs/FSecPkcs_Pkcs05PbMacParametersImpl.h
new file mode 100644 (file)
index 0000000..5b9791d
--- /dev/null
@@ -0,0 +1,194 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs05PbMacParametersImpl.h
+ * @brief              This is the header file for the %_Pkcs05PbMacParametersImpl class.
+ *
+ * This header file contains the declarations of the %_Pkcs05PbMacParametersImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_05_PBMAC_PARAMETERS_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_05_PBMAC_PARAMETERS_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Pkcs05PbMacParametersImpl
+ * @brief              This class implements the functionalities specified by the Pkcs05 MAC scheme.
+ *                                     PBMAC1 combines a password-based key derivation function, which shall be PBKDF2
+ *                                     for this version of PKCS #5, with an underlying message authentication
+ *                                     scheme. The key length and any other parameters for
+ *                                     the underlying message authentication scheme depend on the scheme.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             PBMAC1-params ::= SEQUENCE {
+ *                             keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
+ *                             messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
+ * @since              2.1
+ *
+ */
+
+class _Pkcs05PbMacParametersImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since                       2.1
+        */
+       _Pkcs05PbMacParametersImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since                       2.1
+        */
+       virtual ~_Pkcs05PbMacParametersImpl(void);
+
+       /**
+        * Initializes this instance of %_Pkcs05PbMacParametersImpl with the Bytebuffer which contain Password based message  @n
+        * authentication parameters structure(PBMAC1) in ASN.1 DER format.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer contains _Pkcs05PbMacParametersImpl.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %_Pkcs05PbMacParametersImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   keyDerivationFunc               An instance of AlgorithmIdentifier, holding key derivation function.
+        * @param[in]   messageAuthScheme               An instance of AlgorithmIdentifier, holding message authentication scheme.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& keyDerivationFunc, const AlgorithmIdentifier& messageAuthScheme);
+
+       /**
+        * Gets the encoded form of the _Pkcs05PbMacParametersImpl.
+        * It is assumed that each _Pkcs05PbMacParametersImpl will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       /**
+        * Get the reference to the AlgorithmIdentifier instance  which identifies the underlying key derivation function.
+        * It shall be an algorithm ID with an OID in the set PBES2-KDFs, which for this version of PKCS #5 shall consist of id-PBKDF2.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying key derivation function.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetKeyDerivationAlgorithm(void) const;
+
+       /**
+        * This function implements GetMacAlgorithm API which returns the algorithm identifier which identifies the underlying
+        * MAC algorithm. It shall be an OID like OID_HMAC_SHA1 or OID_HMAC_SHA2_224 etc.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier holding the underlying MAC algorithm.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetMacAlgorithm(void) const;
+
+       /**
+        * Get the AlgoritmParameters Type value.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType holding enum value PKCS_ALGO_PARAM_TYPE_PKCS05_MAC for PBMAC Parameters.
+        */
+       PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %_Pkcs05PbMacParametersImpl equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                             An instance of %_Pkcs05PbMacParametersImpl
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %_Pkcs05PbMacParametersImpl.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %Pkcs05PbMacParameters
+        */
+       int GetHashCode(void) const;
+
+       static _Pkcs05PbMacParametersImpl* GetInstance(Pkcs05PbMacParameters& pkcs05PbMacParameters);
+       static const _Pkcs05PbMacParametersImpl* GetInstance(const Pkcs05PbMacParameters& pkcs05PbMacParameters);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs05PbMacParametersImpl(const _Pkcs05PbMacParametersImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use CloneN() to get an exact copy of the instance. @n
+       // Use Equals() to compare the contents of one instance with the other.
+       //
+       // @since               2.1
+       _Pkcs05PbMacParametersImpl& operator =(const _Pkcs05PbMacParametersImpl& rhs);
+
+private:
+       AlgorithmIdentifier __keyDerivationFunction;
+       AlgorithmIdentifier __messageAuthScheme;
+       friend class Pkcs05PbMacParameters;
+
+};  // _Pkcs05PbMacParametersImpl
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_INTERNAL_PKCS_05_PBMAC_H_
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05SchemesImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs05SchemesImpl.cpp
new file mode 100644 (file)
index 0000000..8719d0f
--- /dev/null
@@ -0,0 +1,463 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs05SchemesImpl.cpp
+ * @brief              This is the implementation file for _Pkcs05SchemesImpl class.
+ *
+ * This header file contains the implementation of _Pkcs05SchemesImpl class.
+ *
+ */
+
+#include <new>
+#include <openssl/hmac.h>
+#include <openssl/x509.h>
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs05Schemes.h>
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_Pkcs05SchemesImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_Pkcs05SchemesImpl::_Pkcs05SchemesImpl(void)
+       : __pMacAlgo(EVP_sha1())
+       , __derivedKeyLength(0)
+{
+
+}
+
+_Pkcs05SchemesImpl::~_Pkcs05SchemesImpl(void)
+{
+       //do nothing
+}
+
+result
+_Pkcs05SchemesImpl::Construct(const Tizen::Base::ByteBuffer& password, int derivedKeyLength)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__password.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, password.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+       SysTryReturnResult(NID_SEC_CRYPTO, derivedKeyLength > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       __derivedKeyLength = derivedKeyLength;
+
+       r = __password.Construct(password);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       return r;
+}
+
+
+ByteBuffer*
+_Pkcs05SchemesImpl::GenerateKeyKdf2N(const Pkcs05PbKdf2Parameters& params)
+{
+
+       result r = E_SUCCESS;
+       std::unique_ptr< ByteBuffer > pOut;
+       std::unique_ptr< ByteBuffer > pSaltBuffer;
+       unsigned char out[1024] = {0, };
+       const char* pPassword = null;
+       int iterationCount = 0;
+       int saltLen = 0;
+       int derivedKeyLength = 0;
+       int passwordLen = 0;
+       int ret = 0;
+       _OidType oidValue = _OID_TYPE_UNKNOWN;
+
+       ClearLastResult();
+
+       SysAssertf(__password.GetPointer() != null, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__password.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       pPassword = reinterpret_cast< const char* >(__password.GetPointer());
+       passwordLen = __password.GetRemaining();
+
+       SysTryReturn(NID_SEC_CRYPTO, params.GetPrf().GetAlgorithmObjectId().GetLength() > 0, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       saltLen = params.GetSaltValue().GetRemaining();
+       SysTryReturn(NID_SEC_CRYPTO, saltLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       iterationCount = params.GetIterationCount();
+       SysTryReturn(NID_SEC_CRYPTO, iterationCount > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       derivedKeyLength = params.GetDerivedKeyLength();
+
+       if (derivedKeyLength <= 0)
+       {
+               derivedKeyLength = __derivedKeyLength;
+       }
+       oidValue = _PkcsUtility::ConvertOidToEnum(params.GetPrf().GetAlgorithmObjectId());
+
+       switch (oidValue)
+       {
+       case _OID_TYPE_HMAC_SHA1:
+               __pMacAlgo = EVP_sha1();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_224:
+               __pMacAlgo = EVP_sha224();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_256:
+               __pMacAlgo = EVP_sha256();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_384:
+               __pMacAlgo = EVP_sha384();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_512:
+               __pMacAlgo = EVP_sha512();
+               break;
+
+       default:
+               r = E_UNSUPPORTED_ALGORITHM;
+               SetLastResult(r);
+               return null;
+       }
+
+       ret = PKCS5_PBKDF2_HMAC(pPassword, passwordLen, params.GetSaltValue().GetPointer(), saltLen, iterationCount, __pMacAlgo, derivedKeyLength, out);
+       SysTryReturn(NID_SEC_CRYPTO, ret == 1, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pOut = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_SEC_CRYPTO, pOut, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOut->Construct(derivedKeyLength);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOut->SetArray(out, 0, derivedKeyLength);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pOut->Flip();
+
+       return pOut.release();
+
+}
+
+ByteBuffer*
+_Pkcs05SchemesImpl::EncryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message)
+{
+
+       result r = E_SUCCESS;
+       std::unique_ptr< ByteBuffer > pDKey;
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKeyDerivationFuncParam;
+       std::unique_ptr< ByteBuffer > pOutBuffer;
+       Tizen::Base::String keyOid = null;
+       Tizen::Base::String tempOid = null;
+       int modeValue = 1;
+
+       ClearLastResult();
+
+       SysTryReturn(NID_SEC_CRYPTO, params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       SysTryReturn(NID_SEC_CRYPTO, params.GetEncryptionScheme().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       tempOid = params.GetEncryptionScheme().GetAlgorithmObjectId();
+
+       pKeyDerivationFuncParam = std::unique_ptr< Pkcs05PbKdf2Parameters >(dynamic_cast< Pkcs05PbKdf2Parameters* >(params.GetKeyDerivationAlgorithm().GetParametersN()));
+       SysTryReturn(NID_SEC_CRYPTO, pKeyDerivationFuncParam, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       keyOid = params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId();
+       SysTryReturn(NID_SEC_CRYPTO, keyOid == OID_PBKDF2, null, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+       pDKey = std::unique_ptr< ByteBuffer >(GenerateKeyKdf2N(*pKeyDerivationFuncParam));
+       r = GetLastResult();
+       SysTryReturn(NID_SEC_CRYPTO, pDKey != null, null, r, "[%s] Failed to generate key.", GetErrorMessage(r));
+
+       pOutBuffer = std::unique_ptr< ByteBuffer >(_PkcsUtility::EncryptDecryptN(params.GetEncryptionScheme(), *pDKey, message, modeValue));
+       r = GetLastResult();
+       SysTryReturn(NID_SEC_CRYPTO, pOutBuffer != null, null, r, "[%s] Failed to encrypt message.", GetErrorMessage(r));
+
+       return pOutBuffer.release();
+}
+
+ByteBuffer*
+_Pkcs05SchemesImpl::DecryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message)
+{
+       result r = E_SUCCESS;
+       std::unique_ptr< ByteBuffer > pDKey;
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKeyDerivationFuncParam;
+       std::unique_ptr< ByteBuffer > pOutBuffer;
+       Tizen::Base::String keyOid = null;
+       Tizen::Base::String tempOid = null;
+       int modeValue = 0;
+
+       ClearLastResult();
+
+       SysTryReturn(NID_SEC_CRYPTO, params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       SysTryReturn(NID_SEC_CRYPTO, params.GetEncryptionScheme().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       tempOid = params.GetEncryptionScheme().GetAlgorithmObjectId();
+
+       pKeyDerivationFuncParam = std::unique_ptr< Pkcs05PbKdf2Parameters >(dynamic_cast< Pkcs05PbKdf2Parameters* >(params.GetKeyDerivationAlgorithm().GetParametersN()));
+       SysTryReturn(NID_SEC_CRYPTO, pKeyDerivationFuncParam, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       keyOid = params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId();
+       SysTryReturn(NID_SEC_CRYPTO, keyOid == OID_PBKDF2, null, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+       pDKey = std::unique_ptr< ByteBuffer >(GenerateKeyKdf2N(*pKeyDerivationFuncParam));
+       r = GetLastResult();
+       SysTryReturn(NID_SEC_CRYPTO, pDKey != null, null, r, "[%s] Failed to generate key.", GetErrorMessage(r));
+
+       pOutBuffer = std::unique_ptr< ByteBuffer >(_PkcsUtility::EncryptDecryptN(params.GetEncryptionScheme(), *pDKey, message, modeValue));
+       r = GetLastResult();
+       SysTryReturn(NID_SEC_CRYPTO, pOutBuffer != null, null, r, "[%s] Failed to encrypt message.", GetErrorMessage(r));
+
+       return pOutBuffer.release();
+}
+
+ByteBuffer*
+_Pkcs05SchemesImpl::GetPbHMacN(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message)
+{
+
+       result r = E_SUCCESS;
+       std::unique_ptr< ByteBuffer > pDKey;
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKeyDerivationFuncParam;
+       std::unique_ptr< byte > pMd;
+       std::unique_ptr< ByteBuffer > pOutput;
+       Tizen::Base::String keyOid = null;
+       Tizen::Base::String messageAuthScheme = null;
+       unsigned int mdLen = 0;
+       int dataLen = 0;
+       int keyLen = 0;
+       byte* pData = null;
+       byte* pKey = null;
+       _OidType oidValue = _OID_TYPE_UNKNOWN;
+
+       ClearLastResult();
+
+       SysTryReturn(NID_SEC_CRYPTO, params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       SysTryReturn(NID_SEC_CRYPTO, params.GetMacAlgorithm().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyOid = params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId();
+       SysTryReturn(NID_SEC_CRYPTO, keyOid == OID_PBKDF2, null, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+       pData = const_cast< byte* >(message.GetPointer());
+       SysTryReturn(NID_SEC_CRYPTO, pData != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       dataLen = message.GetRemaining();
+       SysTryReturn(NID_SEC_CRYPTO, dataLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pKeyDerivationFuncParam = std::unique_ptr< Pkcs05PbKdf2Parameters >(dynamic_cast< Pkcs05PbKdf2Parameters* >(params.GetKeyDerivationAlgorithm().GetParametersN()));
+       SysTryReturn(NID_SEC_CRYPTO, pKeyDerivationFuncParam, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pDKey = std::unique_ptr< ByteBuffer >(GenerateKeyKdf2N(*pKeyDerivationFuncParam));
+       SysTryReturn(NID_SEC_CRYPTO, pDKey, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       messageAuthScheme = params.GetMacAlgorithm().GetAlgorithmObjectId();
+
+       oidValue = _PkcsUtility::ConvertOidToEnum(messageAuthScheme);
+       switch (oidValue)
+       {
+       case _OID_TYPE_HMAC_SHA1:
+               __pMacAlgo = EVP_sha1();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_224:
+               __pMacAlgo = EVP_sha224();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_256:
+               __pMacAlgo = EVP_sha256();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_384:
+               __pMacAlgo = EVP_sha384();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_512:
+               __pMacAlgo = EVP_sha512();
+               break;
+
+       default:
+               r = E_UNSUPPORTED_ALGORITHM;
+               SetLastResult(r);
+               return null;
+       }
+
+       mdLen = EVP_MD_size(__pMacAlgo);
+       SysTryReturn(NID_SEC_CRYPTO, mdLen > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pMd = std::unique_ptr< byte >(new (std::nothrow) byte[mdLen]);
+       SysTryReturn(NID_SEC_CRYPTO, pMd, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       memset(pMd.get(), 0, mdLen);
+
+       pKey = const_cast< byte* >(pDKey->GetPointer());
+       SysTryReturn(NID_SEC_CRYPTO, pKey != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyLen = pDKey->GetRemaining();
+       SysTryReturn(NID_SEC_CRYPTO, keyLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+
+       //gets HMAC of the input data for SEC_MAC_SHA224
+       HMAC(__pMacAlgo, pKey, keyLen, pData, dataLen, pMd.get(), &mdLen);
+       SysTryReturn(NID_SEC_CRYPTO, mdLen != 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       //stores the HMAC output in bytebuffer
+       pOutput = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_SEC_CRYPTO, pOutput, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutput->Construct(mdLen);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_MEMORY] The memory is insufficient.");
+
+       r = pOutput->SetArray(pMd.get(), 0, mdLen);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pOutput->Flip();
+
+       return pOutput.release();
+
+}
+
+result
+_Pkcs05SchemesImpl::VerifyPbMac(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message, const Tizen::Base::ByteBuffer& mac)
+{
+       result r = E_SUCCESS;
+       std::unique_ptr< ByteBuffer > pDKey;
+       std::unique_ptr< Pkcs05PbKdf2Parameters > pKeyDerivationFuncParam;
+       std::unique_ptr< byte > pMd;
+       std::unique_ptr< ByteBuffer > pOutput;
+       Tizen::Base::String keyOid = null;
+       Tizen::Base::String messageAuthScheme = null;
+       unsigned int mdLen = 0;
+       int dataLen = 0;
+       int keyLen = 0;
+       byte* pData = null;
+       byte* pKey = null;
+       _OidType oidValue = _OID_TYPE_UNKNOWN;
+
+       ClearLastResult();
+
+       SysTryReturn(NID_SEC_CRYPTO, params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+       SysTryReturn(NID_SEC_CRYPTO, params.GetMacAlgorithm().GetAlgorithmObjectId().GetLength() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyOid = params.GetKeyDerivationAlgorithm().GetAlgorithmObjectId();
+       SysTryReturn(NID_SEC_CRYPTO, keyOid == OID_PBKDF2, null, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+       pData = const_cast< byte* >(message.GetPointer());
+       SysTryReturn(NID_SEC_CRYPTO, pData != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       dataLen = message.GetRemaining();
+       SysTryReturn(NID_SEC_CRYPTO, dataLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pKeyDerivationFuncParam = std::unique_ptr< Pkcs05PbKdf2Parameters >(dynamic_cast< Pkcs05PbKdf2Parameters* >(params.GetKeyDerivationAlgorithm().GetParametersN()));
+       SysTryReturn(NID_SEC_CRYPTO, pKeyDerivationFuncParam, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pDKey = std::unique_ptr< ByteBuffer >(GenerateKeyKdf2N(*pKeyDerivationFuncParam));
+       SysTryReturn(NID_SEC_CRYPTO, pDKey, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       messageAuthScheme = params.GetMacAlgorithm().GetAlgorithmObjectId();
+
+       oidValue = _PkcsUtility::ConvertOidToEnum(messageAuthScheme);
+       switch (oidValue)
+       {
+       case _OID_TYPE_HMAC_SHA1:
+               __pMacAlgo = EVP_sha1();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_224:
+               __pMacAlgo = EVP_sha224();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_256:
+               __pMacAlgo = EVP_sha256();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_384:
+               __pMacAlgo = EVP_sha384();
+               break;
+
+       case _OID_TYPE_HMAC_SHA2_512:
+               __pMacAlgo = EVP_sha512();
+               break;
+
+       default:
+               r = E_UNSUPPORTED_ALGORITHM;
+               SetLastResult(r);
+               return null;
+       }
+
+       mdLen = EVP_MD_size(__pMacAlgo);
+       SysTryReturn(NID_SEC_CRYPTO, mdLen > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pMd = std::unique_ptr< byte >(new (std::nothrow) byte[mdLen]);
+       SysTryReturn(NID_SEC_CRYPTO, pMd, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       memset(pMd.get(), 0, mdLen);
+
+       pKey = const_cast< byte* >(pDKey->GetPointer());
+       SysTryReturn(NID_SEC_CRYPTO, pKey != null, null, E_KEY_NOT_FOUND, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyLen = pDKey->GetRemaining();
+       SysTryReturn(NID_SEC_CRYPTO, keyLen > 0, null, E_KEY_NOT_FOUND, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+
+       //gets HMAC of the input data for SEC_MAC_SHA224
+       HMAC(__pMacAlgo, pKey, keyLen, pData, dataLen, pMd.get(), &mdLen);
+       SysTryReturn(NID_SEC_CRYPTO, mdLen != 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       //stores the HMAC output in bytebuffer
+       pOutput = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_SEC_CRYPTO, pOutput, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutput->Construct(mdLen);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_MEMORY] The memory is insufficient.");
+
+       r = pOutput->SetArray(pMd.get(), 0, mdLen);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pOutput->Flip();
+
+       if (pOutput->GetRemaining() == mac.GetRemaining())
+       {
+               SysTryReturn(NID_SEC_CRYPTO, mac == *pOutput, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+
+       return r;
+
+}
+
+_Pkcs05SchemesImpl*
+_Pkcs05SchemesImpl::GetInstance(Pkcs05Schemes& pkcs05Schemes)
+{
+       return pkcs05Schemes.__pPkcs05SchemesImpl;
+}
+
+const _Pkcs05SchemesImpl*
+_Pkcs05SchemesImpl::GetInstance(const Pkcs05Schemes& pkcs05Schemes)
+{
+       return pkcs05Schemes.__pPkcs05SchemesImpl;
+}
+
+
+} } } // end of namespace Pkcs05
diff --git a/src/security/pkcs/FSecPkcs_Pkcs05SchemesImpl.h b/src/security/pkcs/FSecPkcs_Pkcs05SchemesImpl.h
new file mode 100644 (file)
index 0000000..954e67d
--- /dev/null
@@ -0,0 +1,203 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs05SchemesImpl.h
+ * @brief              This is the header file for the %_Pkcs05SchemesImpl class.
+ *
+ * This header file contains the declarations of the %_Pkcs05SchemesImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_05_SCHEMES_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_05_SCHEMES_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include <FSecPkcsPkcs05Schemes.h>
+
+struct env_md_st;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+  * @class             _Pkcs05SchemesImpl
+  * @brief             This class implements the functionalities specified by the pkcs05 schemes like Key derivation function,
+  *                                            encryption and signature schemes.
+  * @since             2.1
+  *
+  */
+
+class _Pkcs05SchemesImpl
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        */
+       _Pkcs05SchemesImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~_Pkcs05SchemesImpl(void);
+
+       /**
+        * Initializes the %_Pkcs05SchemesImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code.
+        * @param[in]   password                                        An instance of ByteBuffer , holding the password.
+        * @param[in]   derivedKeyLength        A positive integer contains the length of derived key.@n
+        *                                                                                                                      It is a variable length in PbEs2 based on underlying encryption operation.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& password, int derivedKeyLength);
+
+       /**
+        * This API will generate the Password based derived key using PBKDF2 scheme.
+        * The length of the derived key is essentially unbounded. However, the maximum effective search space for
+        * the derived key may be limited by the structure of the underlying pseudo random function.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to ByteBuffer contains the derived key, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   params                                          An instance of PbKdf2Parameters, containing Kdf2 parameter.
+        *                                                                                                                      salt value, iteration count and key length.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GenerateKeyKdf2N(const Pkcs05PbKdf2Parameters& params);
+
+       /**
+        * This API implements EncryptionScheme2N API which combines the GenerateKeyKdf2N function and encrypts the
+        * message M under a password P to produce a ciphertext C, by applying selected key derivation function KDF
+        * (which is GenerateKeyKdf2N) and selected underlying encryption scheme (which can be any block chiper).
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer contains the encrypted message, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   params                                          An instance of PbEs2Parameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                         An instance of ByteBuffer, holding the plain text to encrypt.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* EncryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message);
+
+       /**
+        * This API implements DecryptionScheme2N API which combines the GenerateKeyKdf2N function and decrypts the ciphertext C,
+        * under a password P to recover message M , by applying selected key derivation function KDF(which is GenerateKeyKdf2N)
+        * and selected underlying decryption algorithm (which can be any block cipher).
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer contains the plain text message.
+        * @param[in]   params                                          An instance of PbEs2Parameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                         An instance of ByteBuffer, holding the cipher text to decrypt.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* DecryptionScheme2N(const Pkcs05PbEs2Parameters& params, const Tizen::Base::ByteBuffer& message);
+
+       /**
+        * This API implements GetPbHMacN API process a message M under a password P to generate a message authentication code T,
+        * by applying selected key derivation function KDF(which is GenerateKeyKdf2N) and selected underlying message authentication scheme
+        * (which can be any HMAC algorithm). GenerateMacN combines a password-based key derivation function, which shall be
+        * GenerateKeyKdf2N for this version of PKCS #5, with an underlying message authentication scheme
+        * The key length and any other parameters for the underlying message authentication scheme
+        * depend on the scheme.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer containing the HMAC generated from message, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   params                                          An instance of bMacParameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                      function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                         An instance of ByteBuffer, holding the message for which MAC needs to be generated.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetPbHMacN(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message);
+
+       /**
+        * This API implements VerifyMac API which processes a message M under a password P to verify a message authentication code T,
+        * by applying a selected key derivation function KDF2 and a selected underlying message authentication scheme combines a
+        * password-based key derivation function, which shall be GenerateKeyKdf2N for this version of PKCS #5, with an underlying
+        * message authentication scheme (which can be any SHA-1 or any SHA-2 algorithm). The key length and any other parameters
+        * for the underlying message authentication scheme depend on the scheme.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   params                                                  An instance of PbMacParameters, parameter structure holding AlgorithmIdentifier for key derivation
+        *                                                                                                                              function and AlgorithmIdentifier for underlying encryption scheme.
+        * @param[in]   message                                                 An instance of ByteBuffer, holding the message M.
+        * @param[in]   mac                                                                     An instance of ByteBuffer, holding the HMAC mac that needs to be verified against message.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       result VerifyPbMac(const Pkcs05PbMacParameters& params, const Tizen::Base::ByteBuffer& message, const Tizen::Base::ByteBuffer& mac);
+
+       static _Pkcs05SchemesImpl* GetInstance(Pkcs05Schemes& pkcs05Schemes);
+       static const _Pkcs05SchemesImpl* GetInstance(const Pkcs05Schemes& pkcs05Schemes);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs05SchemesImpl(const _Pkcs05SchemesImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       _Pkcs05SchemesImpl& operator =(const _Pkcs05SchemesImpl& rhs);
+
+private:
+       Tizen::Base::ByteBuffer __password;
+       const env_md_st* __pMacAlgo;
+       int __derivedKeyLength;
+       friend class Pkcs05Schemes;
+
+}; //_Pkcs05SchemesImpl
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_INTERNAL_PKCS_05_SCHEMES_H_
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp
new file mode 100644 (file)
index 0000000..804da3c
--- /dev/null
@@ -0,0 +1,269 @@
+///
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08AttributeValueImpl.cpp
+ * @brief              This is the implementation file for _Pkcs08AttributeValueImpl class.
+ *
+ * This header file contains the implementation of _Pkcs08AttributeValueImpl class.
+ *
+ */
+
+#include <new>
+#include <openssl/x509.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <openssl/evp.h>
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsPkcs08Attribute.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_Pkcs08AttributeImpl.h"
+
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_Pkcs08AttributeImpl::_Pkcs08AttributeImpl(void)
+{
+       //do nothing
+}
+
+_Pkcs08AttributeImpl::~_Pkcs08AttributeImpl(void)
+{
+       //do nothing
+}
+
+result
+_Pkcs08AttributeImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+       int bufferLen = 0;
+       int value = 0;
+       int attrNid = 0;
+       byte* pTemp = {0, };
+       const byte* pBuffer = null;
+       ByteBuffer asn1TypeBuffer;
+       Tizen::Base::String attrOid = null;
+       X509_ATTRIBUTE* pAttribute = null;
+       ASN1_OBJECT* pObject = null;
+       ASN1_TYPE* pAsnType = null;
+       Pkcs08AttributeValue* pNewObj = null;
+
+       SysAssertf(__attributeType.GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pAttribute = d2i_X509_ATTRIBUTE(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryReturnResult(NID_SEC_CRYPTO, pAttribute != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pObject = pAttribute->object;
+       SysTryCatch(NID_SEC_CRYPTO, pObject != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       attrNid = OBJ_obj2nid(pObject);
+       attrOid = _PkcsUtility::ConvertToOid(attrNid);
+
+       r = GetLastResult();
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), , r, "[%s] Failed to get the object id of an attribute.", GetErrorMessage(r));
+
+       __attributeType = attrOid;
+
+       for (int i = 0; i < X509_ATTRIBUTE_count(pAttribute); i++)
+       {
+
+               pAsnType = sk_ASN1_TYPE_value(pAttribute->value.set, i);
+               SysTryCatch(NID_SEC_CRYPTO, pAsnType != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pNewObj = new (std::nothrow) Pkcs08AttributeValue();
+               SysTryCatch(NID_SEC_CRYPTO, pNewObj != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               value = i2d_ASN1_TYPE(pAsnType, &pTemp);
+               SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               r = asn1TypeBuffer.Construct(value);
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = asn1TypeBuffer.SetArray(pTemp, 0, value);
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               asn1TypeBuffer.Flip();
+
+               r = pNewObj->Construct(asn1TypeBuffer);
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = AddAttributeValue(*pNewObj);
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), , r, "[%s] Failed to add attribute", GetErrorMessage(r));
+
+       }
+
+CATCH:
+
+       X509_ATTRIBUTE_free(pAttribute);
+       return r;
+}
+
+result
+_Pkcs08AttributeImpl::Construct(const Tizen::Base::String& attrType)
+{
+       //Variables local to function
+
+       SysAssertf(__attributeType.GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       //Initialize the Attribute instance with Attribute type
+       __attributeType = attrType;
+
+       //Return SUCCESS
+       return E_SUCCESS;
+}
+
+
+result
+_Pkcs08AttributeImpl::AddAttributeValue(const Pkcs08AttributeValue& value)
+{
+       SysAssertf(__attributeType.GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __attributeValues.Add(value);
+}
+
+result
+_Pkcs08AttributeImpl::RemoveAttributeValue(const Pkcs08AttributeValue& value)
+{
+       SysAssertf(__attributeType.GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __attributeValues.Remove(value);
+}
+
+const Tizen::Base::Collection::ArrayList&
+_Pkcs08AttributeImpl::GetAttributeValues(void) const
+{
+       SysAssertf(__attributeType.GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __attributeValues;
+}
+
+ByteBuffer*
+_Pkcs08AttributeImpl::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+       int attrNid = 0;
+       int count = 0;
+       int value = 0;
+       byte* pTemp = {0, };
+       X509_ATTRIBUTE* pAttribute;
+       std::unique_ptr< ByteBuffer > pAttrVal;
+       std::unique_ptr< ByteBuffer > pAttributeBuffer;
+       Pkcs08TagValue tagType;
+       ASN1_TYPE* pAsn1Type = null;
+       ASN1_STRING* pString = null;
+
+       ClearLastResult();
+
+       SysAssertf(__attributeType.GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       pAttribute = X509_ATTRIBUTE_new();
+       SysTryReturn(NID_SEC_CRYPTO, pAttribute != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       attrNid = _PkcsUtility::ConvertToNid(__attributeType);
+
+       value = X509_ATTRIBUTE_set1_object(pAttribute, OBJ_nid2obj(attrNid));
+       SysTryCatch(NID_SEC_CRYPTO, value == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pAttribute->value.set = sk_ASN1_TYPE_new_null();
+       SysTryCatch(NID_SEC_CRYPTO, pAttribute != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pAttribute->single = 0;
+
+       count = __attributeValues.GetCount();
+       SysTryCatch(NID_SEC_CRYPTO, count > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       for (int i = 0; i < count; i++)
+       {
+               Pkcs08AttributeValue* pObj = const_cast< Pkcs08AttributeValue* >(static_cast< const Pkcs08AttributeValue* >(__attributeValues.GetAt(i)));
+               SysTryCatch(NID_SEC_CRYPTO, pObj != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               tagType = pObj->GetTag();
+
+               pAttrVal = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+               SysTryCatch(NID_SEC_CRYPTO, pAttrVal != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               SysTryCatch(NID_SEC_CRYPTO, pObj->GetValue().GetRemaining() > 0, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pAttrVal->Construct(pObj->GetValue());
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pString = ASN1_STRING_type_new(tagType);
+               SysTryCatch(NID_SEC_CRYPTO, pString != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ASN1_STRING_set(pString, pAttrVal->GetPointer(), pAttrVal->GetRemaining());
+
+               pAsn1Type = ASN1_TYPE_new();
+               SysTryCatch(NID_SEC_CRYPTO, pString != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ASN1_TYPE_set(pAsn1Type, tagType, pString);
+
+               value = sk_ASN1_TYPE_push(pAttribute->value.set, pAsn1Type);
+               SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+
+       count = X509_ATTRIBUTE_count(pAttribute);
+
+       value = i2d_X509_ATTRIBUTE(pAttribute, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pAttributeBuffer = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pAttributeBuffer, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pAttributeBuffer->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pAttributeBuffer->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pAttributeBuffer->Flip();
+
+CATCH:
+
+       X509_ATTRIBUTE_free(pAttribute);
+       OPENSSL_free(pTemp);
+
+       return pAttributeBuffer.release();
+
+}
+
+_Pkcs08AttributeImpl*
+_Pkcs08AttributeImpl::GetInstance(Pkcs08Attribute& pkcs08Attribute)
+{
+       return pkcs08Attribute.__pPkcs08AttributeImpl;
+}
+
+const _Pkcs08AttributeImpl*
+_Pkcs08AttributeImpl::GetInstance(const Pkcs08Attribute& pkcs08Attribute)
+{
+       return pkcs08Attribute.__pPkcs08AttributeImpl;
+}
+
+} } }
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.h b/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.h
new file mode 100644 (file)
index 0000000..87ee30a
--- /dev/null
@@ -0,0 +1,171 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08AttributeImpl.h
+ * @brief              This is the header file for the %_Pkcs08AttributeImpl class.
+ *
+ * This header file contains the declarations of the %_Pkcs08AttributeImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_08_ATTRIBUTE_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_08_ATTRIBUTE_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs08Attribute.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Pkcs08AttributeImpl
+ * @brief              This class implements the functionalities specified by the _Pkcs08AttributeImpl class. An Attribute object consists
+ *                                     of an attribute type (specified by an object identifier) and one or more attribute values. It acts as a
+ *                                     container for adding, inserting, removing, encoding X.509 AttributeValue.
+ * @since              2.1
+ *
+ */
+
+class _Pkcs08AttributeImpl
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        */
+       _Pkcs08AttributeImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~_Pkcs08AttributeImpl(void);
+
+       /**
+        * Intializes this instance of %_Pkcs08AttributeImpl with the Bytebuffer which contain X.509 Attribute @n
+        * structure in ASN.1 DER format. @n
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer of X.509 Attribute structure.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Intializes this instance of %_Pkcs08AttributeImpl with specified attribute type.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributeType                   This parameter specifies object Identifier of particular x.509 attribute type. Object IDs @n
+        *                                                                                                                      (e.g. oid for name is 2.5.4.41)are defined by standard bodies for attribute.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::String& attributeType);
+
+       /**
+        * Get the attribute type.
+        * This function implements GetAttributeType API which returns the Attribute type of this attribute instance.
+        *
+        * @since               2.1
+        *
+        * @return              Containing the Object ID of Attribute Type in string format like 2.5.4.41
+        *
+        */
+       Tizen::Base::String GetAttributeType(void) const;
+
+       /**
+        * This function adds attribute value in the attribute value list.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributeValue                  An instance of Pkcs08AttributeValue to add an attribute in the list.
+        */
+       result AddAttributeValue(const Pkcs08AttributeValue& attributeValue);
+
+       /**
+        * This function remove attribute value in the attribute value list.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributeValue                  An instance of Pkcs08AttributeValue to remove an attribute in the list.
+        */
+       result RemoveAttributeValue(const Pkcs08AttributeValue& attributeValue);
+
+       /**
+        * This function returns the array list containing the attribute values of type @_Pkcs08AttributeValueImpl.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to an ArrayList containing the list of Attribute values.
+        */
+       const Tizen::Base::Collection::ArrayList& GetAttributeValues(void) const;
+
+       /**
+        * Gets the encoded form of the _Pkcs08AttributeImpl.
+        * It is assumed that each _Pkcs08AttributeImpl will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs
+        *
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       static _Pkcs08AttributeImpl* GetInstance(Pkcs08Attribute& pkcs08Attribute);
+       static const _Pkcs08AttributeImpl* GetInstance(const Pkcs08Attribute& pkcs08Attribute);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs08AttributeImpl(const _Pkcs08AttributeImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       _Pkcs08AttributeImpl& operator =(const _Pkcs08AttributeImpl& rhs);
+
+private:
+       Tizen::Base::String __attributeType;
+       Tizen::Base::Collection::ArrayList __attributeValues;
+       friend class Pkcs08Attribute;
+
+}; //_Pkcs08AttributeImpl
+
+}}} // Tizen::Security::Pkcs
+
+
+
+#endif /* _FSEC_PKCS_INTERNAL_PKCS_08_ATTRIBUTE_H_ */
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08AttributeValueImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs08AttributeValueImpl.cpp
new file mode 100644 (file)
index 0000000..c7143f2
--- /dev/null
@@ -0,0 +1,221 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08AttributeValueImpl.cpp
+ * @brief              This is the implementation file for _Pkcs08AttributeValueImpl class.
+ *
+ * This header file contains the implementation of _Pkcs08AttributeValueImpl class.
+ *
+ */
+
+#include <new>
+#include <openssl/x509.h>
+#include <openssl/objects.h>
+#include <openssl/asn1t.h>
+#include <openssl/evp.h>
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+#include "FSecPkcs_Pkcs08AttributeValueImpl.h"
+#include "FSecPkcs_PkcsUtility.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_Pkcs08AttributeValueImpl::_Pkcs08AttributeValueImpl(void)
+       : __tag(PKCS08_TAG_RESERVED)
+{
+       //do nothing
+}
+
+_Pkcs08AttributeValueImpl::~_Pkcs08AttributeValueImpl(void)
+{
+       //do nothing
+}
+
+result
+_Pkcs08AttributeValueImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+       int ans1Type = 0;
+       int bufferLen = 0;
+       int dataLen = 0;
+       ASN1_TYPE* pAsn1Type = null;
+       ASN1_STRING* pStr = null;
+       const unsigned char* pData = null;
+       const byte* pBuffer = null;
+
+       SysAssertf(__attributeValue.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pAsn1Type = d2i_ASN1_TYPE(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryReturnResult(NID_SEC_CRYPTO, pAsn1Type != null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       ans1Type = ASN1_TYPE_get(pAsn1Type);
+
+       __tag = _PkcsUtility::ConvertToTagValue(ans1Type);
+       r = GetLastResult();
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), , r, "[%s] Failed to get the tag type of an attribute.", GetErrorMessage(r));
+
+       pStr = reinterpret_cast< ASN1_STRING* >(pAsn1Type->value.ptr);
+       SysTryCatch(NID_SEC_CRYPTO, pStr != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pData = pStr->data;
+       SysTryCatch(NID_SEC_CRYPTO, pData != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       dataLen = pStr->length;
+       SysTryCatch(NID_SEC_CRYPTO, dataLen > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       r = __attributeValue.Construct(dataLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __attributeValue.SetArray(pData, 0, dataLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       __attributeValue.Flip();
+
+CATCH:
+       ASN1_TYPE_free(pAsn1Type);
+       return r;
+}
+
+result
+_Pkcs08AttributeValueImpl::Construct(const Tizen::Base::ByteBuffer& value, const Pkcs08TagValue tag)
+{
+       //Variables local to function
+       result r = E_SUCCESS;
+
+       SysAssertf(__attributeValue.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, value.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       //Construct __AttributeValuePi object using the input parameters
+       __tag = tag;
+
+       r = __attributeValue.Construct(value);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       return E_SUCCESS;
+}
+
+const ByteBuffer&
+_Pkcs08AttributeValueImpl::GetValue(void) const
+{
+       //Variables local to function
+       ByteBuffer attrVal;
+
+       SysAssertf(__attributeValue.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       //Return the Attribute Value
+       return __attributeValue;
+
+}
+
+Pkcs08TagValue
+_Pkcs08AttributeValueImpl::GetTag(void) const
+{
+       //Return the tag Value
+       SysAssertf(__attributeValue.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __tag;
+}
+
+ByteBuffer*
+_Pkcs08AttributeValueImpl::GetEncodedDataN(void) const
+{
+
+       result r = E_SUCCESS;
+       std::unique_ptr< ByteBuffer > pAttributeValue;
+       ASN1_TYPE* pAsn1Type = null;
+       ASN1_OCTET_STRING* pOctetString = null;
+       const byte* pBuffer = null;
+       byte* pTemp = {0, };
+       char* pDataValue = null;
+       int bufferLen = 0;
+       int value = 0;
+
+       ClearLastResult();
+
+       SysAssertf(__attributeValue.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       pBuffer = __attributeValue.GetPointer();
+       SysTryReturn(NID_SEC_CRYPTO, pBuffer != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       bufferLen = __attributeValue.GetRemaining();
+       SysTryReturn(NID_SEC_CRYPTO, bufferLen > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       pDataValue = reinterpret_cast< char* >(const_cast< byte* >(pBuffer));
+
+       pAsn1Type = ASN1_TYPE_new();
+       SysTryReturn(NID_SEC_CRYPTO, pAsn1Type != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pOctetString = ASN1_OCTET_STRING_new();
+       SysTryCatch(NID_SEC_CRYPTO, pOctetString != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       value = ASN1_OCTET_STRING_set(pOctetString, pBuffer, bufferLen);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       ASN1_TYPE_set(pAsn1Type, __tag, pOctetString);
+
+       value = i2d_ASN1_TYPE(pAsn1Type, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pAttributeValue = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pAttributeValue, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pAttributeValue->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pAttributeValue->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pAttributeValue->Flip();
+
+CATCH:
+
+       ASN1_TYPE_free(pAsn1Type);
+       OPENSSL_free(pTemp);
+       SetLastResult(r);
+       return pAttributeValue.release();
+}
+
+_Pkcs08AttributeValueImpl*
+_Pkcs08AttributeValueImpl::GetInstance(Pkcs08AttributeValue& pkcs08AttributeValue)
+{
+       return pkcs08AttributeValue.__pPkcs08AttributeValueImpl;
+}
+
+const _Pkcs08AttributeValueImpl*
+_Pkcs08AttributeValueImpl::GetInstance(const Pkcs08AttributeValue& pkcs08AttributeValue)
+{
+       return pkcs08AttributeValue.__pPkcs08AttributeValueImpl;
+}
+
+} } }
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08AttributeValueImpl.h b/src/security/pkcs/FSecPkcs_Pkcs08AttributeValueImpl.h
new file mode 100644 (file)
index 0000000..1d01bc6
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08AttributeValueImpl.h
+ * @brief              This is the header file for the %_Pkcs08AttributeValueImpl class.
+ *
+ * This header file contains the declarations of the %_Pkcs08AttributeValueImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_08_ATTRIBUTE_VALUE_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_08_ATTRIBUTE_VALUE_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Pkcs08AttributeValueImpl
+ * @brief              This class implements the functionalities specified by the _Pkcs08AttributeValueImpl class.
+ * @brief              _Pkcs08AttributeValueImpl object will consist of the value of an attribute and the tag value.
+ * @since              2.1
+ *
+ */
+class _Pkcs08AttributeValueImpl
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.1
+        */
+       _Pkcs08AttributeValueImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~_Pkcs08AttributeValueImpl(void);
+
+       /**
+        * Intializes this instance of %_Pkcs08AttributeValueImpl with the Bytebuffer which contain  AttributeValue @n
+        * (contain tag i.e. Ans1_Type and the value)
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                             DER encoded Bytebuffer of AttrributeValue.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Intializes this instance of %_Pkcs08AttributeValueImpl with specified parameters.
+        * This API implements the Construct API which initializes the attribute value instance based on passed byte buffer.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   value                                   An instance of ByteBuffer, holding raw value. @n
+        * @param[in]   tag                                             Tag holding the tag type. This tag number is assigned by ASN1 standards for @n
+        *                                                                                                      basic data types.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& value, const Pkcs08TagValue tag);
+
+       /**
+        * Get the reference to the ByteBuffer contains the attribute value.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to ByteBuffer,containing raw value.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const Tizen::Base::ByteBuffer& GetValue(void) const;
+
+       /**
+        * Get the tag value of an attribute.
+        * This tag number is assigned by ASN1 standards for basic data types..
+        *
+        * @since               2.1
+        *
+        * @return              Tag value that is assigned by ASN1 standards for basic data types.
+        */
+       Pkcs08TagValue GetTag(void) const;
+
+       /**
+        * Gets the pointer to the ByteBuffer that contains the attribute value in encoded format.
+        * It is assumed that each Pkcs08Attribute will have only a single form of encoding example ASN.1 DER.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       static _Pkcs08AttributeValueImpl* GetInstance(Pkcs08AttributeValue& pkcs08AttributeValue);
+       static const _Pkcs08AttributeValueImpl* GetInstance(const Pkcs08AttributeValue& pkcs08AttributeValue);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs08AttributeValueImpl(const _Pkcs08AttributeValueImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       _Pkcs08AttributeValueImpl& operator =(const _Pkcs08AttributeValueImpl& rhs);
+
+private:
+       Pkcs08TagValue __tag;
+       Tizen::Base::ByteBuffer __attributeValue;
+       friend class Pkcs08AttributeValue;
+
+}; //_Pkcs08AttributeValueImpl
+
+}}} //Tizen::Security::Pkcs
+
+#endif /* _FSEC_PKCS_INTERNAL_PKCS_08_ATTRIBUTE_VALUE_H_ */
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp
new file mode 100644 (file)
index 0000000..70913a6
--- /dev/null
@@ -0,0 +1,308 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp
+ * @brief              This is the implementation file for _Pkcs08EncryptedPrivateKeyInfoImpl class.
+ *
+ * This header file contains the implementation of _Pkcs08EncryptedPrivateKeyInfoImpl class.
+ *
+ */
+
+
+#include <new>
+#include <openssl/evp.h>
+#include <openssl/bn.h>
+#include <openssl/x509.h>
+#include <openssl/crypto.h>
+#include <openssl/asn1t.h>
+#include <openssl/asn1.h>
+#include <openssl/objects.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsPkcs08PrivateKeyInfo.h>
+#include <FSecPkcsPkcs08EncryptedPrivateKeyInfo.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+//EncryptedPrivateKeyInfo Class Life cycle
+
+//Default Constructor
+_Pkcs08EncryptedPrivateKeyInfoImpl::_Pkcs08EncryptedPrivateKeyInfoImpl(void)
+{
+}
+
+//Default Destructor
+_Pkcs08EncryptedPrivateKeyInfoImpl::~_Pkcs08EncryptedPrivateKeyInfoImpl(void)
+{
+       //do nothing
+}
+
+result
+_Pkcs08EncryptedPrivateKeyInfoImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+
+       X509_SIG* pPkcs8Key = null;
+       Tizen::Base::String prfOid = null;
+       std::unique_ptr< IAlgorithmParameters > pEncParam;
+       Tizen::Base::ByteBuffer encryptedKeyBuffer;
+       const byte* pBuffer = null;
+       byte* pDigestValue = null;
+       int bufferLen = 0;
+       int digestLength = 0;
+       int prf_nid = 0;
+
+       SysAssertf(__encryptedData.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysAssertf(__encryptionAlgorithm.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pPkcs8Key = d2i_X509_SIG(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryReturnResult(NID_SEC_CRYPTO, pPkcs8Key != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       SysTryCatch(NID_SEC_CRYPTO, pPkcs8Key->digest->type == V_ASN1_OCTET_STRING, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       if (pPkcs8Key->algor)
+       {
+               prf_nid = OBJ_obj2nid(pPkcs8Key->algor->algorithm);
+               prfOid = _PkcsUtility::ConvertToOid(prf_nid);
+
+               r = GetLastResult();
+               SysTryCatch(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+               pEncParam = std::unique_ptr< IAlgorithmParameters >(_PkcsUtility::GernerateParametersFromOidN(prfOid, pPkcs8Key->algor));
+               SysTryCatch(NID_SEC_CRYPTO, pEncParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = __encryptionAlgorithm.Construct(prfOid, pEncParam.get());
+               SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       }
+
+       pDigestValue = pPkcs8Key->digest->data;
+       SysTryCatch(NID_SEC_CRYPTO, pDigestValue, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       digestLength = pPkcs8Key->digest->length;
+       SysTryCatch(NID_SEC_CRYPTO, digestLength > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       r = encryptedKeyBuffer.Construct(digestLength);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = encryptedKeyBuffer.SetArray(pDigestValue, 0, digestLength);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       encryptedKeyBuffer.Flip();
+       r = __encryptedData.Construct(encryptedKeyBuffer);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+CATCH:
+
+       X509_SIG_free(pPkcs8Key);
+       return r;
+
+}
+
+// Encrypted Private Key Info Class Operations
+result
+_Pkcs08EncryptedPrivateKeyInfoImpl::Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__encryptedData.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysAssertf(__encryptionAlgorithm.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturn(NID_SEC_CRYPTO, encryptedData.GetRemaining() > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       r = __encryptionAlgorithm.Construct(algorithmId.GetAlgorithmObjectId(), algorithmId.GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier instance for encryption algorithm.", GetErrorMessage(r));
+
+       r = __encryptedData.Construct(encryptedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return r;
+
+}
+
+
+result
+_Pkcs08EncryptedPrivateKeyInfoImpl::Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfoBuffer)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__encryptedData.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysAssertf(__encryptionAlgorithm.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, key.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+       SysTryReturnResult(NID_SEC_CRYPTO, encodedPrivateKeyInfoBuffer.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       r = __encryptionAlgorithm.Construct(algorithmId.GetAlgorithmObjectId(), algorithmId.GetParametersN());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct algorithm identifier instance for encryption algorithm..", GetErrorMessage(r));
+
+       std::unique_ptr< ByteBuffer > pEncData(_PkcsUtility::EncryptDecryptN(algorithmId, key, encodedPrivateKeyInfoBuffer, 1));
+       SysTryReturnResult(NID_SEC_CRYPTO, pEncData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __encryptedData.Construct(*pEncData);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return r;
+}
+
+const AlgorithmIdentifier&
+_Pkcs08EncryptedPrivateKeyInfoImpl::GetAlgorithm(void) const
+{
+       ClearLastResult();
+       return __encryptionAlgorithm;
+}
+
+ByteBuffer*
+_Pkcs08EncryptedPrivateKeyInfoImpl::GetEncryptedDataN(void) const
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__encryptedData.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__encryptionAlgorithm.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       std::unique_ptr< ByteBuffer > pEncryptedData(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_SEC_CRYPTO, pEncryptedData, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncryptedData->Construct(__encryptedData);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return pEncryptedData.release();
+
+}
+
+ByteBuffer*
+_Pkcs08EncryptedPrivateKeyInfoImpl::DecryptN(const Tizen::Base::ByteBuffer& key)
+{
+       std::unique_ptr< ByteBuffer > pDecryptedData;
+
+       ClearLastResult();
+
+       SysAssertf(__encryptedData.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__encryptionAlgorithm.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       SysTryReturn(NID_SEC_CRYPTO, key.GetRemaining() > 0, null, E_INVALID_ARG, "[E_INVALID_ARG]  The specified input parameter is invalid.");
+
+       pDecryptedData = std::unique_ptr< ByteBuffer >(_PkcsUtility::EncryptDecryptN(__encryptionAlgorithm, key, __encryptedData, 0));
+       SysTryReturn(NID_SEC_CRYPTO, pDecryptedData, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return pDecryptedData.release();
+}
+
+ByteBuffer*
+_Pkcs08EncryptedPrivateKeyInfoImpl::GetEncodedDataN(void) const
+{
+
+       result r = E_SUCCESS;
+       X509_SIG* sig = null;
+       ASN1_OCTET_STRING* pDigest = null;
+       std::unique_ptr< ByteBuffer > pEncPrivKey;
+       int digestLength = 0;
+       int prf_nid = 0;
+       int value = 0;
+       byte* pDigestData = null;
+       byte* pTemp = null;
+
+       std::unique_ptr< IAlgorithmParameters > pParam;
+
+       ClearLastResult();
+
+       SysAssertf(__encryptedData.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__encryptionAlgorithm.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       sig = X509_SIG_new();
+       SysTryReturn(NID_SEC_CRYPTO, sig != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pDigest = M_ASN1_OCTET_STRING_new();
+       SysTryReturn(NID_SEC_CRYPTO, pDigest != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       digestLength = __encryptedData.GetRemaining();
+
+       pDigest->data = static_cast< unsigned char* >(OPENSSL_malloc(digestLength));
+       SysTryReturn(NID_SEC_CRYPTO, pDigest->data != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pDigest->length = digestLength;
+
+       pDigestData = const_cast< byte* >(__encryptedData.GetPointer());
+       memcpy(pDigest->data, pDigestData, digestLength);
+
+       sig->digest = pDigest;
+
+       prf_nid = _PkcsUtility::ConvertToNid(__encryptionAlgorithm.GetAlgorithmObjectId());
+
+       sig->algor = X509_ALGOR_new();
+       SysTryReturn(NID_SEC_CRYPTO, sig->algor != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pParam = std::unique_ptr< IAlgorithmParameters >(__encryptionAlgorithm.GetParametersN());
+       SysTryCatch(NID_SEC_CRYPTO, pParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       sig->algor = _PkcsUtility::GenerateAlgorithmIdentifierStructureN(__encryptionAlgorithm.GetAlgorithmObjectId(), pParam.get());
+       SysTryCatch(NID_SEC_CRYPTO, sig->algor != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       value = i2d_X509_SIG(sig, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncPrivKey = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncPrivKey, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncPrivKey->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncPrivKey->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncPrivKey->Flip();
+
+CATCH:
+
+       X509_SIG_free(sig);
+       SetLastResult(r);
+       return pEncPrivKey.release();
+
+}
+
+_Pkcs08EncryptedPrivateKeyInfoImpl*
+_Pkcs08EncryptedPrivateKeyInfoImpl::GetInstance(Pkcs08EncryptedPrivateKeyInfo& pkcs08EncryptedPrivateKeyInfo)
+{
+       return pkcs08EncryptedPrivateKeyInfo.__pPkcs08EncryptedPrivateKeyInfoImpl;
+}
+
+const _Pkcs08EncryptedPrivateKeyInfoImpl*
+_Pkcs08EncryptedPrivateKeyInfoImpl::GetInstance(const Pkcs08EncryptedPrivateKeyInfo& pkcs08EncryptedPrivateKeyInfo)
+{
+       return pkcs08EncryptedPrivateKeyInfo.__pPkcs08EncryptedPrivateKeyInfoImpl;
+}
+
+} } }
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.h b/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.h
new file mode 100644 (file)
index 0000000..01c238b
--- /dev/null
@@ -0,0 +1,187 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.h
+ * @brief              This is the header file for the %_Pkcs08EncryptedPrivateKeyInfoImpl class.
+ *
+ * This header file contains the declarations of the %_Pkcs08EncryptedPrivateKeyInfoImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsPkcs08EncryptedPrivateKeyInfo.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Pkcs08EncryptedPrivateKeyInfoImpl
+ * @brief              This class implements to encrypt a private key.An Encrypted private key structure consist
+ *                                     of an encryption algorithm and the encrypted Pkcs08PrivateKeyInfo.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             EncryptedPrivateKeyInfo ::= SEQUENCE {
+ *                             encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
+ *                             encryptedData EncryptedData
+ *                             }
+ * @since              2.1
+ *
+ */
+
+class _Pkcs08EncryptedPrivateKeyInfoImpl
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       _Pkcs08EncryptedPrivateKeyInfoImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~_Pkcs08EncryptedPrivateKeyInfoImpl(void);
+
+public:
+       /**
+        * Initializes this instance of %_Pkcs08EncryptedPrivateKeyInfoImpl with the encoded Bytebuffer which contain  @n
+        * EncryptedPrivateKeyInfo structure(EncryptedPrivateKeyInfo) in ASN.1 DER format.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     DER encoded Bytebuffer contains Pkcs08 EncryptedPrivateKeyInfo structure.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %_Pkcs08EncryptedPrivateKeyInfoImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   algorithmId                                     An instance of AlgorithmIdentifier.
+        * @param[in]   encryptedData                           Encrypted private key.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& encryptedData);
+
+       /**
+        * Initializes the %_Pkcs08EncryptedPrivateKeyInfoImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   algorithmId                                             An instance of AlgorithmIdentifier which identifies secret key algorithm.
+        * @param[in]   key                                                                             Key for encrypting privateKeyInfo.
+        * @param[in]   encodedPrivateKeyInfo   An instance of encryptedPrivateKeyInfo.
+        * @exception   E_SUCCESS                                                       The method is successful.
+        * @exception   E_INVALID_ARG                                   The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& algorithmId, const Tizen::Base::ByteBuffer& key, const Tizen::Base::ByteBuffer& encodedPrivateKeyInfo);
+
+       /**
+        * Gets the reference to AlgorithmIdentifier which identifies the  encryption algorithm under which private key is encrypted.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier Contains the algorithm identifier of _Pkcs08EncryptedPrivateKeyInfoImpl object.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetAlgorithm(void) const;
+
+       /**
+        * Gets the pointer to the ByteBuffer which contains encrypted private key.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to ByteBuffer class contains the private key of _Pkcs08EncryptedPrivateKeyInfoImpl object, @n
+        *                              else @c null if an error occurs.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncryptedDataN(void) const;
+
+       /**
+        * This API will provide the implementation of DecryptN to decrypt the _Pkcs08EncryptedPrivateKeyInfoImpl Object
+        * using the Key or Password.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to ByteBuffer Contains the decrypted private key of _Pkcs08EncryptedPrivateKeyInfoImpl object, @n
+        *                              else @c null if an error occurs.
+        * @param[in]   key                             An instance of ByteBuffer, holding key to decrypt private key using particular @n
+        *                                                                                      secret key algorithm.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* DecryptN(const Tizen::Base::ByteBuffer& key);
+
+       /**
+        * Gets the ASN.1 DER encoded pkcs08 encrypted private key structure.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the ByteBuffer class that contains the output, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       static _Pkcs08EncryptedPrivateKeyInfoImpl* GetInstance(Pkcs08EncryptedPrivateKeyInfo& pkcs08EncryptedPrivateKeyInfo);
+       static const _Pkcs08EncryptedPrivateKeyInfoImpl* GetInstance(const Pkcs08EncryptedPrivateKeyInfo& pkcs08EncryptedPrivateKeyInfo);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs08EncryptedPrivateKeyInfoImpl(const _Pkcs08EncryptedPrivateKeyInfoImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       _Pkcs08EncryptedPrivateKeyInfoImpl& operator =(const _Pkcs08EncryptedPrivateKeyInfoImpl& rhs);
+
+private:
+       AlgorithmIdentifier __encryptionAlgorithm;
+       Tizen::Base::ByteBuffer __encryptedData;
+       friend class Pkcs08EncryptedPrivateKeyInfo;
+
+
+}; //_Pkcs08EncryptedPrivateKeyInfoImpl
+
+}}} // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_INTERNAL_PKCS_08_ENCRYPTED_PRIVATE_KEY_INFO_H_
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp
new file mode 100644 (file)
index 0000000..9cc484d
--- /dev/null
@@ -0,0 +1,345 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp
+ * @brief              This is the implementation file for _Pkcs08PrivateKeyInfoImpl class.
+ *
+ * This header file contains the implementation of _Pkcs08PrivateKeyInfoImpl class.
+ *
+ */
+
+
+#include <new>
+#include <openssl/evp.h>
+#include <openssl/crypto.h>
+#include <openssl/x509.h>
+#include <openssl/pkcs12.h>
+#include <openssl/objects.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsPkcs08PrivateKeyInfo.h>
+
+#include "FSecPkcs_PkcsUtility.h"
+#include "FSecPkcs_Pkcs08PrivateKeyInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_Pkcs08PrivateKeyInfoImpl::_Pkcs08PrivateKeyInfoImpl(void)
+       : __version(0)
+{
+       //do nothing
+}
+
+//Default Destructor
+_Pkcs08PrivateKeyInfoImpl::~_Pkcs08PrivateKeyInfoImpl(void)
+{
+       //do nothing
+}
+
+
+result
+_Pkcs08PrivateKeyInfoImpl::Construct(const Tizen::Base::ByteBuffer& encodedData)
+{
+       result r = E_SUCCESS;
+       int version = 0;
+       int privateKeyLen = 0;
+       int bufferLen = 0;
+       int keyAlgoNid = 0;
+       int index = 0;
+       int size = 0;
+       int value = 0;
+       Tizen::Base::String prfOid = null;
+       Tizen::Base::ByteBuffer attributeBuffer;
+       const byte* pBuffer = null;
+       byte* pPrivateKey = null;
+       byte* pTemp = {0, };
+       X509_ALGOR* pAlgo = null;
+       Tizen::Base::ByteBuffer privateKeyBuffer;
+       PKCS8_PRIV_KEY_INFO* pPrivKeyInfo = null;
+       STACK_OF(X509_ATTRIBUTE)* pStackOfAttribute = null;
+       X509_ATTRIBUTE* pAttribute = null;
+       Pkcs08Attribute* pAttributeClassObj = null;
+
+       SysAssertf(__privateKey.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+       SysAssertf(__algorithm.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+
+
+       pBuffer = encodedData.GetPointer();
+       SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       bufferLen = encodedData.GetRemaining();
+       SysTryReturnResult(NID_SEC_CRYPTO, bufferLen > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pPrivKeyInfo = d2i_PKCS8_PRIV_KEY_INFO(null, reinterpret_cast< const unsigned char** >(&pBuffer), bufferLen);
+       SysTryReturnResult(NID_SEC_CRYPTO, pPrivKeyInfo != null, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       pPrivateKey = pPrivKeyInfo->pkey->value.octet_string->data;
+       SysTryCatch(NID_SEC_CRYPTO, pPrivateKey != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       privateKeyLen = pPrivKeyInfo->pkey->value.octet_string->length;
+       SysTryCatch(NID_SEC_CRYPTO, privateKeyLen > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       r = privateKeyBuffer.Construct(privateKeyLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = privateKeyBuffer.SetArray(pPrivateKey, 0, privateKeyLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       privateKeyBuffer.Flip();
+       r = __privateKey.Construct(privateKeyBuffer);
+
+       version = ASN1_INTEGER_get(pPrivKeyInfo->version);
+
+       pAlgo = pPrivKeyInfo->pkeyalg;
+       SysTryCatch(NID_SEC_CRYPTO, pPrivKeyInfo != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       keyAlgoNid = OBJ_obj2nid(pAlgo->algorithm);
+       prfOid = _PkcsUtility::ConvertToOid(keyAlgoNid);
+
+       r = GetLastResult();
+       SysTryCatch(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
+
+       r = __algorithm.Construct(prfOid, null);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       if (pPrivKeyInfo->attributes)
+       {
+               pStackOfAttribute = pPrivKeyInfo->attributes;
+               for (index = 0; index < sk_X509_ATTRIBUTE_num(pStackOfAttribute); index++)
+               {
+                       pAttribute = sk_X509_ATTRIBUTE_value(pStackOfAttribute, index);
+
+                       pAttributeClassObj = new (std::nothrow) Pkcs08Attribute();
+                       SysTryCatch(NID_SEC_CRYPTO, pAttributeClassObj != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       value = i2d_X509_ATTRIBUTE(pAttribute, &pTemp);
+                       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       size = strlen(reinterpret_cast< char* >(pTemp));
+                       r = attributeBuffer.Construct(size);
+                       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       r = attributeBuffer.SetArray(pTemp, 0, size);
+                       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       attributeBuffer.Flip();
+
+                       r = pAttributeClassObj->Construct(attributeBuffer);
+                       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       r = AddAttribute(*pAttributeClassObj);
+                       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+               }
+
+       }
+
+CATCH:
+
+       PKCS8_PRIV_KEY_INFO_free(pPrivKeyInfo);
+       return r;
+
+}
+
+result
+_Pkcs08PrivateKeyInfoImpl::Construct(const AlgorithmIdentifier& privAlgoId, const Tizen::Base::ByteBuffer& privKey)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__privateKey.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+       SysAssertf(__algorithm.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+
+
+       SysTryReturnResult(NID_SEC_CRYPTO, privKey.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       r = __privateKey.Construct(privKey);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       r = __algorithm.Construct(privAlgoId.GetAlgorithmObjectId(), null);
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+_Pkcs08PrivateKeyInfoImpl::GetVersion(void) const
+{
+       ClearLastResult();
+       return __version;
+}
+
+const AlgorithmIdentifier&
+_Pkcs08PrivateKeyInfoImpl::GetPrivateKeyAlgorithm(void) const
+{
+       ClearLastResult();
+       return __algorithm;
+}
+
+const ByteBuffer&
+_Pkcs08PrivateKeyInfoImpl::GetPrivateKey(void) const
+{
+       ByteBuffer privateKey;
+
+       ClearLastResult();
+
+       SysAssertf(__privateKey.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__algorithm.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __privateKey;
+}
+
+const Tizen::Base::Collection::ArrayList&
+_Pkcs08PrivateKeyInfoImpl::GetAttributes(void) const
+{
+       return __attributes;
+}
+
+result
+_Pkcs08PrivateKeyInfoImpl::AddAttribute(const Pkcs08Attribute& attribute)
+{
+       return __attributes.Add(attribute);
+}
+
+result
+_Pkcs08PrivateKeyInfoImpl::RemoveAttribute(const Pkcs08Attribute& attribute)
+{
+       return __attributes.Remove(attribute);
+}
+
+ByteBuffer*
+_Pkcs08PrivateKeyInfoImpl::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+       int value = 0;
+       int privLength = 0;
+       int prf_nid = 0;
+       int ret = 0;
+       int count = 0;
+       byte* pTemp = null;
+       const byte* pBuf = null;
+       byte* pPrivateKeyData = null;
+       std::unique_ptr< ByteBuffer > pEncPrivateKeyInfo;
+       std::unique_ptr< ByteBuffer > pAttrEncoded;
+       PKCS8_PRIV_KEY_INFO* pPrivateKeyInfo = null;
+       ASN1_OCTET_STRING* pPrivKey;
+       STACK_OF(X509_ATTRIBUTE)* pAttributes = null;
+       X509_ATTRIBUTE* pAttributeStruct = null;
+
+       SysAssertf(__privateKey.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+       SysAssertf(__algorithm.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       ClearLastResult();
+
+       pPrivateKeyInfo = PKCS8_PRIV_KEY_INFO_new();
+       SysTryReturn(NID_SEC_CRYPTO, pPrivateKeyInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pPrivKey = M_ASN1_OCTET_STRING_new();
+       SysTryReturn(NID_SEC_CRYPTO, pPrivKey != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pPrivateKeyInfo->pkey->value.octet_string = pPrivKey;
+       pPrivateKeyInfo->pkey->type = V_ASN1_OCTET_STRING;
+
+       privLength = __privateKey.GetRemaining();
+       SysTryCatch(NID_SEC_CRYPTO, privLength > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pPrivKey->data = static_cast< unsigned char* >(OPENSSL_malloc(privLength));
+       SysTryCatch(NID_SEC_CRYPTO, pPrivKey->data != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pPrivKey->length = privLength;
+
+       pPrivateKeyData = const_cast< byte* >(__privateKey.GetPointer());
+
+       memcpy(pPrivKey->data, pPrivateKeyData, privLength);
+
+       ASN1_INTEGER_set(pPrivateKeyInfo->version, __version);
+
+       prf_nid = _PkcsUtility::ConvertToNid(__algorithm.GetAlgorithmObjectId());
+
+       pPrivateKeyInfo->pkeyalg = X509_ALGOR_new();
+       SysTryCatch(NID_SEC_CRYPTO, pPrivateKeyInfo->pkeyalg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       ret = X509_ALGOR_set0(pPrivateKeyInfo->pkeyalg, OBJ_nid2obj(prf_nid), V_ASN1_NULL, NULL);
+       SysTryCatch(NID_SEC_CRYPTO, ret > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       count = __attributes.GetCount();
+
+       if (count != 0)
+       {
+               pAttributes = sk_X509_ATTRIBUTE_new_null();
+               SysTryCatch(NID_SEC_CRYPTO, pAttributes != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pPrivateKeyInfo->attributes = pAttributes;
+       }
+
+       for (int i = 0; i < count; i++)
+       {
+               Pkcs08Attribute* pObj = const_cast< Pkcs08Attribute* >(static_cast< const Pkcs08Attribute* >(__attributes.GetAt(i)));
+               if (pObj != null)
+               {
+                       pAttrEncoded = std::unique_ptr< ByteBuffer >(pObj->GetEncodedDataN());
+                       SysTryCatch(NID_SEC_CRYPTO, pAttrEncoded, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       pBuf = pAttrEncoded->GetPointer();
+                       pAttributeStruct = d2i_X509_ATTRIBUTE(null, reinterpret_cast< const unsigned char** >(&pBuf), pAttrEncoded->GetRemaining());
+                       SysTryCatch(NID_SEC_CRYPTO, pAttributeStruct != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+                       value = sk_X509_ATTRIBUTE_push(pAttributes, pAttributeStruct);
+                       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+               }
+       }
+
+       value = i2d_PKCS8_PRIV_KEY_INFO(pPrivateKeyInfo, &pTemp);
+       SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncPrivateKeyInfo = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncPrivateKeyInfo, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncPrivateKeyInfo->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncPrivateKeyInfo->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncPrivateKeyInfo->Flip();
+
+CATCH:
+
+       PKCS8_PRIV_KEY_INFO_free(pPrivateKeyInfo);
+       OPENSSL_free(pTemp);
+       return pEncPrivateKeyInfo.release();
+}
+
+_Pkcs08PrivateKeyInfoImpl*
+_Pkcs08PrivateKeyInfoImpl::GetInstance(Pkcs08PrivateKeyInfo& pkcs08PrivateKeyInfo)
+{
+       return pkcs08PrivateKeyInfo.__pPkcs08PrivateKeyInfoImpl;
+}
+
+const _Pkcs08PrivateKeyInfoImpl*
+_Pkcs08PrivateKeyInfoImpl::GetInstance(const Pkcs08PrivateKeyInfo& pkcs08PrivateKeyInfo)
+{
+       return pkcs08PrivateKeyInfo.__pPkcs08PrivateKeyInfoImpl;
+}
+
+} } }
diff --git a/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.h b/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.h
new file mode 100644 (file)
index 0000000..870ed23
--- /dev/null
@@ -0,0 +1,203 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Pkcs08PrivateKeyInfoImpl.h
+ * @brief              This is the header file for the %_Pkcs08PrivateKeyInfoImpl class.
+ *
+ * This header file contains the declarations of the %_Pkcs08PrivateKeyInfoImpl class.
+ */
+
+
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_08_PRIVATE_KEY_INFO_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_08_PRIVATE_KEY_INFO_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsPkcs08Attribute.h>
+#include <FSecPkcsPkcs08AttributeValue.h>
+#include <FSecPkcsPkcs08PrivateKeyInfo.h>
+
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Pkcs08PrivateKeyInfoImpl
+ * @brief              This class implements the functionalities specified by the Pkcs08 PrivateKeyInfo class.
+ *                             This class represents the structure of Pkcs08 Private Key Info.
+ *
+ *                             It is defined in ASN.1 as:
+ *
+ *                             PrivateKeyInfo ::= SEQUENCE {
+ *                             version Version,
+ *                             privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
+ *                             privateKey PrivateKey,
+ *                             attributes [0] Attributes OPTIONAL }
+ * @since              2.1
+ *
+ */
+
+class _Pkcs08PrivateKeyInfoImpl
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       _Pkcs08PrivateKeyInfoImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~_Pkcs08PrivateKeyInfoImpl(void);
+
+       /**
+        * Initializes this instance of %_Pkcs08PrivateKeyInfoImpl with the encoded byte buffer which contain  @n
+        * pkcs08 private key info structure(PrivateKeyInfo) in ASN.1 DER format. @n
+        * It parses this encoded buffer and extracts the appropiate values of private key, its algorithm id and attributes.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   encodedData                                     The instance of Bytebuffer, containing DER encoded PrivateKeyInfo structure.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& encodedData);
+
+       /**
+        * Initializes the %_Pkcs08PrivateKeyInfoImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code.
+        * @param[in]   keyAlgorithmId                  An instance of AlgorithIdentifier, holding algorithm identifier of private key algorithm.
+        * @param[in]   privateKey                                      An instance of ByteBuffer holding privatekey.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        */
+       result Construct(const AlgorithmIdentifier& keyAlgorithmId, const Tizen::Base::ByteBuffer& privateKey);
+
+       /**
+        * This function will provide the implementation of GetVersion API to get the private key syntax version number of PrivateKeyInfo object @n
+        * that is used for storing private key and its related information and default value of this version is 0.
+        *
+        * @since               2.1
+        *
+        * @return              An integer valuse contains the version.
+        *
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Gets the reference to AlgorithmIdentifier which identifies the secret key algorithm.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to AlgorithmIdentifier Contains the algorithm identifier of Pkcs08PrivateKeyInfo object.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const AlgorithmIdentifier& GetPrivateKeyAlgorithm(void) const;
+
+       /**
+        * This function will provide the implementation of GetPrivateKeyN API to get the reference to ByteBuffer which contains
+        * the private key in binary format.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to ByteBuffer Contains the private key of Pkcs08PrivateKeyInfo object.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const Tizen::Base::ByteBuffer& GetPrivateKey(void) const;
+
+       /**
+        * This API will provide the implementation of GetAttributes API to get the Attributes of type @Pkcs08Attribute which are extended @n
+        * information of private key in context.
+        *
+        * @since               2.1
+        *
+        * @return              Reference to array list, contains the list of attributes of type @Pkcs08Attribute.
+        */
+       const Tizen::Base::Collection::ArrayList& GetAttributes(void) const;
+
+       /**
+        * This function adds Attributes in private key info i.e. extended information of private key in context.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributes                                      An instance of Pkcs08Attribute class.
+        */
+       result AddAttribute(const Pkcs08Attribute& attributes);
+
+       /**
+        * This function remove Attribute in private key info i.e. extended information of private key in context.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   attributes                                      An instance of Pkcs08Attribute class.
+        */
+       result RemoveAttribute(const Pkcs08Attribute& attributes);
+
+       /**
+        * Gets the DER encoded _Pkcs08PrivateKeyInfoImpl structure.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to ByteBuffer Contains the DER encoded private key info.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       static _Pkcs08PrivateKeyInfoImpl* GetInstance(Pkcs08PrivateKeyInfo& pkcs08PrivateKeyInfo);
+       static const _Pkcs08PrivateKeyInfoImpl* GetInstance(const Pkcs08PrivateKeyInfo& pkcs08PrivateKeyInfo);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Pkcs08PrivateKeyInfoImpl(const _Pkcs08PrivateKeyInfoImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       _Pkcs08PrivateKeyInfoImpl& operator =(const _Pkcs08PrivateKeyInfoImpl& rhs);
+
+private:
+       int __version;
+       AlgorithmIdentifier __algorithm;
+       Tizen::Base::ByteBuffer __privateKey;
+       Tizen::Base::Collection::ArrayList __attributes;
+       friend class Pkcs08PrivateKeyInfo;
+
+}; //_Pkcs08PrivateKeyInfoImpl
+
+}}} // Tizen::Security::Pkcs
+
+#endif // _FSEC_PKCS_INTERNAL_PKCS_08_PRIVATE_KEY_INFO_H_
diff --git a/src/security/pkcs/FSecPkcs_PkcsUtility.cpp b/src/security/pkcs/FSecPkcs_PkcsUtility.cpp
new file mode 100644 (file)
index 0000000..7ad3506
--- /dev/null
@@ -0,0 +1,1472 @@
+///
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_PkcsUtility.cpp
+ * @brief              This is the implementation file for _PkcsUtility class.
+ *
+ * This header file contains the implementation of _PkcsUtility class.
+ *
+ */
+
+
+#include <openssl/x509.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <openssl/evp.h>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseErrors.h>
+#include <FSecCryptoRsaCipher.h>
+#include <FSecPrivateKey.h>
+#include <FSecPublicKey.h>
+#include <FSecPkcsPkcs05Schemes.h>
+#include <FSecPkcsInitialVector.h>
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsPkcs05PbKdf2Parameters.h>
+#include <FSecPkcsPkcs05PbEs2Parameters.h>
+#include <FSecPkcsPkcs05PbMacParameters.h>
+#include <FSecPkcsRc2CbcParameters.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+
+#include "FSecPkcs_PkcsUtility.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Security::Crypto;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+static const int _PKCS05_MAX_KEY_SIZE = 32;
+
+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)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+
+}
+
+
+_OidType
+_PkcsUtility::ConvertOidToEnum(Tizen::Base::String algorithm)
+{
+
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       _OidType oidValue = _OID_TYPE_UNKNOWN;
+
+       if (algorithm == OID_PBKDF2)
+       {
+               oidValue = _OID_TYPE_PBKDF2;
+       }
+       else if (algorithm == OID_PBES2)
+       {
+               oidValue = _OID_TYPE_PBES2;
+       }
+       else if (algorithm == OID_PBMAC1)
+       {
+               oidValue = _OID_TYPE_PBMAC1;
+       }
+       else if (algorithm == OID_HMAC_SHA1)
+       {
+               oidValue = _OID_TYPE_HMAC_SHA1;
+       }
+       else if (algorithm == OID_HMAC_SHA2_224)
+       {
+               oidValue = _OID_TYPE_HMAC_SHA2_224;
+       }
+       else if (algorithm == OID_HMAC_SHA2_256)
+       {
+               oidValue = _OID_TYPE_HMAC_SHA2_256;
+       }
+       else if (algorithm == OID_HMAC_SHA2_384)
+       {
+               oidValue = _OID_TYPE_HMAC_SHA2_384;
+       }
+       else if (algorithm == OID_HMAC_SHA2_512)
+       {
+               oidValue = _OID_TYPE_HMAC_SHA2_512;
+       }
+       else if (algorithm == OID_DES_CBC)
+       {
+               oidValue = _OID_TYPE_DES_CBC;
+       }
+       else if (algorithm == OID_DES_CBC_EDE3)
+       {
+               oidValue = _OID_TYPE_DES_CBC_EDE3;
+       }
+       else if (algorithm == OID_AES_128_CBC)
+       {
+               oidValue = _OID_TYPE_AES_128_CBC;
+       }
+       else if (algorithm == OID_AES_192_CBC)
+       {
+               oidValue = _OID_TYPE_AES_192_CBC;
+       }
+       else if (algorithm == OID_AES_256_CBC)
+       {
+               oidValue = _OID_TYPE_AES_256_CBC;
+       }
+       else if (algorithm == OID_RC2_CBC)
+       {
+               oidValue = _OID_TYPE_RC2_CBC;
+       }
+       else if (algorithm == OID_RSA_ENCRYPTION)
+       {
+               oidValue = _OID_TYPE_RSA_ENCRYPTION;
+       }
+       else
+       {
+               r = E_UNSUPPORTED_ALGORITHM;
+       }
+
+       SetLastResult(r);
+       return oidValue;
+}
+
+Tizen::Base::String
+_PkcsUtility::ConvertToOid(int nidValue)
+{
+       result r = E_SUCCESS;
+       Tizen::Base::String oidValue = null;
+
+       ClearLastResult();
+
+       if (nidValue == NID_id_pbkdf2)
+       {
+               oidValue = OID_PBKDF2;
+       }
+       else if (nidValue == NID_pbes2)
+       {
+               oidValue = OID_PBES2;
+       }
+       else if (nidValue == NID_pbmac1)
+       {
+               oidValue = OID_PBMAC1;
+       }
+       else if (nidValue == NID_hmacWithSHA1)
+       {
+               oidValue = OID_HMAC_SHA1;
+       }
+       else if (nidValue == NID_hmacWithSHA224)
+       {
+               oidValue = OID_HMAC_SHA2_224;
+       }
+       else if (nidValue == NID_hmacWithSHA256)
+       {
+               oidValue = OID_HMAC_SHA2_256;
+       }
+       else if (nidValue == NID_hmacWithSHA384)
+       {
+               oidValue = OID_HMAC_SHA2_384;
+       }
+       else if (nidValue == NID_hmacWithSHA512)
+       {
+               oidValue = OID_HMAC_SHA2_512;
+       }
+       else if (nidValue == NID_des_cbc)
+       {
+               oidValue = OID_DES_CBC;
+       }
+       else if (nidValue == NID_des_ede3_cbc)
+       {
+               oidValue = OID_DES_CBC_EDE3;
+       }
+       else if (nidValue == NID_aes_128_cbc)
+       {
+               oidValue = OID_AES_128_CBC;
+       }
+       else if (nidValue == NID_aes_192_cbc)
+       {
+               oidValue = OID_AES_192_CBC;
+       }
+       else if (nidValue == NID_aes_256_cbc)
+       {
+               oidValue = OID_AES_256_CBC;
+       }
+       else if (nidValue == NID_rc2_cbc)
+       {
+               oidValue = OID_RC2_CBC;
+       }
+       else if (nidValue == NID_rsaEncryption)
+       {
+               oidValue = OID_RSA_ENCRYPTION;
+       }
+       else if (nidValue == NID_commonName)
+       {
+               oidValue = OID_ATTR_COMMON_NAME;
+       }
+       else if (nidValue == NID_countryName)
+       {
+               oidValue = OID_ATTR_COUNTRY_NAME;
+       }
+       else if (nidValue == NID_localityName)
+       {
+               oidValue = OID_ATTR_LOCALITY_NAME;
+       }
+       else if (nidValue == NID_stateOrProvinceName)
+       {
+               oidValue = OID_ATTR_STATE_OR_PROV_NAME;
+       }
+       else if (nidValue == NID_organizationName)
+       {
+               oidValue = OID_ATTR_ORG_NAME;
+       }
+       else if (nidValue == NID_organizationalUnitName)
+       {
+               oidValue = OID_ATTR_ORG_UNIT_NAME;
+       }
+       else if (nidValue == NID_givenName)
+       {
+               oidValue = OID_ATTR_GIVEN_NAME;
+       }
+       else if (nidValue == NID_surname)
+       {
+               oidValue = OID_ATTR_SURNAME;
+       }
+       else if (nidValue == NID_initials)
+       {
+               oidValue = OID_ATTR_INITIAL;
+       }
+       else if (nidValue == NID_serialNumber)
+       {
+               oidValue = OID_ATTR_SERIAL_NUMBER;
+       }
+       else if (nidValue == NID_title)
+       {
+               oidValue = OID_ATTR_TITLE;
+       }
+       else if (nidValue == NID_pkcs9_emailAddress)
+       {
+               oidValue = OID_ATTR_EMAIL_ADDRESS;
+       }
+       else if (nidValue == NID_generationQualifier)
+       {
+               oidValue = OID_ATTR_GEN_QUALIFIER;
+       }
+       else if (nidValue == NID_pseudonym)
+       {
+               oidValue = OID_ATTR_PSEUDONYM;
+       }
+       else if (nidValue == NID_domainComponent)
+       {
+               oidValue = OID_ATTR_DOMAIN_COMPONENT;
+       }
+       else if (nidValue == NID_dnQualifier)
+       {
+               oidValue = OID_ATTR_DN_QUALIFIER;
+       }
+       else if (nidValue == NID_name)
+       {
+               oidValue = OID_ATTR_NAME;
+       }
+       else
+       {
+               r = E_UNSUPPORTED_ALGORITHM;
+       }
+
+       SetLastResult(r);
+       return oidValue;
+}
+
+Pkcs08TagValue
+_PkcsUtility::ConvertToTagValue(int ans1Type)
+{
+       Pkcs08TagValue tagValue;
+
+       switch (ans1Type)
+       {
+       case V_ASN1_PRINTABLESTRING:
+               tagValue = PKCS08_TAG_PRINTABLE_STRING;
+               break;
+
+       case V_ASN1_EOC:
+               tagValue = PKCS08_TAG_RESERVED;
+               break;
+
+       case V_ASN1_BOOLEAN:
+               tagValue = PKCS08_TAG_BOOLEAN;
+               break;
+
+       case V_ASN1_INTEGER:
+               tagValue = PKCS08_TAG_INTEGER;
+               break;
+
+       case V_ASN1_BIT_STRING:
+               tagValue = PKCS08_TAG_BITSTRING;
+               break;
+
+       case V_ASN1_OCTET_STRING:
+               tagValue = PKCS08_TAG_OCTETSTRING;
+               break;
+
+       case V_ASN1_NULL:
+               tagValue = PKCS08_TAG_NULL;
+               break;
+
+       case V_ASN1_OBJECT:
+               tagValue = PKCS08_TAG_OBJECT_ID;
+               break;
+
+       case V_ASN1_OBJECT_DESCRIPTOR:
+               tagValue = PKCS08_TAG_OBJECT_DES;
+               break;
+
+       case V_ASN1_EXTERNAL:
+               tagValue = PKCS08_TAG_EXTERNAL;
+               break;
+
+       case V_ASN1_REAL:
+               tagValue = PKCS08_TAG_REAL;
+               break;
+
+       case V_ASN1_ENUMERATED:
+               tagValue = PKCS08_TAG_ENUM;
+               break;
+
+       case 11:
+               tagValue = PKCS08_TAG_EMBEDDED;
+               break;
+
+       case V_ASN1_UTF8STRING:
+               tagValue = PKCS08_TAG_UTF8STRING;
+               break;
+
+       case 13:
+               tagValue = PKCS08_TAG_REL_OBJ_ID;
+               break;
+
+       case V_ASN1_SEQUENCE:
+               tagValue = PKCS08_TAG_SEQUENCE;
+               break;
+
+       case V_ASN1_SET:
+               tagValue = PKCS08_TAG_SET;
+               break;
+
+       case V_ASN1_NUMERICSTRING:
+               tagValue = PKCS08_TAG_CHAR_STRING;
+               break;
+
+       case V_ASN1_TELETEXSTRING:
+               tagValue = PKCS08_TAG_TELETEXT_STRING;
+               break;
+
+       case V_ASN1_VIDEOTEXSTRING:
+               tagValue = PKCS08_TAG_VIDEOTEXT_STRING;
+               break;
+
+       case V_ASN1_IA5STRING:
+               tagValue = PKCS08_TAG_IA5STRING;
+               break;
+
+       case V_ASN1_UTCTIME:
+               tagValue = PKCS08_TAG_UTC_TIME;
+               break;
+
+       case V_ASN1_GENERALIZEDTIME:
+               tagValue = PKCS08_TAG_GEN_TIME;
+               break;
+
+       case V_ASN1_GRAPHICSTRING:
+               tagValue = PKCS08_TAG_GRAPHICS_STRING;
+               break;
+
+       case V_ASN1_VISIBLESTRING:
+               tagValue = PKCS08_TAG_VISIBLE_STRING;
+               break;
+
+       case V_ASN1_GENERALSTRING:
+               tagValue = PKCS08_TAG_GENERAL_STRING;
+               break;
+
+       case V_ASN1_UNIVERSALSTRING:
+               tagValue = PKCS08_TAG_UNIVERSAL_STRING;
+               break;
+
+       case 29:
+               tagValue = PKCS08_TAG_CHARACTER_STRING;
+               break;
+
+       case V_ASN1_BMPSTRING:
+               tagValue = PKCS08_TAG_BMP_STRING;
+               break;
+
+       default:
+               tagValue = PKCS08_TAG_UNKNOWN;
+               SetLastResult(E_INVALID_ARG);
+               break;
+
+       }
+
+       SetLastResult(E_SUCCESS);
+       return tagValue;
+}
+
+int
+_PkcsUtility::ConvertToNid(Tizen::Base::String algorithm)
+{
+       result r = E_SUCCESS;
+       int nid = 0;
+
+       ClearLastResult();
+
+       if (algorithm == OID_PBKDF2)
+       {
+               nid = NID_id_pbkdf2;
+       }
+       else if (algorithm == OID_PBES2)
+       {
+               nid = NID_pbes2;
+       }
+       else if (algorithm == OID_PBMAC1)
+       {
+               nid = NID_pbmac1;
+       }
+       else if (algorithm == OID_HMAC_SHA1)
+       {
+               nid = NID_hmacWithSHA1;
+       }
+       else if (algorithm == OID_HMAC_SHA2_224)
+       {
+               nid = NID_hmacWithSHA224;
+       }
+       else if (algorithm == OID_HMAC_SHA2_256)
+       {
+               nid = NID_hmacWithSHA256;
+       }
+       else if (algorithm == OID_HMAC_SHA2_384)
+       {
+               nid = NID_hmacWithSHA384;
+       }
+       else if (algorithm == OID_HMAC_SHA2_512)
+       {
+               nid = NID_hmacWithSHA512;
+       }
+       else if (algorithm == OID_DES_CBC)
+       {
+               nid = NID_des_cbc;
+       }
+       else if (algorithm == OID_DES_CBC_EDE3)
+       {
+               nid = NID_des_ede3_cbc;
+       }
+       else if (algorithm == OID_AES_128_CBC)
+       {
+               nid = NID_aes_128_cbc;
+       }
+       else if (algorithm == OID_AES_192_CBC)
+       {
+               nid = NID_aes_192_cbc;
+       }
+       else if (algorithm == OID_AES_256_CBC)
+       {
+               nid = NID_aes_256_cbc;
+       }
+       else if (algorithm == OID_RC2_CBC)
+       {
+               nid = NID_rc2_cbc;
+       }
+       else if (algorithm == OID_RSA_ENCRYPTION)
+       {
+               nid = NID_rsaEncryption;
+       }
+       else if (algorithm == OID_ATTR_COUNTRY_NAME)
+       {
+               nid = NID_countryName;
+       }
+       else if (algorithm == OID_ATTR_NAME)
+       {
+               nid = NID_name;
+       }
+       else if (algorithm == OID_ATTR_COMMON_NAME)
+       {
+               nid = NID_commonName;
+       }
+       else if (algorithm == OID_ATTR_LOCALITY_NAME)
+       {
+               nid = NID_localityName;
+       }
+       else if (algorithm == OID_ATTR_STATE_OR_PROV_NAME)
+       {
+               nid = NID_stateOrProvinceName;
+       }
+       else if (algorithm == OID_ATTR_ORG_NAME)
+       {
+               nid = NID_organizationName;
+       }
+       else if (algorithm == OID_ATTR_ORG_UNIT_NAME)
+       {
+               nid = NID_organizationalUnitName;
+       }
+       else if (algorithm == OID_ATTR_GIVEN_NAME)
+       {
+               nid = NID_givenName;
+       }
+       else if (algorithm == OID_ATTR_SURNAME)
+       {
+               nid = NID_surname;
+       }
+       else if (algorithm == OID_ATTR_INITIAL)
+       {
+               nid = NID_initials;
+       }
+       else if (algorithm == OID_ATTR_SERIAL_NUMBER)
+       {
+               nid = NID_serialNumber;
+       }
+       else if (algorithm == OID_ATTR_TITLE)
+       {
+               nid = NID_title;
+       }
+       else if (algorithm == OID_ATTR_EMAIL_ADDRESS)
+       {
+               nid = NID_pkcs9_emailAddress;
+       }
+       else if (algorithm == OID_ATTR_GEN_QUALIFIER)
+       {
+               nid = NID_generationQualifier;
+       }
+       else if (algorithm == OID_ATTR_PSEUDONYM)
+       {
+               nid = NID_pseudonym;
+       }
+       else if (algorithm == OID_ATTR_DOMAIN_COMPONENT)
+       {
+               nid = NID_domainComponent;
+       }
+       else if (algorithm == OID_ATTR_DN_QUALIFIER)
+       {
+               nid = NID_dnQualifier;
+       }
+       else
+       {
+               r = E_UNSUPPORTED_ALGORITHM;
+       }
+       SetLastResult(r);
+       return nid;
+}
+
+//FSecurity PKCS Utility Operations
+Tizen::Base::ByteBuffer*
+_PkcsUtility::EncryptDecryptN(const AlgorithmIdentifier& algo, const Tizen::Base::ByteBuffer& derivedKey, const Tizen::Base::ByteBuffer& input, int modeValue)
+{
+       result r = E_SUCCESS;
+       EVP_CIPHER_CTX cipherCtx;
+       std::unique_ptr< byte[] > pOut;
+       byte* pData = null;
+       int outLen = 0;
+       int dataLen = 0;
+       int finalLen = 0;
+       int tempLen = 0;
+       int ret = 0;
+       std::unique_ptr< ByteBuffer > pOutBuffer;
+       ByteBuffer ivValue;
+       Tizen::Base::String encOid = null;
+       const evp_cipher_st* pCipherAlgorithm = null;
+       _OidType oidValue = _OID_TYPE_UNKNOWN;
+
+       ClearLastResult();
+
+       EVP_CIPHER_CTX_init(&cipherCtx);
+       encOid = algo.GetAlgorithmObjectId();
+       oidValue = _PkcsUtility::ConvertOidToEnum(encOid);
+
+       switch (oidValue)
+       {
+       case _OID_TYPE_DES_CBC:
+       {
+               std::unique_ptr< InitialVector > pIvObj(dynamic_cast< InitialVector* >(algo.GetParametersN()));
+               if (pIvObj == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               ivValue.Construct(pIvObj->GetInitialVector());
+               SysTryCatch(NID_SEC_CRYPTO, ivValue.GetRemaining() > 0, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pCipherAlgorithm = EVP_des_cbc();
+               ret = EVP_CipherInit(&cipherCtx, pCipherAlgorithm, const_cast< byte* >(derivedKey.GetPointer()), const_cast< byte* >(ivValue.GetPointer()), modeValue);
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       case _OID_TYPE_DES_CBC_EDE3:
+       {
+               std::unique_ptr< InitialVector > pIvObj(dynamic_cast< InitialVector* >(algo.GetParametersN()));
+               if (pIvObj == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               ivValue.Construct(pIvObj->GetInitialVector());
+               SysTryCatch(NID_SEC_CRYPTO, ivValue.GetRemaining() > 0, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+
+               pCipherAlgorithm = EVP_des_ede3();
+               ret = EVP_CipherInit(&cipherCtx, pCipherAlgorithm, const_cast< byte* >(derivedKey.GetPointer()), const_cast< byte* >(ivValue.GetPointer()), modeValue);
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       case _OID_TYPE_AES_128_CBC:
+       {
+               std::unique_ptr< InitialVector > pIvObj(dynamic_cast< InitialVector* >(algo.GetParametersN()));
+               if (pIvObj == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               ivValue.Construct(pIvObj->GetInitialVector());
+               SysTryCatch(NID_SEC_CRYPTO, ivValue.GetRemaining() > 0, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+
+               pCipherAlgorithm = EVP_aes_128_cbc();
+
+               ret = EVP_CipherInit(&cipherCtx, pCipherAlgorithm, const_cast< byte* >(derivedKey.GetPointer()), const_cast< byte* >(ivValue.GetPointer()), modeValue);
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       case _OID_TYPE_AES_192_CBC:
+       {
+               std::unique_ptr< InitialVector > pIvObj(dynamic_cast< InitialVector* >(algo.GetParametersN()));
+               if (pIvObj == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               ivValue.Construct(pIvObj->GetInitialVector());
+               SysTryCatch(NID_SEC_CRYPTO, ivValue.GetRemaining() > 0, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pCipherAlgorithm = EVP_aes_192_cbc();
+               ret = EVP_CipherInit(&cipherCtx, pCipherAlgorithm, const_cast< byte* >(derivedKey.GetPointer()), const_cast< byte* >(ivValue.GetPointer()), modeValue);
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       }
+       break;
+
+       case _OID_TYPE_AES_256_CBC:
+       {
+               std::unique_ptr< InitialVector > pIvObj(dynamic_cast< InitialVector* >(algo.GetParametersN()));
+               if (pIvObj == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pIvObj, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               ivValue.Construct(pIvObj->GetInitialVector());
+               SysTryCatch(NID_SEC_CRYPTO, ivValue.GetRemaining() > 0, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+
+               pCipherAlgorithm = EVP_aes_256_cbc();
+               ret = EVP_CipherInit(&cipherCtx, pCipherAlgorithm, const_cast< byte* >(derivedKey.GetPointer()), const_cast< byte* >(ivValue.GetPointer()), modeValue);
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       }
+       break;
+
+       case _OID_TYPE_RC2_CBC:
+       {
+               std::unique_ptr< Rc2CbcParameters > pRcObj(dynamic_cast< Rc2CbcParameters* >(algo.GetParametersN()));
+               if (pRcObj == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pRcObj, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pRcObj, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               ivValue.Construct(pRcObj->GetInitialVector());
+               SysTryCatch(NID_SEC_CRYPTO, ivValue.GetRemaining() > 0, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+
+               pCipherAlgorithm = EVP_rc2_cbc();
+               ret = EVP_CipherInit(&cipherCtx, pCipherAlgorithm, null, null, modeValue);
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               EVP_CIPHER_CTX_set_key_length(&cipherCtx, derivedKey.GetRemaining());
+
+               ret = EVP_CipherInit(&cipherCtx, null, const_cast< byte* >(derivedKey.GetPointer()), const_cast< byte* >(ivValue.GetPointer()), modeValue);
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+
+       }
+       break;
+
+       case _OID_TYPE_PBES2:
+       {
+               Pkcs05Schemes pkcs05Scheme;
+               std::unique_ptr< Pkcs05PbEs2Parameters > pPbEs2(dynamic_cast< Pkcs05PbEs2Parameters* >(algo.GetParametersN()));
+               if (pPbEs2 == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pPbEs2, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pPbEs2, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               SysTryCatch(NID_SEC_CRYPTO, pPbEs2->GetKeyDerivationAlgorithm().GetAlgorithmObjectId().GetLength() > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               std::unique_ptr< Pkcs05PbKdf2Parameters > pKdfParams(dynamic_cast< Pkcs05PbKdf2Parameters* >(pPbEs2->GetKeyDerivationAlgorithm().GetParametersN()));
+               if (pKdfParams == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pKdfParams, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryCatch(NID_SEC_CRYPTO, pKdfParams, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               int derivedKeyLength = pKdfParams->GetDerivedKeyLength();
+
+               if (derivedKeyLength <= 0)
+               {
+                       derivedKeyLength = _PKCS05_MAX_KEY_SIZE;
+               }
+
+               r = pkcs05Scheme.Construct(derivedKey, derivedKeyLength);
+
+               if (modeValue == 1)
+               {
+                       pOutBuffer = std::unique_ptr< ByteBuffer >(pkcs05Scheme.EncryptionScheme2N(*pPbEs2, input));
+               }
+               else
+               {
+                       pOutBuffer = std::unique_ptr< ByteBuffer >(pkcs05Scheme.DecryptionScheme2N(*pPbEs2, input));
+               }
+
+       }
+               return pOutBuffer.release();
+
+       case _OID_TYPE_RSA_ENCRYPTION:
+       {
+               RsaCipher rsaCipher;
+               if (modeValue == 0)
+               {
+                       PublicKey pubKey;
+
+                       r = pubKey.SetKey(derivedKey);
+                       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+                       rsaCipher.SetPublicKey(pubKey);
+                       pOutBuffer = std::unique_ptr< ByteBuffer >(rsaCipher.DecryptN(input));
+
+               }
+               else
+               {
+                       PrivateKey priKey;
+                       priKey.SetKey(derivedKey);
+                       r = rsaCipher.SetPrivateKey(priKey);
+                       pOutBuffer = std::unique_ptr< ByteBuffer >(rsaCipher.EncryptN(input));
+               }
+       }
+
+               return pOutBuffer.release();
+
+       default:
+               r = E_UNSUPPORTED_ALGORITHM;
+               SetLastResult(r);
+               return null;
+       }
+
+
+
+       // initialize the cipher context
+
+       pData = const_cast< byte* >(input.GetPointer());
+       SysTryCatch(NID_SEC_CRYPTO, pData != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       dataLen = input.GetRemaining();
+       SysTryCatch(NID_SEC_CRYPTO, dataLen > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       // block size
+       tempLen = static_cast< int >((dataLen / pCipherAlgorithm->block_size + 1)* pCipherAlgorithm->block_size);
+
+       pOut = std::unique_ptr< byte[] >(new (std::nothrow) byte[tempLen]);
+       SysTryCatch(NID_SEC_CRYPTO, pOut, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       memset(pOut.get(), 0, tempLen);
+
+       //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.");
+
+       //cipher final operation
+       ret = EVP_CipherFinal(&cipherCtx, pOut.get() + outLen, &finalLen);
+       SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       outLen = outLen + finalLen;
+
+       SysTryCatch(NID_SEC_CRYPTO, outLen <= tempLen, r = E_OVERFLOW, E_OVERFLOW, "[E_OVERFLOW] Length mismatch resulting in overflow.");
+
+       //creating bytebuffer and storing output data from cipher final operation in it
+       pOutBuffer = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pOutBuffer, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->Construct(outLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pOutBuffer->SetArray(pOut.get(), 0, outLen);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pOutBuffer->Flip();
+
+CATCH:
+
+       EVP_CIPHER_CTX_cleanup(&cipherCtx);
+
+       SetLastResult(r);
+       return pOutBuffer.release();
+
+}
+
+X509_ALGOR*
+_PkcsUtility::GenerateKdfParametersN(int iter, unsigned char* pSaltValue, int saltLen, int prfNid, int keyLen)
+{
+       result r = E_SUCCESS;
+       X509_ALGOR* pKeyfunc = null;
+       PBKDF2PARAM* pKdf = null;
+       ASN1_OCTET_STRING* pSalt = null;
+       int ret = 0;
+
+
+       ClearLastResult();
+
+       pKdf = PBKDF2PARAM_new();
+       SysTryReturn(NID_SEC_CRYPTO, pKdf != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pSalt = M_ASN1_OCTET_STRING_new();
+       SysTryCatch(NID_SEC_CRYPTO, pSalt != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pKdf->salt->value.octet_string = pSalt;
+       pKdf->salt->type = V_ASN1_OCTET_STRING;
+
+       pSalt->data = static_cast< unsigned char* >(OPENSSL_malloc(saltLen));
+       SysTryCatch(NID_SEC_CRYPTO, pSalt->data != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pSalt->length = saltLen;
+
+       memcpy(pSalt->data, pSaltValue, saltLen);
+
+       ASN1_INTEGER_set(pKdf->iter, iter);
+
+       if (keyLen > 0)
+       {
+
+               pKdf->keylength = M_ASN1_INTEGER_new();
+               SysTryCatch(NID_SEC_CRYPTO, pKdf->keylength != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ASN1_INTEGER_set(pKdf->keylength, keyLen);
+
+       }
+
+       if (prfNid != NID_hmacWithSHA1)
+       {
+
+               pKdf->prf = X509_ALGOR_new();
+               SysTryCatch(NID_SEC_CRYPTO, pKdf->prf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ret = X509_ALGOR_set0(pKdf->prf, OBJ_nid2obj(prfNid), V_ASN1_NULL, NULL);
+               SysTryCatch(NID_SEC_CRYPTO, ret > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       }
+
+       pKeyfunc = X509_ALGOR_new();
+       SysTryCatch(NID_SEC_CRYPTO, pKeyfunc != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pKeyfunc->algorithm = OBJ_nid2obj(NID_id_pbkdf2);
+
+       pKeyfunc->parameter = ASN1_TYPE_new();
+       ASN1_item_pack(pKdf, ASN1_ITEM_rptr(PBKDF2PARAM), &pKeyfunc->parameter->value.sequence);
+
+       pKeyfunc->parameter->type = V_ASN1_SEQUENCE;
+
+       PBKDF2PARAM_free(pKdf);
+       return pKeyfunc;
+
+CATCH:
+
+       PBKDF2PARAM_free(pKdf);
+       X509_ALGOR_free(pKeyfunc);
+       SetLastResult(r);
+       return null;
+
+}
+
+IAlgorithmParameters*
+_PkcsUtility::GernerateParametersFromOidN(Tizen::Base::String algoOid, X509_ALGOR* pAlgoObj)
+{
+       result r = E_SUCCESS;
+       _OidType oidValue;
+       int pType = 0;
+       int dataLen = 0;
+       int ret = 0;
+       void* pVal = null;
+       long num = 0;
+       unsigned char iv[EVP_MAX_IV_LENGTH];
+       const unsigned char* pData = null;
+       ASN1_STRING* pStr = null;
+       ASN1_TYPE* pAsn1Type = null;
+       Tizen::Base::ByteBuffer ivBuffer;
+       Tizen::Base::ByteBuffer ivBuffer1;
+       Tizen::Base::ByteBuffer paramBuffer;
+       Pkcs05PbEs2Parameters pbEs2Obj;
+       Pkcs05PbKdf2Parameters kdfObj;
+       Rc2CbcParameters rc2CbcObj;
+       Pkcs05PbMacParameters pbMacObj;
+       InitialVector ivObj;
+       std::unique_ptr< IAlgorithmParameters > pAlgoParams;
+
+
+       ClearLastResult();
+
+       oidValue = _PkcsUtility::ConvertOidToEnum(algoOid);
+
+       switch (oidValue)
+       {
+       case _OID_TYPE_DES_CBC:
+       // fall through
+       case _OID_TYPE_DES_CBC_EDE3:
+       // fall through
+       case _OID_TYPE_AES_128_CBC:
+       // fall through
+       case _OID_TYPE_AES_192_CBC:
+       // fall through
+       case _OID_TYPE_AES_256_CBC:
+       {
+               X509_ALGOR_get0(&pAlgoObj->algorithm, &pType, &pVal, pAlgoObj);
+               SysTryReturn(NID_SEC_CRYPTO, pType == V_ASN1_OCTET_STRING, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               SysTryReturn(NID_SEC_CRYPTO, pVal != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pStr = reinterpret_cast< ASN1_STRING* >(pVal);
+               pData = pStr->data;
+               dataLen = pStr->length;
+
+               r = ivBuffer.Construct(dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = ivBuffer.SetArray(pData, 0, dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               ivBuffer.Flip();
+
+               r = ivObj.Construct(ivBuffer);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pAlgoParams = std::unique_ptr< IAlgorithmParameters >(ivObj.CloneN());
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParams, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               return pAlgoParams.release();
+       }
+       break;
+
+       case _OID_TYPE_RC2_CBC:
+       {
+               X509_ALGOR_get0(&pAlgoObj->algorithm, &pType, &pVal, pAlgoObj);
+               SysTryReturn(NID_SEC_CRYPTO, ((pType == V_ASN1_SEQUENCE) || (pType == V_ASN1_OCTET_STRING)), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               SysTryReturn(NID_SEC_CRYPTO, pVal != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pStr = reinterpret_cast< ASN1_STRING* >(pVal);
+               pData = pStr->data;
+               dataLen = pStr->length;
+
+
+               if (pType == V_ASN1_OCTET_STRING)
+               {
+                       r = ivBuffer.Construct(dataLen);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       r = ivBuffer.SetArray(pData, 0, dataLen);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       ivBuffer.Flip();
+
+                       r = rc2CbcObj.Construct(ivBuffer);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               }
+               else
+               {
+
+                       r = ivBuffer.Construct(dataLen);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       r = ivBuffer.SetArray(pData, 0, dataLen);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       ivBuffer.Flip();
+
+                       const byte* pBuffer = ivBuffer.GetPointer();
+
+                       pAsn1Type = d2i_ASN1_TYPE(null, reinterpret_cast< const unsigned char** >(&pBuffer), ivBuffer.GetRemaining());
+                       SysTryReturn(NID_SEC_CRYPTO, pAsn1Type != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       memset(iv, 0, sizeof(iv));
+
+                       ret = ASN1_TYPE_get_int_octetstring(pAsn1Type, &num, iv, sizeof(iv));
+                       SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       r = ivBuffer1.Construct(ret);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       r = ivBuffer1.SetArray(iv, 0, ret);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+                       ivBuffer1.Flip();
+
+                       r = rc2CbcObj.Construct(ivBuffer1, num);
+                       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               }
+
+               pAlgoParams = std::unique_ptr< IAlgorithmParameters >(rc2CbcObj.CloneN());
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParams, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               return pAlgoParams.release();
+
+       }
+       break;
+
+       case _OID_TYPE_HMAC_SHA1:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_224:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_256:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_384:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_512:
+       // fall through
+       case _OID_TYPE_RSA_ENCRYPTION:
+       {
+               pAlgoParams = null;
+               return pAlgoParams.release();
+       }
+       break;
+
+       case _OID_TYPE_PBKDF2:
+       {
+               X509_ALGOR_get0(&(pAlgoObj->algorithm), &pType, &pVal, pAlgoObj);
+               SysTryReturn(NID_SEC_CRYPTO, pType == V_ASN1_SEQUENCE, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               SysTryReturn(NID_SEC_CRYPTO, pVal != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pStr = reinterpret_cast< ASN1_STRING* >(pVal);
+               pData = pStr->data;
+               dataLen = pStr->length;
+
+               r = paramBuffer.Construct(dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = paramBuffer.SetArray(pData, 0, dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               paramBuffer.Flip();
+
+               r = kdfObj.Construct(paramBuffer);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pAlgoParams = std::unique_ptr< IAlgorithmParameters >(kdfObj.CloneN());
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParams, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               return pAlgoParams.release();
+       }
+       break;
+
+       case _OID_TYPE_PBES2:
+       {
+               X509_ALGOR_get0(&(pAlgoObj->algorithm), &pType, &pVal, pAlgoObj);
+               SysTryReturn(NID_SEC_CRYPTO, pType == V_ASN1_SEQUENCE, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               SysTryReturn(NID_SEC_CRYPTO, pVal != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pStr = reinterpret_cast< ASN1_STRING* >(pVal);
+               pData = pStr->data;
+               dataLen = pStr->length;
+
+               r = paramBuffer.Construct(dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = paramBuffer.SetArray(pData, 0, dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               paramBuffer.Flip();
+
+               r = pbEs2Obj.Construct(paramBuffer);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pAlgoParams = std::unique_ptr< IAlgorithmParameters >(pbEs2Obj.CloneN());
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParams, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               return pAlgoParams.release();
+       }
+       break;
+
+       case _OID_TYPE_PBMAC1:
+       {
+               X509_ALGOR_get0(&pAlgoObj->algorithm, &pType, &pVal, pAlgoObj);
+               SysTryReturn(NID_SEC_CRYPTO, pType == V_ASN1_SEQUENCE, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               SysTryReturn(NID_SEC_CRYPTO, pVal != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+               pStr = reinterpret_cast< ASN1_STRING* >(pVal);
+               pData = pStr->data;
+               dataLen = pStr->length;
+
+               r = paramBuffer.Construct(dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = paramBuffer.SetArray(pData, 0, dataLen);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               paramBuffer.Flip();
+
+               r = pbMacObj.Construct(paramBuffer);
+               SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pAlgoParams = std::unique_ptr< IAlgorithmParameters >(pbMacObj.CloneN());
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParams, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               return pAlgoParams.release();
+       }
+       break;
+
+       default:
+
+               r = E_UNSUPPORTED_ALGORITHM;
+               break;
+       }
+
+       SetLastResult(r);
+       return pAlgoParams.release();
+
+}
+
+X509_ALGOR*
+_PkcsUtility::GenerateAlgorithmIdentifierStructureN(Tizen::Base::String algoOid, IAlgorithmParameters* pAlgoParam)
+{
+       result r = E_SUCCESS;
+       X509_ALGOR* pAlgoObj = null;
+       _OidType oidValue;
+       int ret = 0;
+       int algoNid = 0;
+       int version = 0;
+       const byte* pBuf = null;
+       PBKDF2PARAM* pKdf = null;
+       PBE2PARAM* pPbes2Obj = null;
+       PBE2PARAM* pMacObj = null;
+       ASN1_STRING* pbKdf2Str = null;
+       ASN1_STRING* pbE2Str = null;
+       ASN1_STRING* pIv = null;
+       ASN1_TYPE* pAsn1Type = null;
+       Tizen::Base::ByteBuffer ivBuffer;
+
+       ClearLastResult();
+
+       pAlgoObj = X509_ALGOR_new();
+       SysTryReturn(NID_SEC_CRYPTO, pAlgoObj != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       oidValue = _PkcsUtility::ConvertOidToEnum(algoOid);
+       algoNid = _PkcsUtility::ConvertToNid(algoOid);
+
+       switch (oidValue)
+       {
+       case _OID_TYPE_DES_CBC:
+       // fall through
+       case _OID_TYPE_DES_CBC_EDE3:
+       // fall through
+       case _OID_TYPE_AES_128_CBC:
+       // fall through
+       case _OID_TYPE_AES_192_CBC:
+       // 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.");
+
+               ivBuffer.Construct(((dynamic_cast< InitialVector* >(pAlgoParam))->GetInitialVector()));
+               SysTryReturn(NID_SEC_CRYPTO, ivBuffer.GetRemaining() > 0, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pIv = ASN1_STRING_new();
+               SysTryReturn(NID_SEC_CRYPTO, pIv != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pIv->data = static_cast< unsigned char* >(OPENSSL_malloc(ivBuffer.GetRemaining()));
+               SysTryReturn(NID_SEC_CRYPTO, pIv->data != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               memcpy(pIv->data, ivBuffer.GetPointer(), ivBuffer.GetRemaining());
+
+               pIv->length = ivBuffer.GetRemaining();
+
+               ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_OCTET_STRING, reinterpret_cast< void* >(pIv));
+               SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       case _OID_TYPE_RC2_CBC:
+       {
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParam != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               ivBuffer.Construct(((dynamic_cast< Rc2CbcParameters* >(pAlgoParam))->GetInitialVector()));
+               SysTryReturn(NID_SEC_CRYPTO, ivBuffer.GetRemaining() > 0, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               version = (dynamic_cast< Rc2CbcParameters* >(pAlgoParam))->GetVersion();
+
+               if (version == 0)
+               {
+                       pIv = ASN1_STRING_new();
+                       SysTryReturn(NID_SEC_CRYPTO, pIv != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       pIv->data = static_cast< unsigned char* >(OPENSSL_malloc(ivBuffer.GetRemaining()));
+                       SysTryReturn(NID_SEC_CRYPTO, pIv->data != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       memcpy(pIv->data, ivBuffer.GetPointer(), ivBuffer.GetRemaining());
+
+                       pIv->length = ivBuffer.GetRemaining();
+
+                       ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_OCTET_STRING, reinterpret_cast< void* >(pIv));
+                       SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               }
+               else
+               {
+
+                       pAsn1Type = ASN1_TYPE_new();
+                       SysTryReturn(NID_SEC_CRYPTO, pAsn1Type != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       ret = ASN1_TYPE_set_int_octetstring(pAsn1Type, version, const_cast< unsigned char* >(ivBuffer.GetPointer()), ivBuffer.GetRemaining());
+                       SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+                       ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_SEQUENCE, reinterpret_cast< void* >(pAsn1Type->value.ptr));
+                       SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               }
+
+       }
+       break;
+
+       case _OID_TYPE_HMAC_SHA1:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_224:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_256:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_384:
+       // fall through
+       case _OID_TYPE_RSA_ENCRYPTION:
+       // fall through
+       case _OID_TYPE_HMAC_SHA2_512:
+       {
+               ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_NULL, NULL);
+               SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       case _OID_TYPE_PBKDF2:
+       {
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParam != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               std::unique_ptr< ByteBuffer > pKdfBuffer((dynamic_cast< Pkcs05PbKdf2Parameters* >(pAlgoParam))->GetEncodedDataN());
+               if (pKdfBuffer == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryReturn(NID_SEC_CRYPTO, pKdfBuffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryReturn(NID_SEC_CRYPTO, pKdfBuffer, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               pBuf = pKdfBuffer->GetPointer();
+               SysTryReturn(NID_SEC_CRYPTO, pBuf != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pKdf = d2i_PBKDF2PARAM(null, reinterpret_cast< const unsigned char** >(&pBuf), pKdfBuffer->GetRemaining());
+               SysTryReturn(NID_SEC_CRYPTO, pKdf != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               ASN1_item_pack(pKdf, ASN1_ITEM_rptr(PBKDF2PARAM), &pbKdf2Str);
+
+               SysTryReturn(NID_SEC_CRYPTO, pbKdf2Str != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_SEQUENCE, pbKdf2Str);
+               SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       case _OID_TYPE_PBES2:
+       {
+
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParam != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               std::unique_ptr< ByteBuffer > pbEs2Buffer((dynamic_cast< Pkcs05PbEs2Parameters* >(pAlgoParam))->GetEncodedDataN());
+               if (pbEs2Buffer == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryReturn(NID_SEC_CRYPTO, pbEs2Buffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryReturn(NID_SEC_CRYPTO, pbEs2Buffer, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               pBuf = pbEs2Buffer->GetPointer();
+               SysTryReturn(NID_SEC_CRYPTO, pBuf != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pPbes2Obj = d2i_PBE2PARAM(null, reinterpret_cast< const unsigned char** >(&pBuf), pbEs2Buffer->GetRemaining());
+               SysTryReturn(NID_SEC_CRYPTO, pPbes2Obj != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               ASN1_item_pack(pPbes2Obj, ASN1_ITEM_rptr(PBE2PARAM), &pbE2Str);
+
+               ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_SEQUENCE, pbE2Str);
+               SysTryReturn(NID_SEC_CRYPTO, pbE2Str != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       case _OID_TYPE_PBMAC1:
+       {
+               SysTryReturn(NID_SEC_CRYPTO, pAlgoParam != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               std::unique_ptr< ByteBuffer > pbMacBuffer((dynamic_cast< Pkcs05PbMacParameters* >(pAlgoParam))->GetEncodedDataN());
+               if (pbMacBuffer == null)
+               {
+                       r = GetLastResult();
+                       if (r == E_OUT_OF_MEMORY)
+                       {
+                               SysTryReturn(NID_SEC_CRYPTO, pbMacBuffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       }
+                       else
+                       {
+                               SysTryReturn(NID_SEC_CRYPTO, pbMacBuffer, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+                       }
+
+               }
+
+               pBuf = pbMacBuffer->GetPointer();
+               SysTryReturn(NID_SEC_CRYPTO, pBuf != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+               pMacObj = d2i_PBE2PARAM(null, reinterpret_cast< const unsigned char** >(&pBuf), pbMacBuffer->GetRemaining());
+               SysTryReturn(NID_SEC_CRYPTO, pMacObj != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               ASN1_item_pack(pMacObj, ASN1_ITEM_rptr(PBE2PARAM), &pbE2Str);
+
+               ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_SEQUENCE, pbE2Str);
+               SysTryReturn(NID_SEC_CRYPTO, ret > 0, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+       break;
+
+       default:
+               r = E_UNSUPPORTED_ALGORITHM;
+               break;
+       }
+
+       return pAlgoObj;
+
+}
+
+
+
+} } } //OSP::SECURITY::PKCS
diff --git a/src/security/pkcs/FSecPkcs_PkcsUtility.h b/src/security/pkcs/FSecPkcs_PkcsUtility.h
new file mode 100644 (file)
index 0000000..f3e2f91
--- /dev/null
@@ -0,0 +1,250 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_PkcsUtility.h
+ * @brief              This is the header file for the %_PkcsUtility class.
+ *
+ * This header file contains the declarations of the %_PkcsUtility class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_PKCS_UTILITY_H_
+#define _FSEC_PKCS_INTERNAL_PKCS_UTILITY_H_
+
+
+#include <FSecPkcsAlgorithmIdentifier.h>
+#include <FSecPkcsTypes.h>
+
+struct X509_algor_st;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ *@class               _PkcsUtility
+ *@brief               This class contains the declarations for FSecurity PKCS Utility Operations.
+ *@since               2.1
+ *
+ */
+
+/**
+ * @enum _OidType
+ *
+ * Defines the type of Oid.
+ *
+ * @since              2.1
+ */
+
+enum _OidType
+{
+       _OID_TYPE_PKCS05,
+       _OID_TYPE_PBKDF2,
+       _OID_TYPE_PBES2,
+       _OID_TYPE_PBMAC1,
+       _OID_TYPE_HMAC_SHA1,
+       _OID_TYPE_HMAC_SHA2_224,
+       _OID_TYPE_HMAC_SHA2_256,
+       _OID_TYPE_HMAC_SHA2_384,
+       _OID_TYPE_HMAC_SHA2_512,
+       _OID_TYPE_DES_CBC,
+       _OID_TYPE_DES_CBC_EDE3,
+       _OID_TYPE_AES_128_CBC,
+       _OID_TYPE_AES_192_CBC,
+       _OID_TYPE_AES_256_CBC,
+       _OID_TYPE_RC2_CBC,
+       _OID_TYPE_PKCS08,
+       _OID_TYPE_RSA_ENCRYPTION,
+       _OID_TYPE_UNKNOWN
+
+}; //_OidType;
+
+class _PkcsUtility
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This function takes the parameters for encryption and decryption of a message.
+        *
+        * @since                       2.1
+        *
+        * @return                      Returns a pointer to ByteBuffer, contains encrypted/decrypted output data,@n
+        *                                      else @c null if an error occurs.
+        * @param [in]          algo                                            An instance of Algorithm Identifier, contains the algorithm.
+        * @param [in]          derivedKey                                      An instance of ByteBuffer, contains derived key generated from _OID_TYPE_PBKDF2.
+        * @param [in]          dataIn                                          An instance of ByteBuffer, contains the input data.
+        * @param [in]          opMode                                          Specifies the Cipher Operation, contains the operation mode(encryption(1)/decryption(0)).
+        * @param [out]         None
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception           E_SYSTEM                                        Failed to operate openssl library.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::ByteBuffer* EncryptDecryptN(const AlgorithmIdentifier& algo, const Tizen::Base::ByteBuffer& derivedKey, const Tizen::Base::ByteBuffer& dataIn, int opMode);
+
+       /**
+        * This function takes the algorithm and return the _OidType enum value depending on the algorithm.
+        *
+        * @since                       2.1
+        *
+        * @return                      Returns a _OidType enum value.
+        * @param [in]          algorithm                                       String value that contains the algorithm like OID_PBKDF2 etc.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static _OidType ConvertOidToEnum(Tizen::Base::String algorithm);
+
+       /**
+        * This function takes the algorithm and return the defined standard nid value of algorithm.
+        *
+        * @since                       2.1
+        *
+        * @return                      Returns a defined standard nid value of algorithm.
+        * @param [in]          algorithm                                       String value that contains the algorithm like OID_PBKDF2 etc.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static int ConvertToNid(Tizen::Base::String algorithm);
+
+       /**
+        * This function takes the standard nid value of algorithm and return the algorithm Oid in String format.
+        *
+        * @since                       3.0
+        *
+        * @return                      Returns a algorithm Oid in String format.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::String ConvertToOid(int nid);
+
+       /**
+        * This function takes the standard asn1 tag value of an attribute and return the Pkcs08 tag value.
+        *
+        * @since                       3.0
+        *
+        * @return                      Returns a enum value contains Pkcs08 tag value.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Pkcs08TagValue ConvertToTagValue(int ans1Type);
+
+       /**
+        * This function takes the parameters of _OID_TYPE_PBKDF2 and return the X509_ALGOR structure of openssl same as AlgorithmIdentifier for _OID_TYPE_PBKDF2.
+        * It is used for creating the encoded data for _OID_TYPE_PBES2. This structure is used for pbe2->keyfunc. This function is used internally for encoding/decoding.
+        *
+        * @since                       2.1
+        *
+        * @return                      A pointer to the algorithm identifier structure of openssl,@n
+        *                                      else @c null if an error occurs.
+        * @param [in]          iter                                            Integer value contains the iteration count.
+        * @param [in]          pSaltValue                                      An instance of char pointer contains the salt value.
+        * @param [in]          saltLen                                         Integer value contains the salt length.
+        * @param [in]          prfNid                                          Integer value contain the nid value of hmac algorithm.
+        * @param [in]          keyLen                                          Integer value contains the derived key length.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static X509_algor_st* GenerateKdfParametersN(int iter, unsigned char* pSaltValue, int saltLen, int prfNid, int keyLen);
+
+       /**
+        * This function takes the pointer to the X509_ALGOR structure of openssl and the oid value of the algorithm amd return the
+        * algorithm parameters after parsing this openssl structure depending on the algorithm passed.
+        *
+        * @since                       2.1
+        *
+        * @return                      Returns a pointer to the IALgorithmParamters interface,@n
+        *                                      else @c null if an error occurs.
+        * @param [in]          algoOid                                         Oid value of the algorithm in string format.
+        * @param [in]          pAlgoObj                                        Pointer to the X509_ALGOR structure of openssl.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static IAlgorithmParameters* GernerateParametersFromOidN(Tizen::Base::String algoOid, X509_algor_st* pAlgoObj);
+
+       /**
+        * This function takes the pointer to the IAlgorithmParameters and the oid value of the algorithm and return the pointer to the
+        * X509_ALGOR  of openssl structure depending on the algorithm passed.
+        *
+        * @since                       2.1
+        *
+        * @return                      A pointer to the algorithm identifier structure of openssl,@n
+        *                                      else @c null if an error occurs.
+        * @param [in]          algoOid                 Oid value of the algorithm in string format.
+        * @param [in]          pAlgoParam              Pointer to the IAlgorithmParameters contains the parameters for any type depending on the algorithm.
+        * @param [out]         None
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @exception           E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static X509_algor_st* GenerateAlgorithmIdentifierStructureN(Tizen::Base::String algoOid, IAlgorithmParameters* pAlgoParam);
+
+       /**
+        * This function takes the algorithm oid and check whether the parameters exist for this algorithm or not.
+        *
+        * @since                       2.1
+        *
+        * @return                      Returns true if parameters supported for the input algorithm otherwise false.
+        * @param [in]          algorithm                                       Oid value of the algorithm in string format.
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_UNSUPPORTED_ALGORITHM         The input algorithm is not supported.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       static bool IsParameterSupported(Tizen::Base::String algorithm);
+
+private:
+       // This default constructor is intentionally declared as private because this class cannot be constructed.
+       //
+       // @since               2.1
+       _PkcsUtility(void);
+
+       // This default destructor is intentionally declared as private because this class cannot be constructed.
+       //
+       // @since               2.1
+       virtual ~_PkcsUtility(void);
+
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _PkcsUtility(const _PkcsUtility& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       _PkcsUtility& operator =(const _PkcsUtility& rhs);
+
+};
+
+} } } // Tizen::Security::Pkcs
+
+#endif //_FSEC_PKCS_INTERNAL_PKCS_UTILITY_H_
diff --git a/src/security/pkcs/FSecPkcs_Rc2CbcParametersImpl.cpp b/src/security/pkcs/FSecPkcs_Rc2CbcParametersImpl.cpp
new file mode 100644 (file)
index 0000000..7fec67e
--- /dev/null
@@ -0,0 +1,240 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Rc2CbcParametersImpl.cpp
+ * @brief              This is the implementation file for _Rc2CbcParametersImpl class.
+ *
+ * This header file contains the implementation of _Rc2CbcParametersImpl class.
+ *
+ */
+
+#include <new>
+#include <openssl/x509.h>
+#include <openssl/objects.h>
+#include <openssl/obj_mac.h>
+#include <openssl/evp.h>
+#include <unique_ptr.h>
+#include <FBaseErrors.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseInteger.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsRc2CbcParameters.h>
+
+#include "FSecPkcs_Rc2CbcParametersImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+_Rc2CbcParametersImpl::_Rc2CbcParametersImpl(void)
+       : __rc2ParameterVersion(0)
+{
+
+}
+
+_Rc2CbcParametersImpl::~_Rc2CbcParametersImpl(void)
+{
+
+}
+
+result
+_Rc2CbcParametersImpl::Construct(const Tizen::Base::ByteBuffer& initialVector, int version)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__initialVector.GetRemaining() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_SEC_CRYPTO, initialVector.GetRemaining() > 0, E_INVALID_ARG, "The specified input parameter is invalid.");
+
+
+       if (version == 160)
+       {
+               __rc2ParameterVersion = 160;
+       }
+       else if (version == 120)
+       {
+               __rc2ParameterVersion = 120;
+       }
+       else if (version == 58)
+       {
+               __rc2ParameterVersion = 58;
+       }
+       else if (version >= 256)
+       {
+               __rc2ParameterVersion = version;
+       }
+       else if (version == 0)
+       {
+               __rc2ParameterVersion = 0;
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+               return r;
+       }
+
+       r = __initialVector.Construct(initialVector);
+       SysTryReturnResult(NID_SEC_CRYPTO, !IsFailed(r), E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       return r;
+}
+
+const ByteBuffer&
+_Rc2CbcParametersImpl::GetInitialVector(void) const
+{
+
+       ClearLastResult();
+
+       SysAssertf(__initialVector.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __initialVector;
+}
+
+
+
+PkcsAlgorithmParameterType
+_Rc2CbcParametersImpl::GetType(void) const
+{
+       //Return the Parameter type
+       ClearLastResult();
+       return PKCS_ALGO_PARAM_TYPE_RC2;
+}
+
+int
+_Rc2CbcParametersImpl::GetVersion(void) const
+{
+       return __rc2ParameterVersion;
+}
+
+bool
+_Rc2CbcParametersImpl::Equals(const Object& obj) const
+{
+       result r = E_SUCCESS;
+       ByteBuffer initialVector;
+       std::unique_ptr< Tizen::Base::ByteBuffer > pInitialVector;
+       bool value = false;
+
+       const _Rc2CbcParametersImpl* pOther = dynamic_cast< const _Rc2CbcParametersImpl* >(&obj);
+
+       SysTryReturn(NID_SEC_CRYPTO, pOther != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
+
+       if (pOther == this)
+       {
+               return true;
+       }
+
+       r = initialVector.Construct(pOther->GetInitialVector());
+       SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), false, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       value = (__initialVector == initialVector) && (pOther->GetVersion() == __rc2ParameterVersion);
+
+       return value;
+}
+
+int
+_Rc2CbcParametersImpl::GetHashCode(void) const
+{
+       return __initialVector.GetHashCode() + Integer::GetHashCode(__rc2ParameterVersion);
+}
+
+ByteBuffer*
+_Rc2CbcParametersImpl::GetEncodedDataN(void) const
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+       int value = 0;
+       ASN1_TYPE* pAsn1Type = null;
+       ASN1_OCTET_STRING* pInitialVectorStr = null;
+       std::unique_ptr< ByteBuffer > pEncRc2CbcParam;
+       byte* pTemp = {0, };
+
+       ClearLastResult();
+
+       SysAssertf(__initialVector.GetRemaining() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       if (__rc2ParameterVersion == 0)
+       {
+               pInitialVectorStr = M_ASN1_OCTET_STRING_new();
+               SysTryCatch(NID_SEC_CRYPTO, pInitialVectorStr != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pInitialVectorStr->data = static_cast< unsigned char* >(OPENSSL_malloc(__initialVector.GetRemaining()));
+               SysTryCatch(NID_SEC_CRYPTO, pInitialVectorStr->data != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               pInitialVectorStr->length = __initialVector.GetRemaining();
+
+               memcpy(pInitialVectorStr->data, __initialVector.GetPointer(), __initialVector.GetRemaining());
+
+               value = i2d_ASN1_OCTET_STRING(pInitialVectorStr, &pTemp);
+               SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+               SysTryCatch(NID_SEC_CRYPTO, pTemp != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+               ASN1_OCTET_STRING_free(pInitialVectorStr);
+
+       }
+       else
+       {
+
+               pAsn1Type = ASN1_TYPE_new();
+               SysTryCatch(NID_SEC_CRYPTO, pAsn1Type != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               ret = ASN1_TYPE_set_int_octetstring(pAsn1Type, __rc2ParameterVersion, const_cast< unsigned char* >(__initialVector.GetPointer()), __initialVector.GetRemaining());
+               SysTryCatch(NID_SEC_CRYPTO, ret > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               value = i2d_ASN1_TYPE(pAsn1Type, &pTemp);
+               SysTryCatch(NID_SEC_CRYPTO, value > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+               SysTryCatch(NID_SEC_CRYPTO, pTemp != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+               ASN1_TYPE_free(pAsn1Type);
+       }
+
+       pEncRc2CbcParam = std::unique_ptr< ByteBuffer >(new (std::nothrow) ByteBuffer());
+       SysTryCatch(NID_SEC_CRYPTO, pEncRc2CbcParam, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncRc2CbcParam->Construct(value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pEncRc2CbcParam->SetArray(pTemp, 0, value);
+       SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pEncRc2CbcParam->Flip();
+
+CATCH:
+
+       OPENSSL_free(pTemp);
+       SetLastResult(r);
+       return pEncRc2CbcParam.release();
+
+
+}
+
+_Rc2CbcParametersImpl*
+_Rc2CbcParametersImpl::GetInstance(Rc2CbcParameters& rc2CbcParameters)
+{
+       return rc2CbcParameters.__pRc2CbcParametersImpl;
+}
+
+const _Rc2CbcParametersImpl*
+_Rc2CbcParametersImpl::GetInstance(const Rc2CbcParameters& rc2CbcParameters)
+{
+       return rc2CbcParameters.__pRc2CbcParametersImpl;
+}
+
+
+} } }
diff --git a/src/security/pkcs/FSecPkcs_Rc2CbcParametersImpl.h b/src/security/pkcs/FSecPkcs_Rc2CbcParametersImpl.h
new file mode 100644 (file)
index 0000000..6842a9b
--- /dev/null
@@ -0,0 +1,176 @@
+//
+// Open Service Platform
+// Copyright (c) 2013 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               FSecPkcs_Rc2CbcParametersImpl.h
+ * @brief              This is the header file for the %_Rc2CbcParametersImpl class.
+ *
+ * This header file contains the declarations of the %_Rc2CbcParametersImpl class.
+ */
+
+#ifndef _FSEC_PKCS_INTERNAL_RC2_CBC_PARAMETERS_H_
+#define _FSEC_PKCS_INTERNAL_RC2_CBC_PARAMETERS_H_
+
+#include <FBaseByteBuffer.h>
+#include <FSecPkcsIAlgorithmParameters.h>
+#include <FSecPkcsTypes.h>
+#include <FSecPkcsRc2CbcParameters.h>
+
+namespace Tizen { namespace Security { namespace Pkcs
+{
+
+/**
+ * @class              _Rc2CbcParametersImpl
+ * @brief              This class implements the functionalities specified by the Rc2 Cbc mode parameter.
+ * @brief              This class implements the functionalities specified by the Rc2 Cbc mode parameter.
+ *                                     This class represents the Rc2 cbc mode parameter for symmetric ciphers RC2.
+ *                                     ASN.1 format for RC2-CBC-Parameter ::= SEQUENCE {
+ *                                     rc2ParameterVersion INTEGER OPTIONAL,
+ *                                     iv OCTET STRING (SIZE(8)) }
+ *
+ * @since              2.1
+ *
+ */
+
+class _Rc2CbcParametersImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.1
+        */
+       _Rc2CbcParametersImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~_Rc2CbcParametersImpl(void);
+
+       /**
+        * Initializes this instance of %_Rc2CbcParametersImpl with supplied input parameters values.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   initialVector                   An instance of ByteBuffer containing the initial vector.
+        * @param[in]   version                                         An integer value defines the rc2 cbc parameter version.
+        *                                                                                                                      As per Pkcs 5 standard, possible value can be 160,120,58 or any value
+        *                                                                                                                      greater than or equal to 256.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result Construct(const Tizen::Base::ByteBuffer& initialVector, int version = 0);
+
+       /**
+        * Get the algorithm parameter type enum value for _Rc2CbcParametersImpl.
+        *
+        * @since               2.1
+        *
+        * @return              PkcsAlgorithmParameterType      Enum value  containing the PKCS_ALGO_PARAM_TYPE_RC2 value for _Rc2CbcParametersImpl parameter.
+        *
+        */
+       PkcsAlgorithmParameterType GetType(void) const;
+
+       /**
+        * Checks whether the specified instance of %_Rc2CbcParametersImpl equals the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the specified instance equals the current instance, @n
+        *              else @c false
+        * @param[in]   rhs                                             An instance of %_Rc2CbcParametersImpl
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %_Rc2CbcParametersImpl.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value indicating the hash value of the current instance of %_Rc2CbcParametersImpl
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Get the rc2 cbc parameter version value.
+        *
+        * @since               2.1
+        *
+        * @return              An integer value that contains the rc2 cbc parameter version.
+        *
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Get the instance of byte buffer that contains the Initial Vector value.
+        *
+        * @since               2.1
+        *
+        * @return              A reference to ByteBuffer , containing the initial vector data.
+        *
+        */
+       const Tizen::Base::ByteBuffer& GetInitialVector(void) const;
+
+       /**
+        * Gets the encoded form of the _Rc2CbcParametersImpl. @n
+        * It is assumed that each _Rc2CbcParametersImpl type will have only a single form of encoding that is DER encoding.
+        *
+        * @since               2.1
+        *
+        * @return              Pointer to the DER encoded ByteBuffer, @n
+        *                                              else @c null if an error occurs.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
+
+       static _Rc2CbcParametersImpl* GetInstance(Rc2CbcParameters& rc2CbcParameters);
+       static const _Rc2CbcParametersImpl* GetInstance(const Rc2CbcParameters& rc2CbcParameters);
+
+private:
+       // This copy constructor is intentionally declared as private to prohibit @n
+       // copying of objects by users.
+       //
+       // @since               2.1
+       _Rc2CbcParametersImpl(const _Rc2CbcParametersImpl& rhs);
+
+       // The implementation of this copy assignment operator is intentionally blank and @n
+       // declared as private to prohibit copying of objects.Use GetCloneN() to get an exact copy of the instance.
+       //
+       // @since               2.1
+       _Rc2CbcParametersImpl& operator =(const _Rc2CbcParametersImpl& rhs);
+
+private:
+       Tizen::Base::ByteBuffer __initialVector;
+       int __rc2ParameterVersion;      // OPTIONAL
+       friend class Rc2CbcParameters;
+
+}; // _Rc2CbcParametersImpl
+
+} } } // Tizen::Security::Pkcs
+
+#endif /* _FSEC_PKCS_INTERNAL_RC2_CBC_PARAMETERS_H_ */
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..beaeff7
--- /dev/null
@@ -0,0 +1,46 @@
+SET (this_target osp-appfw-server)
+
+INCLUDE_DIRECTORIES (
+       ${SLP_INCLUDE_DIRS}
+       ${CMAKE_SOURCE_DIR}/inc
+       ${CMAKE_SOURCE_DIR}/src/base/inc
+       ${CMAKE_SOURCE_DIR}/src/io/inc
+       ${CMAKE_SOURCE_DIR}/src/system/inc
+       ${CMAKE_SOURCE_DIR}/src/security/inc
+       ${CMAKE_SOURCE_DIR}/src/app/inc
+       inc
+       )
+
+SET (${this_target}_SOURCE_FILES
+       app/FApp_AulServer.cpp
+       io/FIo_IpcServer.cpp
+       )
+       
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} osp-appfw)
+
+SET_TARGET_PROPERTIES(${this_target}
+               PROPERTIES
+               VERSION ${FULLVER}
+               SOVERSION ${MAJORVER}
+               CLEAN_DIRECT_OUTPUT 1
+)
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+               POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} 
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+               COMMENT "strip ${this_target}"
+) 
diff --git a/src/server/app/CMakeLists.txt b/src/server/app/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..a4b51a4
--- /dev/null
@@ -0,0 +1,45 @@
+SET (this_target osp-appfw-server)
+
+INCLUDE_DIRECTORIES (
+       ${SLP_INCLUDE_DIRS}
+       ${CMAKE_SOURCE_DIR}/inc
+       ${CMAKE_SOURCE_DIR}/src/base/inc
+       ${CMAKE_SOURCE_DIR}/src/io/inc
+       ${CMAKE_SOURCE_DIR}/src/system/inc
+       ${CMAKE_SOURCE_DIR}/src/security/inc
+       ${CMAKE_SOURCE_DIR}/src/app/inc
+       inc
+       )
+
+SET (${this_target}_SOURCE_FILES
+       app/FApp_AulServer.cpp
+       )
+       
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} osp-appfw)
+
+SET_TARGET_PROPERTIES(${this_target}
+               PROPERTIES
+               VERSION ${FULLVER}
+               SOVERSION ${MAJORVER}
+               CLEAN_DIRECT_OUTPUT 1
+)
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+               POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} 
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+               COMMENT "strip ${this_target}"
+) 
diff --git a/src/server/app/FApp_AulServer.cpp b/src/server/app/FApp_AulServer.cpp
new file mode 100755 (executable)
index 0000000..d886e96
--- /dev/null
@@ -0,0 +1,618 @@
+//
+// 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        FApp_AulServer.cpp
+ * @brief      This is the implementation for the _AulServer.cpp class.
+ */
+#include <cstdio>
+#include <cstdlib>
+#include <new>
+#include <unistd.h>
+#include <sys/prctl.h>
+#include <signal.h>
+#include <unique_ptr.h>
+
+#include <aul.h>
+#include <bundle.h>
+#include <appsvc/appsvc.h>
+#include <app_manager.h>
+#include <heynoti.h>
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseUtil.h>
+#include <FBaseSysLog.h>
+#include <FBaseColHashMapT.h>
+#include <FAppPkgPackageInfo.h>
+
+#include <FBaseRt_Process.h>
+#include <FBase_StringConverter.h>
+#include "FAppPkg_PackageManagerImpl.h"
+#include "FApp_Types.h"
+#include "FApp_AulServer.h"
+#include "FApp_TemplateUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int aul_listen_app_dead_signal(int (* func)(int, void*), void* data);
+#ifdef __cplusplus
+}
+#endif
+
+using namespace Tizen::App::Package;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+
+namespace
+{
+
+const char _DESKTOP_FILE_PATH[] = "/opt/share/applications";
+const char _DESKTOP_FILE_PATH_FORMAT[] = "%s/%s.desktop";
+
+const char _X_TIZEN_SVC[] = "x-tizen-svc"; //X-TIZEN-SVC=[operation1] | [URI1] | [MIME1] ; [operation2] | [URI2] | [MIME2]
+const int _MAX_TIZEN_SVC_DESC_LEN = 1024;
+
+const int _MAX_CATEGORY = 12;
+const int _MAX_PACKAGE_ID_LENGTH = 10;
+
+const char _APP_PATH_FORMAT[] = "/opt/apps/0000000000/bin/%ls";
+
+}
+
+namespace Tizen { namespace App
+{
+
+struct _CategoryList
+{
+       const char category[_MAX_CATEGORY];
+       _AppType type;
+};
+
+static const _CategoryList _CATEGORY_LIST[] =
+{
+       {"home-screen", _APP_TYPE_HOME_APP},
+       {"lock-screen", _APP_TYPE_LOCK_APP},
+       {"ime", _APP_TYPE_IME_APP},
+};
+
+static const int _NUM_CATEGORY = sizeof(_CATEGORY_LIST) / sizeof(_CategoryList);
+
+
+result
+_AulServer::SendResult(bundle* b, appsvc_result_val res)
+{
+       result r = E_SUCCESS;
+
+       int ret = appsvc_send_result(b, res);
+
+       switch (ret)
+       {
+       case AUL_R_EINVAL:
+               r = E_INVALID_ARG;
+               SysLogException(NID_APP, r, "Invalid result bundle.");
+               break;
+
+       case AUL_R_ECOMM:
+               r = E_SYSTEM;
+               SysLogException(NID_APP, r, "Internal IPC error.");
+               break;
+
+       case AUL_R_ERROR:
+               r = E_SYSTEM;
+               SysLogException(NID_APP, r, "General error.");
+               break;
+
+       default:
+               break;
+       }
+
+       SysLog(NID_APP, "SendResult() ok");
+
+       return r;
+}
+
+
+bool
+_AulServer::IsRunning(const AppId& appId, const String& exeName)
+{
+       char slpPackageName[MAX_SLP_PACKAGE_ID] = {0, };
+       bool isRunning = false;
+
+       _PackageManagerImpl* pPackageManagerImpl = _PackageManagerImpl::GetInstance();
+       SysTryReturn(NID_APP, pPackageManagerImpl != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Invalid package instance.");
+
+       pPackageManagerImpl->GetPackageName(appId, &exeName, slpPackageName, MAX_SLP_PACKAGE_ID);
+
+       app_manager_is_running(slpPackageName, &isRunning);
+
+       SysLog(NID_APP, "'%s' %s running now.", slpPackageName, (isRunning == true) ? "is" : "is NOT");
+
+       return isRunning;
+}
+
+bool
+_AulServer::IsRunning(const String& packageName)
+{
+       bool isRunning = false;
+       std::unique_ptr<char[]> pSlpPackageName(_StringConverter::CopyToCharArrayN(packageName));
+
+       app_manager_is_running(pSlpPackageName.get(), &isRunning);
+
+       SysLog(NID_APP, "'%ls' %s running now.", packageName.GetPointer(), (isRunning) ? "is" : "is NOT");
+       return isRunning;
+}
+
+
+void
+_AulServer::SetOnAppTerminatedCb(int (* pf_app_dead_handler)(int pid, void* pData), void* pData)
+{
+       aul_listen_app_dead_signal(pf_app_dead_handler, pData);
+       SysLog(NID_APP, "'app_dead_handler is set.");
+}
+
+
+result
+_AulServer::TerminateApplicationByPid(int pid)
+{
+       int ret_aul = aul_terminate_pid(pid);
+       result r = E_SUCCESS;
+
+       switch (ret_aul)
+       {
+       case AUL_R_EINVAL:
+               r = E_INVALID_ARG;
+               SysLogException(NID_APP, r, "invaild pid.\n");
+               break;
+
+       case AUL_R_ECOMM:
+               r = E_SYSTEM;
+               SysLogException(NID_APP, r, "internal AUL IPC error.\n");
+               break;
+
+       case AUL_R_ERROR:
+               r = E_SYSTEM;
+               SysLogException(NID_APP, r, "general error.\n");
+               break;
+
+       default:
+               SysLog(NID_APP, "'%d' is terminated.", pid);
+               break;
+       }
+
+       return r;
+}
+
+result
+_AulServer::SetOomAdj(int pid, int adj)
+{
+       // set oom_adj to -17 for system service
+       result r = E_SUCCESS;
+       char buf[FILENAME_MAX];
+       FILE *fP = NULL;
+
+       snprintf(buf, FILENAME_MAX, "/proc/%d/oom_adj", pid);
+       fP = fopen(buf, "w");
+       SysTryReturnResult(NID_APP, fP != NULL, E_SYSTEM, "oom_adj change failed with %s.", strerror(errno));
+
+       fprintf(fP, "%d", adj);
+       fclose(fP);
+
+       return r;
+}
+
+result
+_AulServer::SetPowerOffNotiListener( void (*powerOffCb)(void *pData), void *pData)
+{
+       int heyFd = heynoti_init();
+       SysTryReturnResult(NID_APP, heyFd >= 0, E_SYSTEM, "heynoti_init failed.");
+
+       int ret = heynoti_subscribe(heyFd, "power_off_start", powerOffCb, pData);
+       SysTryReturnResult(NID_APP, ret >= 0, E_SYSTEM, "heynoti_subscribe failed.");
+
+       ret = heynoti_attach_handler(heyFd);
+       SysTryReturnResult(NID_APP, ret >= 0, E_SYSTEM, "heynoti_attach_handler failed.");
+
+       return E_SUCCESS;
+}
+
+int
+_AulServer::GetAppType(const String& category)
+{
+       int ret = 0;
+
+       HashMapT<String, int> map;
+       map.Construct();
+
+       StringTokenizer strTok(category, L';');
+
+       String token;
+       while (strTok.HasMoreTokens())
+       {
+               result r = strTok.GetNextToken(token);
+               if (r == E_SUCCESS)
+               {
+                       map.Add(token, 0);
+               }
+       }
+
+       SysLog(NID_APP, "%d category items .", map.GetCount());
+
+       String key;
+
+       for (int i = 0; i < _NUM_CATEGORY; i++)
+       {
+               bool b = false;
+               key = _CATEGORY_LIST[i].category;
+               result r = map.ContainsKey(key, b);
+               if (r == E_SUCCESS && b)
+               {
+                       ret |= _CATEGORY_LIST[i].type;
+               }
+       }
+
+       return ret;
+}
+
+bool _AulServer::IsInstalled(const AppId& appId)
+{
+       String packageId;
+       packageId = _PackageManagerImpl::GetPackageIdByAppId(appId);
+
+       return _PackageManagerImpl::GetInstance()->IsPackageInstalled(packageId);
+}
+
+int _AulServer::CreateProcess(const AppId& appId)
+{
+       SysTryReturn(NID_APP, appId.GetLength() > 10 && appId[10] == L'.', -1, E_INVALID_ARG, "[E_INVALID_ARG] Wrong appId %ls.", appId.GetPointer());
+
+       int pid = fork();
+
+       if (pid == -1)
+       {
+               return -1;
+       }
+       else if (pid == 0)
+       {
+               char path[FILENAME_MAX];
+               memset(path, '\0', FILENAME_MAX);
+
+               snprintf(path, FILENAME_MAX, _APP_PATH_FORMAT, appId.GetPointer() + 11);
+
+               int ret = wcstombs(path + strlen("/opt/apps/"), appId.GetPointer(), 10);
+               if (ret == -1)
+               {
+                       SysLogException(NID_APP, E_SYSTEM, "Launching service (%ls)(%s) failed with [%s].", appId.GetPointer(), path, strerror(errno));
+                       _Process::Exit(1);
+               }
+
+               SysLog(NID_APP, "Launching %s.", path);
+
+               int currentPid = getpid();
+
+               SetOomAdj(currentPid, -17); // set oom_adj to -17 for system service
+
+               prctl(PR_SET_PDEATHSIG, SIGTERM);
+
+               setpgid(currentPid, currentPid);
+
+               ret = execl(path, path, static_cast<char*>(NULL));
+               if (ret < 0)
+               {
+                       SysLogException(NID_APP, E_SYSTEM, "Launching service (%ls)(%s) failed with [%s].", appId.GetPointer(), path, strerror(errno));
+                       _Process::Exit(1);
+               }
+       }
+
+       return pid;
+
+}
+
+result
+_AulServer::_DesktopFile::MakePath(const AppId& appId, const String* pExeName, char* path, int size)
+{
+       SysTryReturnResult(NID_APP, path != null, E_INVALID_ARG, "");
+
+       char packageName[MAX_SLP_PACKAGE_ID] = {0, };
+       result r = E_SUCCESS;
+       _PackageManagerImpl* pPackageManagerImpl = _PackageManagerImpl::GetInstance();
+       SysTryReturnResult(NID_APP, pPackageManagerImpl, E_INVALID_STATE, "Invalid package manager instance.");
+
+       r = pPackageManagerImpl->GetPackageName(appId, pExeName, packageName, MAX_SLP_PACKAGE_ID);
+       SysTryReturn(NID_APP, !IsFailed(r), r, r, "%s", GetErrorMessage(r));
+
+       snprintf(path, size, _DESKTOP_FILE_PATH_FORMAT, _DESKTOP_FILE_PATH, packageName);
+
+       return r;
+}
+
+result
+_AulServer::_DesktopFile::UpdateService(const AppId& appId, const char* value)
+{
+       char path[FILENAME_MAX] = {0, };
+       MakePath(appId, null, path, FILENAME_MAX);
+
+       return UpdateField(path, _X_TIZEN_SVC, value);
+}
+
+
+result
+_AulServer::_DesktopFile::RemoveService(const AppId& appId, const char* operationOnlyValue)
+{
+       char path[FILENAME_MAX] = {0, };
+       MakePath(appId, null, path, FILENAME_MAX);
+
+       return UpdateField(path, _X_TIZEN_SVC, operationOnlyValue, true);
+}
+
+
+//
+// Update value of specified field.
+// currently only "x-slp-svc" field is supported.
+//
+#define BUFFER_SIZE 1024
+result
+_AulServer::_DesktopFile::UpdateField(const char* path, const char* fieldName, const char* value, bool isRemove)
+{
+       SysTryReturnResult(NID_APP, path != null, E_INVALID_ARG, "path should not be null.");
+       SysTryReturnResult(NID_APP, fieldName != null, E_INVALID_ARG, "fieldName should not be null.");
+       SysTryReturnResult(NID_APP, value != null, E_INVALID_ARG, "value should not be null.");
+
+       FILE* fp = fopen(path, "r+");
+       SysTryReturnResult(NID_APP, fp != null, E_SYSTEM, "falied to open '%s' due to %s", path, strerror(errno));
+
+       char buffer[BUFFER_SIZE] = {0, };
+       bool found = false;
+       int len = 0;
+       int pos = 0;
+       int foundpos = 0;
+       result r = E_SUCCESS;
+       int remains = 0;
+
+       ArrayListT<char*> buffers;
+       buffers.Construct();
+
+       char* pCurrent = null;
+
+       while (fgets(buffer, BUFFER_SIZE, fp) != NULL)
+       {
+               len = strlen(buffer);
+               SysTryCatch(NID_APP, len < BUFFER_SIZE, , r = E_INVALID_ARG, "strlen returns invalid value. (%d)", len );
+
+               if (found)
+               {
+                       pCurrent = new (std::nothrow) char[len + 1];
+                       SysTryCatch(NID_APP, pCurrent != null, , r = E_OUT_OF_MEMORY, "failed to allocate mem pCurrent");
+
+                       strncpy(pCurrent, buffer, len);
+                       buffers.Add(pCurrent);
+               }
+               else
+               {
+                       if (strncmp(buffer, fieldName, len) == 0)
+                       {
+                               int fieldNameLen = strlen(fieldName);
+                               SysTryCatch(NID_APP, len > fieldNameLen, , E_INVALID_ARG, "[E_INVALID_ARG] fieldName(%s)", fieldName);
+
+                               pCurrent = UpdateServiceValueN(buffer + fieldNameLen, value, isRemove);
+                               SysTryCatch(NID_APP, pCurrent != null, , r = GetLastResult(), "[%s] UpdateServiceValue failed", GetErrorMessage(GetLastResult()));
+
+                               buffers.Add(pCurrent);
+
+                               foundpos = pos;
+                               found = true;
+                       }
+               }
+
+               pos += len;
+       }
+
+       if (found)
+       {
+               fsetpos(fp, (fpos_t*) &foundpos);
+
+               remains = buffers.GetCount();   // prevent infinite loop
+               while (buffers.GetCount() > 0 && remains-- > 0)
+               {
+                       pCurrent = null;
+                       buffers.GetAt(0, pCurrent);
+                       buffers.RemoveAt(0);
+                       SysTryCatch(NID_APP, pCurrent != null, , r = E_INVALID_STATE, "");
+
+                       fputs(pCurrent, fp);
+                       len = strlen(pCurrent);
+                       pos += len;
+                       delete[] pCurrent;
+               }
+
+               int ret = truncate(path, pos);
+               SysTryLog(NID_APP, ret == 0, "Truncate failure (%s).", strerror(errno));
+       }
+       else
+       {
+               char svctext[_MAX_TIZEN_SVC_DESC_LEN] = {0, };
+               snprintf(svctext, _MAX_TIZEN_SVC_DESC_LEN, "%s=%s\n", fieldName, value);
+               fputs(svctext, fp);
+       }
+       fclose(fp);
+
+       return E_SUCCESS;
+
+CATCH:
+
+       remains = buffers.GetCount();   // prevent infinite loop
+       while (buffers.GetCount() > 0 && remains-- > 0)
+       {
+               pCurrent = null;
+               buffers.GetAt(0, pCurrent);
+               buffers.RemoveAt(0);
+               if (pCurrent != null)
+               {
+                       delete[] pCurrent;
+               }
+       }
+
+       fclose(fp);
+
+       return r;
+}
+
+//
+//     Tizen service string example
+//     X-TIZEN-SVC= http://tizen.org/appcontrol/operation/pick|NULL|image/jpge; http://tizen.org/appcontrol/operation/pick|NULL|video/mp4; http://tizen.org/appcontrol/operation/pick|NULL|NULL; http://tizen.org/appcontrol/operation/pview|NULL|NULL
+//
+char*
+_AulServer::_DesktopFile::UpdateServiceValueN(char* buffer, const char* newValue, bool isRemove)
+{
+       SysTryReturn(NID_APP, buffer != null, null, E_INVALID_ARG, "");
+       SysTryReturn(NID_APP, newValue != null, null, E_INVALID_ARG, "");
+
+       SysLog(NID_APP, "current(%s), new(%s), isRemove(%s)", buffer, newValue, (isRemove) ? "true" : "false");
+
+       String buf(buffer);
+       bool found = false;
+
+       const String& servicePattern(L"([A-Za-z&=:/\\.\\-]*);?");
+
+       ArrayList services;
+       String resultString;
+
+       Utility::RegularExpression regex;
+       result r = regex.Construct(servicePattern);
+       SysTryReturn(NID_APP, !IsFailed(r), null, r, "");
+
+       String newOperation;
+       String newUrl;
+       String newMimeType;
+       String newService(newValue);
+
+       if (isRemove == false)
+       {
+               ParseService(newService, newOperation, newUrl, newMimeType);
+       }
+       else
+       {
+               newOperation = newValue;
+       }
+
+       services.Construct();
+
+       while (regex.Consume(buf, &services) == true)
+       {
+               String* pCurrentService = (String*) services.GetAt(1);
+               services.RemoveAll(false);
+
+               String operation;
+               String url;
+               String mimeType;
+
+               ParseService(*pCurrentService, operation, url, mimeType);
+
+               if (operation == newOperation)
+               {
+                       if (isRemove == true)
+                       {
+                               SysLog(NID_APP, "opreration '%ls' will be removed", operation.GetPointer());
+                       }
+                       else
+                       {
+                               SysAssertf(found == false, "It's assumed that service doesn't have duplicated operation in tizen desktop file. But it isn't, so now we have to check this case.");
+                               // replace operation.
+                               if (found == false) // ( if duplicated operation is already exist, It will be keeped.
+                               {
+                                       // update value
+                                       AppendServiceValueToString(resultString, newService);
+                                       SysLog(NID_APP, "opreration '%ls;%ls;%ls' will be updated to ;%ls;%ls", operation.GetPointer(), url.GetPointer(), mimeType.GetPointer(), newUrl.GetPointer(), mimeType.GetPointer());
+                               }
+                       }
+                       found = true;
+               }
+               else
+               {
+                       // add not specified service.
+                       AppendServiceValueToString(resultString, *pCurrentService);
+               }
+
+               delete pCurrentService;
+       }
+
+       if (found == false && isRemove == false)
+       {
+               AppendServiceValueToString(resultString, newService);
+               SysLog(NID_APP, "opreration '%ls;%ls;%ls' will be added", newOperation.GetPointer(), newUrl.GetPointer(), newMimeType.GetPointer());
+       }
+
+       SysLog(NID_APP, "updated string is '%ls'", resultString.GetPointer());
+       return _StringConverter::CopyToCharArrayN(resultString);
+}
+
+
+void
+_AulServer::_DesktopFile::AppendServiceValueToString(String& serviceString, const String& newVaue)
+{
+       if (serviceString.GetLength() > 0)
+       {
+               serviceString += ";";
+       }
+
+       serviceString += newVaue;
+}
+
+
+result
+_AulServer::_DesktopFile::ParseService(const String& service, String& operation, String& url, String& mimeType)
+{
+       SysLog(NID_APP, "service(%ls)", service.GetPointer());
+
+       const String& serviceDetailPattern(L"([A-Za-z&=/\\.\\-]*):(.*://[A-Za-z&=/\\.\\-]*|[A-Za-z&=/\\.\\-]*):([A-Za-z&=/\\.\\-]*)");
+
+       Utility::RegularExpression regexDetail;
+       result r = regexDetail.Construct(serviceDetailPattern);
+       SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] RegularExpression::Construct(L\"%ls\") failed.", GetErrorMessage(r), serviceDetailPattern.GetPointer());
+
+       ArrayList matchedItems;
+       matchedItems.Construct();
+       regexDetail.Match(service, true, &matchedItems);
+
+       int matchedCount = matchedItems.GetCount();
+       SysTryLog(NID_APP, matchedCount == 4, "It's assumed that x-slp-svc value always have operation:url:mime in tizen desktop file. But it isn't or our parser is invalid. so now we have to check this case. %d", matchedItems.GetCount());
+
+       if (matchedCount > 1)
+       {
+               operation = *(String*) matchedItems.GetAt(1);
+       }
+
+       if (matchedCount > 2)
+       {
+               url = *(String*) matchedItems.GetAt(2);
+       }
+
+       if (matchedCount > 3)
+       {
+               mimeType = *(String*) matchedItems.GetAt(3);
+       }
+
+       SysLog(NID_APP, "matched(%d) : (%ls;%ls;%ls)", matchedItems.GetCount(), operation.GetPointer(), url.GetPointer(), mimeType.GetPointer());
+       matchedItems.RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+} } // Tizen::App
diff --git a/src/server/inc/FApp_AulServer.h b/src/server/inc/FApp_AulServer.h
new file mode 100755 (executable)
index 0000000..24b2df6
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// 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       FApp_AulServer.h
+ * @brief      This is the header file of the _AulServer class.
+ */
+
+#ifndef _FAPP_INTERNAL_AulServer_H_
+#define _FAPP_INTERNAL_AulServer_H_
+
+#include <appsvc/appsvc.h>
+#include <bundle.h>
+#include <FOspConfig.h>
+#include <FAppTypes.h>
+
+#define MAX_SLP_PACKAGE_ID 128
+
+namespace Tizen { namespace App
+{
+
+/**
+* @class       _AulServer
+* @brief       SysDep class for AppManager
+* @since 2.1
+* @final       This class it not intended for extension.
+*/
+class _OSP_EXPORT_ _AulServer
+{
+public:
+       static result TerminateApplicationByPid(int pid);
+
+       static result SendResult(bundle* b, appsvc_result_val res);
+
+       static bool IsRunning(const AppId& appId, const Tizen::Base::String& exeName);
+
+       static bool IsRunning(const Tizen::Base::String& packageName);
+
+       static void SetOnAppTerminatedCb(int (* pf_app_dead_handler)(int pid, void* pData), void* pData);
+
+       static result SetOomAdj(int pid, int adj);
+
+       static result SetPowerOffNotiListener(void (*powerOffCb)(void *pData), void *pData);
+
+       static int GetAppType(const Tizen::Base::String& category);
+
+       static bool IsInstalled(const AppId& appId);
+
+       static int CreateProcess(const Tizen::Base::String& appId);
+
+public:
+       /**
+        * This is static helper class for desktop file.
+        */
+       class _DesktopFile
+       {
+       public:
+               /**
+                * Updates the service value
+                * @param[in]   appId                   The application's ID to be executed
+                * @param[in]   value                   value to be added or updated.
+                *
+                * @remark              If operations is new, it will be appended.
+                *              but, if same operation is already exist, 'url' and 'mimeType' will be updated.
+                */
+               static result UpdateService(const AppId& appId, const char* value);
+
+               /**
+                * Removes the service value by operation
+                * @param[in]   appId   The application's ID to be executed
+                * @param[in]   operationOnlyValue      operationId of service to be removed
+                */
+               static result RemoveService(const AppId& appId, const char* operationOnlyValue);
+
+       private:
+               /**
+                * Updates value of specified field
+                */
+               static result UpdateField(const char* path, const char* key, const char* value, bool isRemove = false);
+
+               /**
+                * Makes desktop file path from appId (retrives appName using _PackageMamagerImpl)
+                */
+               static result MakePath(const AppId& appId, const Tizen::Base::String* pExeName, char* path, int size);
+
+               /**
+                * Update service value of input buffer with specified value
+                */
+               static char* UpdateServiceValueN(char* buffer, const char* newValue, bool isRemove = false);
+
+               /**
+                * Extracts each informations from one service string.
+                */
+               static result ParseService(const Tizen::Base::String& service, Tizen::Base::String& operation, Tizen::Base::String& url, Tizen::Base::String& mimeType);
+
+               static void AppendServiceValueToString(Tizen::Base::String& string, const Tizen::Base::String& newVaue);
+
+               friend class UTs_AulServer;
+       }; // _DesktopFile
+
+       friend class UTs_AulServer;
+}; // _AulServer
+
+} } // Tizen::App
+
+#endif // _FAPP_INTERNAL_AulServer_H_
similarity index 92%
rename from src/io/inc/FIo_IpcServer.h
rename to src/server/inc/FIo_IpcServer.h
index 9d4b3a5..7458d18 100644 (file)
@@ -51,29 +51,19 @@ class _IIpcServerEventListener;
 /**
  * @class _IpcServer
  * @brief This class provides methods to handle IPC request messages.
- * @since 2.1
  *
  */
 class _OSP_EXPORT_ _IpcServer
        : public Tizen::Base::Object
 {
 public:
-       /**
-        * This is the default constructor for this class.
-        * @since 2.1
-        */
        _IpcServer(void);
 
-       /**
-        * This is the destructor for this class.
-        * @since 2.1
-        */
        virtual ~_IpcServer(void);
 
        /**
         * Constructs the instance of this class and starts the IPC server.
         *
-        * @since 2.1
         * @return An error code
         * @param[in] name                      The name of IPC server
         * @param[in] listener          The listener for IPC server
@@ -88,7 +78,6 @@ public:
        /**
         * Returns the name of the IPC server.
         *
-        * @since 2.1
         * @return The name of the IPC server.
         */
        Tizen::Base::String GetName(void) const;
@@ -96,7 +85,6 @@ public:
        /**
         * Returns the id the of the client which sent a request message.
         *
-        * @since 2.1
         * @return The id of the IPC client.
         * @remark This can be called only in a message handler.
         */
@@ -105,34 +93,38 @@ public:
        /**
         * Returns the process id of the client which sent a request message.
         *
-        * @since 2.1
         * @return The process id of the IPC client.
         * @remark This can be called only in a message handler.
         */
        int GetClientProcessId(void) const;
 
        /**
-        * Returns the app id of the client which sent a request message.
+        * Returns the package id of the client which sent a request message.
         *
-        * @since 2.1
-        * @return The app id of the IPC client.
+        * @return The package id of the IPC client.
         * @remark This can be called only in a message handler.
         */
-       Tizen::App::AppId GetClientAppId(void) const;
+       Tizen::Base::String GetClientAppId(void) const;
 
        /**
         * Returns the executable name of the client which sent a request message.
         *
-        * @since 2.1
         * @return The executable name of the IPC client.
         * @remark This can be called only in a message handler.
         */
        Tizen::Base::String GetClientAppExecutableName(void) const;
 
        /**
+        * Returns the application id of the client which sent a request message.
+        *
+        * @return The application id of the IPC client.
+        * @remark This can be called only in a message handler.
+        */
+       Tizen::App::AppId GetClientApplicationId(void) const;
+
+       /**
         * Stops the IPC server.
         *
-        * @since 2.1
         * @return An error code
         * @exception E_SUCCESS         The method was successful.
         * @exception E_INVALID_STATE   The IPC server has not been started.
@@ -142,7 +134,6 @@ public:
        /**
         * Sends a message to an IPC client.
         *
-        * @since 2.1
         * @return An error code
         * @param[in] clientId      The id of the IPC client
         * @param[in] message   The message to send
@@ -184,7 +175,6 @@ private:
        /**
         *      @struct __ChannelInfo
         *      @brief  This struct represent a channel.
-        *      @since 2.1
         */
        struct  _ChannelInfo
        {
@@ -200,7 +190,6 @@ private:
        /**
         *      @struct __ClientInfo
         *      @brief  This struct represent a client connected to this server.
-        *      @since 2.1
         */
        struct  _ClientInfo
        {
@@ -211,7 +200,7 @@ private:
                _IpcServer* pIpcServer;                    /**< the pointer to an _ IpcServer */
                GIOChannel* pReverseChannel;               /**< the channel for sending reverse message */
                std::vector <struct _ChannelInfo*> channels;   /**< the set of channels associated with a client */
-               Tizen::Base::String appId;
+               Tizen::Base::String pkgId;
                Tizen::Base::String appExecutableName;
        };
 
similarity index 97%
rename from src/io/FIo_IpcServer.cpp
rename to src/server/io/FIo_IpcServer.cpp
index f1a9ebc..1888911 100644 (file)
@@ -84,7 +84,6 @@ _IpcServer::_ClientInfo::_ClientInfo(void)
        : clientId(-1)
        , pIpcServer(null)
        , pReverseChannel(null)
-       , appId("")
 {
 
 }
@@ -218,7 +217,7 @@ _IpcServer::Construct(const String& name, const _IIpcServerEventListener& listen
        SysTryCatch(NID_IO, ret == 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to change permission of a socket(%d, %s): %s", serverSocket,
                           socketName.c_str(), strerror(errno));
 
-       listen(serverSocket, 5);
+       listen(serverSocket, 15);
 
        pGIOChannel = g_io_channel_unix_new(serverSocket);
        SysTryCatch(NID_IO, pGIOChannel != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Not enough memory.");
@@ -276,7 +275,7 @@ struct HelloMessage
 {
        int pid;
        bool reverse;  // true if the connection is for reverse message
-       char appId[256];
+       char pkgId[256];
        char appExecutableName[256];
 };
 
@@ -305,7 +304,7 @@ _IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoi
        SysTryCatch(NID_IO, client != -1, , E_SYSTEM, "[E_SYSTEM] Accept failed.");
 
        read(client, &helloMessage, sizeof(helloMessage));
-       helloMessage.appId[255] = '\0';
+       helloMessage.pkgId[255] = '\0';
        helloMessage.appExecutableName[255] = '\0';
 
        pChannel = g_io_channel_unix_new(client);
@@ -325,12 +324,15 @@ _IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoi
 
                pClientInfo->pIpcServer = pIpcServer;
                pClientInfo->clientId = helloMessage.pid;
-               pClientInfo->appId.Append((wchar_t*) helloMessage.appId);
+               pClientInfo->pkgId.Append((wchar_t*) helloMessage.pkgId);
                pClientInfo->appExecutableName.Append((wchar_t*) helloMessage.appExecutableName);
                pClientInfo->pReverseChannel = null;
 
                pIpcServer->__clients[helloMessage.pid] = pClientInfo;
+
+               pIpcServer->__pCurrentClientInfo = pClientInfo;
                pIpcServer->__pListener->OnIpcClientConnected(*pIpcServer, helloMessage.pid);
+               pIpcServer->__pCurrentClientInfo = null;
        }
 
        if (helloMessage.reverse)
@@ -391,14 +393,14 @@ _IpcServer::GetClientProcessId(void) const
        return -1;
 }
 
-AppId
+String
 _IpcServer::GetClientAppId(void) const
 {
        static String nullString;
 
        if (__pCurrentClientInfo)
        {
-               return __pCurrentClientInfo->appId;
+               return __pCurrentClientInfo->pkgId;
        }
 
        return nullString;
@@ -417,6 +419,23 @@ _IpcServer::GetClientAppExecutableName(void) const
        return nullString;
 }
 
+AppId
+_IpcServer::GetClientApplicationId(void) const
+{
+       static String nullString;
+
+       if (__pCurrentClientInfo)
+       {
+               String appId(__pCurrentClientInfo->pkgId);
+               appId.Append(L'.');
+               appId.Append(__pCurrentClientInfo->appExecutableName);
+
+               return appId;
+       }
+
+       return nullString;
+}
+
 gboolean
 _IpcServer::HandleReceivedMessage(GIOChannel* source, GIOCondition condition, gpointer data)
 {
index 410fdb7..1dac104 100755 (executable)
@@ -16,6 +16,8 @@ INCLUDE_DIRECTORIES(
        )
 
 SET (${this_target}_SOURCE_FILES
+       FSys_CommunicationDispatcherClient.cpp
+       FSys_AlarmManager.cpp
        FSysAlarm.cpp
        FSys_AlarmImpl.cpp
        FSysBattery.cpp
@@ -28,7 +30,6 @@ SET (${this_target}_SOURCE_FILES
        FSys_RuntimeInfoImpl.cpp
        FSysSettingInfo.cpp
        FSys_SettingInfoImpl.cpp
-       FSys_DeviceId.cpp
        FSysSystemInfo.cpp
        FSys_SystemInfoImpl.cpp
        FSysSystemTime.cpp
@@ -40,8 +41,7 @@ SET (${this_target}_SOURCE_FILES
        FSysEnvironment.cpp
        FSys_EnvironmentImpl.cpp
        FSys_DeviceEventListenerContainer.cpp
-       FSys_SettingManager.cpp
-       FSys_SettingIcu.cpp
+       FSys_SettingClient.cpp
 )
 
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
@@ -61,11 +61,6 @@ ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES})
 ## SET LINKER FLAGS
 SET(CMAKE_SHARED_LINKER_FLAGS -Wl, --no-undefined)
 
-TARGET_LINK_LIBRARIES(${this_target} "-lnetwork")
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-wifi")
-TARGET_LINK_LIBRARIES(${this_target} "-lwifi-direct")
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-bluetooth")
-TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-tethering")
 TARGET_LINK_LIBRARIES(${this_target} "-lhaptic")
-TARGET_LINK_LIBRARIES(${this_target} "-lSLP-tapi")
-TARGET_LINK_LIBRARIES(${this_target} "-lsysman")
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-device")
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-power")
index 8610334..0c85e70 100644 (file)
@@ -65,13 +65,37 @@ PowerManager::KeepCpuAwake(bool enable)
 void
 PowerManager::SetScreenEventListener(IScreenEventListener& listener)
 {
-       _PowerManagerImpl::SetScreenEventListener(listener);
+       _PowerManagerImpl::AddScreenEventListener(listener, true);
+}
+
+result
+PowerManager::AddScreenEventListener(IScreenEventListener& listener)
+{
+       return _PowerManagerImpl::AddScreenEventListener(listener);
+}
+
+result
+PowerManager::RemoveScreenEventListener(IScreenEventListener& listener)
+{
+       return _PowerManagerImpl::RemoveScreenEventListener(listener);
 }
 
 void
 PowerManager::SetChargingEventListener(IChargingEventListener& listener)
 {
-       _PowerManagerImpl::SetChargingEventListener(listener);
+       _PowerManagerImpl::AddChargingEventListener(listener, true);
+}
+
+result
+PowerManager::AddChargingEventListener(IChargingEventListener& listener)
+{
+       return _PowerManagerImpl::AddChargingEventListener(listener);
+}
+
+result
+PowerManager::RemoveChargingEventListener(IChargingEventListener& listener)
+{
+       return _PowerManagerImpl::RemoveChargingEventListener(listener);
 }
 
 result
@@ -149,4 +173,16 @@ PowerManager::SetBatteryEventListener(IBatteryEventListener* pListener)
        return _PowerManagerImpl::SetBatteryEventListener(pListener);
 }
 
+result
+PowerManager::AddBootEventListener(IBootEventListener& listener)
+{
+       return _PowerManagerImpl::AddBootEventListener(listener);
+}
+
+result
+PowerManager::RemoveBootEventListener(IBootEventListener& listener)
+{
+       return _PowerManagerImpl::RemoveBootEventListener(listener);
+}
+
 } } //Tizen::System
index 2fe4fb7..ef5f86a 100644 (file)
@@ -115,6 +115,14 @@ SystemInfo::GetPlatformVersion(String& platformVersion)
 }
 
 result
+SystemInfo::GetBuildInfo(String& buildInfo)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_PLATFORMINFO);
+        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+       return _SystemInfoImpl::GetBuildInfo(buildInfo);
+}
+
+result
 SystemInfo::GetNativeApiVersion(String& nativeApiVersion)
 {
        result r = _AccessController::CheckUserPrivilege(_PRV_PLATFORMINFO);
index 9134864..d38db5b 100644 (file)
@@ -65,6 +65,24 @@ Vibrator::Construct(void)
        return r;
 }
 
+
+result
+Vibrator::Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount)
+{
+       result r = E_SUCCESS;
+       r = _AccessController::CheckUserPrivilege(_PRV_VIBRATOR);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+
+       SysAssertf(__pVibratorImpl != null, "Not yet constructed. Construct() should be called before use.");
+       SysTryReturn(NID_SYS, repeatCount > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Count is out of range.");
+
+       r = __pVibratorImpl->Start(patterns, length, repeatCount);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, r, r, "[%s] Error is occured", GetErrorMessage(r));
+
+        return r;
+}
+
+
 result
 Vibrator::Start(long onPeriod, long offPeriod, int count, int level)
 {
index 9f77bee..1996f5b 100644 (file)
 
 #include <FBaseRtIEventArg.h>
 #include <FBaseSysLog.h>
-#include <FBaseColArrayList.h>
-#include <FBaseStringComparer.h>
 
 #include <FBase_NativeError.h>
-#include <FIo_AppServiceIpcMessages.h>
-#include <FIo_IpcClient.h>
 #include "FSys_AlarmImpl.h"
+#include "FSys_AlarmManager.h"
 #include "FSys_SystemTimeImpl.h"
 
 using namespace Tizen::Base;
@@ -44,20 +41,6 @@ using namespace Tizen::Io;
 namespace Tizen { namespace System
 {
 
-static const wchar_t* _COMMUNICATION_DISPATCHER_IPC_ID = L"osp.app.ipcserver.communicationdispatcher";
-static const wchar_t* _ALARM_SERVICE_ID = L"osp.alarm.service";
-static const wchar_t* _ALARM_SET_SINGLEALARM = L"osp.alarm.set.singlealarm";
-static const wchar_t* _ALARM_SET_REPEATEDALARM = L"osp.alarm.set.repeatedalarm";
-static const wchar_t* _ALARM_CANCEL = L"osp.alarm.cancel";
-static const wchar_t* _ALARM_EXPIRY_EVENT = L"osp.alarm.expired.callback";
-static const wchar_t* _ALARM_RESULT_OK = L"osp.alarm.result.ok";
-
-const int _ALARM_SERVICE_IPC_MESSAGE_SERVICE_ID = 0;
-const int _ALARM_SERVICE_IPC_MESSAGE_COMMAND_ID = 1;
-const int _ALARM_SERVICE_RESPONSE_DATA = 2;
-const int _ALARM_SERVICE_ALARM_ID = 3;
-
-
 class _AlarmEventArg : public IEventArg
 {
 public:
@@ -93,189 +76,65 @@ protected:
 };
 
 _AlarmImpl::_AlarmImpl(Alarm* pAlarm)
-       : __pIpcClient(null)
+       : __alarmId(0)
        , __period(0)
-       , __pAlarmId(null)
        , __pEndTime(null)
+       , __isSetEndTime(false)
        , __pEvent(null)
        , __pAlarm(pAlarm)
 {
 
 }
 
-result
-_AlarmImpl::Construct(void)
-{
-       result r = E_SUCCESS;
-
-       if(__pIpcClient == null)
-       {
-               __pIpcClient = new (std::nothrow) _IpcClient();
-               SysTryReturnResult(NID_SYS, __pIpcClient != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-               r = __pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID, this);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "[%s] Error is occured", GetErrorMessage(r));
-       }
-
-       return r;
-}
-
 _AlarmImpl::~_AlarmImpl(void)
 {
-       result r = E_SUCCESS;
-
-       r = Cancel();
-       SysLog(NID_SYS, "Alarm cancel %s", IsFailed(r) ? "failed" : "succeed");
-
-       if(__pIpcClient != null)
+       if(__alarmId.value != 0)
        {
-               delete __pIpcClient;
-       }
-
-       if(__pAlarmId != null)
-       {
-               delete __pAlarmId;
+               Cancel();
        }
 }
 
-_IpcClient*
-_AlarmImpl::GetIpcClient(void)
+result
+_AlarmImpl::Construct(void)
 {
-       return __pIpcClient;
+       return E_SUCCESS;
 }
 
 result
-_AlarmImpl::Set(const Tizen::Base::DateTime& startTime, int period, const Tizen::Base::DateTime* pEndTime)
+_AlarmImpl::Set(const DateTime& startTime, int period, const DateTime* pEndTime)
 {
        result r = E_SUCCESS;
-       ArrayList requestMessage;
-       ArrayList responseMessage;
-       std::unique_ptr<IoService_Request> pRequest(null);
-
-       std::unique_ptr<String> pResult(null);
-       std::unique_ptr<String> pAlarmId(null);
-
-       int alarmVal = -1;
-
-       String startTimeStr;
-       String periodStr;
-       String serviceId = _ALARM_SERVICE_ID;
-       String commandId = _ALARM_SET_SINGLEALARM;
-       DateTime currentTime;
-
-       //Status check
-       SysTryReturnResult(NID_SYS, __pIpcClient != null, E_INVALID_STATE, "This instance has not been constructed as yet.");
-
-       //Argument check
-       r = SystemTime::GetCurrentTime(WALL_TIME, currentTime);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get current time");
-
-       SysTryReturnResult(NID_SYS, DateTime::Compare(currentTime, startTime) < 0, E_INVALID_ARG, "Designated start time has to be greater then current time");
+       _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
+       SysTryReturnResult(NID_SYS, pAlarmManager != null, E_SYSTEM, "It is failed to get AlarmManager.");
 
-       SysTryReturnResult(NID_SYS, period > -1, E_INVALID_ARG, "Period has to greater then -1");
+       __startTime = startTime;
+       __period = period;
 
        if(pEndTime != null)
        {
-               SysTryReturnResult(NID_SYS, DateTime::Compare(startTime, *pEndTime) < 0, E_INVALID_ARG, "Designated end time is less then start time");
+               DateTime* pRequiredEndTime = const_cast <DateTime*> (pEndTime);
+               __pEndTime = pRequiredEndTime;
+               __isSetEndTime = true;
        }
-
-       //Exist alarm check
-       if(__pAlarmId != null)
+       else
        {
-               SysLog(NID_SYS, "Alarm is already registered. Request to unregister to osp-app-service");
-               r = Cancel();
-
-               delete __pAlarmId;
-               __pAlarmId = null;
-
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to unregister exist alarm %s", GetErrorMessage(r));
-               SysLog(NID_SYS, "Exist alarm is unregistered successfully");
+               __isSetEndTime = false;
        }
 
-       //Alarm data construction
-       __startTime = startTime;
-       __period.value = period;
-
-       if(period > 0) //If period is 0, alarm is operated as Single alarm.
+       if(__alarmId.value == 0)
        {
-               commandId = _ALARM_SET_REPEATEDALARM;
+               r = pAlarmManager->RegisterAlarm(this);
        }
-
-       if(pEndTime != null)
+       else
        {
-               SysTryCatch(NID_SYS, startTime.CompareTo(*pEndTime) <= 0, r = E_INVALID_ARG, r, "Start time should be greater then the end time");
-               __pEndTime = new (std::nothrow) DateTime(*pEndTime);
-               SysTryCatch(NID_SYS, __pEndTime != null, r = E_SYSTEM, r, "__pEndTime should not be null");
+               r = pAlarmManager->UpdateAlarm(this);
        }
 
-       //IPC data construction
-       r = requestMessage.Construct();
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to create request instance");
-       r = responseMessage.Construct();
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to create response instance");
-
-       r = requestMessage.Add(serviceId);
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to add service id");
-       r = requestMessage.Add(commandId);
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to add command id");
-       startTimeStr = __startTime.ToString();
-       r = requestMessage.Add(startTimeStr);
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to add start time value");
-       periodStr = __period.ToString();
-       r = requestMessage.Add(periodStr);
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to add period value");
-
-       if(__pEndTime)
+       if(r != E_SUCCESS && r != E_INVALID_ARG)
        {
-               SysLog(NID_SYS, "End time is valid and adding to message");
-               std::unique_ptr<String> pEndTime(new (std::nothrow) String(__pEndTime->ToString()));
-               SysTryCatch(NID_SYS, pEndTime != null, r = E_SYSTEM, r, "pEndTime should not be null");
-
-               r = requestMessage.Add(*(pEndTime.release()));
-               SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to add end time value");
-       }
-
-       pRequest.reset(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
-       SysTryCatch(NID_SYS, pRequest != null, r = E_SYSTEM, r, "Failed to create Ipc message");
-
-       //IPC data delivery
-       r = __pIpcClient->SendRequest(pRequest.get());
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to send ipc message");
-       SysLog(NID_SYS, "Alarm reqeust is deliverted to osp-app-service successfully");
-
-       //IPC data response check
-       pResult.reset((String*)responseMessage.GetAt(_ALARM_SERVICE_RESPONSE_DATA));
-       SysTryCatch(NID_SYS, pResult != null, r = E_SYSTEM, r, "Failed to receive Ipc response");
-       SysTryCatch(NID_SYS, *pResult == _ALARM_RESULT_OK, r = E_SYSTEM, r, "Failed to create alarm");
-
-       pAlarmId.reset((String*)responseMessage.GetAt(_ALARM_SERVICE_ALARM_ID));
-       SysTryCatch(NID_SYS, pAlarmId != null, r = E_SYSTEM, r, "Failed to get Alarm Id");
-
-       Integer::Parse(*(pAlarmId.get()), alarmVal);
-
-       SysLog(NID_SYS, "Reserved alarm id is %d from osp-app-service.", alarmVal);
-
-       __pAlarmId = new (std::nothrow) Integer(alarmVal);
-       SysTryCatch(NID_SYS, __pAlarmId != null, r = E_SYSTEM, r, "Fail to copy alarm id");
-       SysTryCatch(NID_SYS, __pAlarmId->ToInt() >= 0, r = E_SYSTEM, r, "Alarm Id is invalid");
-
-CATCH:
-       if(r != E_SUCCESS)
-       {
-               if(__pEndTime != null)
-               {
-                       delete __pEndTime;
-                       __pEndTime = null;
-               }
-
-               if(__pAlarmId != null)
-               {
-                       delete __pAlarmId;
-                       __pAlarmId = null;
-               }
-       }       
-
+               SysLog(NID_SYS, "It is failed to register alarm. [%s]", GetErrorMessage(r));
+               r = E_SYSTEM;
+       }
        return r;
 }
 
@@ -283,120 +142,17 @@ result
 _AlarmImpl::Cancel(void)
 {
        result r = E_SUCCESS;
+       _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
+       SysTryReturnResult(NID_SYS, pAlarmManager != null, E_SYSTEM, "It is failed to get AlarmManager.");
 
-       ArrayList requestMessage;
-       ArrayList responseMessage;
-       std::unique_ptr<IoService_Request>pRequest(null);
-       std::unique_ptr<String> pResult(null);
-       std::unique_ptr<String> pAlarmIdStr(null);
-       String serviceId = _ALARM_SERVICE_ID;
-       String commandId = _ALARM_CANCEL;
-
-
-       //Status check
-       SysTryReturnResult(NID_SYS, __pIpcClient != null, E_INVALID_STATE, "This instance has not been constructed as yet.");
-       SysTryReturnResult(NID_SYS, __pAlarmId != null, r = E_SUCCESS, "Alarm is not created yet.");
-       SysTryCatch(NID_SYS, (__pAlarmId->ToInt()) != -1, r = E_SYSTEM, r, "Alarm is not created yet.");
-
-       //IPC data construction
-       r = requestMessage.Construct();
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to create request instance");
-       r = responseMessage.Construct();
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to create response instance");
-
-       r = requestMessage.Add(serviceId);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add service id");
-       r = requestMessage.Add(commandId);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add command id");
-       pAlarmIdStr.reset(new (std::nothrow) String(__pAlarmId->ToString()));
-       SysTryCatch(NID_SYS, pAlarmIdStr != null, r = E_SYSTEM, r, "pAlarmIdStr should not be null");
-
-       r = requestMessage.Add(*(pAlarmIdStr.release()));
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add alarm id value");
-
-       //IPC data delivery
-       pRequest.reset(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
-       SysTryCatch(NID_SYS, pRequest != null, r = E_SYSTEM, r, "Failed to create Ipc message");
-
-       r = __pIpcClient->SendRequest(pRequest.get());
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "Failed to send ipc message");
-       SysLog(NID_SYS, "Alarm cancel reqeust is deliverted to osp-app-service successfully");
-
-       //IPC data response check
-       pResult.reset((String*)responseMessage.GetAt(_ALARM_SERVICE_RESPONSE_DATA));
-       SysTryCatch(NID_SYS, pResult != null, r = E_SYSTEM, r, "Failed to receive Ipc response");
-       SysTryCatch(NID_SYS, *pResult == _ALARM_RESULT_OK, r = E_SUCCESS, r, "Failed to cancel alarm");
-
-CATCH:
-       if(__pAlarmId != null)
-       {
-               delete __pAlarmId;
-               __pAlarmId = null;
-       }
-       return r;
-}
-
-void
-_AlarmImpl::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message)
-{
-        IPC_BEGIN_MESSAGE_MAP(_AlarmImpl, message)
-               IPC_MESSAGE_HANDLER_EX(IoService_Data, &client, OnDataReceived)
-        IPC_END_MESSAGE_MAP_EX()
-}
-
-void
-_AlarmImpl::OnDataReceived(const ArrayList& data)
-{
-       result r = E_SUCCESS;
-       StringComparer stringComparer;
-       String alarmIdStr;
-
-       int cmp = 0;
-       std::unique_ptr<String> pServiceId((String*) data.GetAt(_ALARM_SERVICE_IPC_MESSAGE_SERVICE_ID));
-       std::unique_ptr<String> pCommandId((String*) data.GetAt(_ALARM_SERVICE_IPC_MESSAGE_COMMAND_ID));
-       std::unique_ptr<String> pData((String*) data.GetAt(_ALARM_SERVICE_RESPONSE_DATA));
-
-       String serviceId = _ALARM_SERVICE_ID;
-       String commandId = _ALARM_EXPIRY_EVENT;
+       r = pAlarmManager->UnregisterAlarm(this);
 
-       SysTryCatch(NID_SYS, pServiceId != null && pCommandId != null && pData != null, r = E_SYSTEM, 
-                                                E_SYSTEM, "There is no device data.");
-
-       stringComparer.Compare(*(pServiceId.release()), serviceId, cmp);
-       if(cmp == 0)
+       if(r != E_SUCCESS && r != E_INVALID_ARG)
        {
-               stringComparer.Compare(*(pCommandId.release()), commandId, cmp);
-               if(cmp == 0)
-               {
-                       if(__pAlarmId != null)
-                       {
-                               alarmIdStr = __pAlarmId->ToString();
-                               stringComparer.Compare(*(pData.release()), alarmIdStr, cmp);
-                               if(cmp == 0)
-                               {
-                                       OnAlarmExpired(__pAlarmId->ToInt());
-                               }
-                               else
-                               {
-                                       SysLog(NID_SYS, "Wrong alarm is delivered, Reserved alarm id of current instance is %d", __pAlarmId->value);
-                               }
-                       }
-                       else
-                       {
-                               SysLog(NID_SYS, "Current instance does not reserve alarm.");
-                       }
-               }
-               else
-               {
-                       SysLog(NID_SYS, "This is not alarm command.");
-               }
+               SysLog(NID_SYS, "It is failed to register alarm. [%s]", GetErrorMessage(r));
+               r = E_SYSTEM;
        }
-       else
-       {
-               SysLog(NID_SYS, "This is not alarm service.");
-       }
-CATCH:
-       SetLastResult(r);
+       return r;
 }
 
 const DateTime
@@ -438,7 +194,7 @@ _AlarmImpl::SetAlarmEventListener(IAlarmEventListener* pListener)
                {
                        _AlarmEvent* pAlarmEvent = new (std::nothrow) _AlarmEvent();
                        SysTryReturnResult(NID_SYS, pAlarmEvent != null, E_OUT_OF_MEMORY, "It is failed to create Event instance");
-                       __pEvent = pAlarmEvent;                                 
+                       __pEvent = pAlarmEvent;
                }
                __pEvent->AddListener(*pListener);
        }
diff --git a/src/system/FSys_AlarmManager.cpp b/src/system/FSys_AlarmManager.cpp
new file mode 100644 (file)
index 0000000..17589eb
--- /dev/null
@@ -0,0 +1,279 @@
+//
+// 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_AlarmManager.cpp
+ * @brief              This is the implementation file for _AlarmManager class.
+ */
+
+#include <unique_ptr.h>
+
+#include <FBaseSysLog.h>
+#include <FSysSystemTime.h>
+
+#include <FBase_NativeError.h>
+#include <FIo_AppServiceIpcMessages.h>
+
+#include "FSys_AlarmManager.h"
+#include "FSys_CommunicationDispatcherClient.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _ALARM_SERVICE_ID = L"osp.alarm.service";
+static const wchar_t* _ALARM_SET_SINGLEALARM = L"osp.alarm.set.singlealarm";
+static const wchar_t* _ALARM_SET_REPEATEDALARM = L"osp.alarm.set.repeatedalarm";
+static const wchar_t* _ALARM_CANCEL = L"osp.alarm.cancel";
+static const wchar_t* _ALARM_EXPIRED_EVENT = L"osp.alarm.expired.callback";
+static const wchar_t* _ALARM_RESULT_OK = L"osp.alarm.result.ok";
+
+const int _ALARM_SERVICE_IPC_MESSAGE_SERVICE_ID = 0;
+const int _ALARM_SERVICE_IPC_MESSAGE_COMMAND_ID = 1;
+const int _ALARM_SERVICE_RESPONSE_DATA = 2;
+const int _ALARM_SERVICE_ALARM_ID = 3;
+
+ _AlarmManager* _AlarmManager::pAlarmManager = null;
+
+_AlarmManager::_AlarmManager()
+: __pIpcClient(null)
+{
+       result r = E_SUCCESS;
+       static String ALARM_SERVICE_ID(_ALARM_SERVICE_ID);
+       __alarmList.Construct();
+
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+       SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is It is It is failed to get CommunicationDispatcherClient.");
+
+       r = pCommunicationDispatcherClient->RegisterCommunicationListener(ALARM_SERVICE_ID, *this);
+       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is It is It is failed to register on CommunicationDispatcherClient.");
+
+       __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
+
+CATCH:
+       SetLastResult(r);
+}
+
+_AlarmManager::~_AlarmManager()
+{
+}
+
+_AlarmManager*
+_AlarmManager::GetInstance(void)
+{
+       if(pAlarmManager == null)
+       {
+               pAlarmManager = new (std::nothrow) _AlarmManager();
+       }
+       return pAlarmManager;
+}
+
+result
+_AlarmManager::RegisterAlarm(_AlarmImpl* pAlarmImpl)
+{
+       SysTryReturnResult(NID_SYS, pAlarmImpl != null, E_INVALID_ARG, "There is no alarmImpl.");
+       Integer alarmId(pAlarmImpl->__alarmId.value);
+       SysTryReturnResult(NID_SYS, __alarmList.ContainsKey(alarmId) == false, E_OBJ_ALREADY_EXIST, "Required Alarm[%d] is already registered.", pAlarmImpl->__alarmId.value);
+
+       result r = E_SUCCESS;
+       ArrayList requestMessage;
+       ArrayList responseMessage;
+
+       String startTimeStr;
+       String periodStr;
+       String endTimeStr;
+
+       int period = pAlarmImpl->GetPeriod();
+       String serviceId = _ALARM_SERVICE_ID;
+       String commandId = _ALARM_SET_SINGLEALARM;
+       if(period > 0) //If period is 0, alarm is operated as Single alarm.
+       {
+               commandId = _ALARM_SET_REPEATEDALARM;
+       }
+
+       DateTime currentTime;
+       DateTime startTime = pAlarmImpl->GetStartTime();
+       const DateTime* pEndTime = pAlarmImpl->GetEndTime();
+
+       //Status check
+       SysTryReturnResult(NID_SYS, __pIpcClient != null, E_INVALID_STATE, "This instance has not been constructed as yet.");
+
+       //Argument check
+       r = SystemTime::GetCurrentTime(WALL_TIME, currentTime);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is It is failed to get current time");
+       SysTryReturnResult(NID_SYS, DateTime::Compare(currentTime, startTime) < 0, E_INVALID_ARG, "Designated start time has to be greater then current time");
+       SysTryReturnResult(NID_SYS, period > -1, E_INVALID_ARG, "Period has to greater then -1");
+
+       if(pEndTime != null)
+       {
+               SysTryReturnResult(NID_SYS, DateTime::Compare(startTime, *pEndTime) < 0, E_INVALID_ARG, "Designated end time is less then start time");
+       }
+       //End Alarm validation check
+
+       //IPC data construction
+       r = requestMessage.Construct();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to create request instance.");
+       r = responseMessage.Construct();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to create response instance.");
+
+       r = requestMessage.Add(serviceId);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to add service id.");
+       r = requestMessage.Add(commandId);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to add command id.");
+       startTimeStr = startTime.ToString();
+       r = requestMessage.Add(startTimeStr);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to add start time value.");
+       periodStr.Append(period);
+       r = requestMessage.Add(periodStr);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to add period value.");
+
+       if(pEndTime != null)
+       {
+               endTimeStr = pEndTime->ToString();
+               r = requestMessage.Add(endTimeStr);
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to add end time value.");
+       }
+
+       std::unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
+
+       //IPC data delivery
+       r = __pIpcClient->SendRequest(pRequest.get());
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is It is failed to send ipc message.");
+       SysLog(NID_SYS, "Alarm reqeust is deliverted to osp-app-service successfully.");
+
+       //IPC data response check
+
+       String* pResult = (String*)responseMessage.GetAt(_ALARM_SERVICE_RESPONSE_DATA);
+       SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "There is no result.");
+       SysTryReturnResult(NID_SYS, *pResult == _ALARM_RESULT_OK, E_SYSTEM, "It is It is failed to register alarm. [%ls]",  pResult->GetPointer());
+
+       String* pAlarmId = (String*)responseMessage.GetAt(_ALARM_SERVICE_ALARM_ID);
+       SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "There is no alarmId.");
+       SysLog(NID_SYS, "Reserved alarm id is %ls from osp-app-service.", pAlarmId->GetPointer());
+
+       int registeredAlarmId = 0;
+       Integer::Parse(*pAlarmId, registeredAlarmId);
+
+       pAlarmImpl->__alarmId.value = registeredAlarmId;
+       r = __alarmList.Add(&(pAlarmImpl->__alarmId), pAlarmImpl);
+       return r;
+}
+
+result
+_AlarmManager::UnregisterAlarm(_AlarmImpl* pAlarmImpl)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_SYS, pAlarmImpl != null, E_INVALID_ARG, "There is no alarmImpl.");
+
+       Integer alarmId(pAlarmImpl->__alarmId.value);
+       SysTryReturnResult(NID_SYS, __alarmList.ContainsKey(alarmId) == true, E_OBJ_NOT_FOUND, "There is no registered alarm.");
+       r = __alarmList.Remove(alarmId);
+
+       ArrayList requestMessage;
+       ArrayList responseMessage;
+       String serviceId(_ALARM_SERVICE_ID);
+       String commandId(_ALARM_CANCEL);
+
+       //Status check
+       SysTryReturnResult(NID_SYS, __pIpcClient != null, E_INVALID_STATE, "This instance has not been constructed as yet.");
+
+       //IPC data construction
+       r = requestMessage.Construct();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create request instance");
+       r = responseMessage.Construct();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create response instance");
+
+       r = requestMessage.Add(serviceId);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add service id");
+       r = requestMessage.Add(commandId);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add command id");
+
+       String alarmIdStr;
+       alarmIdStr.Append(alarmId.value);
+
+       r = requestMessage.Add(alarmIdStr);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add alarm id value");
+
+       //IPC data delivery
+       std::unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
+
+       r = __pIpcClient->SendRequest(pRequest.get());
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send ipc message.");
+       SysLog(NID_SYS, "Alarm cancel reqeust is deliverted to osp-app-service successfully");
+
+       //IPC data response check
+       String* pResult = (String*)responseMessage.GetAt(_ALARM_SERVICE_RESPONSE_DATA);
+       
+       SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "It is failed to receive Ipc response");
+       SysTryReturnResult(NID_SYS, *pResult == _ALARM_RESULT_OK, E_SYSTEM, "It is failed to cancel alarm");
+
+       return r;
+}
+
+result
+_AlarmManager::UpdateAlarm(_AlarmImpl* pAlarmImpl)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_SYS, pAlarmImpl != null, E_INVALID_ARG, "There is no alarmImpl.");
+
+       Integer alarmId(pAlarmImpl->__alarmId.value);
+       SysTryReturnResult(NID_SYS, __alarmList.ContainsKey(alarmId) == true, E_OBJ_NOT_FOUND, "There is no registered alarm.");
+
+       UnregisterAlarm(pAlarmImpl);
+       RegisterAlarm(pAlarmImpl);
+       return r;
+}
+
+void
+_AlarmManager::OnDataReceived(const Tizen::Base::Collection::ArrayList& data)
+{
+       SysLog(NID_SYS, "IPC message is delivered.");
+       String alarmIdStr;
+
+       String* pServiceId = (String*) data.GetAt(_ALARM_SERVICE_IPC_MESSAGE_SERVICE_ID);
+       String* pCommandId = (String*) data.GetAt(_ALARM_SERVICE_IPC_MESSAGE_COMMAND_ID);
+       String* pData = (String*) data.GetAt(_ALARM_SERVICE_RESPONSE_DATA);
+
+       SysLog(NID_SYS, "IPC message is delivered.");
+       String serviceId(_ALARM_SERVICE_ID);
+       String commandId(_ALARM_EXPIRED_EVENT);
+
+       SysTryReturnVoidResult(NID_SYS, pServiceId != null && pCommandId != null && pData != null, E_SYSTEM, "There is no device data.");
+
+       if(*pServiceId == serviceId && *pCommandId == commandId)
+       {
+               SysLog(NID_SYS, "Alarm expire event is delivered.");
+               int alarmId = 0;
+               Integer::Parse(*pData, alarmId);
+
+               Integer reservedAlarmId(alarmId);
+
+               _AlarmImpl* pAlarmImpl = (_AlarmImpl*)__alarmList.GetValue(reservedAlarmId);
+               if(pAlarmImpl != null)
+               {
+                       SysLog(NID_SYS, "Reserved Alarm[%d] is found.", alarmId);
+                       pAlarmImpl->OnAlarmExpired(alarmId);
+               }
+       }
+}
+
+} } // Tizen::System
diff --git a/src/system/FSys_AlarmManager.h b/src/system/FSys_AlarmManager.h
new file mode 100644 (file)
index 0000000..6ab79b1
--- /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_AlarmManager.h
+ * @brief              This is the header file for _AlarmManager class.
+ */
+
+#ifndef _FSYSTEM_INTERNAL_ALARM_MANAGER_H_
+#define _FSYSTEM_INTERNAL_ALARM_MANAGER_H_
+
+#include <FIo_IpcClient.h>
+#include <FSys_AlarmImpl.h>
+#include <FSys_ICommunicationDispatcherListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _AlarmManager
+       : public Tizen::System::_ICommunicationDispatcherListener
+{
+private:
+       _AlarmManager();
+       ~_AlarmManager();
+
+public:        
+       result RegisterAlarm(_AlarmImpl* pAlarmImpl);
+       result UnregisterAlarm(_AlarmImpl* pAlarmImpl);
+       result UpdateAlarm(_AlarmImpl* pAlarmImpl);
+       void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+
+public:
+       static _AlarmManager* GetInstance(void);
+
+private:
+       Tizen::Base::Collection::HashMap        __alarmList;
+       Tizen::Io::_IpcClient*                  __pIpcClient;
+
+       static _AlarmManager* pAlarmManager;
+};
+
+
+} } // Tizen::Sys
+
+#endif //_FSYSTEM_INTERNAL_ALARM_MANAGER_H_
diff --git a/src/system/FSys_CommunicationDispatcherClient.cpp b/src/system/FSys_CommunicationDispatcherClient.cpp
new file mode 100644 (file)
index 0000000..6c8ebcb
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// 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_CommunicationDispatcherClient.cpp
+ * @brief              This is the implementation file for _CommunicationDispatcherClient class.
+ */
+
+#include <FBaseSysLog.h>
+
+#include <FIo_AppServiceIpcMessages.h>
+
+#include "FSys_CommunicationDispatcherClient.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _COMMUNICATION_DISPATCHER_IPC_ID = L"osp.app.ipcserver.communicationdispatcher";
+
+_CommunicationDispatcherClient* _CommunicationDispatcherClient::__pCommunicationDispatcherClient = null;
+
+_CommunicationDispatcherClient::_CommunicationDispatcherClient()
+: __pIpcClient(null)
+{
+       __communicationDispatcherClientList.Construct(0, 0, __strHashCodeProvider, __strComparer);
+
+       result r = E_SUCCESS;
+       __pIpcClient = new (std::nothrow) _IpcClient();
+       SysTryCatch(NID_SYS, __pIpcClient != null, , r, "It is failed to create IPC client");
+
+       r = __pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID, this);
+       SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "Propagated. [%s]", GetErrorMessage(r));
+
+CATCH:
+       SetLastResult(r);
+
+}
+
+_CommunicationDispatcherClient::~_CommunicationDispatcherClient()
+{
+       delete __pIpcClient;
+       __pIpcClient = null;
+
+       __communicationDispatcherClientList.RemoveAll();
+}
+
+_CommunicationDispatcherClient*
+_CommunicationDispatcherClient::GetInstance()
+{
+       if(__pCommunicationDispatcherClient == null)
+       {
+               __pCommunicationDispatcherClient = new (std::nothrow) _CommunicationDispatcherClient();
+       }
+       return __pCommunicationDispatcherClient;
+}
+
+_IpcClient*
+_CommunicationDispatcherClient::GetIpcClient()
+{
+       return __pIpcClient;
+}
+
+result
+_CommunicationDispatcherClient::RegisterCommunicationListener(String key, _ICommunicationDispatcherListener& listener)
+{
+       result r = E_SUCCESS;
+       bool exist = false;
+
+       r = __communicationDispatcherClientList.ContainsKey(key, exist);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to check exist check.");
+       SysTryReturnResult(NID_SYS, exist == false, E_OBJ_ALREADY_EXIST, "Required key is already registered.");
+       r = __communicationDispatcherClientList.Add(key, &listener);
+
+       return r;
+}
+
+result
+_CommunicationDispatcherClient::UnregisterCommunicationListener(String key)
+{
+       result r = E_SUCCESS;
+       bool exist = false;
+       r = __communicationDispatcherClientList.ContainsKey(key, exist);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to check exist check.");
+       SysTryReturnResult(NID_SYS, exist == true, E_OBJ_NOT_FOUND, "Required key is not registered.");
+       r = __communicationDispatcherClientList.Remove(key);
+       return r;
+}
+
+void
+_CommunicationDispatcherClient::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message)
+{
+       SysLog(NID_SYS, "Enter.");
+       IPC_BEGIN_MESSAGE_MAP(_CommunicationDispatcherClient, message)
+       IPC_MESSAGE_HANDLER_EX(IoService_Data, &client, OnDataReceived)
+       IPC_END_MESSAGE_MAP_EX()
+       SysLog(NID_SYS, "Exit.");
+}
+
+void
+_CommunicationDispatcherClient::OnDataReceived(const ArrayList& data)
+{
+       result r = E_SUCCESS;
+       String* pServiceId = (String*) data.GetAt(0);
+
+        _ICommunicationDispatcherListener* listener = null;
+
+       SysTryReturnVoidResult(NID_SYS, pServiceId != null, E_SYSTEM, "There is no service id.");
+
+       r = __communicationDispatcherClientList.GetValue(*pServiceId, listener);
+
+       SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS && listener != null, E_SYSTEM, "Service[%ls] is available, but listener does not exist. [%s]", pServiceId->GetPointer(), GetErrorMessage(r));
+
+       listener->OnDataReceived(data);
+
+       SysLog(NID_SYS, "Message is delivered to \"%ls\"[%x]", pServiceId->GetPointer(), listener);
+}
+
+}}
diff --git a/src/system/FSys_CommunicationDispatcherClient.h b/src/system/FSys_CommunicationDispatcherClient.h
new file mode 100644 (file)
index 0000000..e11e68a
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// 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_CommunicationDispatcherClient.h
+ * @brief              This is the header file for the _CommunicationDispatcherClient class.
+ */
+
+#ifndef _FSYS_INTERNAL_COMMUNICATION_DISPATCHER_CLIENT_IMPL_H_
+#define _FSYS_INTERNAL_COMMUNICATION_DISPATCHER_CLIENT_IMPL_H_
+
+#include <FBaseString.h>
+#include <FBaseComparerT.h>
+#include <FBaseStringHashCodeProvider.h>
+#include <FBaseColHashMapT.h>
+
+#include <FIo_IpcClient.h>
+#include <FIo_IIpcClientEventListener.h>
+#include <FSys_ICommunicationDispatcherListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _CommunicationDispatcherClient
+       : public Tizen::Io::_IIpcClientEventListener
+{
+private:
+       _CommunicationDispatcherClient();
+       ~_CommunicationDispatcherClient();
+
+public:
+       result RegisterCommunicationListener(Tizen::Base::String key, _ICommunicationDispatcherListener& listener);
+       result UnregisterCommunicationListener(Tizen::Base::String key);
+       void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
+       void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+
+       Tizen::Io::_IpcClient* GetIpcClient(void);
+       static _CommunicationDispatcherClient* GetInstance(void);
+
+private:
+       Tizen::Io::_IpcClient*          __pIpcClient;
+       Tizen::Base::Collection::HashMapT<Tizen::Base::String, _ICommunicationDispatcherListener*>      __communicationDispatcherClientList;
+       Tizen::Base::ComparerT<Tizen::Base::String>                                                     __strComparer;
+       Tizen::Base::StringHashCodeProvider                                                             __strHashCodeProvider;
+
+private:
+       static _CommunicationDispatcherClient* __pCommunicationDispatcherClient;
+};
+
+}} // Tizen::System
+
+#endif //_FSYS_INTERNAL_COMMUNICATION_DISPATCHER_CLIENT_IMPL_H_
diff --git a/src/system/FSys_DeviceId.cpp b/src/system/FSys_DeviceId.cpp
deleted file mode 100644 (file)
index 753734c..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-//\r
-// Open Service Platform\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//     http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-/**\r
- * @file               FSys_DeviceId.cpp\r
- * @brief              This is the implementation file for _DeviceId class.\r
- */\r
-\r
-#include <stdlib.h>\r
-#include <wifi.h>\r
-\r
-#include <FSys_SystemInfoImpl.h>\r
-#include <FTextUtf8Encoder.h>\r
-#include <FTextUtf8Encoding.h>\r
-#include <FTextUtf8Decoder.h>\r
-#include <FBase_StringConverter.h>\r
-#include <FBaseSysLog.h>\r
-#include "FSys_DeviceId.h"\r
-\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Text;\r
-\r
-\r
-namespace Tizen { namespace System\r
-{\r
-\r
-#define POLYNOMIAL 0x04c11db7L\r
-\r
-const int _CONVERT_SIZE = 10;\r
-const int _CRC_TABLE_SIZE = 256;\r
-const int _CRYPT_KEY_SIZE = 8;\r
-const int _CRYPT_MAX_SIZE = 100;\r
-const int _DUID_LENGTH = 13;    // crc64() strlen * 8 / 5\r
-const int _IMEI_SIZE = 18;\r
-\r
-static const char BASE32_CHAR_SET[] = "abcdefghijklmnopqrstuvwxyz0123456789";\r
-\r
-String _DeviceId::__deviceId = "";\r
-\r
-unsigned long long int*\r
-GenCrc64Table(int size)\r
-{\r
-       int i, j;\r
-       unsigned long long int *pCrcTable = null;\r
-       unsigned long long int crcAccum = 0;\r
-\r
-       pCrcTable = (unsigned long long int*)malloc(sizeof(unsigned long long int) * size);\r
-       if(pCrcTable == null)\r
-       {\r
-               return null;\r
-       }\r
-\r
-       memset(pCrcTable, 0, sizeof(unsigned long long int) * size);\r
-\r
-       for(i=0; i<size; i++)\r
-       {\r
-               crcAccum = ((unsigned long long int) i << 56);\r
-               for(j=0; j<8;j++)\r
-               {\r
-                       if(crcAccum & 0x8000000000000000ULL)\r
-                       {\r
-                               crcAccum = (crcAccum << 1) ^ POLYNOMIAL;\r
-                       }\r
-                       else\r
-                       {\r
-                               crcAccum = (crcAccum << 1);\r
-                       }\r
-               }\r
-               pCrcTable[i] = crcAccum;\r
-       }\r
-\r
-       return pCrcTable;\r
-}\r
-\r
-result\r
-_DeviceId::GetId(Tizen::Base::String& deviceId)\r
-{\r
-       result r = E_SUCCESS;\r
-\r
-       if(__deviceId != "")\r
-       {\r
-               deviceId = __deviceId;\r
-               return r;\r
-       }\r
-\r
-\r
-       char* pImei = null;\r
-       char upperImei[_CONVERT_SIZE] = {0, };\r
-       char lowerImei[_CONVERT_SIZE] = {0, };\r
-       int upperImeiInt = 0;\r
-       int lowerImeiInt = 0;\r
-       String imei;\r
-\r
-       unsigned long long tempImei = 0;\r
-       unsigned long long tempRes = 0;\r
-\r
-       //0xCAFEBABECAFEBABE\r
-       const char keyValue[_CRYPT_KEY_SIZE] = {0xCA, 0xFE, 0xBA, 0xBE, 0xCA, 0xFE, 0xBA, 0xBE};\r
-\r
-       char pFirstCrypt[_CRYPT_KEY_SIZE + 1] = {0};\r
-       ByteBuffer crc64Input;\r
-       ByteBuffer crc64Result;\r
-       ByteBuffer base32Result;\r
-\r
-       Utf8Encoding utf8;\r
-       char* pWiFiMacAddress = null;\r
-\r
-       r = _SystemInfoImpl::GetImei(imei);\r
-\r
-       if(r != E_SUCCESS)\r
-       {\r
-               if(wifi_get_mac_address(&pWiFiMacAddress) == 0)\r
-               {\r
-                       imei.Clear();\r
-                       imei.Append("W");\r
-                       imei.Append(pWiFiMacAddress);\r
-                       free(pWiFiMacAddress);\r
-                       r = E_SUCCESS;\r
-               }\r
-       }\r
-\r
-       SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get IMEI or WIFI MAC Address");\r
-\r
-       pImei = _StringConverter::CopyToCharArrayN(imei);\r
-\r
-       SysTryCatch(NID_SYS, pImei != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] IMEI is null string", GetErrorMessage(r));\r
-\r
-       memcpy(upperImei, pImei, sizeof(byte) * _IMEI_SIZE / 2);\r
-       memcpy(lowerImei, pImei + _CONVERT_SIZE - 1, sizeof(byte) * _IMEI_SIZE / 2);\r
-\r
-       upperImeiInt = atoi(upperImei);\r
-       lowerImeiInt = atoi(lowerImei);\r
-\r
-       tempImei = upperImeiInt;\r
-       tempImei = (tempImei << 32) | (unsigned long long) lowerImeiInt;\r
-\r
-       for (int i = 0; i < _CRYPT_KEY_SIZE; i++)\r
-       {\r
-               pFirstCrypt[i] = (char) ((((char*) &tempImei)[i] ^ keyValue[i]));\r
-       }\r
-\r
-       r = crc64Input.Construct(_CRYPT_KEY_SIZE);\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to construct ByteBuffer", GetErrorMessage(r));\r
-\r
-       r = crc64Input.SetArray((byte*) pFirstCrypt, 0, _CRYPT_KEY_SIZE);\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to set array to ByteBuffer", GetErrorMessage(r));\r
-       crc64Input.Flip();\r
-\r
-       r = GenerateCrc64(crc64Input, tempRes);\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to generate CRC64 value", GetErrorMessage(r));\r
-\r
-       r = crc64Result.Construct(sizeof(tempRes));\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to construct ByteBuffer", GetErrorMessage(r));\r
-       r = crc64Result.SetArray((byte*) &tempRes, 0, sizeof(tempRes));\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to set array to ByteBuffer", GetErrorMessage(r));\r
-       crc64Result.Flip();\r
-\r
-       r = Base32Encode(crc64Result, base32Result);\r
-       SysTryCatch(NID_SYS, !IsFailed(r), , r, "[%s] Failed to encode as Base64", GetErrorMessage(r));\r
-\r
-       r = utf8.GetString(base32Result, __deviceId);\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to convert ByteBuffer to String", GetErrorMessage(r));\r
-\r
-       deviceId = __deviceId;\r
-CATCH:\r
-       if (pImei != null)\r
-       {\r
-               delete[] pImei;\r
-       }\r
-\r
-       return r;\r
-}\r
-\r
-result\r
-_DeviceId::GenerateCrc64(Tizen::Base::ByteBuffer& input, unsigned long long int& value)\r
-{\r
-       result r = E_SUCCESS;\r
-\r
-       byte* pPu8 = const_cast <byte*>(input.GetPointer());\r
-       unsigned long long int* pCrcTable = null;\r
-       int inputSize = input.GetRemaining();\r
-\r
-       value = 0ULL;\r
-\r
-       pCrcTable = GenCrc64Table(_CRC_TABLE_SIZE);\r
-\r
-       while (inputSize--)\r
-       {\r
-               value = pCrcTable[(value ^ *pPu8++) & 0xff] ^ (value >> 8);\r
-       }\r
-       free(pCrcTable);\r
-\r
-       return r;\r
-}\r
-\r
-result\r
-_DeviceId::Base32Encode(Tizen::Base::ByteBuffer& input, Tizen::Base::ByteBuffer& output)\r
-{\r
-       result r = E_SUCCESS;\r
-\r
-       byte* pEncodingPointer = null;\r
-       byte* pSrcPointer = null;\r
-       int i = 0;\r
-\r
-       const byte* pInputData = input.GetPointer();\r
-       int inputSize = input.GetRemaining();\r
-\r
-       byte* pBuffer = null;\r
-       int bufferLength = 0;\r
-\r
-       bufferLength = 8 * (inputSize / 5 + 1) + 1;\r
-       pBuffer = (byte*) calloc(1, bufferLength);\r
-       SysTryReturn(NID_SYS, pBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory");\r
-\r
-       pEncodingPointer = pBuffer;\r
-       pSrcPointer = const_cast<byte*>(pInputData);\r
-\r
-       for (i = 0; i < (byte) inputSize; i += 5)\r
-       {\r
-               pEncodingPointer[0] = BASE32_CHAR_SET[(pSrcPointer[0] >> 3)];\r
-               pEncodingPointer[1] = BASE32_CHAR_SET[((pSrcPointer[0] & 0x07) << 2) | ((pSrcPointer[1] & 0xc0) >> 6)];\r
-               pEncodingPointer[2] = (i + 1 < (byte) inputSize) ? BASE32_CHAR_SET[((pSrcPointer[1] & 0x3e) >> 1)] : '\0';\r
-               pEncodingPointer[3] = (i + 1 < (byte) inputSize) ? BASE32_CHAR_SET[((pSrcPointer[1] & 0x01) << 4) | ((pSrcPointer[2] & 0xf0) >> 4)] : '\0';\r
-               pEncodingPointer[4] = (i + 2 < (byte) inputSize) ? BASE32_CHAR_SET[((pSrcPointer[2] & 0x0f) << 1) | ((pSrcPointer[3] & 0x80) >> 7)] : '\0';\r
-               pEncodingPointer[5] = (i + 3 < (byte) inputSize) ? BASE32_CHAR_SET[((pSrcPointer[3] & 0x3e) >> 2)] : '\0';\r
-               pEncodingPointer[6] = (i + 3 < (byte) inputSize) ? BASE32_CHAR_SET[((pSrcPointer[3] & 0x03) << 3) | ((pSrcPointer[4] & 0xe0) >> 5)] : '\0';\r
-               pEncodingPointer[7] = (i + 4 < (byte) inputSize) ? BASE32_CHAR_SET[((pSrcPointer[4] & 0x1f))] : '\0';\r
-\r
-               pSrcPointer += 5;\r
-               pEncodingPointer += 8;\r
-       }\r
-\r
-       r = output.Construct(bufferLength);\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to construct ByteBuffer.");\r
-       r = output.SetArray(pBuffer, 0, bufferLength);\r
-       SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] Failed to set array to ByteBuffer.");\r
-       output.Flip();\r
-\r
-CATCH:\r
-       if (pBuffer != null)\r
-       {\r
-               delete[] pBuffer;\r
-       }\r
-       \r
-       return r;\r
-}\r
-\r
-}} // Tizen::System\r
-\r
diff --git a/src/system/FSys_DeviceId.h b/src/system/FSys_DeviceId.h
deleted file mode 100644 (file)
index 777257f..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// 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_DeviceId.h
- * @brief              This is the header file for _DeviceId class.
- */
-
-
-#ifndef _FSYS_INTERNAL_DEVICE_ID_H_
-#define _FSYS_INTERNAL_DEVICE_ID_H_
-
-
-#include <FOspConfig.h>
-
-namespace Tizen { namespace Base
-{
-class String;
-class ByteBuffer;
-}}
-
-namespace Tizen { namespace System
-{
-
-
-class _DeviceId
-{
-public:
-       /**
-        * Gets device unique ID.
-        *
-        * @since   1.0
-        * @return  An error code
-        * @param[out]  deviceId          The device unique ID.
-        * @exception   E_SUCCESS         The method is successful.
-        * @exception   E_OUT_OF_MEMORY   The memory is insufficient.
-        * @exception   E_SYSTEM          A system error has occurred.
-        */     
-       static result GetId(Tizen::Base::String& deviceId);
-
-private:
-       /**
-     * This is the default constructor for this class.
-     */
-       _DeviceId(void);
-
-       /**
-     * This is the destructor for this class.
-     */
-       ~_DeviceId(void);
-
-       static result GenerateCrc64(Tizen::Base::ByteBuffer& input, unsigned long long int& value);
-       static result Base32Encode(Tizen::Base::ByteBuffer& input, Tizen::Base::ByteBuffer& output);
-       static Tizen::Base::String __deviceId;
-}; //_DeviceId
-
-}}
-
-#endif // _FSYS_INTERNAL_DEVICE_ID_H_
index a602917..93d7713 100644 (file)
@@ -19,6 +19,7 @@
  * @file               FSys_DeviceManagerImpl.cpp
  * @brief              This is the implementation file for _DeviceManagerImpl class.
  */
+
 #include <pthread.h>
 #include <unique_ptr.h>
 #include <system_info.h>
@@ -39,6 +40,8 @@
 #include <FIo_IpcClient.h>
 #include <FSys_SystemInfoImpl.h>
 #include <FSys_PowerManagerImpl.h>
+
+#include "FSys_CommunicationDispatcherClient.h"
 #include "FSys_DeviceManagerImpl.h"
 
 #define VCONFKEY_APPSERVICE_MMC_STATUS "memory/appservice/mmc"
@@ -52,7 +55,6 @@ using namespace Tizen::Io;
 namespace Tizen { namespace System
 {
 
-static const wchar_t* _COMMUNICATION_DISPATCHER_IPC_ID = L"osp.app.ipcserver.communicationdispatcher";
 static const wchar_t* _DEVICE_MANAGER_SERVICE_ID = L"osp.devicemanager.service";
 static const wchar_t* _DEVICE_MANAGER_COMMAND_OPEN = L"osp.devicemanager.command.open";
 static const wchar_t* _DEVICE_MANAGER_COMMAND_CLOSE = L"osp.devicemanager.command.close";
@@ -81,6 +83,7 @@ static const wchar_t* _DEVICE_MANAGER_STATE_UNMOUNTED = L"Unmounted";
 static const wchar_t* _DEVICE_MANAGER_STATE_OPENED = L"Opened";
 static const wchar_t* _DEVICE_MANAGER_STATE_CLOSED = L"Closed";
 
+static const wchar_t* _SYSTEM_INFO_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
 static const wchar_t* _SYSTEM_INFO_INPUT_KEYBOARD = L"http://tizen.org/feature/input.keyboard";
 static const wchar_t* _SYSTEM_INFO_TVOUT_SUPPORTED = L"http://tizen.org/feature/screen.output.rca";
 
@@ -150,30 +153,33 @@ _DeviceManagerImpl::_DeviceManagerImpl()
        result r = E_SUCCESS;
        int headsetState = 0;
        int ret = 0;
+       static String DEVICE_MANAGER_SERVICE_ID(_DEVICE_MANAGER_SERVICE_ID);
+
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+       SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
 
-       __pIpcClient = new (std::nothrow) _IpcClient();
-       SysTryCatch(NID_SYS, __pIpcClient != null, , r, "Fail to create IPC client");
+       r = pCommunicationDispatcherClient->RegisterCommunicationListener(DEVICE_MANAGER_SERVICE_ID, *this);
+       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
 
-       r = __pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID, this);
-       SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "Propagated. [%s]", GetErrorMessage(r));
+       __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
 
        ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED, OnDeviceStateChanged, null);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to register USB event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register USB event");
 
        ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, OnDeviceStateChanged, null);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to register DEVICE_TYPE_CHARGER event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register DEVICE_TYPE_CHARGER event");
 
        ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, OnDeviceStateChanged, null);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to register TV out event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register TV out event");
 
        ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, OnDeviceStateChanged, null);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to register audio jack event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register audio jack event");
 
        ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, OnDeviceStateChanged, null);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to register sliding keyboard event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register sliding keyboard event");
 
        ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &headsetState);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to get audio jack status");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to get audio jack status");
 
        if (headsetState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
        {
@@ -192,10 +198,10 @@ _DeviceManagerImpl::_DeviceManagerImpl()
        {
                ret = vconf_notify_key_changed(VCONFKEY_APPSERVICE_MMC_STATUS, MmcEventVconfCallback, null);
        }
-       SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "Failed to register MMC event callback.");
+       SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "It is failed to register MMC event callback.");
 
        ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack, null);
-       SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "Failed to register HDMI event");
+       SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "It is failed to register HDMI event");
 
        __deviceEventList.Construct();
 
@@ -207,18 +213,20 @@ _DeviceManagerImpl::~_DeviceManagerImpl()
 {
        result r = E_SUCCESS;
        int ret = 0;
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = null;
+       String key(_DEVICE_MANAGER_SERVICE_ID);
 
        ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to unregister USB event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister USB event");
 
        ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to unregister TV out event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister TV out event");
 
        ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to unregister audio jack event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister audio jack event");
 
        ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to unregister sliding keyboard event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister sliding keyboard event");
 
        if (!_AppInfo::IsOspCompat())
        {
@@ -228,27 +236,22 @@ _DeviceManagerImpl::~_DeviceManagerImpl()
        {
                ret = vconf_ignore_key_changed(VCONFKEY_APPSERVICE_MMC_STATUS, MmcEventVconfCallback);
        }
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to unregister MMC event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister MMC event");
 
        ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack);
-       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "Failed to unregister HDMI event");
+       SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister HDMI event");
 
-CATCH:
-       delete __pIpcClient;
-       SetLastResult(r);
-}
 
-_IpcClient*
-_DeviceManagerImpl::GetIpcClient(void)
-{
-       if (__pDeviceManagerImpl != null)
-       {
-               return __pDeviceManagerImpl->__pIpcClient;
-       }
+       pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+       SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
 
-       SysLogException(NID_SYS, E_SYSTEM, "IPC component is not ready");
+       r = pCommunicationDispatcherClient->UnregisterCommunicationListener(key);
+       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
 
-       return null;
+       __pIpcClient = null;
+
+CATCH:
+       SetLastResult(r);
 }
 
 void
@@ -257,7 +260,7 @@ _DeviceManagerImpl::DeviceEventVConfCallBack(keynode_t* node, void* userData)
        int ret = 0;
        int value = 0;
        String event;
-       
+
        if (strcmp(VCONFKEY_SYSMAN_MMC_STATUS, vconf_keynode_get_name(node)) == 0)
        {
                SysLog(NID_SYS, "MMC callback is occured");
@@ -337,7 +340,7 @@ _DeviceManagerImpl::SendEvent(DeviceType deviceType, String& state)
                        _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
                        pEnumerator->GetCurrent(pDeviceEventListenerContainer);
                        SysTryReturnVoidResult(NID_SYS, pDeviceEventListenerContainer != null,E_SYSTEM, "Container is empty");
-                       
+
                        switch(deviceType)
                        {
                        case DEVICE_TYPE_BLUETOOTH_HEADSET:
@@ -448,27 +451,27 @@ _DeviceManagerImpl::RequireBluetoothEvent(void)
                ArrayList responseMessages;
 
                r = requestMessages.Construct();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to create request instance");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create request instance");
                r = responseMessages.Construct();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to create response instance");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create response instance");
 
                String serviceId = _DEVICE_MANAGER_SERVICE_ID;
                String commandId = _DEVICE_MANAGER_COMMAND_OPEN;
                String deviceId = _DEVICE_MANAGER_BLUETOOTH;
 
                r = requestMessages.Add(serviceId);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add service id");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add service id");
                r = requestMessages.Add(commandId);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add command id");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add command id");
                r = requestMessages.Add(deviceId);
 
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add device id (bluetooth)");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add device id (bluetooth)");
 
                pRequest.reset(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to send bluetooth event subscribe by IPC");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
 
                r = __pIpcClient->SendRequest(pRequest.get());
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS,E_SYSTEM, "Failed to add bluetooth id");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS,E_SYSTEM, "It is failed to add bluetooth id");
        }
        return r;
 }
@@ -489,26 +492,26 @@ _DeviceManagerImpl::ReleaseBluetoothEvent(void)
                ArrayList responseMessages;
 
                r = requestMessages.Construct();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to create request instance");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create request instance");
                r = responseMessages.Construct();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to create response instance");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create response instance");
 
                String serviceId = _DEVICE_MANAGER_SERVICE_ID;
                String commandId = _DEVICE_MANAGER_COMMAND_CLOSE;
                String deviceId = _DEVICE_MANAGER_BLUETOOTH;
 
                r = requestMessages.Add(serviceId);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add service id");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add service id");
                r = requestMessages.Add(commandId);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add command id");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add command id");
                r = requestMessages.Add(deviceId);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add bluetooth id");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add bluetooth id");
 
                pRequest.reset(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to send bluetooth event subscribe by IPC");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
 
                r = __pIpcClient->SendRequest(pRequest.get());
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to add bluetooth id");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add bluetooth id");
        }
        return r;
 }
@@ -645,7 +648,7 @@ _DeviceManagerImpl::AddOnExistedListener(DeviceType deviceType, const IDeviceEve
                                {
                                        bool keyboard = false;
                                        r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
-       
+
                                        SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
 
                                        if (keyboard == false)
@@ -694,7 +697,7 @@ _DeviceManagerImpl::AddOnExistedListener(DeviceType deviceType, const IDeviceEve
                                }
                                }
                        }
-               }               
+               }
        }
        return r;
 }
@@ -716,7 +719,7 @@ _DeviceManagerImpl::AddDeviceEventListener(DeviceType deviceType, IDeviceEventLi
                {
                        if(!_AppInfo::IsOspCompat())
                        {
-                               r = E_UNSUPPORTED_OPERATION;                                            
+                               r = E_UNSUPPORTED_OPERATION;
                        }
                        else
                        {
@@ -760,7 +763,7 @@ _DeviceManagerImpl::AddDeviceEventListener(DeviceType deviceType, IDeviceEventLi
        r = AddOnExistedListener(deviceType, pListener);
 
        if(r == E_OBJ_NOT_FOUND)
-       {               
+       {
                std::unique_ptr<_DeviceEventListenerContainer> pDeviceEventContainer(new (std::nothrow) _DeviceEventListenerContainer());
                SysTryReturnResult(NID_SYS, pDeviceEventContainer != null, E_OUT_OF_MEMORY, "It is failed to create instance of _DeviceEventListenerContainer");
 
@@ -829,7 +832,7 @@ _DeviceManagerImpl::AddDeviceEventListener(DeviceType deviceType, IDeviceEventLi
                {
                        bool keyboard = false;
                        r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
-       
+
                        SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
 
                        if (keyboard == false)
@@ -876,7 +879,7 @@ _DeviceManagerImpl::RemoveDeviceEventListener(DeviceType deviceType, IDeviceEven
        SysTryReturnResult(NID_SYS, pListener != null, E_INVALID_ARG, "There is no listener isntance.");
        SysTryReturnResult(NID_SYS, (deviceType >= DEVICE_TYPE_BLUETOOTH_HEADSET && deviceType <= DEVICE_TYPE_HDMI), E_INVALID_ARG, "There is no listener isntance.");
        SysTryReturnResult(NID_SYS, __deviceEventList.GetCount() > 0, E_INVALID_ARG, "There is no registered listener.");
-       
+
        std::unique_ptr< IEnumeratorT<_DeviceEventListenerContainer*> > pEnumerator(__deviceEventList.GetEnumeratorN());
 
        SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
@@ -891,7 +894,7 @@ _DeviceManagerImpl::RemoveDeviceEventListener(DeviceType deviceType, IDeviceEven
                {
                        if(!_AppInfo::IsOspCompat())
                        {
-                               r = E_UNSUPPORTED_OPERATION;                                            
+                               r = E_UNSUPPORTED_OPERATION;
                        }
                        else
                        {
@@ -948,7 +951,7 @@ _DeviceManagerImpl::RemoveDeviceEventListener(DeviceType deviceType, IDeviceEven
                                        return E_OBJ_NOT_FOUND;
                                }
                                pDeviceEventListenerContainer->__bluetoothHeadset = false;
-                               ReleaseBluetoothEvent();                                
+                               ReleaseBluetoothEvent();
                                break;
                        }
                        case DEVICE_TYPE_CHARGER:
@@ -1040,7 +1043,7 @@ result
 _DeviceManagerImpl::RemoveAllDeviceEventListeners(void)
 {
        result r = E_SUCCESS;
-       
+
        IEnumeratorT<_DeviceEventListenerContainer*>* pEnumerator = __deviceEventList.GetEnumeratorN();
        SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
 
@@ -1079,7 +1082,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &state);
                if (ret != RUNTIME_INFO_ERROR_NONE)
                {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get usb state");
+                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get usb state");
                        return;
                }
 
@@ -1102,7 +1105,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &state);
                if (ret != RUNTIME_INFO_ERROR_NONE)
                {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get charger state");
+                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get charger state");
                        return;
                }
 
@@ -1125,7 +1128,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &state);
                if (ret != RUNTIME_INFO_ERROR_NONE)
                {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get tv connect state");
+                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get tv connect state");
                        return;
                }
 
@@ -1145,7 +1148,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
                ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &state);
                if (ret != RUNTIME_INFO_ERROR_NONE)
                {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get audion jack state");
+                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get audion jack state");
                        return;
                }
 
@@ -1192,7 +1195,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, &state);
                if (ret != RUNTIME_INFO_ERROR_NONE)
                {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get keyboard state");
+                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get keyboard state");
                        return;
                }
 
@@ -1228,6 +1231,21 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
 
        case DEVICE_TYPE_BLUETOOTH_HEADSET:
        {
+               bool bluetooth = false;
+               r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_NETWORK_BLUETOOTH, bluetooth);
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option.");
+               if (bluetooth == false)
+               {
+                       if(!_AppInfo::IsOspCompat())
+                       {
+                               return E_UNSUPPORTED_OPERATION;
+                       }
+                       else
+                       {
+                               return E_DEVICE_UNAVAILABLE;
+                       }
+               }
+
                ArrayList requestMessages;
                ArrayList responseMessages;
 
@@ -1259,7 +1277,7 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        {
                bool chargerState = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &chargerState);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get charger state");
+               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get charger state");
 
                if (chargerState == true)
                {
@@ -1276,7 +1294,7 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        {
                bool cableState = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &cableState);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get usb state");
+               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get usb state");
 
                if (cableState == true)
                {
@@ -1309,7 +1327,7 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
 
                bool tvState = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &tvState);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get tv state");
+               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get tv state");
                if (tvState == true)
                {
                        state = _DEVICE_MANAGER_STATE_INSERTED;
@@ -1325,7 +1343,7 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        {
                int audioState = 0;
                ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &audioState);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get audio state");
+               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio state");
 
                if (audioState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE)
                {
@@ -1342,7 +1360,7 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        {
                int audioState = 0;
                ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &audioState);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get audio state");
+               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio state");
 
                if (audioState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
                {
@@ -1424,16 +1442,6 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
 }
 
 void
-_DeviceManagerImpl::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message)
-{
-       SysLog(NID_SYS, "Enter.");
-       IPC_BEGIN_MESSAGE_MAP(_DeviceManagerImpl, message)
-       IPC_MESSAGE_HANDLER_EX(IoService_Data, &client, OnDataReceived)
-       IPC_END_MESSAGE_MAP_EX()
-       SysLog(NID_SYS, "Exit.");
-}
-
-void
 _DeviceManagerImpl::OnDataReceived(const ArrayList& data)
 {
        StringComparer stringComparer;
@@ -1443,7 +1451,7 @@ _DeviceManagerImpl::OnDataReceived(const ArrayList& data)
        String* pCommandId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_COMMAND_ID);
        String* pDeviceId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_DEVICE_ID);
        String* pEventId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_DATA);
-       
+
        String serviceId = _DEVICE_MANAGER_SERVICE_ID;
        String commandId = _DEVICE_MANAGER_COMMAND_EVENT;
        String deviceId = _DEVICE_MANAGER_BLUETOOTH;
index 1836173..36797d8 100644 (file)
@@ -33,7 +33,8 @@
 #include <FBaseUuId.h>
 #include <FSysDeviceManager.h>
 
-#include <FIo_IIpcClientEventListener.h>
+#include <FIo_IpcClient.h>
+#include <FSys_ICommunicationDispatcherListener.h>
 #include <FSys_DeviceEventListenerContainer.h>
 
 namespace Tizen { namespace Base
@@ -52,7 +53,7 @@ namespace Tizen { namespace System
 {
 
 class _DeviceManagerImpl
-       : public Tizen::Io::_IIpcClientEventListener
+       : public Tizen::System::_ICommunicationDispatcherListener
 {
 private:
        _DeviceManagerImpl();
@@ -68,7 +69,6 @@ public:
 
        result RemoveAllDeviceEventListeners(void);
 
-       void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
 
        void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
 
@@ -78,8 +78,6 @@ public:
 
        static _DeviceManagerImpl* GetInstance(void);
 
-       static Tizen::Io::_IpcClient* GetIpcClient(void);
-
 private:
        _DeviceManagerImpl(const _DeviceManagerImpl& deviceManagerImpl);
 
similarity index 51%
rename from src/system/FSys_SettingIcu.h
rename to src/system/FSys_ICommunicationDispatcherListener.h
index b414b76..d980faa 100644 (file)
 //
 
 /**
- * @file               FSys_SettingIcu.cpp
- * @brief              This is the header file for _SettingIcu class.
+ * @file               FSys_ICommunicationDispatcherListener.h
+ * @brief              This is the header file for the _ICommunicationDispatcherListener class.
  */
 
-#include <unicode/ustring.h>
-#include <unicode/uloc.h>
-#include <unicode/utypes.h>
-#include <unicode/udat.h>
-#include <unicode/udatpg.h>
+
+#ifndef _FSYS_INTERNAL_ICOMMUNICATION_DISPATCHER_LISTENER_IMPL_H_
+#define _FSYS_INTERNAL_ICOMMUNICATION_DISPATCHER_LISTENER_IMPL_H_
+
+#include <FBaseColArrayList.h>
+#include <FBaseResult.h>
+#include <FBaseRtIEventListener.h>
 
 namespace Tizen { namespace System
 {
 
-class _SettingIcu
+class _ICommunicationDispatcherListener
+       : public Tizen::Base::Runtime::IEventListener
 {
 public:
-       _SettingIcu();
-       virtual ~_SettingIcu();
-       char* GetIcuPatternN(const char* pLocale, UChar* pCustomSkeleton);
-       char* GetDateTimeFormatN(const char* pIcuFormat);
+       virtual ~_ICommunicationDispatcherListener(void) {}
+       virtual void OnDataReceived(const Tizen::Base::Collection::ArrayList& data) = 0;
 };
-} } // Tizen::System
+
+}} // Tizen::System
+
+#endif //_FSYS_INTERNAL_ICOMMUNICATION_DISPATCHER_LISTENER_IMPL_H_
index efa1cb9..65b20b0 100644 (file)
@@ -26,6 +26,7 @@
 #include <power.h>
 #include <device.h>
 #include <runtime_info.h>
+#include <vconf.h>
 
 #include <FAppIActiveAppEventListener.h>
 #include <FBaseSysLog.h>
@@ -34,6 +35,7 @@
 #include <FSysIBatteryEventListener.h>
 #include <FSysIChargingEventListener.h>
 #include <FSysIScreenEventListener.h>
+#include <FSysIBootEventListener.h>
 #include <FSys_IPowerManagerEventListener.h>
 
 #include <FApp_AppImpl.h>
@@ -64,16 +66,21 @@ static const int _APPID_LENGTH = 10;
 static const int _DEACTIVATED_BRIGHTNESS_CONTROL = -1;
 static const float _BRIGHTNESS_RESOLUTION = 10.0;
 
+#ifndef VCONFKEY_SERVICE_READY
+#define VCONFKEY_SERVICE_READY "memory/appservice/serviceready"
+#endif
+
 bool _activeApp = false;
 bool _deviceCpuPowerOn = false;
 bool _keepCpuAwake = false;
 bool _keepScreenOnState = false;
 
 IBatteryEventListener* pIBatteryEventListener = null;
-IChargingEventListener* pIChargingEventListener = null;
-IScreenEventListener* pIScreenEventListener = null;
 
+ArrayListT<IScreenEventListener*>*     __pSceenEventList = null;
+ArrayListT<IChargingEventListener*>*   __pChargingEventList = null;
 ArrayListT<_IPowerManagerEventListener*>       __powerEventList;
+ArrayListT<IBootEventListener*>*       __pBootEventList = null;
 
 bool _PowerManagerImpl::_InitPowerManager = false;
 
@@ -89,9 +96,7 @@ void
 _ActiveEventListener::OnActiveAppChanged(const Tizen::App::AppId& appId)
 {
        int ret = 0;
-       String activeAppId;
-       appId.SubString(0, _APPID_LENGTH, activeAppId);
-       if(activeAppId == _AppInfo::GetAppId())
+       if(appId == _AppInfo::GetApplicationId())
        {
                _activeApp = true;
        }
@@ -102,14 +107,14 @@ _ActiveEventListener::OnActiveAppChanged(const Tizen::App::AppId& appId)
                if (_keepScreenOnState == true) //In case of Screen power control, it has to be released automatically, when application goes deactive state.
                {
                        ret = pm_unlock_state(LCD_NORMAL, GOTO_STATE_NOW);
-                       SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to unlock the power state");
+                       SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to unlock the power state");
                        _keepScreenOnState = false;
                }
 
                if (_keepCpuAwake == true || _deviceCpuPowerOn == true) //In case of CPU power control, it has to be keep despite of deactive state.
                {
                        ret = power_lock_state(POWER_STATE_SCREEN_OFF, 0);
-                       SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to lock the power state");
+                       SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to lock the power state");
                }               
        }
 }
@@ -179,13 +184,25 @@ RuntimeInfoChangedCallback(runtime_info_key_e key, void* userData)
 
        if(_AppInfo::GetAppState() == RUNNING)
        {
-               if (pIChargingEventListener != null)
+               if (__pChargingEventList != null)
                {
                        bool charging = false;
                        ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, &charging);
                        if (ret == 0)
                        {
-                               pIChargingEventListener->OnChargingStateChanged(charging);
+                               for(int i = 0; i < __pChargingEventList->GetCount(); i++)
+                               {
+                                       result r = E_SUCCESS;
+                                       IChargingEventListener* pIChargingEventListener = null;
+
+                                       r = __pChargingEventList->GetAt(i, pIChargingEventListener);
+
+                                       if (IsFailed(r) == false)
+                                       {
+                                               pIChargingEventListener->OnChargingStateChanged(charging);
+                                       }
+                               }
+
                        }
                }
        }
@@ -196,11 +213,21 @@ PowerChangedCallback(power_state_e state, void* userData)
 {
        std::unique_ptr< IEnumeratorT<_IPowerManagerEventListener*> > pEnumerator(__powerEventList.GetEnumeratorN());
        _IPowerManagerEventListener* pIPowerManagerEventListener = null;
-       if (pIScreenEventListener != null)
+
+       if (__pSceenEventList != null)
        {
                if (state == POWER_STATE_SCREEN_OFF)
                {
-                       pIScreenEventListener->OnScreenOff();
+                       for (int i = 0; i < __pSceenEventList->GetCount(); i++)
+                       {
+                               IScreenEventListener* pIScreenEventListener = null;
+                               result r = E_SUCCESS;
+                               r = __pSceenEventList->GetAt(i, pIScreenEventListener);
+                               if (IsFailed(r) == false)
+                               {
+                                       pIScreenEventListener->OnScreenOff();
+                               }
+                       }
 
                        if(pEnumerator != null)
                        {
@@ -217,7 +244,16 @@ PowerChangedCallback(power_state_e state, void* userData)
                }
                else
                {
-                       pIScreenEventListener->OnScreenOn();
+                        for (int i = 0; i < __pSceenEventList->GetCount(); i++)
+                        {
+                                IScreenEventListener* pIScreenEventListener = null;
+                                result r = E_SUCCESS;
+                                r = __pSceenEventList->GetAt(i, pIScreenEventListener);
+                                if (IsFailed(r) == false)
+                                {
+                                        pIScreenEventListener->OnScreenOn();
+                                }
+                        }
 
                        if(pEnumerator != null)
                        {
@@ -234,6 +270,45 @@ PowerChangedCallback(power_state_e state, void* userData)
        }
 }
 
+void
+ScreenEventVConfCallback(keynode_t* node, void* userData)
+{
+       int errorCode = 0;
+       int sysBrightness = 0;
+
+       if (__pSceenEventList == null)
+        {
+                SysLogException(NID_SYS, E_SYSTEM, "SceenEventList is not initialized.");
+                return;
+        }
+       errorCode = vconf_get_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, &sysBrightness);
+
+       if ( errorCode != 0)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It failed to get Screen brightness");
+               return;
+       }
+
+       for (int i = 0; i < __pSceenEventList->GetCount(); i++)
+       {
+               IScreenEventListener* pIScreenEventListener = null;
+               __pSceenEventList->GetAt(i, pIScreenEventListener);
+               if (pIScreenEventListener != null)
+               {
+                       int brightness = -1;
+                       int maxBrightness = -1;
+                       int ret = device_get_max_brightness(0, &maxBrightness);
+                       if (ret != 0)
+                       {
+                               SysLogException(NID_SYS, E_SYSTEM, "It failed to get the device max brightness");
+                               maxBrightness = 100;
+                       }
+                       brightness = (int)ceil(((_BRIGHTNESS_RESOLUTION / (float) maxBrightness)) * sysBrightness);
+                       pIScreenEventListener->OnScreenBrightnessChanged(brightness);
+               }
+       }
+}
+
 _PowerManagerImpl::_PowerManagerImpl(void)
 {
 }
@@ -264,8 +339,7 @@ _PowerManagerImpl::Term()
 bool
 _PowerManagerImpl::IsActive(void)
 {
-       AppId activeExcutable;
-       String activeAppId;
+       AppId appId;
        result r = E_SUCCESS;
        _AppManagerImpl* pAppManagerImpl = _AppManagerImpl::GetInstance();
 
@@ -275,12 +349,11 @@ _PowerManagerImpl::IsActive(void)
        }
        else
        {
-               r = pAppManagerImpl->GetActiveApp(activeExcutable);
-               activeExcutable.SubString(0, _APPID_LENGTH, activeAppId);
+               r = pAppManagerImpl->GetActiveApp(appId);
 
                if(r == E_SUCCESS)
                {
-                       if(activeAppId == _AppInfo::GetAppId())
+                       if(appId == _AppInfo::GetApplicationId())
                        {
                                _activeApp = true;
                        }
@@ -314,13 +387,13 @@ _PowerManagerImpl::KeepScreenOnState(bool keepOn, bool dimming)
                        state = LCD_NORMAL;
                }
                ret = pm_lock_state(state, GOTO_STATE_NOW, 0);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to lock the screen state");
+               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to lock the screen state");
                _keepScreenOnState = true;
        }
        else
        {
                ret = pm_unlock_state(LCD_NORMAL, GOTO_STATE_NOW);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to unlock the screen state");
+               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to unlock the screen state");
                _keepScreenOnState = false;
        }
 
@@ -336,7 +409,7 @@ _PowerManagerImpl::KeepCpuAwake(bool enable)
        if (enable)
        {
                ret = power_lock_state(POWER_STATE_SCREEN_OFF, 0);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to lock the power state");
+               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to lock the power state");
                _keepCpuAwake = true;
        }
        else
@@ -344,7 +417,7 @@ _PowerManagerImpl::KeepCpuAwake(bool enable)
                 if(_deviceCpuPowerOn == false)
                {
                        ret = power_unlock_state(POWER_STATE_SCREEN_OFF);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to unlock the power state");
+                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to unlock the power state");
                }
                _keepCpuAwake = false;
        }
@@ -359,7 +432,7 @@ _PowerManagerImpl::InitBatteryEvent(void)
        int ret = 0;
        ret = device_battery_warning_set_cb(DeviceBatteryWarnCallback, null);
 
-       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set the battery event");
+       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It failed to set the battery event");
 
        return E_SUCCESS;
 }
@@ -390,7 +463,7 @@ _PowerManagerImpl::RestoreScreenBrightness(void)
         SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
 
         r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] Fail to create IpcClient", GetErrorMessage(r));
+        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] It failed to create IpcClient", GetErrorMessage(r));
 
         requestMessage.Construct();
         responseMessage.Construct();
@@ -405,7 +478,7 @@ _PowerManagerImpl::RestoreScreenBrightness(void)
         SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message");
 
         r = pIpcClient->SendRequest(pMsg.get());
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] Fail to ipc message", GetErrorMessage(r));
+        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] It failed to ipc message", GetErrorMessage(r));
 
         unique_ptr<String> pResult((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA));
 
@@ -430,7 +503,7 @@ _PowerManagerImpl::SetScreenBrightness(int brightness)
        SysLog(NID_SYS, "Set brightness (%d)", brightness);
 
        ret = device_get_max_brightness(0, &maxBrightness);
-       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the device max brightness");
+       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It failed to get the device max brightness");
 
        actualBrightness = maxBrightness * brightness / _BRIGHTNESS_RESOLUTION;
 
@@ -441,7 +514,7 @@ _PowerManagerImpl::SetScreenBrightness(int brightness)
         SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
 
         r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] Fail to create IpcClient", GetErrorMessage(r));
+        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] It failed to create IpcClient", GetErrorMessage(r));
 
         requestMessage.Construct();
         responseMessage.Construct();
@@ -459,7 +532,7 @@ _PowerManagerImpl::SetScreenBrightness(int brightness)
         SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message");
 
         r = pIpcClient->SendRequest(pMsg.get());
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] Fail to ipc message", GetErrorMessage(r));
+        SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] It failed to ipc message", GetErrorMessage(r));
 
         unique_ptr<String> pResult((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA));
 
@@ -481,7 +554,7 @@ _PowerManagerImpl::GetScreenBrightness(void)
        ret = device_get_brightness(0, &brightness);
        if (ret != 0)
        {
-               SysLogException(NID_SYS, E_SYSTEM, "Failed to get the device brightness");
+               SysLogException(NID_SYS, E_SYSTEM, "It failed to get the device brightness");
                SetLastResult(E_SYSTEM);
                return _DEACTIVATED_BRIGHTNESS_CONTROL;
        }
@@ -495,7 +568,7 @@ _PowerManagerImpl::GetScreenBrightness(void)
        ret = device_get_max_brightness(0, &maxBrightness);
        if (ret != 0)
        {
-               SysLogException(NID_SYS, E_SYSTEM, "Failed to get the device max brightness");
+               SysLogException(NID_SYS, E_SYSTEM, "It failed to get the device max brightness");
                SetLastResult(E_SYSTEM);
                return _DEACTIVATED_BRIGHTNESS_CONTROL;
        }
@@ -523,7 +596,7 @@ _PowerManagerImpl::TurnScreenOn(void)
        result r = E_SUCCESS;
        int ret = power_wakeup(true);
 
-       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unlock the normal screen state");
+       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It failed to unlock the normal screen state");
 
        return r;
 }
@@ -534,7 +607,7 @@ _PowerManagerImpl::TurnScreenOff(void)
        result r = E_SUCCESS;
        int ret = pm_change_state(LCD_OFF);
 
-       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unlock the screen off screen state");
+       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It failed to unlock the screen off screen state");
 
        return r;
 }
@@ -542,38 +615,132 @@ _PowerManagerImpl::TurnScreenOff(void)
 void
 _PowerManagerImpl::SetScreenEventListener(IScreenEventListener& listener)
 {
-       int ret = 0;
+       result r = E_SUCCESS;
+
+       r = AddScreenEventListener(listener, true);
+
+       if (IsFailed(r))
+        {
+                SysLog(NID_SYS, "It failed to register ScreenEventListener");
+               return;
+        }
+       SysLog(NID_SYS,"It successed to register ScreenEventListener");
+}
+
+
+result
+_PowerManagerImpl::AddScreenEventListener(IScreenEventListener& listener, bool isSet)
+{
+       result r = E_SUCCESS;
 
-       if(pIScreenEventListener == null)
+       if (__pSceenEventList == null)
        {
-               ret = power_set_changed_cb(PowerChangedCallback, null);
+               std::unique_ptr< ArrayListT<IScreenEventListener*> > pSceenEventList(new ArrayListT<IScreenEventListener*>);
+               SysTryReturnResult(NID_SYS, pSceenEventList, E_SYSTEM, "Memory allocation failed");
+               pSceenEventList->Construct();
+               int errorCode = 0;
+               errorCode = vconf_notify_key_changed(VCONFKEY_PM_CURRENT_BRIGHTNESS, ScreenEventVConfCallback, null);
+               SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It failed to add ScreenEvent listener.");
 
-               if (ret == 0)
-               {
-                       pIScreenEventListener = &listener;
-               }
+               errorCode = power_set_changed_cb(PowerChangedCallback, null);
+               SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It failed to add ScreenEvent listener.");
+               __pSceenEventList = pSceenEventList.release();
+               SysLog(NID_SYS,"It successed to register power_set_changed_cb");
+       }
+
+       if (isSet == true && __pSceenEventList->GetCount() != 0)
+       {
+               r = __pSceenEventList->SetAt(&listener, 0);
        }
        else
        {
-               pIScreenEventListener = &listener;
+               r = __pSceenEventList->Add(&listener);
        }
+       return r;
+}
+
+
+result
+_PowerManagerImpl::RemoveScreenEventListener(IScreenEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_SYS,__pSceenEventList != null, E_OBJ_NOT_FOUND, "IScreenEventListener list is empty");
+
+       r = __pSceenEventList->Remove(&listener);
 
+       if (__pSceenEventList->GetCount() == 0)
+       {
+               delete __pSceenEventList;
+               __pSceenEventList = null;
+       }
+       return r;
 }
 
+
 void
 _PowerManagerImpl::SetChargingEventListener(IChargingEventListener& listener)
 {
-       int ret = 0;
+       result r = E_SUCCESS;
+
+       r = AddChargingEventListener(listener, true);
 
-       if(pIChargingEventListener == null)
+       if (IsFailed(r))
        {
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, RuntimeInfoChangedCallback, null);
-               if (ret != 0)
-               {
-                       SysLog(NID_SYS, "Failed to register battery charging  event");
-               }
+               SysLog(NID_SYS, "It failed to register battery charging  event");
+               return;
+       }
+}
+
+
+result
+_PowerManagerImpl::AddChargingEventListener(IChargingEventListener& listener, bool isSet)
+{
+        result r = E_SUCCESS;
+
+        if (__pChargingEventList == null)
+        {
+                __pChargingEventList = new ArrayListT<IChargingEventListener*>;
+                SysTryReturnResult(NID_SYS, __pChargingEventList, E_SYSTEM, "Memory allocation failed");
+                __pChargingEventList->Construct();
+                int errorCode = 0;
+               errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, RuntimeInfoChangedCallback, null);
+               if (errorCode != 0)
+                {
+                        SysLog(NID_SYS, "It failed to register battery charging  event");
+                       delete __pChargingEventList;
+                       __pChargingEventList = null;
+                       return E_SYSTEM;
+                }
+        }
+
+       if (isSet == false || __pChargingEventList->GetCount() == 0)
+       {
+               r = __pChargingEventList->Add(&listener);       
+       }
+       else
+       {
+               r = __pChargingEventList->SetAt(&listener, 0);
        }
-       pIChargingEventListener = &listener;
+        return r;
+}
+
+
+result
+_PowerManagerImpl::RemoveChargingEventListener(IChargingEventListener& listener)
+{
+        result r = E_SUCCESS;
+
+        SysTryReturnResult(NID_SYS,__pChargingEventList != null, E_OBJ_NOT_FOUND, "__pChargingEventList list is empty");
+
+        r = __pChargingEventList->Remove(&listener);
+
+        if (__pChargingEventList->GetCount() == 0)
+        {
+                delete __pChargingEventList;
+                __pChargingEventList = null;
+        }
+        return r;
 }
 
 result
@@ -589,7 +756,7 @@ _PowerManagerImpl::SetBatteryEventListener(IBatteryEventListener* pListener)
                        ret = device_battery_set_cb(DeviceBatteryCallback, null);
                        if (ret != 0)
                        {
-                               SysLog(NID_SYS, "Failed to register battery event");
+                               SysLog(NID_SYS, "It failed to register battery event");
                        }
                }
                pIBatteryEventListener = pListener;
@@ -600,7 +767,7 @@ _PowerManagerImpl::SetBatteryEventListener(IBatteryEventListener* pListener)
                ret = device_battery_unset_cb();
                if (ret != 0)
                {
-                       SysLog(NID_SYS, "Failed to unregister battery event");
+                       SysLog(NID_SYS, "It failed to unregister battery event");
                }
 
        }
@@ -616,7 +783,7 @@ _PowerManagerImpl::PowerControl(int deviceId, int level)
                if(level == _DEVICE_POWER_LEVEL_ON)
                {
                        ret = power_lock_state(POWER_STATE_SCREEN_OFF, 0);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to lock the power state");
+                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to lock the power state");
                        _deviceCpuPowerOn = true;
 
                        return E_SUCCESS;
@@ -626,7 +793,7 @@ _PowerManagerImpl::PowerControl(int deviceId, int level)
                        if(_keepScreenOnState == false)
                        {
                                ret = power_unlock_state(POWER_STATE_SCREEN_OFF);
-                               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to unlock the power state");                         
+                               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] It failed to unlock the power state");
                        }
                        _deviceCpuPowerOn = false;
                        return E_SUCCESS;
@@ -654,7 +821,7 @@ BatteryLevel
 _PowerManagerImpl::GetCurrentBatteryLevel(void)
 {
        int ret = 0;
-       int batteryLevel = 0;
+       //int batteryLevel = 0;
        BatteryLevel level = BATTERY_FULL;
        device_battery_warn_e batteryStatus = DEVICE_BATTERY_WARN_EMPTY;
 
@@ -722,6 +889,78 @@ _PowerManagerImpl::Remove_IPowerManagerEventListener(_IPowerManagerEventListener
        return E_SUCCESS;
 }
 
+static void
+BootEventVconfCallback(keynode_t* node, void* userData)
+{
+       if (__pBootEventList == null)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "BootEventList is not initialized.");
+               return;
+       }
+
+       int bootReady = -1;
+       const int errorCode = vconf_get_int(VCONFKEY_SERVICE_READY, &bootReady);
+
+       if (errorCode != 0)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It failed to get Boot event status");
+               return;
+       }
+
+       std::unique_ptr< IEnumeratorT<IBootEventListener*> > pEnum(__pBootEventList->GetEnumeratorN());
+
+       if (pEnum.get())
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       IBootEventListener* pListener = null;
+                       pEnum->GetCurrent(pListener);
+
+                       pListener->OnBootCompleted();
+               }
+       }
+
+       SysLog(NID_SYS, "Finished invoking boot complete event listener.");
+}
+
+result
+_PowerManagerImpl::AddBootEventListener(IBootEventListener& listener)
+{
+       if (__pBootEventList == null)
+       {
+               std::unique_ptr< ArrayListT<IBootEventListener*> > pBootEventList(new ArrayListT<IBootEventListener*>);
+               SysTryReturnResult(NID_SYS, pBootEventList, E_SYSTEM, "Memory allocation failed");
+               pBootEventList->Construct();
+
+               int errorCode = 0;
+               errorCode = vconf_notify_key_changed(VCONFKEY_SERVICE_READY, BootEventVconfCallback, null);
+               SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It failed to add BootEvent listener.");
+
+               __pBootEventList = pBootEventList.release();
+               SysLog(NID_SYS, "It successed to register boot event listener.");
+       }
+
+       return __pBootEventList->Add(&listener);
+}
+
+result
+_PowerManagerImpl::RemoveBootEventListener(IBootEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_SYS,__pBootEventList != null, E_OBJ_NOT_FOUND, "IBootEventListener list is empty");
+
+       r = __pBootEventList->Remove(&listener);
+
+       if (__pBootEventList->GetCount() == 0)
+       {
+               delete __pBootEventList;
+               __pBootEventList = null;
+       }
+
+       return E_SUCCESS;
+}
+
 _PowerManagerImpl*
 _PowerManagerImpl::GetInstance(PowerManager& powerManager)
 {
index 68f2441..0d4bf1d 100644 (file)
@@ -56,6 +56,7 @@ namespace Tizen { namespace System
 
 static const wchar_t* _ALLOCATED_MEMORY = L"AllocatedMemory";
 static const wchar_t* _MEMORY_ALLOCATED = L"http://tizen.org/runtime/memory.allocated";
+static const wchar_t* _MEMORY_ALLOCATED_SELF = L"http://tizen.org/runtime/memory.allocated.self";
 
 static const wchar_t* _AVAILABLE_EXTERNAL_STORAGE = L"AvailableExternalStorage";
 static const wchar_t* _STORAGE_AVAILABLE_EXTERNAL = L"http://tizen.org/runtime/storage.available.external";
@@ -226,7 +227,6 @@ protected:
                        {                               
                                pIntListener->OnResultReceivedForGetValueAsync(runtimeArg->intValue, runtimeArg->errorCode);
                                RemoveListener(listener);
-                               delete pIntListener;
                        }
                }
                break;
@@ -237,7 +237,6 @@ protected:
                        {
                                pLonglongListener->OnResultReceivedForGetValueAsync(runtimeArg->longLongValue, runtimeArg->errorCode);
                                RemoveListener(listener);
-                               delete pLonglongListener;
                        }
                }
                break;
@@ -278,66 +277,15 @@ _RuntimeInfoImpl::GetValue(const String& key, int& value)
                SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
                value = free_size * 1024;
        }
-       else if (key == _AVAILABLE_MEMORY || key == _AVAILABLE_VIDEO_MEMORY || key == _MAX_ALLOCATABLE_MEMORY || key == _MEMORY_AVAILABLE || key == _MEMORY_AVAILABLE_VIDEO)
+       else if (key == _AVAILABLE_MEMORY || key == _AVAILABLE_VIDEO_MEMORY || key == _MAX_ALLOCATABLE_MEMORY)
        {
                r = GetFromProc(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
                SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
                value = free_size * 1024;
        }
-       else if (key == _MEMORY_ALLOCATED || key == _MEMORY_ALLOCATED_VIDEO)
-       {
-               r = GetFromProc(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_TOTAL, total_size);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
-               r = GetFromProc(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
-               value = (total_size - free_size) * 1024;
-       }
        return r;
 }
 
-long long
-_RuntimeInfoImpl::GetDirectorySize(const char* path)
-{
-       if(path == null)
-       {
-               return 0;
-       }
-
-       char command[512] = {0,};
-       long long size = 0;
-       int ret = 0;
-
-       sprintf(command, "du -sk -P %s >> /tmp/size_of_directory.tmp", path);
-
-       system("rm -rf /tmp/size_of_directory.tmp");
-       system(command);
-
-       FILE* pFile = null;
-       pFile = fopen("/tmp/size_of_directory.tmp", "r");
-       if(pFile == null)
-       {
-               return 0;
-       }
-       ret = fscanf(pFile, "%lld", &size);
-
-       if(ret < 1)
-       {
-               if(pFile != null)
-               {
-                       fclose(pFile);
-               }
-
-               return false;
-       }
-
-       if(pFile != null)
-       {
-               fclose(pFile);
-       }
-       system("rm -rf /tmp/size_of_directory.tmp");
-       return size;
-}
-
 result
 _RuntimeInfoImpl::GetValue(const String& key, long long& value)
 {
@@ -360,6 +308,12 @@ _RuntimeInfoImpl::GetValue(const String& key, long long& value)
                SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
                value = (total_size - free_size) * 1024;
        }
+       else if (key == _MEMORY_ALLOCATED_SELF)
+        {   
+                r = GetFromProcLonglong(_PROC_PROCESS_MEMORY_INFO, _PROC_KEY_PROCESS_MEMORY, free_size);
+                SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
+                value = free_size * 1024;
+        } 
        else if (key == _AVAILABLE_INTERNAL_STORAGE)
        {
                return GetAvailableInternalStorage(value);
@@ -384,9 +338,56 @@ _RuntimeInfoImpl::GetValue(const String& key, long long& value)
        {
                return GetAvailableMediaStorage(value);
        }
+       else
+       {
+               SysLogException(NID_SYS, r, "Key[%ls] is not valid.", key.GetPointer());
+       }
        return r;
 }
 
+long long
+_RuntimeInfoImpl::GetDirectorySize(const char* path)
+{
+       if(path == null)
+       {
+               return 0;
+       }
+
+       char command[512] = {0,};
+       long long size = 0;
+       int ret = 0;
+
+       sprintf(command, "du -sk -P %s >> /tmp/size_of_directory.tmp", path);
+
+       system("rm -rf /tmp/size_of_directory.tmp");
+       system(command);
+
+       FILE* pFile = null;
+       pFile = fopen("/tmp/size_of_directory.tmp", "r");
+       if(pFile == null)
+       {
+               return 0;
+       }
+       ret = fscanf(pFile, "%lld", &size);
+
+       if(ret < 1)
+       {
+               if(pFile != null)
+               {
+                       fclose(pFile);
+               }
+
+               return 0;
+       }
+
+       if(pFile != null)
+       {
+               fclose(pFile);
+       }
+       system("rm -rf /tmp/size_of_directory.tmp");
+       return size;
+}
+
 result
 _RuntimeInfoImpl::GetValue(const String& key, double& value)
 {
diff --git a/src/system/FSys_SettingClient.cpp b/src/system/FSys_SettingClient.cpp
new file mode 100644 (file)
index 0000000..29eef74
--- /dev/null
@@ -0,0 +1,1075 @@
+//
+// 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_SettingClient.h"
+
+#include <FBaseSysLog.h>
+
+#include <FApp_AppInfo.h>
+#include <FIo_AppServiceIpcMessages.h>
+#include "FSys_CommunicationDispatcherClient.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+//MOTION
+static const wchar_t* _MOTION_UI = L"http://tizen.org/setting/motion.ui";
+static const wchar_t* _ENABLE_MOTION = L"EnableMotion";
+
+//Font
+static const wchar_t* _FONT_SIZE = L"http://tizen.org/setting/font.size";
+static const wchar_t* _FONTSIZE = L"FontSize";
+
+static const wchar_t* _FONT_TYPE = L"http://tizen.org/setting/font.type";
+static const wchar_t* _FONTTYPE = L"FontType";
+
+
+//Locale
+//Locale Country
+static const wchar_t* _LOCALE_COUNTRY = L"http://tizen.org/setting/locale.country";
+static const wchar_t* _COUNTRY = L"Country";
+
+//Locale Format
+static const wchar_t* _LOCALE_DATE_FORMAT = L"http://tizen.org/setting/locale.date.format";
+static const wchar_t* _DATE_FORMAT = L"DateFormat";
+
+static const wchar_t* _LOCALE_TIME_FORMAT = L"http://tizen.org/setting/locale.time.format";
+static const wchar_t* _TIME_FORMAT = L"TimeFormat";
+
+static const wchar_t* _LOCALE_TIME_FORMAT_24HOUR = L"http://tizen.org/setting/locale.time.format.24hour";
+static const wchar_t* _HOUR_FORMAT_SELECTED = L"24HourFormatSelected";
+
+//Locale Language
+static const wchar_t* _LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
+static const wchar_t* _LANGUAGE = L"Language";
+
+//Locale Time
+static const wchar_t* _LOCALE_DATETIME_FORMAT = L"http://tizen.org/setting/locale.date_time.format";
+static const wchar_t* _DATE_TIME_FORMAT = L"DateTimeFormat";
+
+
+//Location
+static const wchar_t* _LOCATION_GPS = L"http://tizen.org/setting/location.gps";
+static const wchar_t* _GPS_ENABLED = L"GPSEnabled";
+
+static const wchar_t* _LOCATION_WPS = L"http://tizen.org/setting/location.wps";
+static const wchar_t* _WPS_ENABLED = L"WPSEnabled";
+
+//Network
+static const wchar_t* _NETWORK_FLIGHTMODE = L"http://tizen.org/setting/network.flight_mode";
+static const wchar_t* _FLIGHT_MODE_ENABLED = L"FlightModeEnabled";
+
+//Network Telephony
+static const wchar_t* _NETWORK_TELEPHONY_PACKETSERVICE = L"http://tizen.org/setting/network.telephony.packet_service";
+static const wchar_t* _PACKET_SERVICE_ALLOWED = L"PacketServiceAllowed";
+
+static const wchar_t* _NETWORK_TELEPHONY_ROAMING = L"http://tizen.org/setting/network.telephony.roaming";
+static const wchar_t* _DATA_ROAMING_ENABLED = L"DataRoamingEnabled";
+
+//Screen
+static const wchar_t* _SCREEN_WALLPAPER = L"http://tizen.org/setting/screen.wallpaper";
+static const wchar_t* _WALLPAPER = L"Wallpaper";
+
+//Sound
+static const wchar_t* _SOUND_MEDIA_VOLUME = L"http://tizen.org/setting/sound.media.volume";
+static const wchar_t* _MEDIA_SOUND_VOLUME = L"MediaSoundVolume";
+
+static const wchar_t* _SOUND_NOTIFICATION_VOLUME = L"http://tizen.org/setting/sound.notification.volume";
+static const wchar_t* _NOTIFICATION_SOUND_VOLUME = L"NotificationSoundVolume";
+
+static const wchar_t* _SOUND_RINGTONE = L"http://tizen.org/setting/sound.ringtone";
+static const wchar_t* _RINGTONE = L"Ringtone";
+
+static const wchar_t* _SOUND_RINGTONE_VOLUME = L"http://tizen.org/setting/sound.ringtone.volume";
+static const wchar_t* _RINGTONE_SOUND_VOLUME = L"RingtoneSoundVolume";
+
+static const wchar_t* _SOUND_SYSTEM_VOLUME = L"http://tizen.org/setting/sound.system.volume";
+static const wchar_t* _SYSTEM_SOUND_VOLUME = L"SystemSoundVolume";
+
+static const wchar_t* _SOUND_SILENTMODE = L"http://tizen.org/setting/sound.silent_mode";
+static const wchar_t* _SILENT_MODE = L"SilentMode";
+
+//Vibration
+static const wchar_t* _TOUCH_VIBRATION_LEVEL = L"TouchVibrationLevel";
+static const wchar_t* _VIBRATOR_LEVEL = L"http://tizen.org/setting/vibrator.level";
+
+//USB
+static const wchar_t* _USBMODE = L"UsbMode";
+static const wchar_t* _USBMODE_MTP = L"MTP";
+
+static const wchar_t* _SETTING_SERVICE_ID = L"osp.setting.service";
+static const wchar_t* _SETTING_SERVICE_TYPE_EVENT = L"osp.setting.service.type.event";
+
+static const wchar_t* _SETTING_COMMAND_GET_BOOL = L"osp.setting.command.get.bool";
+static const wchar_t* _SETTING_COMMAND_SET_BOOL = L"osp.setting.command.set.bool";
+static const wchar_t* _SETTING_COMMAND_SET_BOOL_ASYNC = L"osp.setting.command.set.bool.async";
+static const wchar_t* _SETTING_COMMAND_GET_BOOL_PRIV = L"osp.setting.command.get.bool.priv";
+static const wchar_t* _SETTING_COMMAND_SET_BOOL_PRIV = L"osp.setting.command.set.bool.priv";
+static const wchar_t* _SETTING_COMMAND_SET_BOOL_ASYNC_PRIV = L"osp.setting.command.set.bool.async.priv";
+
+static const wchar_t* _SETTING_COMMAND_GET_INT = L"osp.setting.command.get.int";
+static const wchar_t* _SETTING_COMMAND_SET_INT = L"osp.setting.command.set.int";
+
+static const wchar_t* _SETTING_COMMAND_GET_STRING = L"osp.setting.command.get.string";
+static const wchar_t* _SETTING_COMMAND_SET_STRING = L"osp.setting.command.set.string";
+static const wchar_t* _SETTING_COMMAND_SET_STRING_PRIV = L"osp.setting.command.set.string.priv";
+static const wchar_t* _SETTING_COMMAND_SET_STRING_ASYNC = L"osp.setting.command.set.string.async";
+
+static const wchar_t* _SETTING_COMMAND_ADD_EVENT = L"osp.setting.command.add.event";
+static const wchar_t* _SETTING_COMMAND_REMOVE_EVENT = L"osp.setting.command.remove.event";
+
+static const wchar_t* _SETTING_COMMAND_SUPPORTED = L"osp.setting.command.supported";
+
+static const wchar_t* _SETTING_RESULT_SUCCESS = L"osp.system.result.success";
+static const wchar_t* _SETTING_RESULT_SYSTEM = L"osp.system.result.system";
+static const wchar_t* _SETTING_RESULT_INVALID_ARG = L"osp.system.result.invalid_arg";
+static const wchar_t* _SETTING_RESULT_PRIVILEGE_DENIED = L"osp.system.result.privilege_denied";
+static const wchar_t* _SETTING_RESULT_UNSUPPORTED_OPERATION = L"osp.system.result.unsupported_operation";
+static const wchar_t* _SETTING_RESULT_OBJ_NOT_FOUND = L"osp.system.result.obj_not_found";
+static const wchar_t* _SETTING_RESULT_OBJ_ALREADY_EXIST = L"osp.system.result.obj_already_exist";
+static const wchar_t* _SETTING_RESULT_IN_PROGRESS = L"osp.system.result.in_progress";
+
+_SettingClient* _SettingClient::__pSettingClient = null;
+
+class _SettingEventArg : public IEventArg
+{
+public:
+       String KeyName;
+};
+
+class _SettingEvent : public Event
+{
+public:
+       _SettingEvent()
+       : __count(0)
+       {
+       }
+
+       result AddSettingEventListener(ISettingEventListener& listener)
+       {
+               result  r = AddListener(listener);
+               SysTryReturnResult(NID_SYS, __count >= 0, E_SYSTEM, "Listenr count[%d] is error.", __count);
+
+               if(r == E_SUCCESS)
+               {
+                       __count++;
+               }
+               return r;
+       }
+
+       result RemoveSettingEventListener(ISettingEventListener& listener)
+       {
+               result  r = RemoveListener(listener);
+               SysTryReturnResult(NID_SYS, __count > 0, E_SYSTEM, "Listenr count[%d] is error.", __count);
+               if(r == E_SUCCESS)
+               {
+                       __count--;
+               }
+               return r;
+       }
+
+       int GetCount(void)
+       {
+               return __count;
+       }
+
+private:
+       int __count;
+protected:
+       virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
+       {
+               ISettingEventListener* pListener = dynamic_cast<ISettingEventListener*> (&listener);
+               const _SettingEventArg* pArg = dynamic_cast<const _SettingEventArg*>(&arg);
+
+               if(pListener == null || pArg == null)
+               {
+                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnt");
+                       return;
+               }
+
+               String value =pArg->KeyName;
+               pListener->OnSettingChanged(value);
+       }
+};
+
+class _SettingAsyncEventArg : public IEventArg
+{
+public:
+       String Key;
+       result errorCode;
+};
+
+class _SettingAsyncEvent : public Event
+{
+protected:
+       virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
+       {
+               ISettingInfoSetValueAsyncResultListener* pListener = dynamic_cast<ISettingInfoSetValueAsyncResultListener*> (&listener);
+               const _SettingAsyncEventArg* pArg = dynamic_cast<const _SettingAsyncEventArg*>(&arg);
+
+               if(pListener == null || pArg == null)
+               {
+                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnt");
+                       return;
+               }
+
+               result r = pArg->errorCode;
+               pListener->OnResultReceivedForSetValueAsync(pArg->Key, r);
+               RemoveListener(listener);
+       }
+};
+
+void
+_SettingClient::InitSettingClient(void)
+{
+       static _SettingClient settingManager;
+       __pSettingClient = &settingManager;
+}
+
+_SettingClient*
+_SettingClient::GetInstance(void)
+{
+       static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+       if(__pSettingClient == null)
+       {
+               pthread_once(&once_block, InitSettingClient);
+       }
+       return __pSettingClient;
+}
+
+_SettingClient::_SettingClient()
+       : __pSettingEvent(null)
+       , __pSettingEventForInternal(null)
+       , __subscribed(false)
+       , __pIpcClient(null)
+       , __pListener(null)
+{
+       result r = E_SUCCESS;
+       static String SETTING_SERVICE_ID(_SETTING_SERVICE_ID);
+
+       __pSettingEvent = new (std::nothrow) _SettingEvent();
+
+       __pSettingEventForInternal = new (std::nothrow) _SettingEvent();
+
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+       SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
+
+       r = pCommunicationDispatcherClient->RegisterCommunicationListener(SETTING_SERVICE_ID, *this);
+       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
+
+       __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
+
+       __asyncEventList.Construct();
+CATCH:
+       SetLastResult(r);
+}
+
+_SettingClient::~_SettingClient()
+{
+       result r = E_SUCCESS;
+       String key(_SETTING_SERVICE_ID);
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+       SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
+
+       r = pCommunicationDispatcherClient->UnregisterCommunicationListener(key);
+       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
+
+       __pIpcClient = null;
+CATCH:
+       SetLastResult(r);
+}
+
+result 
+_SettingClient::ConvertCode(String code)
+{
+       result r = E_SUCCESS;
+       if(code == _SETTING_RESULT_SUCCESS)
+       {
+               r = E_SUCCESS;
+       }
+       else if(code == _SETTING_RESULT_INVALID_ARG)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if(code == _SETTING_RESULT_PRIVILEGE_DENIED)
+       {
+               r = E_PRIVILEGE_DENIED;
+       }
+       else if(code == _SETTING_RESULT_UNSUPPORTED_OPERATION)
+       {
+               r = E_UNSUPPORTED_OPERATION;
+       }
+       else if(code == _SETTING_RESULT_OBJ_NOT_FOUND)
+       {
+               r = E_OBJ_NOT_FOUND;
+       }
+       else if(code == _SETTING_RESULT_OBJ_ALREADY_EXIST)
+       {
+               r = E_OBJ_ALREADY_EXIST;
+       }
+       else if(code == _SETTING_RESULT_IN_PROGRESS)
+       {
+               r = E_IN_PROGRESS;
+       }
+       else if(code == _SETTING_RESULT_SYSTEM)
+       {
+               r = E_SYSTEM;
+       }
+       else
+       {
+               r = E_SYSTEM;
+       }
+       return r;
+}
+
+String
+_SettingClient::ConvertKeyOspToTizen(String ospKey)
+{
+       String tizenKey = ospKey;
+
+       if(tizenKey == _HOUR_FORMAT_SELECTED)
+               tizenKey = _LOCALE_TIME_FORMAT_24HOUR;
+
+       else if(tizenKey == _ENABLE_MOTION)
+               tizenKey = _MOTION_UI;
+
+       else if(tizenKey == _DATA_ROAMING_ENABLED)
+               tizenKey = _NETWORK_TELEPHONY_ROAMING;
+
+       else if(tizenKey == _GPS_ENABLED)
+               tizenKey = _LOCATION_GPS;
+
+       else if(tizenKey == _PACKET_SERVICE_ALLOWED)
+               tizenKey = _NETWORK_TELEPHONY_PACKETSERVICE;
+
+       else if(tizenKey == _SILENT_MODE)
+               tizenKey = _SOUND_SILENTMODE;
+
+       else if(tizenKey == _WPS_ENABLED)
+               tizenKey = _LOCATION_WPS;
+
+       else if(tizenKey == _FLIGHT_MODE_ENABLED)
+               tizenKey = _NETWORK_FLIGHTMODE;
+
+       else if(tizenKey == _TOUCH_VIBRATION_LEVEL)
+               tizenKey = _VIBRATOR_LEVEL;
+
+       else if(tizenKey == _MEDIA_SOUND_VOLUME)
+               tizenKey = _SOUND_MEDIA_VOLUME;
+
+       else if(tizenKey == _NOTIFICATION_SOUND_VOLUME)
+               tizenKey = _SOUND_NOTIFICATION_VOLUME;
+
+       else if(tizenKey == _RINGTONE_SOUND_VOLUME)
+               tizenKey = _SOUND_RINGTONE_VOLUME;
+
+       else if(tizenKey == _SYSTEM_SOUND_VOLUME)
+               tizenKey = _SOUND_SYSTEM_VOLUME;
+
+       else if(tizenKey == _COUNTRY)
+               tizenKey = _LOCALE_COUNTRY;
+
+       else if(tizenKey == _DATE_FORMAT)
+               tizenKey = _LOCALE_DATE_FORMAT;
+
+       else if(tizenKey == _DATE_TIME_FORMAT)
+               tizenKey = _LOCALE_DATETIME_FORMAT;
+
+       else if(tizenKey == _FONTTYPE)
+               tizenKey = _FONT_TYPE;
+
+       else if(tizenKey == _FONTSIZE)
+               tizenKey = _FONT_SIZE;
+
+       else if(tizenKey == _RINGTONE)
+               tizenKey = _SOUND_RINGTONE;
+
+       else if(tizenKey == _TIME_FORMAT)
+               tizenKey = _LOCALE_TIME_FORMAT;
+
+       else if(tizenKey == _WALLPAPER)
+               tizenKey = _SCREEN_WALLPAPER;
+
+       return tizenKey;
+}
+
+result
+_SettingClient::ConvertKeyTizenToOsp(String tizenKey, String& ospKey)
+{
+       result r = E_SUCCESS;
+       if(tizenKey == _LOCALE_TIME_FORMAT_24HOUR)
+       {
+               ospKey = _HOUR_FORMAT_SELECTED;
+       }
+       else if(tizenKey == _MOTION_UI)
+       {
+               ospKey = _ENABLE_MOTION;
+       }
+       else if(tizenKey == _NETWORK_TELEPHONY_ROAMING)
+       {
+               ospKey = _DATA_ROAMING_ENABLED;
+       }
+       else if(tizenKey == _LOCATION_GPS)
+       {
+               ospKey = _GPS_ENABLED;
+       }
+       else if(tizenKey == _NETWORK_TELEPHONY_PACKETSERVICE)
+       {
+               ospKey = _PACKET_SERVICE_ALLOWED;
+       }
+       else if(tizenKey == _SOUND_SILENTMODE)
+       {
+               ospKey = _SILENT_MODE;
+       }
+       else if(tizenKey == _LOCATION_WPS)
+       {
+               ospKey = _WPS_ENABLED;
+       }
+       else if(tizenKey == _NETWORK_FLIGHTMODE)
+       {
+               ospKey = _FLIGHT_MODE_ENABLED;
+       }
+       else if(tizenKey == _VIBRATOR_LEVEL)
+       {
+               ospKey = _TOUCH_VIBRATION_LEVEL;
+       }
+       else if(tizenKey == _SOUND_MEDIA_VOLUME)
+       {
+               ospKey = _MEDIA_SOUND_VOLUME;
+       }
+       else if(tizenKey == _SOUND_NOTIFICATION_VOLUME)
+       {
+               ospKey = _NOTIFICATION_SOUND_VOLUME;
+       }
+       else if(tizenKey == _SOUND_RINGTONE_VOLUME)
+       {
+               ospKey = _RINGTONE_SOUND_VOLUME;
+       }
+       else if(tizenKey == _SOUND_SYSTEM_VOLUME)
+       {
+               ospKey = _SYSTEM_SOUND_VOLUME;
+       }
+       else if(tizenKey == _LOCALE_COUNTRY)
+       {
+               ospKey = _COUNTRY;
+       }
+       else if(tizenKey == _LOCALE_DATE_FORMAT)
+       {
+               ospKey = _DATE_FORMAT;
+       }
+       else if(tizenKey == _LOCALE_DATETIME_FORMAT)
+       {
+               ospKey = _DATE_TIME_FORMAT;
+       }
+       else if(tizenKey == _FONT_TYPE)
+       {
+               ospKey = _FONTTYPE;
+       }
+       else if(tizenKey == _FONT_SIZE)
+       {
+               ospKey = _FONTSIZE;
+       }
+       else if(tizenKey == _SOUND_RINGTONE)
+       {
+               ospKey = _RINGTONE;
+       }
+       else if(tizenKey == _LOCALE_TIME_FORMAT)
+       {
+               ospKey = _TIME_FORMAT;
+       }
+       else if(tizenKey == _SCREEN_WALLPAPER)
+       {
+               ospKey = _WALLPAPER;
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+       }
+
+       return r;
+}
+
+result
+_SettingClient::GetOnService(String commandId, String key, String& response)
+{
+       result r = E_SUCCESS;
+       String requestKey = ConvertKeyOspToTizen(key);
+
+       ArrayList requestMessages;
+       ArrayList responseMessages;
+
+       requestMessages.Construct();
+       responseMessages.Construct();
+
+       String serviceId(_SETTING_SERVICE_ID);
+
+       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 = ConvertCode(*pResult);
+       if(r == E_SUCCESS)
+       {
+               String* pValue = (String*)responseMessages.GetAt(3);
+               SysTryReturnResult(NID_SYS, pValue != null, E_SYSTEM, "There is no result value.");
+               response = *pValue;
+       }
+       return r;
+}
+
+result
+_SettingClient::SetOnService(String commandId, String key, String& value)
+{
+       result r = E_SUCCESS;
+       String requestKey = ConvertKeyOspToTizen(key);
+
+       ArrayList requestMessages;
+       ArrayList responseMessages;
+
+       requestMessages.Construct();
+       responseMessages.Construct();
+
+       String serviceId(_SETTING_SERVICE_ID);
+
+       requestMessages.Add(serviceId);
+       requestMessages.Add(commandId);
+       requestMessages.Add(requestKey);
+       requestMessages.Add(value);
+
+       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.");
+       SysLog(NID_SYS, "Result is %ls.", pResult->GetPointer());
+       r = ConvertCode(*pResult);
+       SysLog(NID_SYS, "r is %s.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_SettingClient::GetValue(const String& key, bool& value)
+{
+       String response;
+       result r = GetOnService(_SETTING_COMMAND_GET_BOOL, key, response);
+
+       if(r == E_SUCCESS)
+       {
+               if(response == L"0")
+               {
+                       value = false;
+               }
+               else if(response == L"1")
+               {
+                       value = true;
+               }
+               else
+               {
+                       SysLogException(NID_SYS, E_SYSTEM, "There are wrong value [%ls].", key.GetPointer());
+                       return E_SYSTEM;
+               }
+       }
+
+       return r;
+}
+
+result
+_SettingClient::GetValue(const String& key, int& value)
+{
+       String response;
+       result r = GetOnService(_SETTING_COMMAND_GET_INT, key, response);
+
+       if(r == E_SUCCESS)
+       {
+               r = Integer::Parse(response, value);
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to convert to integer from [%s]", response.GetPointer());
+       }
+
+       return r;
+}
+
+result
+_SettingClient::GetValue(const String& key, long long& value)
+{
+       return E_OBJ_NOT_FOUND;
+}
+
+result
+_SettingClient::GetValue(const String& key, double& value)
+{
+       return E_OBJ_NOT_FOUND;
+}
+
+result
+_SettingClient::GetValue(const String& key, UuId& value)
+{
+       return E_OBJ_NOT_FOUND;
+}
+
+result
+_SettingClient::GetValue(const String& key, String& value)
+{
+       String response;
+       result r = E_SUCCESS;
+
+       if(key == _USBMODE) //This is compatible issue. USB mode is fixed on Tizen.
+       {
+               value = _USBMODE_MTP;
+               return E_SUCCESS;
+       }
+
+       if(key == _LANGUAGE) //This is not full compatible.
+       {
+               r = GetOnService(_SETTING_COMMAND_GET_STRING, _LOCALE_LANGUAGE, response);
+       }
+       else
+       {
+               r = GetOnService(_SETTING_COMMAND_GET_STRING, key, response);
+       }
+
+       if(r == E_SUCCESS)
+       {
+               value = response;
+       }
+
+       if(key == _LANGUAGE) //This is not full compatible.
+       {
+               r = value.SubString(0, 3, value);
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to sub string on %ls.", value.GetPointer());
+       }
+
+       return r;
+}
+
+result
+_SettingClient::GetValueForPrivilegedKey(const String& key, bool& value)
+{
+       String response;
+       result r = GetOnService(_SETTING_COMMAND_GET_BOOL_PRIV, key, response);
+
+       if(r == E_SUCCESS)
+       {
+               if(response == L"0")
+               {
+                       value = false;
+               }
+               else if(response == L"1")
+               {
+                       value = true;
+               }
+               else
+               {
+                       SysLogException(NID_SYS, E_SYSTEM, "There are wrong value [%ls].", key.GetPointer());
+                       return E_SYSTEM;
+               }
+       }
+
+       return r;
+}
+
+result
+_SettingClient::SetValue(const String& key, const bool& value)
+{
+       String requestValue;
+       if(value == true)
+       {
+               requestValue.Append("true");
+       }
+       else
+       {
+               requestValue.Append("false");
+       }
+       return SetOnService(_SETTING_COMMAND_SET_BOOL, key, requestValue);
+}
+
+result
+_SettingClient::SetValue(const String& key, const int& value)
+{
+       String requestValue;
+       requestValue.Append(value);
+       return SetOnService(_SETTING_COMMAND_SET_INT, key, requestValue);
+}
+
+result
+_SettingClient::SetValue(const String& key, const String& value)
+{
+       String requestValue;
+       requestValue.Append(value);
+       return SetOnService(_SETTING_COMMAND_SET_STRING, key, requestValue);
+}
+
+result
+_SettingClient::SetValueForPrivilegedKey(const String& key, bool value)
+{
+       String requestValue;
+       if(value == true)
+       {
+               requestValue.Append("true");
+       }
+       else
+       {
+               requestValue.Append("false");
+       }
+       return SetOnService(_SETTING_COMMAND_SET_BOOL_PRIV, key, requestValue);
+}
+
+result
+_SettingClient::SetValueForPrivilegedKey(const String& key, String value)
+{
+       String requestValue;
+       requestValue.Append(value);
+       return SetOnService(_SETTING_COMMAND_SET_STRING_PRIV, key, requestValue);
+}
+
+result
+_SettingClient::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+       result r = E_SUCCESS;
+       String requestValue;
+
+       SysTryReturnResult(NID_SYS, __asyncEventList.ContainsKey(key) == false, E_IN_PROGRESS, "Required key[%ls] is already in progress.", key.GetPointer());
+
+       if(value == true)
+       {
+               requestValue.Append("true");
+       }
+       else
+       {
+               requestValue.Append("false");
+       }
+
+       r = SetOnService(_SETTING_COMMAND_SET_BOOL_ASYNC_PRIV, key, requestValue);
+
+       if(r == E_SUCCESS)
+       {
+               _SettingAsyncEvent* pEvent = new (std::nothrow) _SettingAsyncEvent();
+               pEvent->AddListener(*listener);
+
+               __asyncEventList.Add(new String(key), pEvent);
+       }
+
+       return r;
+}
+
+void
+_SettingClient::OnDataReceived(const ArrayList& data)
+{
+       result r = E_SUCCESS;
+       String* pServiceId = (String*)(data.GetAt(0));
+       String* pResponseId = (String*)(data.GetAt(1));
+       String* pKey = (String*)(data.GetAt(2));
+       String* pValue = null;
+
+       SysTryReturnVoidResult(NID_SYS, pServiceId != null, E_SYSTEM, "There is no service Id.");
+       SysTryReturnVoidResult(NID_SYS, pResponseId != null, E_SYSTEM, "There is response Id.");
+       SysTryReturnVoidResult(NID_SYS, pKey != null, E_SYSTEM, "There is no key.");
+
+       SysLog(NID_SYS, "ServiceId: %ls, ResponseId: %ls, Key: %ls", pServiceId->GetPointer(), pResponseId->GetPointer(), pKey->GetPointer());
+
+       if(*pResponseId ==  _SETTING_COMMAND_SET_BOOL_ASYNC || *pResponseId == _SETTING_COMMAND_SET_BOOL_ASYNC_PRIV
+               || *pResponseId ==  _SETTING_COMMAND_SET_STRING_ASYNC)
+       {
+
+               pValue =  (String*)(data.GetAt(3));
+
+               SysTryReturnVoidResult(NID_SYS, pValue != null, E_SYSTEM, "There is no value.");
+               SysLog(NID_SYS, "Value: %ls", pValue->GetPointer());
+
+               _SettingAsyncEvent* pEvent =  dynamic_cast <_SettingAsyncEvent*> (__asyncEventList.GetValue(*pKey));
+               r = ConvertCode(*pValue);
+
+               if(pEvent != null)
+               {
+                       _SettingAsyncEventArg* pSettingAsyncEventArg = new (std::nothrow) _SettingAsyncEventArg;
+                       pSettingAsyncEventArg->Key = *pKey;
+                       pSettingAsyncEventArg->errorCode = r;
+                       pEvent->Fire(*pSettingAsyncEventArg);
+               }
+               r = __asyncEventList.Remove(*pKey, true);
+       }
+       else if(*pResponseId == _SETTING_SERVICE_TYPE_EVENT)
+       {
+               SysTryReturnVoidResult(NID_SYS, __pSettingEvent != null, E_SYSTEM, "Event is not ready.");
+
+               _SettingEventArg* pSettingEventArg = new (std::nothrow) _SettingEventArg();
+                pSettingEventArg->KeyName = *pKey;
+
+
+               if(pSettingEventArg->KeyName == _LOCALE_LANGUAGE
+                       || pSettingEventArg->KeyName == _LOCALE_COUNTRY
+                       || pSettingEventArg->KeyName == _FONT_TYPE
+                       || pSettingEventArg->KeyName == _FONT_SIZE)
+               {
+                       if(__pSettingEventForInternal != null)
+                       {
+                               _SettingEventArg* pSettingEventArgForInternal = new (std::nothrow) _SettingEventArg();
+                               pSettingEventArgForInternal->KeyName = pSettingEventArg->KeyName;
+                               __pSettingEventForInternal->Fire(*pSettingEventArgForInternal);
+                       }
+                       else
+                       {
+                               SysLogException(NID_SYS, E_SYSTEM, "Internal Event is not ready.");
+                       }
+               }
+
+
+               if(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat() == true)
+               {
+                       String ospKey;
+                       r = ConvertKeyTizenToOsp(pSettingEventArg->KeyName, ospKey);
+                       if(r == E_SUCCESS)
+                       {
+                               pSettingEventArg->KeyName = ospKey;
+                               __pSettingEvent->Fire(*pSettingEventArg);
+                       }
+               }
+               else
+               {
+                       __pSettingEvent->Fire(*pSettingEventArg);
+               }
+       }
+}
+
+bool
+_SettingClient::HasKey(const String& key)
+{
+       String response;
+       result r = GetOnService(_SETTING_COMMAND_SUPPORTED, key, response);
+
+       if(response == L"1" && r == E_SUCCESS)
+       {
+               return true;
+       }
+       return false;
+}
+
+result
+_SettingClient::ResetToFactoryDefault(void)
+{
+       return E_SUCCESS;
+}
+
+//For OSP_COMPAT mode
+result
+_SettingClient::SetVolume(const String& soundCategory, int level)
+{
+       result r = SetValue(soundCategory, level);
+       if (r == E_INVALID_ARG)
+       {
+               r = E_OUT_OF_RANGE;
+       }
+       else if(r == E_OBJ_NOT_FOUND)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if(r == E_UNSUPPORTED_OPERATION)
+       {
+               r = E_SYSTEM;
+       }
+       return r;
+}
+
+//Event Management
+result
+_SettingClient::SubscribeEvent(void)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_SYS, __pSettingEvent != null, E_SYSTEM, "listener list is not ready.");
+       _SettingEvent* pSettingEvent = dynamic_cast<_SettingEvent*> (__pSettingEvent);
+
+       SysTryReturnResult(NID_SYS, __pSettingEventForInternal != null, E_SYSTEM, "listener list is not ready.");
+       _SettingEvent* pSettingEventForInternal = dynamic_cast<_SettingEvent*> (__pSettingEventForInternal);
+
+       if(pSettingEvent->GetCount() > 0 || pSettingEventForInternal->GetCount() >0)
+       {
+               if(__subscribed == false)
+               {
+                       ArrayList requestMessages;
+                       ArrayList responseMessages;
+
+                       requestMessages.Construct();
+                       responseMessages.Construct();
+
+                       String serviceId(_SETTING_SERVICE_ID);
+                       String eventId(_SETTING_COMMAND_ADD_EVENT);
+
+                       requestMessages.Add(serviceId);
+                       requestMessages.Add(eventId);
+
+                       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 = ConvertCode(*pResult);
+
+                       if(r == E_SUCCESS)
+                       {
+                               __subscribed = true;
+                       }
+               }
+       }
+       else if(pSettingEvent->GetCount() == 0 && pSettingEventForInternal->GetCount() == 0)
+       {
+               if(__subscribed == true)
+               {
+                       ArrayList requestMessages;
+                       ArrayList responseMessages;
+
+                       requestMessages.Construct();
+                       responseMessages.Construct();
+
+                       String serviceId(_SETTING_SERVICE_ID);
+                       String eventId(_SETTING_COMMAND_REMOVE_EVENT);
+
+                       requestMessages.Add(serviceId);
+                       requestMessages.Add(eventId);
+
+                       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 = ConvertCode(*pResult);
+
+                       if(r == E_SUCCESS)
+                       {
+                               __subscribed = false;
+                       }
+               }
+       }
+
+       return r;
+}
+
+result
+_SettingClient::AddSettingEventListener(ISettingEventListener& listener)
+{
+       SysTryReturnResult(NID_SYS, __pSettingEvent != null, E_SYSTEM, "listener list is not ready.");
+       _SettingEvent* pSettingEvent = dynamic_cast<_SettingEvent*> (__pSettingEvent);
+       result r = pSettingEvent->AddSettingEventListener(listener);
+       if (r == E_INVALID_OPERATION)
+       {
+               r = E_SYSTEM;
+       }
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add event listener.");
+
+       r = SubscribeEvent();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to request to add event listener.");
+
+       return r;
+}
+
+result
+_SettingClient::RemoveSettingEventListener(ISettingEventListener& listener)
+{
+       SysTryReturnResult(NID_SYS, __pSettingEvent != null, E_SYSTEM, "listener list is not ready.");
+       _SettingEvent* pSettingEvent = dynamic_cast<_SettingEvent*> (__pSettingEvent);
+       result r = pSettingEvent->RemoveSettingEventListener(listener);
+
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to remove event listener.");
+
+       r = SubscribeEvent();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to request to remove event listener.");
+
+       return r;
+}
+
+// Event for internal
+result
+_SettingClient::AddSettingEventListenerForInternal(ISettingEventListener& listener)
+{
+       SysTryReturnResult(NID_SYS, __pSettingEventForInternal != null, E_SYSTEM, "listener list is not ready.");
+       _SettingEvent* pSettingEvent = dynamic_cast<_SettingEvent*> (__pSettingEventForInternal);
+       result r = pSettingEvent->AddSettingEventListener(listener);
+       if (r == E_INVALID_OPERATION)
+       {
+               r = E_SYSTEM;
+       }
+
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to add event listener.");
+
+       r = SubscribeEvent();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to request to add event listener.");
+
+       return r;
+}
+
+result
+_SettingClient::RemoveSettingEventListenerForInternal(ISettingEventListener& listener)
+{
+       SysTryReturnResult(NID_SYS, __pSettingEventForInternal != null, E_SYSTEM, "listener list is not ready.");
+       _SettingEvent* pSettingEvent = dynamic_cast<_SettingEvent*> (__pSettingEventForInternal);
+       result r =  pSettingEvent->RemoveSettingEventListener(listener);
+
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to remove event listener.");
+
+       r = SubscribeEvent();
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to request to remove event listener.");
+
+       return r;
+}
+
+//For OSP_COMPAT mode
+result
+_SettingClient::SetSettingEventListener(ISettingEventListener* pListener)
+{
+       result r = E_SUCCESS;
+       if(__pListener != null)
+       {
+               r = RemoveSettingEventListener(*pListener);
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to unregister exist listener.");
+               if(pListener != null)
+               {
+                       r = AddSettingEventListener(*pListener);
+                       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to register listener.");
+               }
+       }
+
+       __pListener = pListener;
+
+       return r;
+}
+
+} } // Tizen::System
similarity index 52%
rename from src/system/FSys_SettingManager.h
rename to src/system/FSys_SettingClient.h
index 9e9b07d..f0c7816 100644 (file)
 //
 
 /**
- * @file               FSys_SettingManager.h
- * @brief              This is the header file for _SettingManager class.
+ * @file               FSys_SettingClient.h
+ * @brief              This is the header file for _SettingClient class.
  */
 
-#ifndef _FSYSTEM_INTERNAL_SETTING_MANAGER_H_
-#define _FSYSTEM_INTERNAL_SETTING_MANAGER_H_
+#ifndef _FSYSTEM_INTERNAL_SETTING_CLIENT_H_
+#define _FSYSTEM_INTERNAL_SETTING_CLIENT_H_
 
-#include <media/sound_manager.h>
-#include <runtime_info.h>
-#include <system/system_settings.h>
-#include <vconf.h>
-#include <tethering.h>
-#include <tapi_common.h>
-#include <wifi-direct.h>
-#include <ITapiModem.h>
-#include <haptic/haptic.h>
+#include <FIo_IpcClient.h>
 
-#include <FBaseColArrayListT.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColHashMap.h>
+#include <FBaseObject.h>
 #include <FBaseRtEvent.h>
-#include <FSysSettingInfo.h>
-#include "FSys_SettingIcu.h"
+#include <FBaseRtIEventArg.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseString.h>
+#include <FBaseInteger.h>
+#include <FBaseUuId.h>
+#include <FSysISettingEventListener.h>
+#include <FSys_ICommunicationDispatcherListener.h>
+#include <FSysISettingInfoSetValueAsyncResultListener.h>
 
 namespace Tizen { namespace System
 {
 
-class _OSP_EXPORT_ _SettingManager
+class _SettingClient
        : public Tizen::Base::Object
+       , public Tizen::System::_ICommunicationDispatcherListener
 {
 private:
-       _SettingManager(void);
-       virtual ~_SettingManager(void);
+       _SettingClient(void);
+       virtual ~_SettingClient(void);
 
 public:
        result GetValue(const Tizen::Base::String& key, bool& value);
+       result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
        result GetValue(const Tizen::Base::String& key, double& value);
        result GetValue(const Tizen::Base::String& key, int& value);
        result GetValue(const Tizen::Base::String& key, long long& value);
        result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
        result GetValue(const Tizen::Base::String& key, Tizen::Base::UuId& value);
-       result SetSettingEventListener(ISettingEventListener* pListener);
-       result AddSettingEventListenerForInternal(ISettingEventListener& listener);
-       result RemoveSettingEventListenerForInternal(ISettingEventListener& listener);
-       result AddSettingEventListener(ISettingEventListener& listener);
-       result RemoveSettingEventListener(ISettingEventListener& listener);
-
-       result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
 
        bool HasKey(const Tizen::Base::String& key);
 
        result SetValue(const Tizen::Base::String& key, const bool& value);
-       result SetValue(const Tizen::Base::String& key, const int& value);
-       result SetValue(const Tizen::Base::String& key, const Tizen::Base::String& value);
-
        result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
        result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
+       result SetValue(const Tizen::Base::String& key, const int& value);
+       result SetValue(const Tizen::Base::String& key, const Tizen::Base::String& value);
        result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
 
+       result AddSettingEventListenerForInternal(ISettingEventListener& listener);
+       result RemoveSettingEventListenerForInternal(ISettingEventListener& listener);
+       result AddSettingEventListener(ISettingEventListener& listener);
+       result RemoveSettingEventListener(ISettingEventListener& listener);
+
+       result SetSettingEventListener(ISettingEventListener* pListener);
+
        result ResetToFactoryDefault(void);
 
-       static _SettingManager* GetInstance(void);
+       static _SettingClient* GetInstance(void);
 
 private:
-       void DeliverSettingEvent(Tizen::Base::String keyName);
+       void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+       result ConvertCode(Tizen::Base::String code);
+
+       Tizen::Base::String ConvertKeyOspToTizen(Tizen::Base::String ospKey);
+       result ConvertKeyTizenToOsp(Tizen::Base::String tizenKey, Tizen::Base::String& ospKey);
+
+       result GetOnService(Tizen::Base::String commandId, Tizen::Base::String key, Tizen::Base::String& response);
+       result SetOnService(Tizen::Base::String commandId, Tizen::Base::String key, Tizen::Base::String& value);
        result SetVolume(const Tizen::Base::String& soundCategory, int level);
-       result StartSettingEventListen(void);
-       result StopSettingEventListen(void);
-       result StartSettingEventListenForInternal(void);
-       result StopSettingEventListenForInternal(void);
-       static void InitSettingManager(void);
-       result LoadWifiDll();
-       void UnloadWifiDll();
-       result LoadBluetoothDll();
-       void UnloadBluetoothDll();
-
-       static void SettingEventRuntimeInfo(runtime_info_key_e key, void* userData);
-       static void SettingEventSettingInfo(system_settings_key_e key, void* userData);
-       static void SettingEventSoundManager(sound_type_e type, unsigned int volume, void* userData);
-       static void SettingEventVConf(keynode_t* node, void* userData);
-       static void SettingEventTetheringEnabled(tethering_error_e tetheringErr, tethering_type_e deviceType, bool isRequested, void* date);
-       static void SettingEventTetheringDisabled(tethering_error_e tetheringErr, tethering_type_e deviceType, tethering_disabled_cause_e tetheringCause, void* dati);
-       static void SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data);
 
+       result SubscribeEvent(void);
+
+       static void InitSettingClient(void);
 private:
-       ISettingEventListener*          __pSettingEventListener;
+       Tizen::Base::Collection::HashMap __asyncEventList;
        Tizen::Base::Runtime::Event*    __pSettingEvent;
-       int                             __listenerCount;
-       _SettingIcu                     __settingIcu;
-       bool                            __registeredSettingEvents;
-       haptic_device_h                 __hapticHandle;
-       TapiHandle*                     __tapiHandle;
-       tethering_h                     __tetheringHandle;
-       Tizen::Base::Runtime::Event*    __pSettingAsyncEvent;
        Tizen::Base::Runtime::Event*    __pSettingEventForInternal;
-       int                             __listenerInternalCount;
-       static _SettingManager*         __pSettingManager;
-       bool                            __registeredSettingEventsForInternal;
-       void*                           __pWifiDllHandle;
-       void*                           __pBluetoothDllHandle;
+       bool                            __subscribed;
+
+       Tizen::Io::_IpcClient* __pIpcClient;
+       ISettingEventListener* __pListener;
+
+       static _SettingClient*          __pSettingClient;
+
 };
 
 } } // Tizen::System
 
-#endif //_FSYSTEM_INTERNAL_SETTING_MANAGER_H_
+#endif //_FSYSTEM_INTERNAL_SETTING_CLIENT_H_
diff --git a/src/system/FSys_SettingIcu.cpp b/src/system/FSys_SettingIcu.cpp
deleted file mode 100644 (file)
index bea4545..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-
-//
-// 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_SettingIcu.cpp
- * @brief              This is the implementation file for _SettingIcu class.
- */
-
-#include <stdlib.h>
-#include <memory.h>
-#include <runtime_info.h>
-
-#include <FBaseSysLog.h>
-#include <FBase_NativeError.h>
-#include "FSys_SettingIcu.h"
-
-namespace Tizen { namespace System
-{
-
-static const int _MAX_COUNTRY_LENTH = 2;
-static const int _LANGUAGE_START_INDEX = 0;
-static const int _MAX_LANGUAGE_LENTH = 2;
-
-_SettingIcu::_SettingIcu()
-{
-}
-
-_SettingIcu::~_SettingIcu()
-{
-}
-
-char*
-_SettingIcu::GetIcuPatternN(const char* pLocale, UChar* pCustomSkeleton)
-{
-       UErrorCode status = U_ZERO_ERROR;
-       UDateTimePatternGenerator* pGenerator = null;
-       UChar bestPattern[64] = {0,};
-
-       if(pLocale == null || pCustomSkeleton == null)
-       {
-               return null;
-       }
-
-       char*   pBestPatternString = null;
-       int32_t bestPatternCapacity = 0;
-       int32_t bestPatternLength = 0;
-
-       pGenerator = udatpg_open(pLocale, &status);
-
-       if (U_FAILURE(status) == true)
-       {
-               return null;
-       }
-
-       status = U_ZERO_ERROR;
-
-       bestPatternCapacity = (int32_t)(sizeof(bestPattern)/sizeof((bestPattern)[0]));
-       bestPatternLength = udatpg_getBestPattern(pGenerator, pCustomSkeleton, u_strlen(pCustomSkeleton), bestPattern, bestPatternCapacity, &status);
-       if (U_FAILURE(status) == true)
-       {
-               return null;
-       }
-
-       status = U_ZERO_ERROR;
-       pBestPatternString = (char*)malloc(128);
-       if (pBestPatternString == null)
-       {
-               return null;
-       }
-       memset(pBestPatternString, 0, 128);
-       u_austrncpy(pBestPatternString, bestPattern, 128);
-       udatpg_close(pGenerator);
-       SysLog(NID_SYS, "Format is [%s] \n", pBestPatternString);
-       return pBestPatternString;
-}
-
-char*
-_SettingIcu::GetDateTimeFormatN(const char* pIcuFormat)
-{
-       char* pFormatString = null;
-       char* pLangset = null;
-       char* pDateTimeFormat = null;
-
-       if (pIcuFormat == null)
-       {
-               return null;
-       }
-
-       UChar   customSkeleton[256] = {0, };
-       int res = 0;
-       const char* pLocaleDefault = uloc_getDefault();
-
-       res = runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &pLangset);
-       pDateTimeFormat = const_cast< char* > (pLocaleDefault);
-
-       u_uastrncpy(customSkeleton, pIcuFormat, sizeof(customSkeleton));
-       pFormatString = GetIcuPatternN(pDateTimeFormat, customSkeleton);
-
-       free(pLangset);
-       return pFormatString;
-}
-
-} } // Tizen::System
index 6d5418f..1f66097 100644 (file)
 
 #include <FBaseColArrayList.h>
 #include <FBaseSysLog.h>
-#include <FIo_AppServiceIpcMessages.h>
-#include <FIo_IpcClient.h>
 
 #include <FBase_NativeError.h>
 #include <FSys_SettingInfoImpl.h>
-#include "FSys_SettingManager.h"
+#include "FSys_SettingClient.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -51,142 +49,160 @@ static const wchar_t* _SETTING_SOUND_RINGTONE_VOLUME = L"http://tizen.org/settin
 static const wchar_t* _SETTING_NOTIFICATION_SOUND_VOLUME = L"NotificationSoundVolume";
 static const wchar_t* _SETTING_SOUND_NOTIFICATION_VOLUME = L"http://tizen.org/setting/sound.notification.volume";
 
-static _SettingManager* pSettingManager = null;
+static _SettingClient* pSettingClient = null;
 
 void
-_SettingInfoImpl::InitSettingManager(void)
+_SettingInfoImpl::InitSettingClient(void)
 {
-       if(pSettingManager == null)
+       if(pSettingClient == null)
        {
-               pSettingManager =  _SettingManager::GetInstance();
+               pSettingClient =  _SettingClient::GetInstance();
        }
 }
 result
 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, Tizen::Base::String& value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->GetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->GetValue(key, value);
 }
 
 result
 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, int& value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->GetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->GetValue(key, value);
 }
 
 result
 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, long long& value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->GetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->GetValue(key, value);
 }
 
 result
 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, double& value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->GetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->GetValue(key, value);
 }
 
 result
 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, bool& value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->GetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->GetValue(key, value);
 }
 
 result
 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, Tizen::Base::UuId& value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->GetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->GetValue(key, value);
 }
 
 result
 _SettingInfoImpl::SetWallpaper(const Tizen::Base::String& filePath)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValue(_SETTING_SCREEN_WALLPAPER, filePath);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       result r = pSettingClient->SetValue(_SETTING_SCREEN_WALLPAPER, filePath);
+
+       if(r == E_INVALID_ARG)
+               r = E_FILE_NOT_FOUND;
+       else if(r == E_OBJ_NOT_FOUND)
+               r = E_SYSTEM;
+       else if(r == E_UNSUPPORTED_OPERATION)
+               r = E_SYSTEM;
+
+       return r;
 }
 
 result
 _SettingInfoImpl::GetValueForPrivilegedKey(const String& key, bool& value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->GetValueForPrivilegedKey(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->GetValueForPrivilegedKey(key, value);
 }
 
 result
 _SettingInfoImpl::SetValue(const String& key, bool value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetValue(key, value);
 }
 
 result
 _SettingInfoImpl::SetValue(const String& key, int value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetValue(key, value);
 }
 
 
 result
 _SettingInfoImpl::SetValue(const String& key, String value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValue(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetValue(key, value);
 }
 
 result
 _SettingInfoImpl::SetValueForPrivilegedKey(const String& key, bool value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValueForPrivilegedKey(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetValueForPrivilegedKey(key, value);
 }
 
 result
 _SettingInfoImpl::SetValueForPrivilegedKey(const String& key, String value)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValueForPrivilegedKey(key, value);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetValueForPrivilegedKey(key, value);
 }
 
 bool
 _SettingInfoImpl::HasKey(const String& key)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->HasKey(key);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->HasKey(key);
 }
 result
 _SettingInfoImpl::ResetToFactoryDefault(void)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->ResetToFactoryDefault();
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->ResetToFactoryDefault();
 }
 
 result
 _SettingInfoImpl::SetRingtone(const Tizen::Base::String& filePath)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValue(_SETTING_SOUND_RINGTONE, filePath);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       result r = pSettingClient->SetValue(_SETTING_SOUND_RINGTONE, filePath);
+
+       if(r == E_INVALID_ARG)
+               r = E_FILE_NOT_FOUND;
+       else if(r == E_OBJ_NOT_FOUND)
+               r = E_SYSTEM;
+       else if(r == E_UNSUPPORTED_OPERATION)
+               r = E_SYSTEM;
+
+       return r;
 }
 
 result
@@ -195,8 +211,8 @@ _SettingInfoImpl::SetVolume(const Tizen::Base::String& soundCategory, int level)
        result r = E_SUCCESS;
        String key;
 
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
 
        if (soundCategory == _SETTING_SYSTEM_SOUND_VOLUME)
        {
@@ -219,61 +235,69 @@ _SettingInfoImpl::SetVolume(const Tizen::Base::String& soundCategory, int level)
                key = soundCategory;
        }
 
-       r = pSettingManager->SetValue(key, level);
+       r = pSettingClient->SetValue(key, level);
 
        if (r == E_OBJ_NOT_FOUND)
        {
                r = E_INVALID_ARG;
        }
+       else if(r == E_INVALID_ARG)
+       {
+               r = E_OUT_OF_RANGE;
+       }
+       else if(r == E_UNSUPPORTED_OPERATION)
+       {
+               r = E_SYSTEM;
+       }
        return r;
 }
 
 result
 _SettingInfoImpl::AddSettingEventListener(ISettingEventListener& listener)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->AddSettingEventListener(listener);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->AddSettingEventListener(listener);
 }
 
 result
 _SettingInfoImpl::RemoveSettingEventListener(ISettingEventListener& listener)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->RemoveSettingEventListener(listener);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->RemoveSettingEventListener(listener);
 }
 
 result
 _SettingInfoImpl::AddSettingEventListenerForInternal(ISettingEventListener& listener)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->AddSettingEventListenerForInternal(listener);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->AddSettingEventListenerForInternal(listener);
 }
 
 result
 _SettingInfoImpl::RemoveSettingEventListenerForInternal(ISettingEventListener& listener)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->RemoveSettingEventListenerForInternal(listener);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->RemoveSettingEventListenerForInternal(listener);
 }
 
 result
 _SettingInfoImpl::SetSettingEventListener(ISettingEventListener* pListener)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetSettingEventListener(pListener);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetSettingEventListener(pListener);
 }
 
 result
 _SettingInfoImpl::SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
 {
-       InitSettingManager();
-       SysTryReturnResult(NID_SYS, pSettingManager != null, E_SYSTEM, "It is failed to intialize setting manager");
-       return pSettingManager->SetValueAsyncForPrivilegedKey(key, value, listener);
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetValueAsyncForPrivilegedKey(key, value, listener);
 }
 
 _SettingInfoImpl*
diff --git a/src/system/FSys_SettingManager.cpp b/src/system/FSys_SettingManager.cpp
deleted file mode 100644 (file)
index 0296feb..0000000
+++ /dev/null
@@ -1,3488 +0,0 @@
-//
-// 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_SettingManager.cpp
- * @brief              This is the implementation file for _SettingManager class.
- */
-
-#include <pthread.h>
-#include <unique_ptr.h>
-#include <string>
-#include <stdlib.h>
-#include <unicode/ustring.h>
-#include <unicode/uloc.h>
-#include <unicode/utypes.h>
-#include <unicode/udat.h>
-#include <unicode/udatpg.h>
-#include <unicode/locid.h>
-#include <device.h>
-#include <telephony_network.h>
-#include <sysman.h>
-#include <tethering.h>
-#include <sim.h>
-#include <dlfcn.h>
-
-#include <FBaseColIMapEnumerator.h>
-#include <FBaseInteger.h>
-#include <FBaseRtIEventArg.h>
-#include <FBaseSysLog.h>
-#include <FBaseUtilStringUtil.h>
-#include <FLclLocale.h>
-#include <FLclDateTimeFormatter.h>
-#include <FIoFile.h>
-#include <FSysIBatteryEventListener.h>
-#include <FSysIChargingEventListener.h>
-#include <FSysIDeviceEventListener.h>
-#include <FSysIScreenEventListener.h>
-#include <FSysSystemInfo.h>
-
-#include <FApp_AppInfo.h>
-#include <FBase_NativeError.h>
-#include <FBase_StringConverter.h>
-#include <FBaseColAllElementsDeleter.h>
-#include <FIo_AppServiceIpcMessages.h>
-#include <FIo_RegistryImpl.h>
-#include <FLcl_LocaleImpl.h>
-#include <FLcl_LocaleManagerImpl.h>
-#include <FSys_SettingManager.h>
-#include <FSys_SystemInfoImpl.h>
-
-using namespace Tizen::App;
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
-using namespace Tizen::Base::Utility;
-using namespace Tizen::Io;
-using namespace Tizen::Locales;
-
-namespace Tizen { namespace System
-{
-
-//Battery
-static const wchar_t* _BATTERY_FORMAT_PERCENTAGE = L"http://tizen.org/setting/battery.format.percentage";
-
-static const wchar_t* _ENABLE_MOTION = L"EnableMotion";
-
-//Font
-static const wchar_t* _FONT_SIZE = L"http://tizen.org/setting/font.size";
-static const wchar_t* _FONT_SIZE_GIANT = L"Giant";
-static const wchar_t* _FONT_SIZE_HUGE = L"Huge";
-static const wchar_t* _FONT_SIZE_LARGE = L"Large";
-static const wchar_t* _FONT_SIZE_MEDIUM = L"Medium";
-static const wchar_t* _FONT_SIZE_SMALL = L"Small";
-static const wchar_t* _FONT_SIZE_GIANT_LOWERCASE = L"giant";
-static const wchar_t* _FONT_SIZE_HUGE_LOWERCASE = L"huge";
-static const wchar_t* _FONT_SIZE_LARGE_LOWERCASE = L"large";
-static const wchar_t* _FONT_SIZE_MEDIUM_LOWERCASE = L"medium";
-static const wchar_t* _FONT_SIZE_SMALL_LOWERCASE = L"small";
-static const int _FONT_SIZE_GIANT_VCONF = 4;
-static const int _FONT_SIZE_HUGE_VCONF = 3;
-static const int _FONT_SIZE_LARGE_VCONF = 2;
-static const int _FONT_SIZE_MEDIUM_VCONF = 1;
-static const int _FONT_SIZE_SMALL_VCONF = 0;
-static const wchar_t* _FONTSIZE = L"FontSize";
-static const wchar_t* _FONTTYPE = L"FontType";
-static const wchar_t* _FONT_TYPE = L"http://tizen.org/setting/font.type";
-static const wchar_t* _GPS_ENABLED = L"GPSEnabled";
-static const wchar_t* _HOUR_FORMAT_SELECTED = L"24HourFormatSelected";
-
-//Locale
-//Locale Country
-static const wchar_t* _LOCALE_COUNTRY = L"http://tizen.org/setting/locale.country";
-static const wchar_t* _LOCALE_COUNTRY_LATIN_AMERICA = L"419";
-static const wchar_t* _COUNTRY = L"Country";
-
-//Locale Format
-static const wchar_t* _LOCALE_DATE_FORMAT = L"http://tizen.org/setting/locale.date.format";
-static const wchar_t* _LOCALE_DATETIME_FORMAT = L"http://tizen.org/setting/locale.date_time.format";
-static const wchar_t* _LOCALE_TIME_FORMAT = L"http://tizen.org/setting/locale.time.format";
-static const wchar_t* _LOCALE_TIME_FORMAT_24HOUR = L"http://tizen.org/setting/locale.time.format.24hour";
-static const wchar_t* _DATE_FORMAT = L"DateFormat";
-static const wchar_t* _TIME_FORMAT = L"TimeFormat";
-
-//Locale Language
-static const wchar_t* _LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
-static const wchar_t* _LANGUAGE = L"Language";
-
-//Locale Time
-static const wchar_t* _LOCALE_TIMEZONE = L"http://tizen.org/setting/locale.time_zone";
-static const wchar_t* _LOCALE_UPDATE_AUTO= L"http://tizen.org/setting/locale.update.auto";
-static const char* _LOCALE_TIMEZONE_ROOT_PATH = "/usr/share/zoneinfo/";
-static const char* _LOCALE_TIMEZONE_LINK = "/opt/etc/localtime";
-static const int _LOCALE_TIMEZONE_ROOT_PATH_LENGTH = 20;
-static const wchar_t* _LOCALE_WEEK_FORMAT_FIRSTDAY = L"http://tizen.org/setting/locale.week.format.firstday";
-static const wchar_t* _LOCALE_WEEK_FORMAT_FIRSTDAY_MONDAY = L"Monday";
-static const wchar_t* _LOCALE_WEEK_FORMAT_FIRSTDAY_SUNDAY = L"Sunday";
-static const int _LOCALE_WEEK_FORMAT_VCONF_SUNDAY = 0;
-static const int _LOCALE_WEEK_FORMAT_VCONF_MONDAY = 1;
-static const wchar_t* _DATE_TIME_FORMAT = L"DateTimeFormat";
-
-static const wchar_t* _LOCALE_DATE = L"http://tizen.org/setting/locale.date";
-static const wchar_t* _LOCALE_TIME = L"http://tizen.org/setting/locale.time";
-static const wchar_t* _LOCALE_DATETIME = L"http://tizen.org/setting/locale.date_time";
-
-//Location
-static const wchar_t* _LOCATION_GPS = L"http://tizen.org/setting/location.gps";
-static const wchar_t* _LOCATION_GPS_ADVANCED = L"http://tizen.org/setting/location.gps.advanced";
-static const wchar_t* _LOCATION_WPS = L"http://tizen.org/setting/location.wps";
-static const wchar_t* _MEDIA_SOUND_VOLUME = L"MediaSoundVolume";
-static const wchar_t* _WPS_ENABLED = L"WPSEnabled";
-
-//Network
-static const wchar_t* _NETWORK_FLIGHTMODE = L"http://tizen.org/setting/network.flight_mode";
-static const wchar_t* _FLIGHT_MODE_ENABLED = L"FlightModeEnabled";
-
-//Network Telephony
-static const wchar_t* _NETWORK_TELEPHONY_MODE = L"http://tizen.org/setting/network.telephony.mode";
-String _tmpNetworkTelephonyMode = L"UMTS";
-static const wchar_t* _NETWORK_TELEPHONY_PACKETSERVICE = L"http://tizen.org/setting/network.telephony.packet_service";
-static const wchar_t* _NETWORK_TELEPHONY_PROVIDER = L"http://tizen.org/setting/network.telephony.provider";
-String _tmpNetworkTelephonyProvider = L"Tizen";
-static const wchar_t* _NETWORK_TELEPHONY_ROAMING = L"http://tizen.org/setting/network.telephony.roaming";
-static const wchar_t* _DATA_ROAMING_ENABLED = L"DataRoamingEnabled";
-static const wchar_t* _SYSTEM_NETWORK_TELEPHONY = L"http://tizen.org/feature/network.telephony";
-
-//Network Wifi
-static const wchar_t* _NETWORK_WIFI = L"http://tizen.org/setting/network.wifi";
-static const wchar_t* _NETWORK_WIFI_NOTIFICATION = L"http://tizen.org/setting/network.wifi.notification";
-static const wchar_t* _NETWORK_WIFI_TETHERING = L"http://tizen.org/setting/network.wifi.tethering";
-static const wchar_t* _NETWORK_WIFI_TETHERING_HIDE = L"http://tizen.org/setting/network.wifi.tethering.hide";
-static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY = L"http://tizen.org/setting/network.wifi.tethering.security";
-static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD = L"http://tizen.org/setting/network.wifi.tethering.security.password";
-static const wchar_t* _NETWORK_WIFI_DIRECT = L"http://tizen.org/setting/network.wifi.direct";
-static const wchar_t* _SYSTEM_NETWORK_WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
-static const wchar_t* _SYSTEM_NETWORK_WIFI = L"http://tizen.org/feature/network.wifi";
-
-//Network Bluetooth
-static const wchar_t* _NETWORK_BLUETOOTH = L"http://tizen.org/setting/network.bluetooth";
-static const wchar_t* _NETWORK_BLUETOOTH_TETHERING = L"http://tizen.org/setting/network.bluetooth.tethering";
-static const wchar_t* _SYSTEM_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
-
-//Sound
-static const wchar_t* _NOTIFICATION_SOUND_VOLUME = L"NotificationSoundVolume";
-static const wchar_t* _PACKET_SERVICE_ALLOWED = L"PacketServiceAllowed";
-static const wchar_t* _RINGTONE = L"Ringtone";
-static const wchar_t* _RINGTONE_SOUND_VOLUME = L"RingtoneSoundVolume";
-static const wchar_t* _SILENT_MODE = L"SilentMode";
-static const wchar_t* _SOUND_MEDIA_VOLUME = L"http://tizen.org/setting/sound.media.volume";
-static const wchar_t* _SOUND_NOTIFICATION_VOLUME = L"http://tizen.org/setting/sound.notification.volume";
-static const wchar_t* _SOUND_RINGTONE = L"http://tizen.org/setting/sound.ringtone";
-static const wchar_t* _SOUND_RINGTONE_VOLUME = L"http://tizen.org/setting/sound.ringtone.volume";
-static const wchar_t* _SOUND_SILENTMODE = L"http://tizen.org/setting/sound.silent_mode";
-static const wchar_t* _SOUND_SYSTEM_VOLUME = L"http://tizen.org/setting/sound.system.volume";
-static const wchar_t* _SOUND_TOUCH = L"http://tizen.org/setting/sound.touch";
-static const wchar_t* _SOUND_LOCK = L"http://tizen.org/setting/sound.lock";
-
-//Screen
-static const wchar_t* _SCREEN_WALLPAPER = L"http://tizen.org/setting/screen.wallpaper";
-static const wchar_t* _SCREEN_WALLPAPER_LOCK = L"http://tizen.org/setting/screen.wallpaper.lock";
-static const wchar_t* _WALLPAPER = L"Wallpaper";
-static const wchar_t* _SCREEN_BRIGHTNESS = L"http://tizen.org/setting/screen.brightness";
-static const wchar_t* _SCREEN_BRIGHTNESS_AUTO = L"http://tizen.org/setting/screen.brightness.auto";
-static const wchar_t* _SCREEN_BACKLIGHT_TIME = L"http://tizen.org/setting/screen.backlight.time";
-static const wchar_t* _SCREEN_ROTATION_AUTO = L"http://tizen.org/setting/screen.rotation.auto";
-static const wchar_t* _SCREEN_MODE = L"http://tizen.org/setting/screen.mode";
-static const wchar_t* _SCREEN_MODE_DYNAMIC = L"Dynamic";
-static const wchar_t* _SCREEN_MODE_STANDARD = L"Standard";
-static const wchar_t* _SCREEN_MODE_NATURAL = L"Natural";
-static const wchar_t* _SCREEN_MODE_MOVIE = L"Movie";
-static const char* _SCREEN_MODE_VCONFKEY = VCONFKEY_SETAPPL_PREFIX"/screenmode/selected_name";
-
-//Directory
-static const wchar_t* _STORAGE_DIRECTORY_WAP_DOWNLOAD = L"http://tizen.org/setting/storage.directory.wap.download";
-String _tmpStorageDirectoryWapDownload = L"";
-static const wchar_t* _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD = L"http://tizen.org/setting/storage.directory.bluetooth.download";
-String _tmpStorageDirectoryBluetoothDownload = L"";
-static const wchar_t* _STORAGE_DIRECTORY_CAMERA_RECORD = L"http://tizen.org/setting/storage.directory.camera.record";
-String _tmpStorageDirectoryCameraRecord = L"";
-static const wchar_t* _STORAGE_DIRECTORY_VOICE_RECORD = L"http://tizen.org/setting/storage.directory.voice.record";
-String _tmpStorageDirectoryVoiceRecord = L"";
-static const wchar_t* _STORAGE_DIRECTORY_RADIO_BROADCAST = L"http://tizen.org/setting/storage.directory.radio.broadcast";
-String _tmpStorageDirectoryRadioBroadcast = L"";
-static const wchar_t* _STORAGE_DIRECTORY_VIDEO_BROADCAST = L"http://tizen.org/setting/storage.directory.video.broadcast";
-String _tmpStorageDirectoryVideoBroadcast = L"";
-static const wchar_t* _SYSTEM_SOUND_VOLUME = L"SystemSoundVolume";
-
-//Device Name
-static const wchar_t* _DEVICE_NAME = L"http://tizen.org/setting/device_name";
-
-//Vibration
-static const wchar_t* _TOUCH_VIBRATION_LEVEL = L"TouchVibrationLevel";
-static const wchar_t* _VIBRATOR = L"http://tizen.org/setting/vibrator";
-static const wchar_t* _VIBRATOR_LEVEL = L"http://tizen.org/setting/vibrator.level";
-
-static const wchar_t* _VIBRATOR_LEVEL_NOTIFICATION = L"http://tizen.org/setting/vibrator.level.notification";
-
-//USB
-static const wchar_t* _USBMODE = L"UsbMode";
-static const wchar_t* _USBMODE_MTP = L"MTP";
-static const wchar_t* _USB_TETHERING = L"http://tizen.org/setting/usb.tethering";
-
-//WEB
-static const wchar_t* _WEB_APPLICATION_COOKIE_SHARE = L"http://tizen.org/setting/web.application.cookie.share";
-bool _tmpWebApplicationCookieShare = false;
-
-//Motion UI
-static const wchar_t* _MOTION_UI = L"http://tizen.org/setting/motion.ui";
-
-//Contact Order
-static const wchar_t* _CONTACT_ORDER_FIRSTNAME = L"http://tizen.org/setting/contacts.order.firstname";
-static const int _CONTACT_ORDER_FIRSTNAME_FIRSTLAST = 0;
-static const int _CONTACT_ORDER_FIRSTNAME_LASTFIRST = 1;
-
-//Privileged key
-static const wchar_t* _DEVELOPER_USBDEBUGGING = L"http://tizen.org/setting/developer.usb_debugging";
-
-static const int _MAX_COUNTRY_LENTH = 2;
-static const int _LANGUAGE_START_INDEX = 0;
-static const int _MAX_LANGUAGE_LENTH = 2;
-static const int _TOUCH_FEEDBACK_RESOLUTION = 20;
-
-static const int _OSP_USB_DEFAULT_MODE = 0;
-
-// ICU
-static const char* _ICU_DATE_FORMAT = "yMMMMEEEEd";
-static const char* _ICU_TIME_24_FORMAT = "Hms";
-static const char* _ICU_TIME_12_FORMAT = "hms";
-
-static const int _DEVELOPER_USBDEBUGGING_ON = 1;
-static const int _DEVELOPER_USBDEBUGGING_OFF = 0;
-
-// wifi direct
-static const char* _WIFI_DIRECT_LIBRARY_NAME = "libosp-wifi.so";
-static const char* _BLUETOOTH_LIBRARY_NAME = "libosp-bluetooth.so";
-
-static result (*pWifiDirectDeviceImpl_Activate)(void) = null;
-static result (*pWifiDirectDeviceImpl_Deactivate)(void) = null;
-static bool (*pWifiDirectDeviceImpl_IsActivated)(void) = null;
-static result (*pWifiManagerImpl_Activate)(void) = null;
-static result (*pWifiManagerImpl_Deactivate)(void) = null;
-static result (*pBluetoothManagerImpl_Activate)(void) = null;
-static result (*pBluetoothManagerImpl_Deactivate)(void) = null;
-
-_SettingManager* _SettingManager::__pSettingManager = null;
-
-class _SettingEventArg : public IEventArg
-{
-public:
-       String KeyName;
-};
-
-class _SettingEvent : public Event
-{
-protected:
-       virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
-       {
-               ISettingEventListener* pListener = dynamic_cast<ISettingEventListener*> (&listener);
-               const _SettingEventArg* pArg = dynamic_cast<const _SettingEventArg*>(&arg);
-
-               if(pListener == null || pArg == null)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnt");
-                       return;
-               }
-
-               String value =pArg->KeyName;
-               pListener->OnSettingChanged(value);
-       }
-};
-
-class _SettingAsyncEventArg : public IEventArg
-{
-public:
-       String Key;
-       result errorCode;
-};
-
-class _SettingAsyncEvent : public Event
-{
-protected:
-       virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
-       {
-               ISettingInfoSetValueAsyncResultListener* pListener = dynamic_cast<ISettingInfoSetValueAsyncResultListener*> (&listener);
-               const _SettingAsyncEventArg* pArg = dynamic_cast<const _SettingAsyncEventArg*>(&arg);
-
-               if(pListener == null || pArg == null)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnt");
-                       return;
-               }
-
-               result r = pArg->errorCode;
-               pListener->OnResultReceivedForSetValueAsync(pArg->Key, r);
-               RemoveListener(listener);
-               delete pListener;
-       }
-};
-
-void
-_SettingManager::InitSettingManager(void)
-{
-       static _SettingManager settingManager;
-       __pSettingManager = &settingManager;
-}
-
-_SettingManager*
-_SettingManager::GetInstance(void)
-{
-       static pthread_once_t once_block = PTHREAD_ONCE_INIT;
-       if(__pSettingManager == null)
-       {
-               pthread_once(&once_block, InitSettingManager);
-       }
-       return __pSettingManager;
-}
-
-_SettingManager::_SettingManager()
-       : __pSettingEventListener(null)
-       , __pSettingEvent(null)
-       , __listenerCount(0)
-       , __registeredSettingEvents(false)
-       , __tapiHandle(null)
-       , __pSettingAsyncEvent(null)
-       , __pSettingEventForInternal(null)
-       , __listenerInternalCount(0)
-       , __registeredSettingEventsForInternal(false)
-       , __pWifiDllHandle(null)
-{
-       __pSettingEvent = new (std::nothrow) _SettingEvent();
-       __pSettingEventForInternal = new (std::nothrow) _SettingEvent();
-       
-       tethering_create(&__tetheringHandle);
-}
-
-_SettingManager::~_SettingManager()
-{
-
-       if(__registeredSettingEvents == true)
-       {
-               __listenerCount = 0;
-               StopSettingEventListen();
-       }
-
-       delete __pSettingEvent;
-
-       if(__tetheringHandle != null)
-       {
-               tethering_destroy(__tetheringHandle);
-       }
-
-       if(__pSettingAsyncEvent != null)
-       {
-               delete __pSettingAsyncEvent;
-       }
-       __pSettingManager = null;
-}
-
-result
-_SettingManager::GetValue(const String& key, String& value)
-{
-       result r = E_SUCCESS;
-
-       if (key == _COUNTRY)
-       {
-               int ret = 0;
-               char* pCountry = null;
-               String countryValue;
-
-               ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &pCountry);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE && pCountry != null, E_SYSTEM, "[E_SYSTEM] runtime_info_get_value_string RUNTIME_INFO_KEY_LANGUAGE failed");
-
-               Tizen::Locales::Locale ospLoc = _LocaleImpl(pCountry).GetOspLocale();
-               value = ospLoc.GetCountryCodeString();
-               free (pCountry);
-       }
-       else if (key == _LOCALE_COUNTRY)
-       {
-               int ret = 0;
-               char* pCountry = null;
-               String countryValue;
-
-               ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &pCountry);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE && pCountry != null, E_SYSTEM, "[E_SYSTEM] runtime_info_get_value_string RUNTIME_INFO_KEY_LANGUAGE failed");
-
-               Tizen::Locales::Locale ospLoc = _LocaleImpl(pCountry).GetOspLocale();
-               value = ospLoc.GetLocaleCodeString();
-               free (pCountry);
-       }
-       else if (key == _DEVICE_NAME)
-       {
-               std::unique_ptr<char> pDeviceName (vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR));
-               String deviceName;
-               r = StringUtil::Utf8ToString(pDeviceName.get(), deviceName);
-               SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-
-               value = deviceName;
-       }
-       else if (key == _LOCALE_DATE)
-       {
-               DateTime currentTime;
-               SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
-               String currentFormat;
-               GetValue(_LOCALE_DATE_FORMAT, currentFormat);
-
-               std::unique_ptr<DateTimeFormatter> pFormatter(DateTimeFormatter::CreateTimeFormatterN());
-               SysTryReturnResult(NID_SYS, pFormatter != null, E_OUT_OF_MEMORY, "Failed to create DateTimeFomatter");
-               pFormatter->ApplyPattern(currentFormat);
-               value.Clear();
-               pFormatter->Format(currentTime, value);
-       }
-       else if (key == _LANGUAGE)
-       {
-               int ret = 0;
-               char* pLanguage = null;
-               String langValue;
-               LanguageCode langCode = LANGUAGE_ENG;
-
-               ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &pLanguage);
-
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE && pLanguage != null, E_SYSTEM, "[E_SYSTEM] runtime_info_get_value_string RUNTIME_INFO_KEY_LANGUAGE failed");
-
-               r = StringUtil::Utf8ToString(pLanguage, langValue);
-               free(pLanguage);
-               SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-
-               if (langValue.GetLength() > 2)
-               {
-                       langValue.SubString(0, 2, langValue);
-               }
-
-               langCode = Tizen::Locales::Locale::TwoLetterLanguageCodeStringToLanguageCode(langValue);
-               langValue = Tizen::Locales::Locale::LanguageCodeToString(langCode);
-               SysTryReturnResult(NID_SYS, langValue.GetLength() == 3, E_SYSTEM, "[E_SYSTEM] _LANGUAGEcode transform failed. value is \"%ls\"", langValue.GetPointer());
-
-               value = langValue;
-       }
-       else if (key == _LOCALE_LANGUAGE)
-       {
-               int ret = 0;
-               char* pCountry = null;
-               String countryValue;
-               String langValue;
-               LanguageCode langCode = LANGUAGE_ENG;
-
-               ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &pCountry);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE && pCountry != null, E_SYSTEM, "[E_SYSTEM] runtime_info_get_value_string RUNTIME_INFO_KEY_LANGUAGE failed");
-
-               r = StringUtil::Utf8ToString(pCountry, countryValue);
-               SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-
-               free(pCountry);
-
-               countryValue.SubString(0, 2, langValue);
-               countryValue.SubString(3, 2, countryValue);
-
-               langCode = Tizen::Locales::Locale::TwoLetterLanguageCodeStringToLanguageCode(langValue);
-               langValue = Tizen::Locales::Locale::LanguageCodeToString(langCode);
-               SysTryReturnResult(NID_SYS, langValue.GetLength() == 3, E_SYSTEM, "[E_SYSTEM] _LANGUAGEcode transform failed. value is \"%ls\"", langValue.GetPointer());
-               value.Clear();
-               value.Append(langValue);
-               value.Append("_");
-               value.Append(countryValue);
-       }
-       else if (key == _DATE_FORMAT || key == _LOCALE_DATE_FORMAT)
-       {
-               char* pDateFormat = __settingIcu.GetDateTimeFormatN(_ICU_DATE_FORMAT);
-               SysTryReturnResult(NID_SYS, pDateFormat != null, E_SYSTEM, "Failed to get date format");
-               r = StringUtil::Utf8ToString(pDateFormat, value);
-               free(pDateFormat);
-       }
-       else if (key == _LOCALE_DATETIME)
-       {
-               DateTime currentTime;
-               SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
-               String currentFormat;
-               GetValue(_LOCALE_DATETIME_FORMAT, currentFormat);
-
-               std::unique_ptr<DateTimeFormatter> pFormatter(DateTimeFormatter::CreateTimeFormatterN());
-               pFormatter->ApplyPattern(currentFormat);
-               value.Clear();
-               pFormatter->Format(currentTime, value);
-       }
-       else if (key == _DATE_TIME_FORMAT || key == _LOCALE_DATETIME_FORMAT)
-       {
-               char* pDateFormat = __settingIcu.GetDateTimeFormatN(_ICU_DATE_FORMAT);
-               char* pTimeFormat = null;
-               String timeFormat;
-               bool selected24Format = false;
-
-               SysLog(NID_SYS, "Date Time format");
-               SysTryReturnResult(NID_SYS, pDateFormat != null, E_SYSTEM, "Failed to get date format");
-
-               r = GetValue(_HOUR_FORMAT_SELECTED, selected24Format);
-               if(r != E_SUCCESS)
-               {
-                       free(pDateFormat);
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get 24 hour select state");
-                       return E_SYSTEM;
-               }
-               SysLog(NID_SYS, "24hour format, %d", selected24Format);
-               SysLog(NID_SYS, "%s", pDateFormat);
-
-               if (selected24Format == true)
-               {
-                       pTimeFormat = __settingIcu.GetDateTimeFormatN(_ICU_TIME_24_FORMAT);
-               }
-               else
-               {
-                       pTimeFormat = __settingIcu.GetDateTimeFormatN(_ICU_TIME_12_FORMAT);
-               }
-
-               if(pTimeFormat == null)
-               {
-                       free(pDateFormat);
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get date time format");
-                       return E_SYSTEM;
-               }
-
-               r = StringUtil::Utf8ToString(pDateFormat, value);
-               r = StringUtil::Utf8ToString(pTimeFormat, timeFormat);
-
-               value.Append(" ");
-               value.Append(timeFormat);
-               free(pDateFormat);
-               free(pTimeFormat);
-       }
-       else if (key == _LOCALE_TIME)
-       {
-               DateTime currentTime;
-               SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
-               String currentFormat;
-               GetValue(_LOCALE_TIME_FORMAT, currentFormat);
-
-               std::unique_ptr<DateTimeFormatter> pFormatter(DateTimeFormatter::CreateTimeFormatterN());
-               pFormatter->ApplyPattern(currentFormat);
-               value.Clear();
-               pFormatter->Format(currentTime, value);
-       }
-       else if (key == _LOCALE_TIMEZONE)
-       {
-               char pTZPath[256] = {0,};
-               ssize_t nLen = readlink(_LOCALE_TIMEZONE_LINK, pTZPath, sizeof(pTZPath)-1);
-               if (nLen != -1)
-               {
-                       pTZPath[nLen] = '\0';
-               }
-               else
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to get timezone");
-               }
-               value.Clear();
-               value.Append(&pTZPath[_LOCALE_TIMEZONE_ROOT_PATH_LENGTH]);
-       }
-       else if (key == _LOCALE_WEEK_FORMAT_FIRSTDAY)
-       {
-               int firstDay = 0;
-               int ret = -1;
-
-               ret = vconf_get_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, &firstDay);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT vconf");
-
-               if (firstDay == _LOCALE_WEEK_FORMAT_VCONF_SUNDAY)
-               {
-                       value = _LOCALE_WEEK_FORMAT_FIRSTDAY_SUNDAY;
-               }
-               else if (firstDay == _LOCALE_WEEK_FORMAT_VCONF_MONDAY)
-               {
-                       value = _LOCALE_WEEK_FORMAT_FIRSTDAY_MONDAY;
-               }
-               else
-               {
-                       r = E_SYSTEM;
-               }
-       }
-       else if (key == _NETWORK_TELEPHONY_MODE)
-       {
-               value = _tmpNetworkTelephonyMode;
-       }
-       else if (key == _NETWORK_TELEPHONY_PROVIDER)
-       {
-               value = _tmpNetworkTelephonyProvider;
-       }
-       else if (key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
-       {
-               int ret = 0;
-               char* password = null;
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               ret = tethering_wifi_get_passphrase(__tetheringHandle, &password);
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get password");
-
-               value.Clear();
-               value.Append(password);
-               free(password);
-       }
-       else if (key == _SCREEN_MODE)
-       {
-               std::unique_ptr<char> curmode(vconf_get_str(_SCREEN_MODE_VCONFKEY));
-               value.Clear();
-               value.Append(curmode.get());
-       }
-       else if (key == _STORAGE_DIRECTORY_WAP_DOWNLOAD)
-       {
-               value = _tmpStorageDirectoryWapDownload;
-       }
-       else if (key == _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD)
-       {
-               value = _tmpStorageDirectoryBluetoothDownload;
-       }
-       else if (key == _STORAGE_DIRECTORY_CAMERA_RECORD)
-       {
-               value = _tmpStorageDirectoryCameraRecord;
-       }
-       else if (key == _STORAGE_DIRECTORY_VOICE_RECORD)
-       {
-               value = _tmpStorageDirectoryVoiceRecord;
-       }
-       else if (key == _STORAGE_DIRECTORY_RADIO_BROADCAST)
-       {
-               value = _tmpStorageDirectoryRadioBroadcast;
-       }
-       else if (key == _STORAGE_DIRECTORY_VIDEO_BROADCAST)
-       {
-               value = _tmpStorageDirectoryVideoBroadcast;
-       }
-       else if (key == _FONTTYPE || key == _FONT_TYPE)
-       {
-               char* pFontType = null;
-               int res = 0;
-               res = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &pFontType);
-               SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "Failed to get font type");
-               r = StringUtil::Utf8ToString(pFontType, value);
-               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-               free(pFontType);
-       }
-       else if (key == _FONT_SIZE || key == _FONTSIZE)
-       {
-               int fontSize = 0;
-               int res = 0;
-               res = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &fontSize);
-               SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "Failed to get font size");
-               value.Clear();
-               switch (fontSize)
-               {
-               case _FONT_SIZE_GIANT_VCONF:
-                       if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-                       {
-                               value.Append(_FONT_SIZE_GIANT);
-                               break;
-                       }
-               case _FONT_SIZE_HUGE_VCONF:
-                       if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-                       {
-                               value.Append(_FONT_SIZE_HUGE);
-                               break;
-                       }
-               case _FONT_SIZE_LARGE_VCONF:
-                       value.Append(_FONT_SIZE_LARGE);
-                       break;
-               case _FONT_SIZE_MEDIUM_VCONF:
-                       value.Append(_FONT_SIZE_MEDIUM);
-                       break;
-               case _FONT_SIZE_SMALL_VCONF:
-                       value.Append(_FONT_SIZE_SMALL);
-                       break;
-               default:
-                       r = E_SYSTEM;
-                       break;
-               }
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       value.ToLowerCase();
-               }
-       }
-       else if (key == _RINGTONE || key == _SOUND_RINGTONE)
-       {
-               char* pRingtone = null;
-               int res = 0;
-               res = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &pRingtone);
-               SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "Failed to get ringtone");
-
-               r = StringUtil::Utf8ToString(pRingtone, value);
-               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-
-               free(pRingtone);
-
-       }
-       else if (key == _TIME_FORMAT || key == _LOCALE_TIME_FORMAT)
-       {
-               char* pTimeFormat = null;
-               bool selected24Format = false;
-
-               r = GetValue(_HOUR_FORMAT_SELECTED, selected24Format);
-
-               if (selected24Format == true)
-               {
-                       pTimeFormat = __settingIcu.GetDateTimeFormatN(_ICU_TIME_24_FORMAT);
-               }
-               else
-               {
-                       pTimeFormat = __settingIcu.GetDateTimeFormatN(_ICU_TIME_12_FORMAT);
-               }
-               SysTryReturnResult(NID_SYS, pTimeFormat != null, E_SYSTEM, "Failed to get time format");
-               r = StringUtil::Utf8ToString(pTimeFormat, value);
-               free(pTimeFormat);
-       }
-       else if (key == _WALLPAPER || key == _SCREEN_WALLPAPER)
-       {
-               int ret = 0;
-               char* pWallpaper = null;
-
-               ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &pWallpaper);
-               SysTryReturn(NID_SYS, ret == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get wallpaper of home screen");
-
-               r = StringUtil::Utf8ToString(pWallpaper, value);
-               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-
-               free(pWallpaper);
-       }
-       else if (key == _SCREEN_WALLPAPER_LOCK)
-       {
-               int ret = 0;
-               char* pWallpaper = null;
-
-               ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &pWallpaper);
-               SysTryReturn(NID_SYS, ret == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get wallpaper of lock screen");
-
-               r = StringUtil::Utf8ToString(pWallpaper, value);
-               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-
-               free(pWallpaper);
-       }
-       else if (key == _USBMODE)
-       {
-               value = _USBMODE_MTP;
-       }
-       else
-       {
-               r = E_OBJ_NOT_FOUND;
-       }
-       return r;
-}
-
-result
-_SettingManager::GetValue(const String& key, int& value)
-{
-       result r = E_SUCCESS;
-       if (key == _TOUCH_VIBRATION_LEVEL || key == _VIBRATOR_LEVEL)
-       {
-               int vibLevel = -1;
-               int ret = 0;
-               ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK, &vibLevel);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "runtime_info_get_value_int(RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK) is Failed");
-
-               value = vibLevel * _TOUCH_FEEDBACK_RESOLUTION;
-       }
-       else if (key == _MEDIA_SOUND_VOLUME || key == _SOUND_MEDIA_VOLUME)
-       {
-               int volume = 0;
-               int maxVolume = 0;
-
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_MEDIA, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume Failed");
-
-               ret = sound_manager_get_volume(SOUND_TYPE_MEDIA, &volume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume Failed");
-
-               value = volume;
-       }
-       else if (key == _NOTIFICATION_SOUND_VOLUME || key == _SOUND_NOTIFICATION_VOLUME)
-       {
-               int volume = 0;
-               int maxVolume = 0;
-
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_NOTIFICATION, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume Failed");
-
-               ret = sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &volume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume Failed");
-
-               value = volume;
-       }
-       else if (key == _RINGTONE_SOUND_VOLUME || key == _SOUND_RINGTONE_VOLUME)
-       {
-               int volume = 0;
-               int maxVolume = 0;
-
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_RINGTONE, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume Failed");
-
-               ret = sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume Failed");
-
-               value = volume;
-       }
-       else if (key == _SYSTEM_SOUND_VOLUME || key == _SOUND_SYSTEM_VOLUME)
-       {
-               int volume = 0;
-               int maxVolume = 0;
-
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_SYSTEM, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume Failed");
-
-               ret = sound_manager_get_volume(SOUND_TYPE_SYSTEM, &volume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume Failed");
-
-               value = volume;
-       }
-       else if (key == _SCREEN_BRIGHTNESS)
-       {
-               int brightness = 0;
-               int ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_LCD_BRIGHTNESS vconf");
-               value = brightness;
-       }
-       else if (key == _SCREEN_BACKLIGHT_TIME)
-       {
-               int timeout = 0;
-               int ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &timeout);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_TIMEOUT_NORMAL vconf");
-               value = timeout;
-       }
-       else if (key == _VIBRATOR_LEVEL_NOTIFICATION)
-       {
-               int level = 0;
-               int ret = vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT vconf");
-               value = level;
-       }
-       else
-       {
-               r = E_OBJ_NOT_FOUND;
-       }
-       return r;
-}
-
-result
-_SettingManager::GetValue(const String& originalKey, long long& value)
-{
-       return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingManager::GetValue(const String& originalKey, double& value)
-{
-       return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingManager::GetValue(const String& key, bool& value)
-{
-       result r = E_SUCCESS;
-       int vconf_bool = 0;
-       int ret = -1;
-
-       if (key == _BATTERY_FORMAT_PERCENTAGE)
-       {
-               ret = vconf_get_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, &vconf_bool);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL vconf");
-
-               if(vconf_bool == 0)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-       }
-       else if (key == _LOCALE_UPDATE_AUTO)
-       {
-               ret = vconf_get_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &vconf_bool);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL vconf");
-               value = vconf_bool ? true : false;
-       }
-       else if (key == _NETWORK_WIFI)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               int wifiState = 0;
-               ret = vconf_get_int(VCONFKEY_WIFI_STATE, &wifiState);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_WIFI_STATE vconf");
-               if(wifiState== VCONFKEY_WIFI_OFF)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-               return r;
-       }
-       else if (key == _NETWORK_WIFI_NOTIFICATION)
-       {
-               int wifiQSState = 0;
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               ret = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &wifiQSState);
-               SysTryReturnResult(NID_SYS, ret != -1, E_UNSUPPORTED_OPERATION, "Current device does not support %ls key.", key.GetPointer());
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_WIFI_ENABLE_QS vconf");
-
-               if(wifiQSState == VCONFKEY_WIFI_QS_DISABLE)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-               return r;
-       }
-       else if (key == _NETWORK_WIFI_TETHERING)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI);
-               return r;
-       }
-       else if (key == _NETWORK_WIFI_TETHERING_HIDE)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               ret = tethering_wifi_get_ssid_visibility(__tetheringHandle, &value);
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to get wifi tethering visibility state");
-               return r;
-       }
-       else if (key == _NETWORK_WIFI_TETHERING_SECURITY)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               tethering_wifi_security_type_e securityType;
-               ret = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to get wifi tethering securiy state");
-               if(securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-               return r;
-       }
-       else if (key == _NETWORK_WIFI_DIRECT)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI_DIRECT, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support WiFi direct feature");
-               SysTryReturnResult(NID_SYS, LoadWifiDll() == E_SUCCESS, E_SYSTEM, "Failed to open wifi so");
-       
-               bool isActivated = false;
-               isActivated = pWifiDirectDeviceImpl_IsActivated();
-               
-               UnloadWifiDll();
-               SysTryReturnResult(NID_SYS, GetLastResult() == E_SUCCESS, E_SYSTEM, "Failed to get wifi direct state");
-               value = isActivated;
-               return r;
-       }
-       else if (key == _NETWORK_BLUETOOTH)
-       {
-               int bluetoothStatus = VCONFKEY_BT_STATUS_OFF;
-               ret = vconf_get_int(VCONFKEY_BT_STATUS, &bluetoothStatus);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to read bluetooth status.");
-
-               if(bluetoothStatus == VCONFKEY_BT_STATUS_OFF)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-
-               return r;
-       }
-       else if (key == _NETWORK_BLUETOOTH_TETHERING)
-       {
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               value  = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT);
-               return r;
-       }
-       else if (key == _SCREEN_BRIGHTNESS_AUTO)
-       {
-               int brightnessAuto = 0;
-               int ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &brightnessAuto);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL vconf");
-
-               if(brightnessAuto == 0)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-               return r;
-       }
-       else if (key == _SOUND_LOCK)
-       {
-               int soundLock = 0;
-               int ret = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &soundLock);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_SOUND_LOCK_BOO vconf");
-               if(soundLock == 0)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-               return r;
-       }
-       else if (key == _SOUND_TOUCH)
-       {
-               int soundTouch = 0;
-               int ret = vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &soundTouch);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL vconf");
-               if(soundTouch == 0)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-               return r;
-       }
-       else if (key == _VIBRATOR)
-       {
-               ret = vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_bool);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL vconf");
-               value = vconf_bool ? true : false;
-               return r;
-       }
-       else if (key == _USB_TETHERING)
-       {
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB);
-               return r;
-       }
-       else if (key == _WEB_APPLICATION_COOKIE_SHARE)
-       {
-               value = _tmpWebApplicationCookieShare;
-               return r;
-       }
-       else if (key == _LOCATION_GPS_ADVANCED)
-       {
-               int agps = 0;
-               ret = vconf_get_int(VCONFKEY_LOCATION_AGPS_ENABLED, &agps);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL vconf");
-
-               if(agps == 0)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-
-               return r;
-       }
-       else if (key == _SCREEN_ROTATION_AUTO)
-       {
-               ret = vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_bool);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL vconf");
-               value = vconf_bool;
-       }
-       else if (key == _HOUR_FORMAT_SELECTED || key == _LOCALE_TIME_FORMAT_24HOUR)
-       {
-               bool is24HoueEnabled = false;
-               ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED, &is24HoueEnabled);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__WIFI_SUPPORTED");
-               value = is24HoueEnabled;
-
-               return r;
-       }
-       else if (key == _ENABLE_MOTION || key == _MOTION_UI)
-       {
-               bool enableMotion = false;
-               ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, &enableMotion);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the SYSTEM_SETTINGS_KEY_MOTION_ACTIVIATION");
-               value = enableMotion;
-
-               return r;
-       }
-       else if (key == _DATA_ROAMING_ENABLED || key == _NETWORK_TELEPHONY_ROAMING)
-       {
-               bool dataRoamingEnabled = false;
-               ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, &dataRoamingEnabled);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED");
-               value = dataRoamingEnabled;
-
-               return r;
-       }
-       else if (key == _GPS_ENABLED || key == _LOCATION_GPS)
-       {
-               int gps_value = 0;
-               ret = vconf_get_int(VCONFKEY_LOCATION_ENABLED, &gps_value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the VCONFKEY_LOCATION_ENABLED");
-               if(gps_value == 0)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-       }
-       else if (key == _PACKET_SERVICE_ALLOWED || key == _NETWORK_TELEPHONY_PACKETSERVICE)
-       {
-               bool packetServiceAllowed = false;
-               ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, &packetServiceAllowed);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the RUNTIME_INFO_KEY_PACKET_DATA_ENABLED");
-               value = packetServiceAllowed;
-
-               return r;
-       }
-       else if (key == _SILENT_MODE || key == _SOUND_SILENTMODE)
-       {
-               bool silentModeEnabled = false;
-               ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, &silentModeEnabled);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the RUNTIME_INFO_KEY_SILENT_MODE_ENABLED");
-               value = !silentModeEnabled;
-
-               return r;
-       }
-       else if (key == _WPS_ENABLED || key == _LOCATION_WPS)
-       {
-               int wps_value = 0;
-               ret = vconf_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED, &wps_value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the VCONFKEY_LOCATION_NETWORK_ENABLED");
-               if(wps_value == 0)
-               {
-                       value = false;
-               }
-               else
-               {
-                       value = true;
-               }
-
-       }
-       else if (key == _FLIGHT_MODE_ENABLED || key == _NETWORK_FLIGHTMODE)
-       {
-               bool flightModeEnabled = false;
-               ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, &flightModeEnabled);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED");
-               value = flightModeEnabled;
-
-               return r;
-       }
-       else if (key == _DEVELOPER_USBDEBUGGING)
-       {
-               int usbMode = 0;
-               ret = vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &usbMode);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL");
-               value = usbMode == _DEVELOPER_USBDEBUGGING_ON;
-       }
-       else if (key == _NETWORK_TELEPHONY_ROAMING)
-       {
-               ret = vconf_get_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, &vconf_bool);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL");
-               value = vconf_bool ? true : false;
-       }
-       else if (key == _CONTACT_ORDER_FIRSTNAME)
-       {
-               int contactOrder = 0;
-               ret = vconf_get_int(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, &contactOrder);
-               SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER");
-
-               if (contactOrder == _CONTACT_ORDER_FIRSTNAME_FIRSTLAST)
-               {
-                       value = true;
-               }
-               else if (contactOrder == _CONTACT_ORDER_FIRSTNAME_LASTFIRST)
-               {
-                       value = false;
-               }
-               else
-               {
-                       return E_SYSTEM;
-               }
-       }
-       else
-       {
-               r = E_OBJ_NOT_FOUND;
-       }
-
-       return r;
-}
-
-result
-_SettingManager::GetValue(const String& originalKey, UuId& value)
-{
-       return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingManager::GetValueForPrivilegedKey(const String& originalKey, bool& value)
-{
-       return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingManager::SetValue(const String& key, const bool& value)
-{
-       int ret = -1;
-
-       if(key == _LOCALE_TIME_FORMAT_24HOUR)
-       {               
-               ret = vconf_set_int(VCONFKEY_REGIONFORMAT_TIME1224, value ? VCONFKEY_TIME_FORMAT_24 : VCONFKEY_TIME_FORMAT_12);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_REGIONFORMAT_TIME1224 vconf");
-       }
-       else if(key == _BATTERY_FORMAT_PERCENTAGE)
-       {
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL vconf");
-       }
-       else if(key == _LOCALE_UPDATE_AUTO)
-       {
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL vconf");
-       }
-       else if(key == _NETWORK_WIFI_NOTIFICATION)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               int currentValue = 0;
-               ret = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &currentValue);
-               SysTryReturnResult(NID_SYS, ret != -1, E_UNSUPPORTED_OPERATION, "This device does not support %ls key.", key.GetPointer());
-
-               if(value == true)
-               {
-                       ret = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_ENABLE);
-               }
-               else
-               {
-                       ret = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_DISABLE);
-               }
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_WIFI_ENABLE_QS vconf");
-       }
-       else if(key == _NETWORK_WIFI_TETHERING)
-       {
-               result r = E_SUCCESS;
-
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-                sim_state_e simState;
-                ret = sim_get_state(&simState);
-
-                SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the SIM state");
-                SysTryReturnResult(NID_SYS, simState != SIM_STATE_UNAVAILABLE, E_INVALID_STATE, "SIM is not available");
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-
-               bool state = false;
-               r = GetValue(_NETWORK_WIFI, state);
-                SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to get the WIFI state");
-                SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "WIFI is not activated");
-       
-               if(value == true)
-               {
-                       if(tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI) == false)
-                       {
-                               ret = tethering_enable(__tetheringHandle, TETHERING_TYPE_WIFI);
-                       }
-               }
-               else
-               {
-                       if(tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI) == true)
-                       {
-                               ret = tethering_disable(__tetheringHandle, TETHERING_TYPE_WIFI);
-                       }
-               }
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to change tethering option");
-       }
-       else if(key == _NETWORK_WIFI_TETHERING_HIDE)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               bool currentState = false;
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               ret = tethering_wifi_get_ssid_visibility(__tetheringHandle, &currentState);
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to current wifi tethering visibility setting");
-
-               if(value == true && currentState == false)
-               {
-                       ret = tethering_wifi_set_ssid_visibility(__tetheringHandle, true);
-               }
-               else if(value == false && currentState == true)
-               {
-                       ret = tethering_wifi_set_ssid_visibility(__tetheringHandle, false);
-               }
-
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to change wifi tethering visibility setting");
-       }
-       else if(key == _NETWORK_WIFI_TETHERING_SECURITY)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               tethering_wifi_security_type_e securityType;
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               ret = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to get wifi tethering securiy state");
-
-               if(value == true && securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
-               {
-                       ret = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK);
-               }
-               else if(value == false && securityType == TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK)
-               {
-                       ret = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_NONE);
-               }
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to change wifi tethering visibility setting");
-       }
-       else if(key == _NETWORK_BLUETOOTH)
-       {
-               bool supported = false;
-               int bluetoothStatus = VCONFKEY_BT_STATUS_OFF;
-               result r = E_SUCCESS;
-               r = _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_BLUETOOTH, supported);
-               SysTryReturnResult(NID_SYS, supported == true && r == E_SUCCESS, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-               SysTryReturnResult(NID_SYS, LoadBluetoothDll() == E_SUCCESS, E_SYSTEM, "It is failed to load bluetooth library.");
-
-               ret = vconf_get_int(VCONFKEY_BT_STATUS, &bluetoothStatus);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to read bluetooth status.");
-
-               if(value == true)
-               {
-                       if(bluetoothStatus == VCONFKEY_BT_STATUS_OFF)
-                       {
-                               r = pBluetoothManagerImpl_Activate();
-                       }
-               }
-               else
-               {
-                       if(bluetoothStatus != VCONFKEY_BT_STATUS_OFF)
-                       {
-                               r = pBluetoothManagerImpl_Deactivate();
-                       }
-               }
-
-               UnloadBluetoothDll();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to change bluetooth state.");
-       }
-       else if(key == _NETWORK_BLUETOOTH_TETHERING)
-       {
-               result r = E_SUCCESS;
-                sim_state_e simState;
-                ret = sim_get_state(&simState);
-
-                SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the SIM state");
-                SysTryReturnResult(NID_SYS, simState != SIM_STATE_UNAVAILABLE, E_INVALID_STATE, "SIM is not available");
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-
-               bool state = false;
-               r = GetValue(_NETWORK_BLUETOOTH, state);
-                SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to get the Bluetooth state");
-                SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "Bluetooth is not activated");
-       
-               if(value == true)
-               {
-                       if(tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT) == false)
-                       {
-                               ret = tethering_enable(__tetheringHandle, TETHERING_TYPE_BT);
-                       }
-               }
-               else
-               {
-                       if(tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT) == true)
-                       {
-                               ret = tethering_disable(__tetheringHandle, TETHERING_TYPE_BT);
-                       }
-               }
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to change tethering option");
-       }
-       else if(key == _SCREEN_BRIGHTNESS_AUTO)
-       {
-               if(value == true)
-               {
-                       ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
-               }
-               else
-               {
-                       ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
-               }
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL vconf");
-       }
-       else if(key == _SOUND_LOCK)
-       {
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_SOUND_LOCK_BOOL vconf");
-       }
-       else if(key == _SOUND_TOUCH)
-       {
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL vconf");
-       }
-       else if(key == _USB_TETHERING)
-       {
-                sim_state_e simState;
-                ret = sim_get_state(&simState);
-
-                SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the SIM state");
-                SysTryReturnResult(NID_SYS, simState != SIM_STATE_UNAVAILABLE, E_INVALID_STATE, "SIM is not available");
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-
-               if(value == true)
-               {
-                       if(tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB) == false)
-                       {
-                               ret = tethering_enable(__tetheringHandle, TETHERING_TYPE_USB);
-                       }
-               }
-               else
-               {
-                       if(tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB) == true)
-                       {
-                               ret = tethering_disable(__tetheringHandle, TETHERING_TYPE_USB);
-                       }
-               }
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to change tethering option");
-       }
-       else if(key == _WEB_APPLICATION_COOKIE_SHARE)
-       {
-               _tmpWebApplicationCookieShare = value;
-       }
-       else if(key == _VIBRATOR)
-       {
-               if(!value)
-               {
-                       ret = haptic_open(HAPTIC_DEVICE_0, &__hapticHandle);
-                       SysTryReturnResult(NID_SYS, ret == HAPTIC_ERROR_NONE, E_SYSTEM, "It is failed to open haptic library");
-                       haptic_stop_all_effects(__hapticHandle);
-                       ret = haptic_close(__hapticHandle);
-                       SysTryReturnResult(NID_SYS, ret == HAPTIC_ERROR_NONE, E_SYSTEM, "It is failed to close haptic library");
-                       __hapticHandle = null;
-               }
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL vconf");
-       }
-       else if(key == _SCREEN_ROTATION_AUTO)
-       {
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL vconf");
-       }
-       else if(key == _SOUND_SILENTMODE)
-       {
-               bool silentMode = !value;
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, silentMode);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_SOUND_STATUS_BOOL vconf");
-       }
-       else if (key == _CONTACT_ORDER_FIRSTNAME)
-       {
-               int contactOrder = 0;
-
-               if (value)
-               {
-                       contactOrder = _CONTACT_ORDER_FIRSTNAME_FIRSTLAST;
-               }
-               else
-               {
-                       contactOrder = _CONTACT_ORDER_FIRSTNAME_LASTFIRST;
-               }
-               ret = vconf_set_int(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, contactOrder);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER vconf");
-       }
-       else if(key == _MOTION_UI)
-       {
-               ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set the SYSTEM_SETTINGS_KEY_MOTION_ACTIVIATION");
-       }
-       else
-       {
-               return E_OBJ_NOT_FOUND;
-       }
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::SetValue(const String& key, const int& value)
-{
-       if(key == _VIBRATOR_LEVEL)
-       {
-               SysTryReturnResult(NID_SYS, value >= 0 && value <= 100, E_INVALID_ARG, "Speicified value is not valid");
-               int ret = vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT vconf");
-       }
-       else if(key == _VIBRATOR_LEVEL_NOTIFICATION)
-       {
-               SysTryReturnResult(NID_SYS, value >= 0 && value <= 100, E_INVALID_ARG, "Speicified value is not valid");
-               int ret = vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT vconf");
-       }
-       else if(key == _SCREEN_BRIGHTNESS)
-       {
-               SysTryReturnResult(NID_SYS, value > 0 && value <= 100, E_INVALID_ARG, "Out of range");
-
-               int ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_TIMEOUT_NORMAL vconf");
-               ret = device_set_brightness(0, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to update on Screen Brightness vconf");
-       }
-       else if(key == _SCREEN_BACKLIGHT_TIME)
-       {
-               SysTryReturnResult(NID_SYS, value == 15 || value == 30 || value == 60 || value == 120 || value == 300 || value == 600, E_INVALID_ARG, "Out of range");
-
-               int ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL vconf");
-       }
-       else if (key == _SOUND_SYSTEM_VOLUME)
-       {
-               return SetVolume(_SYSTEM_SOUND_VOLUME, value);
-       }
-       else if (key == _SOUND_MEDIA_VOLUME)
-       {
-               return SetVolume(_MEDIA_SOUND_VOLUME, value);
-       }
-       else if (key ==_SOUND_RINGTONE_VOLUME)
-       {
-               return SetVolume(_RINGTONE_SOUND_VOLUME, value);
-       }
-       else if (key == _SOUND_NOTIFICATION_VOLUME)
-       {
-               return SetVolume(_NOTIFICATION_SOUND_VOLUME, value);
-       }
-       else
-       {
-               return E_OBJ_NOT_FOUND;
-       }
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::SetValue(const String& key, const String& value)
-{
-       result r = E_SUCCESS;
-
-       if (key == _LOCALE_DATE_FORMAT
-               || key == _LOCALE_DATETIME_FORMAT
-               || key == _LOCALE_TIME_FORMAT )
-       {
-       }
-       else if(key == _DEVICE_NAME)
-       {
-               char* deviceName = _StringConverter::CopyToCharArrayN(value);
-               SysTryReturnResult(NID_SYS, deviceName != null, E_SYSTEM, "Failed to convert String to string");
-
-               int err = vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, deviceName);
-               delete [] deviceName;
-               SysTryReturnResult(NID_SYS, err == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_DEVICE_NAME_STR vconf");
-       }
-       else if(key == _LOCALE_COUNTRY)
-       {
-               int err = 0;
-               std::unique_ptr<char> lang (_StringConverter::CopyToCharArrayN(value));
-               SysTryReturnResult(NID_SYS, lang != null, E_SYSTEM, "Failed to convert String to string");
-
-               icu::Locale locale(lang.get());
-               err = locale.isBogus();
-               SysTryReturnResult(NID_SYS, err == 0, E_INVALID_ARG, "Unknown language format");
-
-               std::string localeCode(locale.getLanguage());
-               localeCode.append("_");
-               localeCode.append(locale.getCountry());
-               localeCode.append(".utf8");
-
-               err = vconf_set_str(VCONFKEY_REGIONFORMAT, localeCode.c_str());
-               SysTryReturnResult(NID_SYS, err == 0, E_SYSTEM, "Failed to set on VCONFKEY_REGIONFORMAT vconf");
-       }
-       else if(key == _LOCALE_LANGUAGE)
-       {
-               int err = 0;
-               std::unique_ptr<char> lang (_StringConverter::CopyToCharArrayN(value));
-               SysTryReturnResult(NID_SYS, lang != null, E_SYSTEM, "Failed to convert String to string");
-
-               icu::Locale locale(lang.get());
-               err = locale.isBogus();
-               SysTryReturnResult(NID_SYS, err == 0, E_INVALID_ARG, "Unknown language format");
-
-               std::string localeCode(locale.getLanguage());
-               localeCode.append("_");
-               localeCode.append(locale.getCountry());
-               localeCode.append(".utf8");
-
-               err = vconf_set_str(VCONFKEY_LANGSET, localeCode.c_str());
-               SysTryReturnResult(NID_SYS, err == 0, E_SYSTEM, "Failed to set on VCONFKEY_LANGSET vconf");
-       }
-       else if(key == _LOCALE_WEEK_FORMAT_FIRSTDAY)
-       {
-               int firstDay = 0;
-               int ret = -1;
-
-               if (value == _LOCALE_WEEK_FORMAT_FIRSTDAY_SUNDAY)
-               {
-                       firstDay = _LOCALE_WEEK_FORMAT_VCONF_SUNDAY;
-               }
-               else if (value == _LOCALE_WEEK_FORMAT_FIRSTDAY_MONDAY)
-               {
-                       firstDay = _LOCALE_WEEK_FORMAT_VCONF_MONDAY;
-               }
-               else
-               {
-                       return E_INVALID_ARG;
-               }
-
-               ret = vconf_set_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, firstDay);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT vconf");
-       }
-       else if (key == _FONT_SIZE)
-       {
-               int fontSize = 0;
-               int res = 0;
-
-               if (value == _FONT_SIZE_GIANT_LOWERCASE)
-               {
-                       fontSize = _FONT_SIZE_GIANT_VCONF;
-               }
-               else if (value == _FONT_SIZE_HUGE_LOWERCASE)
-               {
-                       fontSize = _FONT_SIZE_HUGE_VCONF;
-               }
-               else if (value == _FONT_SIZE_LARGE_LOWERCASE)
-               {
-                       fontSize = _FONT_SIZE_LARGE_VCONF;
-               }
-               else if (value == _FONT_SIZE_MEDIUM_LOWERCASE)
-               {
-                       fontSize = _FONT_SIZE_MEDIUM_VCONF;
-               }
-               else if (value == _FONT_SIZE_SMALL_LOWERCASE)
-               {
-                       fontSize = _FONT_SIZE_SMALL_VCONF;
-               }
-               else
-               {
-                       return E_UNSUPPORTED_OPERATION;
-               }
-               res = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, fontSize);
-               SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "Failed to set font size");
-       }
-       else if(key == _LOCALE_TIMEZONE)
-       {
-               r = E_SUCCESS;
-               std::unique_ptr<IMap, AllElementsDeleter> pSupportedTimeZoneList(_LocaleManagerImpl::GetAvailableTimeZonesN());
-
-               SysTryReturnResult(NID_SYS, pSupportedTimeZoneList != null, E_SYSTEM, "It is failed to get supported timezone list.");
-               SysTryReturnResult(NID_SYS, pSupportedTimeZoneList->ContainsKey(value) == true, E_INVALID_ARG, "Specified timezone id[%S] is not valid", value.GetPointer());
-
-               std::unique_ptr<char> tzpath (_StringConverter::CopyToCharArrayN(value));
-               SysTryReturnResult(NID_SYS, tzpath != null, E_SYSTEM, "It is failed to convert String to string");
-               std::string tzStr(_LOCALE_TIMEZONE_ROOT_PATH);
-               tzStr.append(tzpath.get());
-               std::unique_ptr<char> cstrTzpath (strdup(tzStr.c_str()));
-               int ret = sysman_set_timezone(cstrTzpath.get());
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to set timezone");
-
-               ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_ID, cstrTzpath.get()+_LOCALE_TIMEZONE_ROOT_PATH_LENGTH);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to set VCONFKEY_SETAPPL_TIMEZONE_ID vconf");
-
-               ret = vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED, -1);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to notify to system about time changing");
-       }
-       else if(key == _FONT_TYPE)
-       {
-               char* pFontType = null;
-               int res = 0;
-
-               pFontType = _StringConverter::CopyToCharArrayN(value);
-               SysTryReturnResult(NID_SYS, pFontType != null, E_SYSTEM, "Failed to convert String to string");
-               SysLog(NID_SYS, "Requested font type is %s.", pFontType);
-               res = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, pFontType);
-               delete [] pFontType;
-               SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "Failed to set font type");
-       }
-       else if(key == _NETWORK_TELEPHONY_MODE)
-       {
-               _tmpNetworkTelephonyMode = value;
-       }
-       else if(key ==_NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
-       {
-               int ret = 0;
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature");
-               std::unique_ptr<char> password(_StringConverter::CopyToCharArrayN(value));
-               SysTryReturnResult(NID_SYS, password != null, E_SYSTEM, "Failed to convert String to string");
-               ret = tethering_wifi_set_passphrase(__tetheringHandle, password.get());
-               SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to set password");
-       }
-       else if(key == _SCREEN_MODE)
-       {
-               int ret = 0;
-               
-
-               SysTryReturnResult(NID_SYS, value == _SCREEN_MODE_DYNAMIC || value == _SCREEN_MODE_STANDARD || value == _SCREEN_MODE_NATURAL || value == _SCREEN_MODE_MOVIE, E_INVALID_ARG, "designated value(%ls) is invalid", value.GetPointer());
-               char* screenMode = _StringConverter::CopyToCharArrayN(value);
-               ret  = vconf_set_str(_SCREEN_MODE_VCONFKEY, screenMode);
-
-               if(ret == 0)
-               {
-                       r = E_SYSTEM;
-                       SysLog(NID_SYS, "Failed to change screen mode");
-               }
-               if(screenMode != null)
-               {
-                       delete [] screenMode;
-               }
-       }
-       else if(key == _SCREEN_WALLPAPER)
-       {
-               int ret = 0;
-               SysTryReturn(NID_SYS, File::IsFileExist(value) == true, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "The entry for the specified wallpaper file or the file path cannot be found");
-               std::unique_ptr<char> pFilePath(_StringConverter::CopyToCharArrayN(value));
-
-               SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "Failed to convert type of filePath");
-
-               ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, pFilePath.get());
-               SysTryReturn(NID_SYS, ret == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to set wallpaper of home screen");
-       }
-       else if(key == _SCREEN_WALLPAPER_LOCK)
-       {
-               int ret = 0;
-               char* pFilePath = null;
-
-               SysTryReturn(NID_SYS, File::IsFileExist(value) == true, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] The entry for the specified wallpaper file or the file path cannot be found");
-               pFilePath = _StringConverter::CopyToCharArrayN(value);
-
-               SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to convert type of filePath");
-
-               ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, const_cast<char*>(pFilePath));
-               delete [] pFilePath;
-               SysTryReturn(NID_SYS, ret == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to set wallpaper of home screen");
-       }
-       else if(key == _SOUND_RINGTONE)
-       {
-               int ret = 0;
-               char* pFilePath = null;
-
-               SysTryReturn(NID_SYS, File::IsFileExist(value) == true, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] The entry for the specified ringtone file or the file path cannot be found");
-               pFilePath = _StringConverter::CopyToCharArrayN(value);
-
-               SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to convert type of filePath");
-
-               ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, const_cast<char*>(pFilePath));
-               SysTryReturn(NID_SYS, ret == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to set ringtone");
-
-               delete [] pFilePath;
-       }
-       else if(key == _STORAGE_DIRECTORY_WAP_DOWNLOAD)
-       {
-               _tmpStorageDirectoryWapDownload = value;
-       }
-       else if(key == _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD)
-       {
-               _tmpStorageDirectoryWapDownload = value;
-       }
-       else if(key == _STORAGE_DIRECTORY_CAMERA_RECORD)
-       {
-               _tmpStorageDirectoryWapDownload = value;
-       }
-       else if(key == _STORAGE_DIRECTORY_VOICE_RECORD)
-       {
-               _tmpStorageDirectoryVoiceRecord = value;
-       }
-       else if(key == _STORAGE_DIRECTORY_RADIO_BROADCAST)
-       {
-               _tmpStorageDirectoryRadioBroadcast = value;
-       }
-       else if(key == _STORAGE_DIRECTORY_VIDEO_BROADCAST)
-       {
-               _tmpStorageDirectoryVideoBroadcast = value;
-       }
-       else
-       {
-               SysLog(NID_SYS, "required key(%ls) is not existed", key.GetPointer());
-               r = E_OBJ_NOT_FOUND;
-       }
-       return r;
-}
-
-result
-_SettingManager::SetValueForPrivilegedKey(const String& key, String value)
-{
-       result r = E_SUCCESS;
-       if(key == _NETWORK_TELEPHONY_PROVIDER)
-       {
-               _tmpNetworkTelephonyProvider = value;
-       }
-       else if(key == _NETWORK_TELEPHONY_MODE)
-       {
-               _tmpNetworkTelephonyMode= value;
-       }
-       else
-       {
-               r = E_OBJ_NOT_FOUND;
-       }
-       return r;
-}
-
-result
-_SettingManager::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
-{
-       int ret = -1;
-
-       if(key == _NETWORK_FLIGHTMODE)
-       {
-               SysTryReturnResult(NID_SYS, __tapiHandle == null, E_SYSTEM, "Tapi is already ready");
-               __tapiHandle = tel_init(null);
-               SysTryReturnResult(NID_SYS, __tapiHandle != null, E_SYSTEM, "Tapi is not ready.");
-
-               if(__pSettingAsyncEvent == null)
-               {
-                       _SettingAsyncEvent* pEvent = new (std::nothrow) _SettingAsyncEvent();
-                       SysTryReturnResult(NID_SYS, pEvent != null, E_OUT_OF_MEMORY, "It is failed to create instance of Event");
-                       __pSettingAsyncEvent = pEvent;
-               }
-               __pSettingAsyncEvent->AddListener(*listener);
-
-               ret = tel_set_flight_mode(__tapiHandle, 
-                               value ? TAPI_POWER_FLIGHT_MODE_ENTER : TAPI_POWER_FLIGHT_MODE_LEAVE,
-                               SettingEventFlightMode, (void*)__pSettingAsyncEvent);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to set on Network Flight mode");
-       }
-
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::SetValueForPrivilegedKey(const String& key, bool value)
-{
-       int ret = -1;
-       result r = E_SUCCESS;
-       if(key == _LOCATION_GPS)
-       {
-               if(value == true)
-               {
-                       ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 1);
-               }
-               else
-               {
-                       ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 0);
-               }
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_LOCATION_ENABLED vconf");
-       }
-       else if(key == _LOCATION_WPS)
-       {
-               if(value == true)
-               {
-                       ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 1);
-               }
-               else
-               {
-                       ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 0);
-               }
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_LOCATION_NETWORK_ENABLED vconf");
-       }
-       else if(key == _LOCATION_GPS_ADVANCED)
-       {
-               if(value == true)
-               {
-                       ret = vconf_set_int(VCONFKEY_LOCATION_AGPS_ENABLED, 1);
-               }
-               else
-               {
-                       ret = vconf_set_int(VCONFKEY_LOCATION_AGPS_ENABLED, 0);
-               }
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get on VCONFKEY_LOCATION_AGPS_ENABLED vconf");
-       }
-       else if(key == _NETWORK_TELEPHONY_ROAMING)
-       {
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL vconf");
-       }
-       else if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
-       {
-               ret = vconf_set_bool(VCONFKEY_3G_ENABLE, value);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_3G_ENABLE vconf");
-       }
-       else if(key == _NETWORK_WIFI)
-       {
-               int wifiState = 0;
-               bool supported = false;
-               r = _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               SysTryReturnResult(NID_SYS, supported == true && r == E_SUCCESS, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
-               ret = vconf_get_int(VCONFKEY_WIFI_STATE, &wifiState);
-               SysTryReturnResult(NID_SYS, ret == 0, E_UNSUPPORTED_OPERATION, "Failed to set on VCONFKEY_WIFI_STATE vconf");
-               SysTryReturnResult(NID_SYS, LoadWifiDll() == E_SUCCESS , E_SYSTEM,"Failed to get wifi so");
-
-               if(value == true)
-               {
-                       if(wifiState == VCONFKEY_WIFI_OFF)
-                       {
-                               r = pWifiManagerImpl_Activate();
-                       }
-               }
-               else
-               {
-                       if(wifiState != VCONFKEY_WIFI_OFF)
-                       {
-                               r = pWifiManagerImpl_Deactivate();
-                       }
-
-               }
-               UnloadWifiDll();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to change wifi state.");
-       }
-       else if(key == _NETWORK_WIFI_DIRECT)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI_DIRECT, supported);
-               SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support WiFi direct feature");
-               SysTryReturnResult(NID_SYS, LoadWifiDll() == E_SUCCESS , E_SYSTEM,"Failed to get wifi so");
-
-               bool isActivated = pWifiDirectDeviceImpl_IsActivated();
-               
-               if (isActivated == false && value == true)
-               {
-                       ret = pWifiDirectDeviceImpl_Activate();
-               }
-               else if (isActivated == true && value == false)
-               {
-                       ret = pWifiDirectDeviceImpl_Deactivate();
-               }
-               UnloadWifiDll();
-               SysTryReturnResult(NID_SYS, ret == E_SUCCESS, E_SYSTEM, "Failed to change Wi-Fi direct state");
-       }
-       else if(key == _DEVELOPER_USBDEBUGGING)
-       {
-#ifndef _OSP_EMUL_     
-               ret = vconf_set_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL,
-                               value ? _DEVELOPER_USBDEBUGGING_ON : _DEVELOPER_USBDEBUGGING_OFF);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to set on VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL vconf");
-#else
-               r = E_UNSUPPORTED_OPERATION;
-#endif
-       }
-       else
-       {
-               r = E_OBJ_NOT_FOUND;
-       }
-       return r;
-}
-
-bool
-_SettingManager::HasKey(const String& key)
-{
-       if(key == _BATTERY_FORMAT_PERCENTAGE)
-       {
-               return true;
-       }
-       else if(key == _FONT_SIZE)
-       {
-               return true;
-       }
-       else if(key == _FONT_TYPE)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_COUNTRY)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_DATE)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_DATE_FORMAT)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_DATETIME)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_DATETIME_FORMAT)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_LANGUAGE)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_TIME)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_TIME_FORMAT)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_TIME_FORMAT_24HOUR)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_TIMEZONE)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_UPDATE_AUTO)
-       {
-               return true;
-       }
-       else if(key == _LOCALE_WEEK_FORMAT_FIRSTDAY)
-       {
-               return true;
-       }
-       else if(key == _LOCATION_GPS)
-       {
-               return true;
-       }
-       else if(key == _LOCATION_GPS_ADVANCED)
-       {
-               return true;
-       }
-       else if(key == _LOCATION_WPS)
-       {
-               return true;
-       }
-       else if(key == _MOTION_UI)
-       {
-               return true;
-       }
-       else if(key == _NETWORK_FLIGHTMODE)
-       {
-               return true;
-       }
-       else if(key == _NETWORK_TELEPHONY_MODE || key == _NETWORK_TELEPHONY_PACKETSERVICE || key == _NETWORK_TELEPHONY_PROVIDER || key == _NETWORK_TELEPHONY_ROAMING)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-
-               return supported;
-       }
-       else if(key == _NETWORK_WIFI)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-
-               return supported;
-       }
-       else if(key == _NETWORK_WIFI_NOTIFICATION)
-       {
-               int ret = 0;
-               int currentValue = 0;
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               if(supported == false)
-               {
-                       return false;
-               }
-               ret = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &currentValue);
-
-               if(ret == -1)
-               {
-                       return false;
-               }
-               
-               return true;
-       }
-       else if(key == _NETWORK_WIFI_TETHERING)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               if(supported == false)
-               {
-                       return false;
-               }
-               if(__tetheringHandle == null)
-               {
-                       return false;
-               }
-               return true;
-       }
-       else if(key == _NETWORK_WIFI_TETHERING_HIDE)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               if(supported == false)
-               {
-                       return false;
-               }
-               if(__tetheringHandle == null)
-               {
-                       return false;
-               }
-               return true;
-       }
-       else if(key == _NETWORK_WIFI_TETHERING_SECURITY)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               if(supported == false)
-               {
-                       return false;
-               }
-               if(__tetheringHandle == null)
-               {
-                       return false;
-               }
-               return true;
-       }
-       else if(key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI, supported);
-               if(supported == false)
-               {
-                       return false;
-               }
-               if(__tetheringHandle == null)
-               {
-                       return false;
-               }
-               return true;
-       }
-       else if(key == _NETWORK_WIFI_DIRECT)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI_DIRECT, supported);
-               return supported;
-       }
-       else if(key == _NETWORK_BLUETOOTH)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_BLUETOOTH, supported);
-               return supported;
-       }
-       else if(key == _NETWORK_BLUETOOTH_TETHERING)
-       {
-               bool supported = false;
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI_DIRECT, supported);
-               
-               if(__tetheringHandle == null || supported == false)
-               {
-                       return false;
-               }
-               return true;
-       }
-       else if(key == _SCREEN_WALLPAPER)
-       {
-               return true;
-       }
-       else if(key == _SCREEN_WALLPAPER_LOCK)
-       {
-               return true;
-       }
-       else if(key == _SCREEN_BRIGHTNESS)
-       {
-               return true;
-       }
-       else if(key == _SCREEN_BRIGHTNESS_AUTO)
-       {
-               return true;
-       }
-       else if(key == _SCREEN_MODE)
-       {
-               return true;
-       }
-       else if(key == _SCREEN_BACKLIGHT_TIME)
-       {
-               return true;
-       }
-       else if(key == _SOUND_LOCK)
-       {
-               return true;
-       }
-       else if(key == _SOUND_MEDIA_VOLUME)
-       {
-               return true;
-       }
-       else if(key == _SOUND_NOTIFICATION_VOLUME)
-       {
-               return true;
-       }
-       else if(key == _SOUND_RINGTONE)
-       {
-               return true;
-       }
-       else if(key == _SOUND_RINGTONE_VOLUME)
-       {
-               return true;
-       }
-       else if(key == _SOUND_SILENTMODE)
-       {
-               return true;
-       }
-       else if(key == _SOUND_SYSTEM_VOLUME)
-       {
-               return true;
-       }
-       else if(key == _SOUND_TOUCH)
-       {
-               return true;
-       }
-       else if(key == _STORAGE_DIRECTORY_WAP_DOWNLOAD)
-       {
-               return true;
-       }
-       else if(key == _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD)
-       {
-               return true;
-       }
-       else if(key == _STORAGE_DIRECTORY_CAMERA_RECORD)
-       {
-               return true;
-       }
-       else if(key == _STORAGE_DIRECTORY_VOICE_RECORD)
-       {
-               return true;
-       }
-       else if(key == _STORAGE_DIRECTORY_RADIO_BROADCAST)
-       {
-               return true;
-       }
-       else if(key == _STORAGE_DIRECTORY_VIDEO_BROADCAST)
-       {
-               return true;
-       }
-       else if(key == _VIBRATOR)
-       {
-               return true;
-       }
-       else if(key == _VIBRATOR_LEVEL)
-       {
-               return true;
-       }
-       else if(key == _VIBRATOR_LEVEL_NOTIFICATION)
-       {
-               return true;
-       }
-       else if(key == _USB_TETHERING)
-       {
-               if(__tetheringHandle == null)
-               {
-                       return false;
-               }
-               return true;
-       }
-       else if(key == _WEB_APPLICATION_COOKIE_SHARE)
-       {
-               return true;
-       }
-       else if(key == _SCREEN_ROTATION_AUTO)
-       {
-               return true;
-       }
-       else if(key == _CONTACT_ORDER_FIRSTNAME)
-       {
-               return true;
-       }
-       else if(key == _DEVELOPER_USBDEBUGGING)
-       {
-               return true;
-       }
-       return false;
-}
-
-result
-_SettingManager::ResetToFactoryDefault(void)
-{
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::SetVolume(const String& soundCategory, int level)
-{
-       int res = 0;
-       int maxVolume = 0;
-
-       sound_type_e soundType;
-
-       if (soundCategory == _SYSTEM_SOUND_VOLUME)
-       {
-               soundType = SOUND_TYPE_SYSTEM;
-       }
-       else if (soundCategory == _MEDIA_SOUND_VOLUME)
-       {
-               soundType = SOUND_TYPE_MEDIA;
-       }
-       else if (soundCategory == _RINGTONE_SOUND_VOLUME)
-       {
-               soundType = SOUND_TYPE_RINGTONE;
-       }
-       else if (soundCategory == _NOTIFICATION_SOUND_VOLUME)
-       {
-               soundType = SOUND_TYPE_NOTIFICATION;
-       }
-       else
-       {
-               SysLogException(NID_SYS, E_INVALID_ARG, "The specified soundCategory is invalid");
-               return E_INVALID_ARG;
-       }
-
-       res = sound_manager_get_max_volume(soundType, &maxVolume);
-       SysTryReturn(NID_SYS, res == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get max volume");
-
-       SysTryReturn(NID_SYS, maxVolume >= level, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified level is outside the bounds of soundCategory");
-
-       res = sound_manager_set_volume(soundType, level);
-       SysTryReturn(NID_SYS, res == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A sy8stem error has occured.");
-
-       return E_SUCCESS;
-}
-
-//Event Management
-result
-_SettingManager::AddSettingEventListener(ISettingEventListener& listener)
-{
-       result r = E_SUCCESS;
-       SysTryReturnResult(NID_SYS, __pSettingEvent != null, E_SYSTEM, "Event system is not ready.");
-       r = __pSettingEvent->AddListener(listener);
-       SysTryReturnResult(NID_SYS, r != E_OBJ_ALREADY_EXIST, r, "listener is already registered.");
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add listener");
-       __listenerCount++;
-       return StartSettingEventListen();
-}
-
-result
-_SettingManager::RemoveSettingEventListener(ISettingEventListener& listener)
-{
-       result r = E_SUCCESS;
-       SysTryReturnResult(NID_SYS, __pSettingEvent != null, E_SYSTEM, "Event system is not ready.");
-       r = __pSettingEvent->RemoveListener(listener);
-       SysTryReturnResult(NID_SYS, r != E_OBJ_NOT_FOUND, r, "listener is not registered.");
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to remove listener");
-       __listenerCount--;
-       return StopSettingEventListen();
-}
-
-// Event for internal
-result
-_SettingManager::AddSettingEventListenerForInternal(ISettingEventListener& listener)
-{
-       result r = E_SUCCESS;
-       SysTryReturnResult(NID_SYS, __pSettingEventForInternal != null, E_SYSTEM, "Event system is not ready.");
-       __pSettingEventForInternal->AddListener(listener);
-       SysTryReturnResult(NID_SYS, r != E_OBJ_ALREADY_EXIST, r, "listener is already registered.");
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "The memory is insufficient.");
-       if(__listenerInternalCount == 0)
-       {
-               r = StartSettingEventListenForInternal();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to start internal event.");
-       }
-       __listenerInternalCount++;
-       return r;
-}
-
-result
-_SettingManager::RemoveSettingEventListenerForInternal(ISettingEventListener& listener)
-{
-       result r = E_SUCCESS;
-       SysTryReturnResult(NID_SYS, __pSettingEventForInternal != null, E_SYSTEM, "Event system is not ready.");
-       r = __pSettingEventForInternal->RemoveListener(listener);
-       SysTryReturnResult(NID_SYS, r != E_OBJ_NOT_FOUND, r, "listener is not registered.");
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "The listener is not added.");
-       __listenerInternalCount--;
-
-       if(__listenerInternalCount == 0 && __listenerCount == 0)
-       {
-               r = StopSettingEventListenForInternal();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to stop internal event.");
-       }
-       return r;
-}
-
-result
-_SettingManager::StartSettingEventListenForInternal(void)
-{
-       if(__registeredSettingEventsForInternal == false)
-       {
-               int ret = 0;
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_REGION, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register region event listener");
-
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LANGUAGE, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register language event listener");
-
-               ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE, SettingEventSettingInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register font type event listener");
-
-               ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, SettingEventSettingInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register font size event listener");
-
-               __registeredSettingEventsForInternal = true;
-       }
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::StopSettingEventListenForInternal(void)
-{
-       if(__registeredSettingEventsForInternal == true)
-       {
-               int ret = 0;
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_REGION);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_LANGUAGE);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-
-               ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-
-               ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-
-               __registeredSettingEventsForInternal = false;
-       }
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::StartSettingEventListen(void)
-{
-       if (__listenerCount > 0 && __registeredSettingEvents == false)
-       {
-               int ret = 0;
-               result r = E_SUCCESS;
-               int currentIntValue = 0;
-               bool currentBoolValue = false;
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register 24 hour event listener");
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register roaming event listener");
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register flight mode event listener");
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register location service event listener");
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register network position event listener");
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register packet data event listener");
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register silent mode event listener");
-               ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK, SettingEventRuntimeInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register vibration event listener");
-               ret = sound_manager_set_volume_changed_cb(SettingEventSoundManager, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register sound volume event listener");
-
-               ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, SettingEventSettingInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register rington event listener");
-               ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, SettingEventSettingInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register wallpaper event listener");
-               ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, SettingEventSettingInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register wallpaper event listener");
-               ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, SettingEventSettingInfo, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register wallpaper event listener");
-
-               if(__tetheringHandle != null)
-               {
-                       ret = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringEnabled, null);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to register USB Tethering event listener");
-
-                       ret = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringEnabled, null);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to register WIFI Tethering event listener");
-
-                       ret = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringEnabled, null);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to register BT Tethering event listener");
-
-                       ret = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringDisabled, null);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to register USB Tethering event listener");
-
-                       ret = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringDisabled, null);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to register WIFI Tethering event listener");
-
-                       ret = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringDisabled, null);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to register BT Tethering event listener");
-               }
-
-               ret = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &currentIntValue);
-               if(ret != -1)
-               {
-                       ret = vconf_notify_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf, null);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register WIFI QS event listener");
-               }
-
-               ret = vconf_notify_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register BT event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register WIFI event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_LOCATION_AGPS_ENABLED, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register vibration enable event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register rotate lock event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register usb mode selection event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register automatic time update enable event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register first day of week event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register contact display order event listener");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register time event");
-
-               ret = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY, &currentIntValue);
-               if(ret != -1)
-               {
-                       ret = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf, null);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register mobile hotspot security event");
-               }
-
-               ret = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_HIDE, &currentIntValue);
-               if(ret != -1)
-               {
-                       ret = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf, null);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register mobile hotspot hide event");
-               }
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL changed event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register VCONFKEY_SETAPPL_LCD_BRIGHTNESS changed event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT changed event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_TIMEZONE_ID, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register VCONFKEY_SETAPPL_TIMEZONE_ID changed event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT changed event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register TOUCH_SOUNDS changed event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register SOUND_LOCK changed event");
-
-               ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register device name changed event");
-
-               ret = vconf_notify_key_changed(_SCREEN_MODE_VCONFKEY, SettingEventVConf, null);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register screen mode changed event");
-
-               _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI_DIRECT, currentBoolValue);
-
-               if(currentBoolValue == true)
-               {
-                       ret = vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf, null);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register wifi direct changed event");
-               }
-
-               r = StartSettingEventListenForInternal();
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to register internal events");
-
-               __registeredSettingEvents = true;
-       }
-
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::StopSettingEventListen(void)
-{
-       if (__listenerCount == 0 && __registeredSettingEvents == true)
-       {
-               int ret = 0;
-               int currentIntValue = 0;
-               bool currentBoolValue =false;
-               result r = E_SUCCESS;
-
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               sound_manager_unset_volume_changed_cb();
-
-               ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-               ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-
-               //3.0 extensions
-               if(__tetheringHandle != null)
-               {
-                       ret = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to unregister USB Tethering event listener");
-
-                       ret = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to unregister WIFI Tethering event listener");
-
-                       ret = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to unregister Bluetooth Tethering event listener");
-
-                       ret = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to unregister USB Tethering event listener");
-
-                       ret = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to unregister WIFI Tethering event listener");
-
-                       ret = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
-                       SysTryReturnResult(NID_SYS, ret == TETHERING_ERROR_NONE, E_SYSTEM, "Failed to unregister Bluetooth Tethering event listener");
-               }
-
-               ret = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &currentIntValue);
-               if(ret != -1)
-               {
-                       ret = vconf_ignore_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister WIFI QS event listener");
-               }
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_TIMEZONE_ID, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister VCONFKEY_SETAPPL_TIMEZONE_ID changed event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister BT event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister WIFI event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_LOCATION_AGPS_ENABLED, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister vibration enable event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister rotate lock event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister usb mode selection event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister automatic time update enable event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister first day of week event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister contact display order event listener");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister time event");
-
-               ret = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY, &currentIntValue);
-               if(ret != -1)
-               {
-                       ret = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister mobile hotspot security event");
-               }
-
-               ret = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_HIDE, &currentIntValue);
-               if(ret != -1)
-               {
-                       ret = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister mobile hotspot hide event");
-               }
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL changed event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister VCONFKEY_SETAPPL_LCD_BRIGHTNESS changed event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT changed event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT changed event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister TOUCH_SOUNDS changed event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister SOUND_LOCK changed event");
-
-               ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister device name changed event");
-
-               ret = vconf_ignore_key_changed(_SCREEN_MODE_VCONFKEY, SettingEventVConf);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to unregister screen mode changed event");
-
-               r = _SystemInfoImpl::GetSysInfo(_SYSTEM_NETWORK_WIFI_DIRECT, currentBoolValue);
-
-               if(r == E_SUCCESS && currentBoolValue == true)
-               {
-                       ret = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf);
-                       SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to register wifi direct changed event");
-               }
-
-               if(__listenerInternalCount == 0)
-               {
-                       r = StopSettingEventListenForInternal();
-                       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to register internal events");
-               }
-
-               __registeredSettingEvents = false;
-       }
-       return E_SUCCESS;
-}
-
-result
-_SettingManager::SetSettingEventListener(ISettingEventListener* pListener)
-{
-       result r = E_SUCCESS;
-       if (pListener != null)
-       {
-               __pSettingEventListener = pListener;
-               r = AddSettingEventListener(*pListener);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add event listener");
-       }
-       else
-       {
-               if (__pSettingEventListener == null)
-               {
-                       SysLog(NID_SYS, "listener is not registered");
-                       return E_SUCCESS;
-               }               
-               r = RemoveSettingEventListener(*__pSettingEventListener);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to remove event listener");
-               __pSettingEventListener = null;
-       }
-       return E_SUCCESS;
-}
-
-//Event
-void
-_SettingManager::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
-{
-       SysLog(NID_SYS, "SettingEventListener called [%d]", key);
-
-       if(__pSettingManager == null)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "SettingManager is not initialized");
-               return;
-       }
-
-       String settingKey;
-       switch (key)
-       {
-       case RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _NETWORK_FLIGHTMODE;
-               }
-               else
-               {
-                       settingKey = _FLIGHT_MODE_ENABLED;
-               }
-               break;
-       case RUNTIME_INFO_KEY_LANGUAGE:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _LOCALE_LANGUAGE;
-               }
-               else
-               {
-                       settingKey = _LANGUAGE;
-               }
-               break;
-       case RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       __pSettingManager->DeliverSettingEvent(_LOCALE_TIME_FORMAT);
-                       __pSettingManager->DeliverSettingEvent(_LOCALE_DATETIME_FORMAT);
-                       settingKey = _LOCALE_TIME_FORMAT_24HOUR;
-               }
-               else
-               {
-                       __pSettingManager->DeliverSettingEvent(_DATE_TIME_FORMAT);
-                       __pSettingManager->DeliverSettingEvent(_TIME_FORMAT);
-                       settingKey = _HOUR_FORMAT_SELECTED;
-               }
-               break;
-       case RUNTIME_INFO_KEY_REGION:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _LOCALE_DATE_FORMAT;
-               }
-               else
-               {
-                       settingKey = _DATE_FORMAT;
-               }
-               __pSettingManager->DeliverSettingEvent(settingKey);
-
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _LOCALE_DATETIME_FORMAT;
-               }
-               else
-               {
-                       settingKey = _DATE_TIME_FORMAT;
-               }
-               __pSettingManager->DeliverSettingEvent(settingKey);
-
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _LOCALE_TIME_FORMAT;
-               }
-               else
-               {
-                       settingKey = _TIME_FORMAT;
-               }
-               __pSettingManager->DeliverSettingEvent(settingKey);
-
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _LOCALE_COUNTRY;
-               }
-               else
-               {
-                       settingKey = _COUNTRY;
-               }
-
-               break;
-
-       case RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _NETWORK_TELEPHONY_ROAMING;
-               }
-               else
-               {
-                       settingKey = _DATA_ROAMING_ENABLED;
-               }
-               break;
-       case RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _LOCATION_GPS;
-               }
-               else
-               {
-                       settingKey = _GPS_ENABLED;
-               }
-               break;
-       case RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _LOCATION_WPS;
-               }
-               else
-               {
-                       settingKey = _WPS_ENABLED;
-               }
-               break;
-       case RUNTIME_INFO_KEY_PACKET_DATA_ENABLED:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _NETWORK_TELEPHONY_PACKETSERVICE;
-               }
-               else
-               {
-                       settingKey = _PACKET_SERVICE_ALLOWED;
-               }
-               break;
-       case RUNTIME_INFO_KEY_SILENT_MODE_ENABLED:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SOUND_SILENTMODE;
-               }
-               else
-               {
-                       settingKey = _SILENT_MODE;
-               }
-               break;
-       case RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey =  _VIBRATOR_LEVEL;
-               }
-               else
-               {
-                       settingKey = _TOUCH_VIBRATION_LEVEL;
-               }
-               break;
-       default:
-               SysLog(NID_SYS, "NOT IMPLEMENTED");
-               return;
-       }
-
-       SysLog(NID_SYS, "Event(%ls) is deliverted.", settingKey.GetPointer());
-       __pSettingManager->DeliverSettingEvent(settingKey);
-}
-
-void
-_SettingManager::SettingEventSettingInfo(system_settings_key_e key, void* userData)
-{
-       SysLog(NID_SYS, "System setting is changed[%d]", key);
-
-       if(__pSettingManager == null)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "SettingManager is not initialized");
-               return;
-       }
-
-       String settingKey;
-       switch (key)
-       {
-       case SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION:
-       {
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _MOTION_UI;
-               }
-               else
-               {
-                       settingKey = _ENABLE_MOTION;
-               }
-               break;
-       }
-       case SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE:
-       {
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SOUND_RINGTONE;
-               }
-               else
-               {
-                       settingKey = _RINGTONE;
-               }
-               break;
-       }
-       case SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN:
-       {
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SCREEN_WALLPAPER;
-               }
-               else
-               {
-                       settingKey = _WALLPAPER;
-               }
-               break;
-       }
-       case SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN:
-       {
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SCREEN_WALLPAPER_LOCK;
-               }
-               else
-               {
-                       return;
-               }
-               break;
-       }
-
-       case SYSTEM_SETTINGS_KEY_FONT_SIZE:
-       {
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _FONT_SIZE;
-               }
-               else
-               {
-                       settingKey = _FONTSIZE;
-               }
-               break;
-       }
-       case SYSTEM_SETTINGS_KEY_FONT_TYPE:
-       {
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _FONT_TYPE;
-               }
-               else
-               {
-                       settingKey = _FONTTYPE;
-               }
-               break;
-       }
-       default:
-               SysLog(NID_SYS, "NOT IMPLEMENTED");
-               return;
-       }
-
-       __pSettingManager->DeliverSettingEvent(settingKey);
-}
-
-void
-_SettingManager::SettingEventSoundManager(sound_type_e type, unsigned int volume, void* userData)
-{
-       SysLog(NID_SYS, "Sound Volume is changed [%d]", type);
-
-       if(__pSettingManager == null)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "SettingManager is not initialized");
-               return;
-       }
-
-       String settingKey;
-       switch (type)
-       {
-       case SOUND_TYPE_SYSTEM:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SOUND_SYSTEM_VOLUME;
-               }
-               else
-               {
-                       settingKey = _SYSTEM_SOUND_VOLUME;
-               }
-               break;
-       case SOUND_TYPE_MEDIA:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SOUND_MEDIA_VOLUME;
-               }
-               else
-               {
-                       settingKey = _MEDIA_SOUND_VOLUME;
-               }
-               break;
-       case SOUND_TYPE_RINGTONE:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SOUND_RINGTONE_VOLUME;
-               }
-               else
-               {
-                       settingKey = _RINGTONE_SOUND_VOLUME;
-               }
-               break;
-       case SOUND_TYPE_NOTIFICATION:
-               if(!(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
-               {
-                       settingKey = _SOUND_NOTIFICATION_VOLUME;
-               }
-               else
-               {
-                       settingKey = _NOTIFICATION_SOUND_VOLUME;
-               }
-               break;
-       default:
-               SysLog(NID_SYS, "NOT IMPLEMENTED");
-               return;
-       }
-
-       __pSettingManager->DeliverSettingEvent(settingKey);
-}
-
-void
-_SettingManager::SettingEventVConf(keynode_t* node, void* userData)
-{
-       SysLog(NID_SYS, "VConf change event is occured");
-
-       if(__pSettingManager == null)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "SettingManager is not initialized");
-               return;
-       }
-       SysLog(NID_SYS, "Vconf is changed [%s]", vconf_keynode_get_name(node));
-
-       String settingKey;
-
-       if (strcmp(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _BATTERY_FORMAT_PERCENTAGE;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _VIBRATOR;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _SCREEN_ROTATION_AUTO;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _DEVELOPER_USBDEBUGGING;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _LOCALE_UPDATE_AUTO;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _LOCALE_WEEK_FORMAT_FIRSTDAY;
-       }
-       else if (strcmp(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _CONTACT_ORDER_FIRSTNAME;
-       }
-       else if (strcmp(VCONFKEY_SYSTEM_TIME_CHANGED, vconf_keynode_get_name(node)) == 0)
-       {
-               __pSettingManager->DeliverSettingEvent(_LOCALE_DATETIME);
-               __pSettingManager->DeliverSettingEvent(_LOCALE_DATE);
-               settingKey = _LOCALE_TIME;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_TIMEZONE_ID, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _LOCALE_TIMEZONE;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _DEVICE_NAME;
-       }
-       else if (strcmp(VCONFKEY_LOCATION_AGPS_ENABLED, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _LOCATION_GPS_ADVANCED;
-       }
-       else if (strcmp(VCONFKEY_WIFI_STATE, vconf_keynode_get_name(node)) == 0)
-       {
-               int state = VCONFKEY_WIFI_OFF;
-               int ret = 0;
-               ret = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
-
-               if(ret == 0 && (state == VCONFKEY_WIFI_OFF || state == VCONFKEY_WIFI_UNCONNECTED))
-               {
-                       settingKey = _NETWORK_WIFI;
-               }
-               else
-               {
-                       SysLog(NID_SYS, "It is not Wi-Fi on/off event.");
-                       return;
-               }
-       }
-       else if (strcmp(VCONFKEY_BT_STATUS, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _NETWORK_BLUETOOTH;
-       }
-       else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_SECURITY, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _NETWORK_WIFI_TETHERING_SECURITY;
-       }
-       else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_HIDE, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _NETWORK_WIFI_TETHERING_HIDE;
-       }
-       else if (strcmp(VCONFKEY_WIFI_ENABLE_QS, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _NETWORK_WIFI_NOTIFICATION;
-       }
-       else if (strcmp(_SCREEN_MODE_VCONFKEY, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _SCREEN_MODE;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _SOUND_TOUCH;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _SOUND_LOCK;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _VIBRATOR_LEVEL_NOTIFICATION;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _SCREEN_BACKLIGHT_TIME;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _SCREEN_BRIGHTNESS;
-       }
-       else if (strcmp(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, vconf_keynode_get_name(node)) == 0)
-       {
-               settingKey = _SCREEN_BRIGHTNESS_AUTO;
-       }
-       else if (strcmp(VCONFKEY_WIFI_DIRECT_STATE, vconf_keynode_get_name(node)) == 0)
-       {
-               int state = VCONFKEY_WIFI_DIRECT_DEACTIVATED;
-               int ret = 0;
-               ret = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
-               SysLog(NID_SYS, "Wi-Fi Direct state is changed. %d", state);
-               if(ret == 0 && (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED || state == VCONFKEY_WIFI_DIRECT_ACTIVATED))
-               {
-                       settingKey = _NETWORK_WIFI_DIRECT;
-               }
-               else
-               {
-                       SysLog(NID_SYS, "It is not Wi-Fi direct on/off event. %d", state);
-                       return;
-               }
-       }
-       else
-       {
-               return;
-       }
-
-       __pSettingManager->DeliverSettingEvent(settingKey);
-}
-
-void
-_SettingManager::SettingEventTetheringEnabled(tethering_error_e err, tethering_type_e type, bool is_requested, void* data)
-{
-       if(__pSettingManager == null)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "SettingManager is not initialized");
-               return;
-       }
-
-       String settingKey;
-       switch(type)
-       {
-       case TETHERING_TYPE_USB:
-               settingKey = _USB_TETHERING;
-       break;
-       case TETHERING_TYPE_WIFI:
-               settingKey = _NETWORK_WIFI_TETHERING;
-       break;
-       case TETHERING_TYPE_BT:
-               settingKey = _NETWORK_BLUETOOTH_TETHERING;
-       break;
-       default:
-               return;
-       }
-       __pSettingManager->DeliverSettingEvent(settingKey);
-}
-
-void
-_SettingManager::SettingEventTetheringDisabled(tethering_error_e err, tethering_type_e type, tethering_disabled_cause_e cause,void* data)
-{
-       SettingEventTetheringEnabled(err, type, false, null);
-}
-
-void
-_SettingManager::DeliverSettingEvent(String keyName)
-{
-       if(__pSettingEvent != null)
-       {
-               _SettingEventArg* settingEventArg = new (std::nothrow) _SettingEventArg();
-               if(settingEventArg == null)
-               {
-                       SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of _SettingEventArg");
-               }
-               settingEventArg->KeyName = keyName;
-               __pSettingEvent->Fire(*settingEventArg);
-       }
-
-       if(__listenerInternalCount > 0)
-       {
-               if(__pSettingEventForInternal != null)
-               {
-                       _SettingEventArg* settingEventArgForInternal = new (std::nothrow) _SettingEventArg();
-                       if(settingEventArgForInternal == null)
-                       {
-                               SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of _SettingEventArg");
-                       }
-                       settingEventArgForInternal->KeyName = keyName;
-
-                       __pSettingEventForInternal->Fire(*settingEventArgForInternal);
-               }
-       }
-}
-
-void
-_SettingManager::SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data)
-{
-       SysLog(NID_SYS, "TAPI change event is occured");
-       result r = E_SUCCESS;
-       int ret = 0;
-
-       if(__pSettingManager == null)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "SettingManager is not initialized");
-               return;
-       }
-
-       if(__pSettingManager->__tapiHandle != handle)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "SettingManager is not initialized");
-               return;
-       }
-
-       SysLog(NID_SYS, "Flight mode changed");
-
-       switch (res)
-       {
-       case TAPI_POWER_FLIGHT_MODE_RESP_ON:
-               SysLog(NID_SYS, "success change flight mode on");
-
-               ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
-               if (ret != 0)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf");
-               }
-               break;
-       case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
-               SysLog(NID_SYS, "success change flight mode off");
-
-               ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
-               if (ret != 0)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "Failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf");
-               }
-               break;
-       case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
-       default:
-               SysLogException(NID_SYS, E_SYSTEM, "Failed to change flight mode");
-               r = E_SYSTEM;
-       }
-
-       _SettingAsyncEvent* pEvent = (_SettingAsyncEvent*)user_data;
-
-       if(pEvent != null)
-       {
-               _SettingAsyncEventArg* pSettingAsyncEventArg = new (std::nothrow) _SettingAsyncEventArg;
-               pSettingAsyncEventArg->Key = _NETWORK_FLIGHTMODE;
-               pSettingAsyncEventArg->errorCode = r;
-               pEvent->Fire(*pSettingAsyncEventArg);
-       }
-
-       if(__pSettingManager->__tapiHandle != null)
-       {
-               tel_deinit(__pSettingManager->__tapiHandle);
-               __pSettingManager->__tapiHandle = null;
-       }
-       else
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "TAPI is not ready");
-               return;
-       }
-}
-
-result
-_SettingManager::LoadBluetoothDll()
-{
-       result r = E_SUCCESS;
-       if(__pBluetoothDllHandle == null)
-       {
-               __pBluetoothDllHandle = dlopen(_BLUETOOTH_LIBRARY_NAME, RTLD_LAZY);
-               SysTryReturnResult(NID_SYS, __pBluetoothDllHandle, E_SYSTEM, "It is failed to open bluetooth library.");
-
-               pBluetoothManagerImpl_Activate = reinterpret_cast< result(*)(void)> (dlsym(__pBluetoothDllHandle, "_BluetoothManagerImpl_Activate"));
-               pBluetoothManagerImpl_Deactivate = reinterpret_cast< result(*)(void)> (dlsym(__pBluetoothDllHandle, "_BluetoothManagerImpl_Deactivate"));
-
-               SysTryCatch(NID_SYS, pBluetoothManagerImpl_Activate != null, r = E_SYSTEM, E_SYSTEM, "It is failed to find _BluetoothManagerImpl_Activate method");
-               SysTryCatch(NID_SYS, pBluetoothManagerImpl_Deactivate != null, r = E_SYSTEM, E_SYSTEM, "It is failed to find _BluetoothManagerImpl_Deactivate method");
-       }
-CATCH:
-       if(r != E_SUCCESS)
-       {
-               UnloadBluetoothDll();
-       }
-
-       return E_SUCCESS;
-}
-
-void
-_SettingManager::UnloadBluetoothDll()
-{
-       if (__pBluetoothDllHandle != null)
-       {
-               pBluetoothManagerImpl_Activate = null;
-               pBluetoothManagerImpl_Deactivate = null;
-
-               dlclose(__pBluetoothDllHandle);
-               __pBluetoothDllHandle = null;
-       }
-}
-
-result
-_SettingManager::LoadWifiDll()
-{
-       result r = E_SUCCESS;
-       if (__pWifiDllHandle == null)
-       {
-               __pWifiDllHandle = dlopen(_WIFI_DIRECT_LIBRARY_NAME, RTLD_LAZY);
-               SysTryReturnResult(NID_SYS, __pWifiDllHandle, E_SYSTEM, "It is failed to open wifi library.");
-
-               pWifiDirectDeviceImpl_Activate = reinterpret_cast< result(*)(void)> (dlsym(__pWifiDllHandle, "_WifiDirectDeviceImpl_Activate"));
-               pWifiDirectDeviceImpl_Deactivate = reinterpret_cast< result(*)(void)> (dlsym(__pWifiDllHandle, "_WifiDirectDeviceImpl_Deactivate"));
-               pWifiDirectDeviceImpl_IsActivated = reinterpret_cast< bool(*)(void)> (dlsym(__pWifiDllHandle, "_WifiDirectDeviceImpl_IsActivated"));
-               pWifiManagerImpl_Activate = reinterpret_cast< result(*)(void)> (dlsym(__pWifiDllHandle, "_WifiManagerImpl_Activate"));
-               pWifiManagerImpl_Deactivate = reinterpret_cast< result(*)(void)> (dlsym(__pWifiDllHandle, "_WifiManagerImpl_Deactivate"));
-
-               SysTryCatch(NID_SYS, pWifiDirectDeviceImpl_Activate != null, r = E_SYSTEM, E_SYSTEM, "It is failed to find _WifiDirectDeviceImpl_Activate method");
-               SysTryCatch(NID_SYS, pWifiDirectDeviceImpl_Deactivate != null, r = E_SYSTEM, E_SYSTEM, "It is failed to find _WifiDirectDeviceImpl_Deactivate method");
-               SysTryCatch(NID_SYS, pWifiDirectDeviceImpl_IsActivated != null, r = E_SYSTEM, E_SYSTEM, "It is failed to find _WifiDirectDeviceImpl_IsActivated method");
-               SysTryCatch(NID_SYS, pWifiManagerImpl_Activate != null, r = E_SYSTEM, E_SYSTEM, "It is failed to find _WifiManagerImpl_Activate method");
-               SysTryCatch(NID_SYS, pWifiManagerImpl_Deactivate != null, r = E_SYSTEM, E_SYSTEM, "It is failed to find _WifiManagerImpl_Deactivate method");
-       }
-CATCH:
-       if(r != E_SUCCESS)
-       {
-               UnloadWifiDll();
-       }
-
-       return E_SUCCESS;
-}
-
-void
-_SettingManager::UnloadWifiDll()
-{
-       if (__pWifiDllHandle != null)
-       {
-               pWifiDirectDeviceImpl_Activate = null;
-               pWifiDirectDeviceImpl_Deactivate = null;
-               pWifiDirectDeviceImpl_IsActivated = null;
-               pWifiManagerImpl_Activate = null;
-               pWifiManagerImpl_Deactivate = null;
-
-               dlclose(__pWifiDllHandle);
-               __pWifiDllHandle = null;
-       }
-}
-
-} } // Tizen::System
index 6a30f6e..8b23f9d 100644 (file)
  * @file               FSys_SystemInfoImpl.cpp
  * @brief              This is the implementation file for _SystemInfoImpl class.
  */
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <media/sound_manager.h>
-#include <sim.h>
-#include <sensor.h>
-#include <sensors.h>
-#include <system_info.h>
-#include <telephony_network.h>
-#include <locations.h>
-
-#include <FBaseColIMapEnumerator.h>
+#include <unique_ptr.h>
+
 #include <FBaseInteger.h>
-#include <FBaseSysLog.h>
-#include <FBaseUtilStringUtil.h>
-#include <FBaseUtilStringTokenizer.h>
-#include <FIoRegistry.h>
-#include <FSysIDeviceEventListener.h>
-#include <FSysIScreenEventListener.h>
-#include <FSysIChargingEventListener.h>
-#include <FSysIBatteryEventListener.h>
 
 #include <FBase_NativeError.h>
 #include <FIo_RegistryImpl.h>
-#include <FSys_DeviceId.h>
 #include <FSys_SystemInfoImpl.h>
+#include <FIo_AppServiceIpcMessages.h>
+#include <FIo_IpcClient.h>
+#include <FSys_Types.h>
+
+using namespace std;
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Utility;
 using namespace Tizen::Io;
 
 namespace Tizen { namespace System
 {
 
-static const wchar_t* _REGISTRY_PATH = L"/usr/etc/system-info.ini";
-static const wchar_t* _SYSTEM_INFO_SESSION = L"SystemInfo";
+static const wchar_t* _REGISTRY_PATH = L"/tmp/osp/system_info_cache.ini";
+static const wchar_t* _SYSTEM_INFO_SESSION = L"SystemInformation";
 
 //Bluetooth
 static const wchar_t* _BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
 static const wchar_t* _BLUETOOTH_SUPPORTED = L"BluetoothSupported";
 
 //Camera
-static const wchar_t* _CAMERA = L"http://tizen.org/feature/camera";
+
 static const wchar_t* _CAMERA_FRONT = L"http://tizen.org/feature/camera.front";
-static const wchar_t* _CAMERA_FRONT_FLASH = L"http://tizen.org/feature/camera.front.flash";
+
 static const wchar_t* _CAMERA_BACK = L"http://tizen.org/feature/camera.back";
-static const wchar_t* _CAMERA_BACK_FLASH = L"http://tizen.org/feature/camera.back.flash";
-static const wchar_t* _CAMERA_COUNT = L"CameraCount";
 
-//Database
-static const wchar_t* _DATABASE_ENCRYPTION = L"http://tizen.org/feature/database.encryption";
-static const char* _DATABASE_LIBRARY_PATH = "/usr/lib/libsqlite3.so.0";
-static const char* _DATABASE_ENCRYPTION_SYMBOL = "sqlite3_key";
+static const wchar_t* _CAMERA_COUNT = L"CameraCount";
 
 //DUID
 static const wchar_t* _DUID = L"http://tizen.org/system/duid";
@@ -83,19 +64,14 @@ static const wchar_t* _FM_RADIO_SUPPORTED = L"FmRadioSupported";
 
 //Keyboard
 static const wchar_t* _KEYBOARD_TYPE = L"KeyboardType";
-static const wchar_t* _INPUT_KEYBOARD = L"http://tizen.org/feature/input.keyboard";
 static const wchar_t* _INPUT_KEYBOARD_LAYOUT = L"http://tizen.org/feature/input.keyboard.layout";
 
 //Location
-static const wchar_t* _LOCATION = L"http://tizen.org/feature/location";
 static const wchar_t* _GPS_SUPPORTED = L"GPSSupported";
 static const wchar_t* _LOCATION_GPS = L"http://tizen.org/feature/location.gps";
 static const wchar_t* _WPS_SUPPORTED = L"WPSSupported";
 static const wchar_t* _LOCATION_WPS = L"http://tizen.org/feature/location.wps";
 
-//Microphone
-static const wchar_t* _MICROPHONE = L"http://tizen.org/feature/microphone";
-
 //Model name
 static const wchar_t* _MODELNAME = L"http://tizen.org/system/model_name";
 static const wchar_t* _MODEL_NAME = L"ModelName";
@@ -105,41 +81,17 @@ static const wchar_t* _MULTIPOINTTOUCH_POINTCOUNT = L"http://tizen.org/feature/m
 static const wchar_t* _MULTIPOINT_TOUCH_COUNT = L"MultiPointTouchCount";
 
 //NFC
-static const wchar_t* _NFC = L"http://tizen.org/feature/nfc";
 static const wchar_t* _NETWORK_NFC = L"http://tizen.org/feature/network.nfc";
 static const wchar_t* _NFC_SUPPORTED = L"NFCSupported";
 
 //Opengles
-static const wchar_t* _OPENGLES_TEXTUREFORMAT_UTC = L"http://tizen.org/feature/opengles.texture_format.utc";
-static const wchar_t* _OPENGLES_TEXTUREFORMAT_PTC = L"http://tizen.org/feature/opengles.texture_format.ptc";
-static const wchar_t* _OPENGLES_TEXTUREFORMAT_ETC = L"http://tizen.org/feature/opengles.texture_format.etc";
-static const wchar_t* _OPENGLES_TEXTUREFORMAT_3DC = L"http://tizen.org/feature/opengles.texture_format.3dc";
-static const wchar_t* _OPENGLES_TEXTUREFORMAT_ATC = L"http://tizen.org/feature/opengles.texture_format.atc";
-static const wchar_t* _OPENGLES_TEXTUREFORMAT_PVRTC = L"http://tizen.org/feature/opengles.texture_format.pvrtc";
-
 static const wchar_t* _OPENGLES_VERSION_1_1 = L"http://tizen.org/feature/opengles.version.1_1";
 static const wchar_t* _OPENGLES_VERSION_2_0 = L"http://tizen.org/feature/opengles.version.2_0";
 static const wchar_t* _OPENGL_ES_VERSION = L"OpenGLESVersion";
 
-//Platform name
-static const wchar_t* _PLATFORM_NAME = L"http://tizen.org/system/platform.name";
-
-//CPU
-static const wchar_t* _PLATFORM_CORE_CPU_ARCH_ARMV6 = L"http://tizen.org/feature/platform.core.cpu.arch.armv6";
-static const wchar_t* _PLATFORM_CORE_CPU_ARCH_ARMV7 = L"http://tizen.org/feature/platform.core.cpu.arch.armv7";
-static const wchar_t* _PLATFORM_CORE_CPU_ARCH_X86 = L"http://tizen.org/feature/platform.core.cpu.arch.x86";
-
-//FPU
-static const wchar_t* _PLATFORM_CORE_FPU_ARCH_VFPV2 = L"http://tizen.org/feature/platform.core.fpu.arch.vfpv2";
-static const wchar_t* _PLATFORM_CORE_FPU_ARCH_VFPV3 = L"http://tizen.org/feature/platform.core.fpu.arch.vfpv3";
-static const wchar_t* _PLATFORM_CORE_FPU_ARCH_SSE2 = L"http://tizen.org/feature/platform.core.fpu.arch.sse2";
-static const wchar_t* _PLATFORM_CORE_FPU_ARCH_SSE3 = L"http://tizen.org/feature/platform.core.fpu.arch.sse3";
-static const wchar_t* _PLATFORM_CORE_FPU_ARCH_SSSE3 = L"http://tizen.org/feature/platform.core.fpu.arch.ssse3";
-
 // Screen
 static const wchar_t* _SCREEN_BPP = L"http://tizen.org/feature/screen.bpp";
 static const wchar_t* _SCREEN_BITS_PER_PIXEL = L"ScreenBitsPerPixel";
-static const wchar_t* _SCREEN_DESKTOPMODE = L"http://tizen.org/feature/screen.desktop_mode";
 static const wchar_t* _SCREEN_DPI = L"http://tizen.org/feature/screen.dpi";
 static const wchar_t* _SCREEN_HEIGHT = L"http://tizen.org/feature/screen.height";
 static const wchar_t* _SCREENHEIGHT = L"ScreenHeight";
@@ -148,29 +100,9 @@ static const wchar_t* _SCREENWIDTH = L"ScreenWidth";
 static const wchar_t* _SCREENDPI = L"ScreenDPI";
 
 //HDMI RCA
-static const wchar_t* _SCREEN_OUTPUT_HDMI = L"http://tizen.org/feature/screen.output.hdmi";
 static const wchar_t* _SCREEN_OUTPUT_RCA = L"http://tizen.org/feature/screen.output.rca";
 static const wchar_t* _TV_OUT_SUPPORTED = L"TvOutSupported";
 
-//Sensors
-static const wchar_t* _SENSOR_ACCELEROMETER = L"http://tizen.org/feature/sensor.accelerometer";
-static const wchar_t* _SENSOR_ACCELEROMETER_WAKEUP = L"http://tizen.org/feature/sensor.accelerometer.wakeup";
-static const wchar_t* _SENSOR_BAROMETER = L"http://tizen.org/feature/sensor.barometer";
-static const wchar_t* _SENSOR_BAROMETER_WAKEUP = L"http://tizen.org/feature/sensor.barometer.wakeup";
-static const wchar_t* _SENSOR_MAGNETOMETER = L"http://tizen.org/feature/sensor.magnetometer";
-static const wchar_t* _SENSOR_MAGNETOMETER_WAKEUP = L"http://tizen.org/feature/sensor.magnetometer.wakeup";
-static const wchar_t* _SENSOR_GYROSCOPE = L"http://tizen.org/feature/sensor.gyroscope";
-static const wchar_t* _SENSOR_GYROSCOPE_WAKEUP = L"http://tizen.org/feature/sensor.gyroscope.wakeup";
-static const wchar_t* _SENSOR_PHOTOMETER = L"http://tizen.org/feature/sensor.photometer";
-static const wchar_t* _SENSOR_PHOTOMETER_WAKEUP = L"http://tizen.org/feature/sensor.photometer.wakeup";
-static const wchar_t* _SENSOR_TILTMETER = L"http://tizen.org/feature/sensor.tiltmeter";
-static const wchar_t* _SENSOR_TILTMETER_WAKEUP = L"http://tizen.org/feature/sensor.tiltmeter.wakeup";
-static const wchar_t* _SENSOR_PROXIMITY = L"http://tizen.org/feature/sensor.proximity";
-static const wchar_t* _SENSOR_PROXIMITY_WAKEUP = L"http://tizen.org/feature/sensor.proximity.wakeup";
-
-//VOIP
-static const wchar_t* _SIP_VOIP = L"http://tizen.org/feature/sip.voip";
-
 //Sound
 static const wchar_t* _SOUND_MEDIA_VOLUME_MAX = L"http://tizen.org/system/sound.media.volume.resolution.max";
 static const wchar_t* _MAX_MEDIA_SOUND_VOLUME = L"MaxMediaSoundVolume";
@@ -181,9 +113,6 @@ static const wchar_t* _MAX_RINGTONE_SOUND_VOLUME = L"MaxRingtoneSoundVolume";
 static const wchar_t* _SOUND_SYSTEM_VOLUME_MAX = L"http://tizen.org/system/sound.system.volume.resolution.max";
 static const wchar_t* _MAX_SYSTEM_SOUND_VOLUME = L"MaxSystemSoundVolume";
 
-//Speech Recognition
-static const wchar_t* _SPEECH_RECOGNITION = L"http://tizen.org/feature/speech.recognition";
-
 //Telephony
 static const wchar_t* _TELEPHONY = L"http://tizen.org/feature/network.telephony";
 static const wchar_t* _TELEPHONY_SERVICE_GSM = L"http://tizen.org/feature/network.telephony.service.gsm";
@@ -197,935 +126,338 @@ static const wchar_t* _TELEPHONY_SERVICE_LTE = L"http://tizen.org/feature/networ
 static const wchar_t* _TELEPHONY_SERVICE_CDMA = L"http://tizen.org/feature/network.telephony.service.cdma";
 static const wchar_t* _NETWORK_TYPE = L"NetworkType";
 static const wchar_t* _NETWORK_EMERGENCY = L"Emergency";
+static const wchar_t* _NETWORK_NO_SERVICE = L"NoService";
 
-//USB
-static const wchar_t* _USB_HOST = L"http://tizen.org/feature/usb.host";
-static const wchar_t* _USB_ACCESSORY = L"http://tizen.org/feature/usb.accessory";
 
 //WIFI
 static const wchar_t* _WIFI = L"http://tizen.org/feature/network.wifi";
 static const wchar_t* _WIFI_SUPPORTED = L"WiFiSupported";
-static const wchar_t* _WIFI_DIRECT_SUPPORTED = L"WiFiDirectSupported";
 static const wchar_t* _WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
+static const wchar_t* _WIFI_DIRECT_SUPPORTED = L"WiFiDirectSupported";
 
 //Version
 static const wchar_t* _PLATFORM_VERSION = L"http://tizen.org/feature/platform.version";
 static const wchar_t* _PLATFORM_NATIVE_API_VERSION = L"http://tizen.org/feature/platform.native.api.version";
 static const wchar_t* _PLATFORM_WEB_API_VERSION = L"http://tizen.org/feature/platform.web.api.version";
+static const wchar_t* _BUID_STRING = L"http://tizen.org/system/build.string";
 
 static const wchar_t* _WAC_VERSION = L"WACVersion";
 static const wchar_t* _SUPPORTED = L"Supported";
 static const wchar_t* _UNSUPPORTED = L"Unsupported";
 
-result
-_SystemInfoImpl::GetSysInfo(const String& key, String& value)
+String
+_SystemInfoImpl::ConvertToTizen(const String& key)
 {
-       int ret = 0;
-       result r = E_SYSTEM;
-       char* pValue = null;
-
-       if (key == _NETWORK_TYPE)
-       {
-               sim_state_e simState;
-               ret = sim_get_state(&simState);
-
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "Failed to get the SIM state");
-
-               if (simState == SIM_STATE_UNAVAILABLE)
-               {
-                       value.Append(_NETWORK_EMERGENCY);
-                       return E_SUCCESS;
-               }
-
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_NETWORK_TYPE, &pValue);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_NETWORK_TYPE\"failed");
-
-               if(pValue == null)
-               {
-                       value.Clear();
-                       return E_SUCCESS;
-               }
+       String code(key);
 
-               r = StringUtil::Utf8ToString(pValue, value);
-               SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-       }
-       else if (key == _DEVICE_ID || key == _DUID)
+       if(code == _DEVICE_ID)
        {
-               r = _DeviceId::GetId(value);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Failed to get the key[%ls]", key.GetPointer());
-               return E_SUCCESS;
-       }
-       else if (key == _MODEL_NAME || key == _MODELNAME)
-       {
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &pValue);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE && pValue, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_MODEL");
-
-               r = StringUtil::Utf8ToString(pValue, value);
-               SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-       }
-       else if (key == _OPENGL_ES_VERSION)
-       {
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &pValue);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE && pValue, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_OPENGLES_TEXTURE_FORMAT\"failed");
-
-               r = StringUtil::Utf8ToString(pValue, value);
-               SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-       }       
-       else if (key == _KEYBOARD_TYPE || key == _INPUT_KEYBOARD_LAYOUT)
-       {
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_KEYBOARD_TYPE, &pValue);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_KEYBOARD_TYPE\"failed");
-
-               if(pValue == null)
-               {
-                       value.Clear();
-                       return E_SUCCESS;
-               }
-
-               r = StringUtil::Utf8ToString(pValue, value);
-               SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-
-               if(key == _INPUT_KEYBOARD_LAYOUT)
-               {
-                       value.ToLowerCase();
-               }
-       }
-       else if (key == _WAC_VERSION)
-       {
-               value = "";
-               return E_SUCCESS;
-       }
-       else if (key == _BLUETOOTH_SUPPORTED)
-       {
-               value.Clear();
-               bool bluetoothSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED, &bluetoothSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__BLUETOOTH_SUPPORTED");
-               if(bluetoothSupported == true)
-               {
-                       value = _SUPPORTED;
-               }
-               else
-               {
-                       value = _UNSUPPORTED;
-               }
-
-               r = E_SUCCESS;
+               code = _DUID;
        }
-       else if (key == _GPS_SUPPORTED)
+       else if(code == _MODEL_NAME)
        {
-               value.Clear();
-               bool gpsSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_GPS_SUPPORTED, &gpsSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__GPS_SUPPORTED");
-               if(gpsSupported == true)
-               {
-                       value = _SUPPORTED;
-               }
-               else
-               {
-                       value = _UNSUPPORTED;
-               }
-               r = E_SUCCESS;
+               code = _MODELNAME;
        }
-       else if (key == _WIFI_SUPPORTED)
+       else if(code == _KEYBOARD_TYPE)
        {
-               value.Clear();
-               bool wiFiSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_SUPPORTED, &wiFiSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__WIFI_SUPPORTED");
-               if(wiFiSupported == true)
-               {
-                       value = _SUPPORTED;
-               }
-               else
-               {
-                       value = _UNSUPPORTED;
-               }
-               r = E_SUCCESS;
+               code == _INPUT_KEYBOARD_LAYOUT;
        }
-       else if (key == _PLATFORM_VERSION)
+       else if(code == _SCREEN_BITS_PER_PIXEL)
        {
-               char* pPlatformVersion = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &pPlatformVersion);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_PLATFORM_NAME\"failed");
-
-               r = StringUtil::Utf8ToString(pPlatformVersion, value);
-               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-               free(pPlatformVersion);
-               return r;
-
+               code = _SCREEN_BPP;
        }
-       else if (key == _PLATFORM_NAME)
+       else if(code == _SCREENHEIGHT)
        {
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_PLATFORM_NAME, &pValue);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_PLATFORM_NAME\"failed");
-
-               r = StringUtil::Utf8ToString(pValue, value);
-               SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
+               code = _SCREEN_HEIGHT;
        }
-       else if (key == _PLATFORM_NATIVE_API_VERSION)
+       else if(code == _SCREENWIDTH)
        {
-               return E_OBJ_NOT_FOUND;
+               code = _SCREEN_WIDTH;
        }
-       else if (key == _PLATFORM_WEB_API_VERSION)
+       else if(code == _SCREENDPI)
        {
-               return E_OBJ_NOT_FOUND;
+               code = _SCREEN_DPI;
        }
-       else
+       else if(code == _MAX_SYSTEM_SOUND_VOLUME)
        {
-               r = GetFromRegistry(key, value);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "Failed to get the key[%ls]", key.GetPointer());
-               return E_SUCCESS;
+               code = _SOUND_SYSTEM_VOLUME_MAX;
        }
-CATCH:
-       if(pValue != null)
+       else if(code == _MAX_MEDIA_SOUND_VOLUME)
        {
-               free(pValue);
+               code = _SOUND_MEDIA_VOLUME_MAX;
        }
-       return r;
-}
-
-
-result
-_SystemInfoImpl::GetSysInfo(const String& key, int& value)
-{
-       int ret = -1;
-       result r = E_SUCCESS;
-
-       if (key == _CAMERA_COUNT)
+       else if(code == _MAX_RINGTONE_SOUND_VOLUME)
        {
-               int cameraCount = 0;
-               ret = system_info_get_value_int(SYSTEM_INFO_KEY_CAMERA_COUNT, &cameraCount);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__CAMERA_COUNT");
-               value = cameraCount;
+               code = _SOUND_RINGTONE_VOLUME_MAX;
        }
-       else if (key == _SCREEN_BITS_PER_PIXEL ||key == _SCREEN_BPP)
+       else if(code == _MAX_NOTIFICATION_SOUND_VOLUME)
        {
-               int screenBitsPerPixel = 0;
-               ret = system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_BITS_PER_PIXEL, &screenBitsPerPixel);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__SCREEN_BITS_PER_PIXEL");
-               value = screenBitsPerPixel;
+               code = _SOUND_NOTIFICATION_VOLUME_MAX;
        }
-       else if (key == _SCREENHEIGHT || key == _SCREEN_HEIGHT)
+       else if(code == _MULTIPOINT_TOUCH_COUNT)
        {
-               int screenHeight = 0;
-               ret = system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_HEIGHT, &screenHeight);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__SCREEN_HEIGHT");
-               value = screenHeight;
+               code = _MULTIPOINTTOUCH_POINTCOUNT;
        }
-       else if (key == _SCREENWIDTH || key == _SCREEN_WIDTH)
+       else if(code == _BLUETOOTH_SUPPORTED)
        {
-               int screenWidth = 0;
-               ret = system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH, &screenWidth);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__SCREEN_WIDTH");
-               value = screenWidth;
+               code = _BLUETOOTH;
        }
-       else if (key == _SCREENDPI || key == _SCREEN_DPI)
+       else if(code == _GPS_SUPPORTED)
        {
-               int screenDPI = 0;
-               ret = system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_DPI, &screenDPI);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__SCREEN_DPI");
-               value = screenDPI;
+               code = _LOCATION_GPS;
        }
-       else if (key == _MAX_SYSTEM_SOUND_VOLUME || key == _SOUND_SYSTEM_VOLUME_MAX)
+       else if(code == _WPS_SUPPORTED)
        {
-               int maxVolume = 0;
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_SYSTEM, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "Failed to get the max volume");
-               value = maxVolume;
+               code = _LOCATION_WPS;
        }
-       else if (key == _MAX_MEDIA_SOUND_VOLUME || key == _SOUND_MEDIA_VOLUME_MAX)
+       else if(code == _WIFI_SUPPORTED)
        {
-               int maxVolume = 0;
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_MEDIA, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "Failed to get the max volume");
-
-               value = maxVolume;
+               code = _WIFI;
        }
-       else if (key == _MAX_RINGTONE_SOUND_VOLUME || key == _SOUND_RINGTONE_VOLUME_MAX)
+       else if(code == _WIFI_DIRECT_SUPPORTED)
        {
-               int maxVolume = 0;
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_RINGTONE, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "Failed to get the max volume");
-
-               value = maxVolume;
+               code = _WIFI_DIRECT;
        }
-       else if (key == _MAX_NOTIFICATION_SOUND_VOLUME || key == _SOUND_NOTIFICATION_VOLUME_MAX)
+       else if(code == _FM_RADIO_SUPPORTED)
        {
-               int maxVolume = 0;
-               int ret = sound_manager_get_max_volume(SOUND_TYPE_NOTIFICATION, &maxVolume);
-               SysTryReturnResult(NID_SYS, ret == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "Failed to get the max volume");
-               value = maxVolume;
+               code = _FMRADIO;
        }
-       else if (key == _MULTIPOINT_TOUCH_COUNT || key == _MULTIPOINTTOUCH_POINTCOUNT)
+       else if(code == _TV_OUT_SUPPORTED)
        {
-               int multiPointTouchCount = 0;
-               ret = system_info_get_value_int(SYSTEM_INFO_KEY_MULTI_POINT_TOUCH_COUNT, &multiPointTouchCount);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the ISYSTEM_INFO_KEY_MULTI_POINT_TOUCH_COUNT");
-               value = multiPointTouchCount;
+               code = _SCREEN_OUTPUT_RCA;
        }
-       else
+       else if(code == _NFC_SUPPORTED)
        {
-               r = GetFromRegistry(key, value);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "Failed to get the key[%ls]", key.GetPointer());
+               code = _NETWORK_NFC;
        }
-       
-       return E_SUCCESS;
+       return code;
 }
 
-
 result
-_SystemInfoImpl::GetSysInfo(const String& key, long long& value)
-{
-       return E_OBJ_NOT_FOUND;
-}
-
-
-result
-_SystemInfoImpl::GetSysInfo(const String& key, double& value)
-{
-       return E_OBJ_NOT_FOUND;
-}
-
-
-result
-_SystemInfoImpl::GetSysInfo(const String& key, bool& value)
+_SystemInfoImpl::GetSysInfo(const String& key, String& value)
 {
-       int ret = 0;
-       result r = E_SUCCESS;
-
-       if (key == _BLUETOOTH_SUPPORTED || key == _BLUETOOTH)
-       {
-               bool bluetoothSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED, &bluetoothSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED");
-               value = bluetoothSupported;
-       }
-       else if (key == _CAMERA)
-       {
-               int cameraCount = 0;
-               ret = system_info_get_value_int(SYSTEM_INFO_KEY_CAMERA_COUNT, &cameraCount);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY__CAMERA_COUNT");
+       result r = E_OBJ_NOT_FOUND;
+       String tizenKey = ConvertToTizen(key);
+
+       if (key == _NETWORK_TYPE) //Compatibility
+       {
+               bool supported = false;
+               GetSysInfo(_TELEPHONY, supported);
+               if(supported == false)
+               {
+                       value = _NETWORK_EMERGENCY;
+               }
+
+               bool supportedGsm = false;
+               bool supportedGprs = false;
+               bool supportedEdge = false;
+               bool supportedUmts = false;
+               bool supportedHsdpa = false;
+               bool supportedHsupa = false;
+               bool supportedHspa = false;
+               bool supportedLte = false;
+               bool supportedCdma = false;
+
+               GetSysInfo(_TELEPHONY_SERVICE_GSM, supportedGsm);
+               GetSysInfo(_TELEPHONY_SERVICE_GPRS, supportedGprs);
+               GetSysInfo(_TELEPHONY_SERVICE_EDGE, supportedEdge);
+               GetSysInfo(_TELEPHONY_SERVICE_UMTS, supportedUmts);
+               GetSysInfo(_TELEPHONY_SERVICE_HSDPA, supportedHsdpa);
+               GetSysInfo(_TELEPHONY_SERVICE_HSUPA, supportedHsupa);
+               GetSysInfo(_TELEPHONY_SERVICE_HSPA, supportedHspa);
+               GetSysInfo(_TELEPHONY_SERVICE_LTE, supportedLte);
+               GetSysInfo(_TELEPHONY_SERVICE_CDMA, supportedCdma);
 
-               if (cameraCount > 0)
+               value.Clear();
+               if(supportedGsm == false && supportedGprs == false
+                       && supportedEdge == false && supportedUmts == false
+                       && supportedHsdpa == false && supportedHsupa == false
+                       && supportedHspa == false && supportedLte == false
+                       && supportedCdma == false)
                {
-                       value = true;
+                       value = _NETWORK_NO_SERVICE;
                }
-               else
+               else if(supportedGsm == true)
                {
-                       value = false;
+                       value.Append(L"GSM");
                }
-       }
-       else if (key == _CAMERA_FRONT)
-       {
-               bool frontCameraSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED, &frontCameraSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED");
-               value = frontCameraSupported;
-       }
-       else if (key == _CAMERA_FRONT_FLASH)
-       {
-               bool frontCameraFlashSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_FRONT_CAMERA_FLASH_SUPPORTED, &frontCameraFlashSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_FRONT_CAMERA_FLASH_SUPPORTED");
-               value = frontCameraFlashSupported;
-       }
-       else if (key == _CAMERA_BACK)
-       {
-               bool backCameraSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_BACK_CAMERA_SUPPORTED, &backCameraSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED");
-               value = backCameraSupported;
-       }
-       else if ( key == _CAMERA_BACK_FLASH)
-       {
-               bool backCameraFlashSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_BACK_CAMERA_FLASH_SUPPORTED, &backCameraFlashSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_FRONT_CAMERA_FLASH_SUPPORTED");
-               value = backCameraFlashSupported;
-       }
-       else if (key == _DATABASE_ENCRYPTION)
-       {
-#ifndef _OSP_EMUL_
-               void* handle = dlopen(_DATABASE_LIBRARY_PATH, RTLD_NOW);
-               SysTryReturnResult(NID_SYS, handle != null, E_SYSTEM, "Failed to open database library file");
-               void* function = dlsym(handle, _DATABASE_ENCRYPTION_SYMBOL);
-               if (function != null)
+               else if(supportedGprs == true)
                {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-               dlclose(handle);
-#else
-               value = true;
-#endif
-       }
-       else if (key == _LOCATION)
-       {
-               bool gpsSupported = false;
-               bool wpsSupported = false;
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_GPS_SUPPORTED, &gpsSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_GPS_SUPPORTED");                
-               wpsSupported = location_manager_is_supported_method(LOCATIONS_METHOD_WPS);
-
-               if(gpsSupported == true || wpsSupported == true)
-               {
-                       value = true;
+                       value.Append(L"GPRS");
                }
-               else
+               else if(supportedEdge == true)
                {
-                       value = false;
-               }
-       }
-       else if (key == _GPS_SUPPORTED || key == _LOCATION_GPS)
-       {
-               bool gpsSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_GPS_SUPPORTED, &gpsSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_GPS_SUPPORTED");
-               value = gpsSupported;
-       }
-       else if (key == _WPS_SUPPORTED || key == _LOCATION_WPS)
-       {
-               bool wpsSupported = false;
-               wpsSupported = location_manager_is_supported_method(LOCATIONS_METHOD_WPS);
-               value = wpsSupported;
-       }       
-       else if (key == _MICROPHONE)
-       {
-               bool micSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_MICROPHONE_SUPPORTED, &micSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_MICROPHONE_SUPPORTED");
-               value = micSupported;
-       }
-       else if (key == _PLATFORM_CORE_CPU_ARCH_ARMV6)
-       {
-               char* cpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_CPU_ARCH, &cpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_CPU_ARCH\"failed");
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               if(strcmp(cpu, "ARMv6") == 0)
-               {
-                       value = true;
+                       value.Append(L"EDGE");
                }
-               else
+               else if(supportedUmts == true)
                {
-                       value = false;
-               }
-               free(cpu);
-       }
-       else if (key == _PLATFORM_CORE_CPU_ARCH_ARMV7)
-       {
-               char* cpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_CPU_ARCH, &cpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_CPU_ARCH\"failed");
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               if(strcmp(cpu, "ARMv7") == 0)
-               {
-                       value = true;
+                       value.Append(L"UMTS");
                }
-               else
+               else if(supportedHsdpa == true)
                {
-                       value = false;
-               }
-               free(cpu);
-       }
-       else if (key == _PLATFORM_CORE_CPU_ARCH_X86)
-       {
-               char* cpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_CPU_ARCH, &cpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_CPU_ARCH\"failed");
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               if(strcmp(cpu, "x86") == 0)
-               {
-                       value = true;
+                       value.Append(L"HSDPA");
                }
-               else
+               else if(supportedHsupa == true)
                {
-                       value = false;
-               }
-               free(cpu);
-       }
-       else if (key == _PLATFORM_CORE_FPU_ARCH_VFPV2)
-       {
-               char* fpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &fpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_fPU_ARCH\"failed");
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               if(strcmp(fpu, "vfpv2") == 0)
-               {
-                       value = true;
+                       value.Append(L"HSUPA");
                }
-               else
+               else if(supportedHspa == true)
                {
-                       value = false;
-               }
-               free(fpu);
-       }
-       else if (key == _PLATFORM_CORE_FPU_ARCH_VFPV3)
-       {
-               char* fpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &fpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_fPU_ARCH\"failed");
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               if(strcmp(fpu, "vfpv3") == 0)
-               {
-                       value = true;
+                       value.Append(L"HSPA");
                }
-               else
+               else if(supportedLte == true)
                {
-                       value = false;
-               }
-               free(fpu);
-       }
-       else if (key == _PLATFORM_CORE_FPU_ARCH_SSE2)
-       {
-               char* fpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &fpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_fPU_ARCH\"failed");
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               if(strcmp(fpu, "sse2") == 0)
-               {
-                       value = true;
+                       value.Append(L"LTE");
                }
-               else
+               else if(supportedCdma == true)
                {
-                       value = false;
-               }
-               free(fpu);
-       }
-       else if (key == _PLATFORM_CORE_FPU_ARCH_SSE3)
-       {
-               char* fpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &fpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_fPU_ARCH\"failed");
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
 
-               if(strcmp(fpu, "sse3") == 0)
-               {
-                       value = true;
+                       value.Append(L"CDMA");
                }
-               else
-               {
-                       value = false;
-               }
-               free(fpu);
+
        }
-       else if (key == _PLATFORM_CORE_FPU_ARCH_SSSE3)
+       else if (key == _OPENGL_ES_VERSION)
        {
-               char* fpu = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &fpu);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_CORE_fPU_ARCH\"failed");
+               bool opengles_11 = false;
+               bool opengles_20 = false;
+
+               GetSysInfo(_OPENGLES_VERSION_1_1, opengles_11);
+               GetSysInfo(_OPENGLES_VERSION_2_0, opengles_20);
 
-               if(strcmp(fpu, "ssse3") == 0)
+               if(opengles_11 == true)
                {
-                       value = true;
+                       value.Append(L"1.1");
                }
-               else
+               else if(opengles_20 == true)
                {
-                       value = false;
+                       if(value.GetLength() > 0)
+                               value.Append(L" | ");
+
+                       value.Append(L"2.0");
                }
-               free(fpu);
-       }
-       else if (key == _WIFI_SUPPORTED || key == _WIFI)
-       {
-               bool wifiSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_SUPPORTED, &wifiSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_WIFI_SUPPORTED");
-               value = wifiSupported;
        }
-       else if (key == _WIFI_DIRECT || key == _WIFI_DIRECT_SUPPORTED)
+       else if(key == _BLUETOOTH_SUPPORTED)
        {
-               bool wifiDirectSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_DIRECT_SUPPORTED, &wifiDirectSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_WIFI_DIRECT_SUPPORTED");
-               value = wifiDirectSupported;
+               bool supported = false;
+               GetSysInfo(_BLUETOOTH, supported);
+               if(supported == false)
+                       value = _SUPPORTED;
+               else
+                       value = _UNSUPPORTED;
        }
-       else if (key == _FM_RADIO_SUPPORTED || key == _FMRADIO)
+       else if (key == _GPS_SUPPORTED)
        {
-               bool fmRadioSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_FMRADIO_SUPPORTED, &fmRadioSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_FMRADIO_SUPPORTED");
-               value = fmRadioSupported;
+               bool supported = false;
+               GetSysInfo(_LOCATION_GPS, supported);
+               if(supported == false)
+                       value = _SUPPORTED;
+               else
+                       value = _UNSUPPORTED;
        }
-       else if (key == _TV_OUT_SUPPORTED)
+       else if (key == _WIFI_SUPPORTED)
        {
-               bool tvOutSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_TVOUT_SUPPORTED, &tvOutSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_TVOUT_SUPPORTED");
-               value = tvOutSupported;
+               bool supported = false;
+               GetSysInfo(_WIFI, supported);
+               if(supported == false)
+                       value = _SUPPORTED;
+               else
+                       value = _UNSUPPORTED;
        }
-       else if (key == _SCREEN_OUTPUT_RCA)
+       else if (key == _WAC_VERSION)
        {
-               bool rcaSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_RCA_SUPPORTED, &rcaSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_RCA_SUPPORTED");
-               value = rcaSupported;
+               value.Clear();
+               r = E_SUCCESS;
        }
-       else if (key == _SCREEN_OUTPUT_HDMI)
+       else if (key == _PLATFORM_NATIVE_API_VERSION || key == _PLATFORM_WEB_API_VERSION || key == _PLATFORM_VERSION)
        {
-               bool hdmiSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_HDMI_SUPPORTED, &hdmiSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_HDMI_SUPPORTED");
-               value = hdmiSupported;
+               r = E_OBJ_NOT_FOUND;
        }
-       else if (key == _NFC_SUPPORTED || key == _NFC || key == _NETWORK_NFC)
+       else
        {
-               bool nfcSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_NFC_SUPPORTED, &nfcSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_NFC_SUPPORTED");
-               value = nfcSupported;
+               r = GetFromRegistry(tizenKey, value);
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+               r = E_SUCCESS;
        }
-       else if (key == _TELEPHONY)
-       {
-               sim_state_e simState;
-               ret = sim_get_state(&simState);
+       return r;
+}
 
-               if(ret == 0)
-               {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-       }
-       else if (key == _TELEPHONY_SERVICE_GSM || key == _TELEPHONY_SERVICE_GPRS || key == _TELEPHONY_SERVICE_EDGE
-                       || key == _TELEPHONY_SERVICE_UMTS || key == _TELEPHONY_SERVICE_HSDPA || key == _TELEPHONY_SERVICE_HSUPA
-                       || key == _TELEPHONY_SERVICE_HSPA || key == _TELEPHONY_SERVICE_LTE || key == _TELEPHONY_SERVICE_CDMA)
-       {
-               String telephonyInfo;
-               char* pValue = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_NETWORK_TYPE, &pValue);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_NETWORK_TYPE\"failed");
 
-               if(pValue == null)
-               {
-                       value = false;
-                       return E_SUCCESS;
-               }
+result
+_SystemInfoImpl::GetSysInfo(const String& key, int& value)
+{
+       result r = E_SUCCESS;
+       String tizenKey = ConvertToTizen(key);
 
-               r = StringUtil::Utf8ToString(pValue, telephonyInfo);
-               if(r != E_SUCCESS)
-               {
-                       free(pValue);
-                       return E_SYSTEM;
-               }
-               telephonyInfo.ToLowerCase();
-               if(key == _TELEPHONY_SERVICE_GSM && telephonyInfo.Contains("gsm"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_GPRS && telephonyInfo.Contains("gprs"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_EDGE && telephonyInfo.Contains("edge"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_UMTS && telephonyInfo.Contains("umts"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_HSDPA && telephonyInfo.Contains("hsdpa"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_HSUPA && telephonyInfo.Contains("hsupa"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_HSPA && telephonyInfo.Contains("hspa"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_LTE && telephonyInfo.Contains("lte"))
-               {
-                       value = true;
-               }
-               else if(key == _TELEPHONY_SERVICE_CDMA && telephonyInfo.Contains("cdma"))
-               {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-               free(pValue);
-       }
-       else if (key == _SENSOR_BAROMETER)
-       {
-               bool barometerSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_BAROMETER_SENSOR_SUPPORTED, &barometerSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_BAROMETER_SENSOR_SUPPORTED");
-               value = barometerSupported;
-       }
-       else if (key == _SENSOR_BAROMETER_WAKEUP)
-       {
-               bool barometerWakeupSupported = false;
-               ret = sf_is_wakeup_supported(BAROMETER_SENSOR);
-               if(ret == 0)
-               {
-                       barometerWakeupSupported = true;
-               }
-               value = barometerWakeupSupported;
-       }
-       else if (key == _SENSOR_ACCELEROMETER)
-       {
-               bool accelerometerSupported = false;
-               ret = sensor_is_supported(SENSOR_ACCELEROMETER, &accelerometerSupported);
-               SysTryReturnResult(NID_SYS, ret == SENSOR_ERROR_NONE, E_SYSTEM, "Failed to get the SENSOR_ACCELEROMETER");
-               value = accelerometerSupported;
-       }
-       else if (key == _SENSOR_ACCELEROMETER_WAKEUP)
-       {
-               bool accelerometerWakeupSupported = false;
-               ret = sf_is_wakeup_supported(ACCELEROMETER_SENSOR);
-               if(ret == 0)
-               {
-                       accelerometerWakeupSupported = true;
-               }
-               value = accelerometerWakeupSupported;
-       }
-       else if (key == _SENSOR_MAGNETOMETER)
-       {
-               bool magnetometerSupported = false;
-               ret = sensor_is_supported(SENSOR_MAGNETIC, &magnetometerSupported);
-               SysTryReturnResult(NID_SYS, ret == SENSOR_ERROR_NONE, E_SYSTEM, "Failed to get the SENSOR_MAGNETOMETER");
-               value = magnetometerSupported;
-       }
-       else if (key == _SENSOR_MAGNETOMETER_WAKEUP)
-       {
-               bool magnetometerWakeupSupported = false;
-               ret = sf_is_wakeup_supported(GEOMAGNETIC_SENSOR);
-               if(ret == 0)
-               {
-                       magnetometerWakeupSupported = true;
-               }
-               value = magnetometerWakeupSupported;
-       }
-       else if (key == _SENSOR_PHOTOMETER)
-       {
-               bool lightSupported = false;
-               ret = sensor_is_supported(SENSOR_LIGHT, &lightSupported);
-               SysTryReturnResult(NID_SYS, ret == SENSOR_ERROR_NONE, E_SYSTEM, "Failed to get the SENSOR_PHOTOMETER");
-               value = lightSupported;
-       }
-       else if (key == _SENSOR_PHOTOMETER_WAKEUP)
-       {
-               bool photometerWakeupSupported = false;
-               ret = sf_is_wakeup_supported(LIGHT_SENSOR);
-               if(ret == 0)
-               {
-                       photometerWakeupSupported = true;
-               }
-               value = photometerWakeupSupported;
-       }
-       else if (key == _SENSOR_GYROSCOPE)
-       {
-               bool gyroscopeSupported = false;
-               ret = sensor_is_supported(SENSOR_GYROSCOPE, &gyroscopeSupported);
-               SysTryReturnResult(NID_SYS, ret == SENSOR_ERROR_NONE, E_SYSTEM, "Failed to get the SENSOR_GYROSCOPE");
-               value = gyroscopeSupported;
-       }
-       else if (key == _SENSOR_GYROSCOPE_WAKEUP)
-       {
-               bool gyroscopeWakeupSupported = false;
-               ret = sf_is_wakeup_supported(GYROSCOPE_SENSOR);
-               if(ret == 0)
-               {
-                       gyroscopeWakeupSupported = true;
-               }
-               value = gyroscopeWakeupSupported;
-       }
-       else if (key == _SENSOR_PROXIMITY)
-       {
-               bool proximitySupported = false;
-               ret = sensor_is_supported(SENSOR_PROXIMITY, &proximitySupported);
-               SysTryReturnResult(NID_SYS, ret == SENSOR_ERROR_NONE, E_SYSTEM, "Failed to get the SENSOR_PROXIMITY");
-               value = proximitySupported;
-       }
-       else if (key == _SENSOR_PROXIMITY_WAKEUP)
-       {
-               bool proximityWakeupSupported = false;
-               ret = sf_is_wakeup_supported(PROXIMITY_SENSOR);
-               if(ret == 0)
-               {
-                       proximityWakeupSupported = true;
-               }
-               value = proximityWakeupSupported;
-       }
-       else if (key == _SENSOR_TILTMETER)
+       if (key == _CAMERA_COUNT)
        {
-               bool magnetometerSupported = false;
-               ret = sensor_is_supported(SENSOR_MAGNETIC, &magnetometerSupported);
-               SysTryReturnResult(NID_SYS, ret == SENSOR_ERROR_NONE, E_SYSTEM, "Failed to get the SENSOR_MAGNETOMETER");
+               bool supported = false;
+               int cameraCount = 0;
 
-               bool accelerometerSupported = false;
-               ret = sensor_is_supported(SENSOR_ACCELEROMETER, &accelerometerSupported);
-               SysTryReturnResult(NID_SYS, ret == SENSOR_ERROR_NONE, E_SYSTEM, "Failed to get the SENSOR_ACCELEROMETER");
+               GetSysInfo(_CAMERA_FRONT, supported);
+               if(supported == true)
+                       cameraCount++;
 
-               if(magnetometerSupported == true && accelerometerSupported == true)
-               {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-       }
-       else if (key == _SENSOR_TILTMETER_WAKEUP)
-       {
-               int magnetic = 0;
-               int accelerometer = 0;
-               magnetic = sf_is_wakeup_supported(GEOMAGNETIC_SENSOR);
-               accelerometer = sf_is_wakeup_supported(ACCELEROMETER_SENSOR);
-               if(magnetic == 0 && accelerometer == 0)
-               {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-       }
-       else if (key == _OPENGLES_VERSION_1_1)
-       {
-               char* pOpenglVersion = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &pOpenglVersion);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE && pOpenglVersion, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_OPENGLES_VERSION\"failed");
-               if(strcmp(pOpenglVersion, "1.1") != -1)
-               {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-               free(pOpenglVersion);
-       }
-       else if (key == _OPENGLES_VERSION_2_0)
+               GetSysInfo(_CAMERA_BACK, supported);
+               if(supported == true)
+                       cameraCount++;
+
+               value = cameraCount;
+       }       
+       else
        {
-               char* pOpenglVersion = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &pOpenglVersion);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE && pOpenglVersion, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_OPENGLES_VERSION\"failed");
-               if(strcmp(pOpenglVersion + strlen(pOpenglVersion) - 3, "2.0") != -1)
-               {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-               free(pOpenglVersion);
+               r = GetFromRegistry(tizenKey, value);
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
        }
-       else if(key == _OPENGLES_TEXTUREFORMAT_UTC || key == _OPENGLES_TEXTUREFORMAT_PTC || key == _OPENGLES_TEXTUREFORMAT_ETC
-                       || key == _OPENGLES_TEXTUREFORMAT_3DC || key == _OPENGLES_TEXTUREFORMAT_ATC || key == _OPENGLES_TEXTUREFORMAT_PVRTC)
-       {
-               int ret = 0;
-               String openglesTexture;
-               
-               char* pTextureFormat = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_TEXTURE_FORMAT, &pTextureFormat);
+       
+       return r;
+}
 
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE && pTextureFormat, E_SYSTEM, "system_info_get_value_string : \"SYSTEM_INFO_KEY_OPENGLES_VERSION\"failed");
 
-               r = StringUtil::Utf8ToString(pTextureFormat, openglesTexture);
+result
+_SystemInfoImpl::GetSysInfo(const String& key, long long& value)
+{
+       return E_OBJ_NOT_FOUND;
+}
 
-               if (r != E_SUCCESS)
-               {
-                       free(pTextureFormat);
-                       SysLog(NID_SYS, "Fail to convert string");
-               }
 
-               openglesTexture.ToUpperCase();
-               if (key == _OPENGLES_TEXTUREFORMAT_UTC && openglesTexture.Contains(L"UTC") == true)
-               {
-                       value = true;
-               }
-               else if (key == _OPENGLES_TEXTUREFORMAT_PTC && openglesTexture.Contains(L"PTC") == true)
-               {
-                       value = true;
-               }
-               else if (key == _OPENGLES_TEXTUREFORMAT_ETC && openglesTexture.Contains(L"ETC") == true)
-               {
-                       value = true;
-               }
-               else if (key == _OPENGLES_TEXTUREFORMAT_3DC && openglesTexture.Contains(L"3DC") == true)
-               {
-                       value = true;
-               }
-               else if (key == _OPENGLES_TEXTUREFORMAT_ATC && openglesTexture.Contains(L"ATC") == true)
-               {
-                       value = true;
-               }
-               else if (key == _OPENGLES_TEXTUREFORMAT_PVRTC && openglesTexture.Contains(L"PVRTC") == true)
-               {
-                       value = true;
-               }
-               else
-               {
-                       value = false;
-               }
-       }
-       else if (key == _SCREEN_DESKTOPMODE)
-       {               
-               value = false;
-       }
-       else if (key == _SPEECH_RECOGNITION)
-       {
-               bool speechRecognitionSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED, &speechRecognitionSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED");
-               value = speechRecognitionSupported;
-       }
-       else if (key == _SIP_VOIP)
-       {
-               bool sipVoipSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_SIP_VOIP_SUPPORTED, &sipVoipSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_SIP_VOIP_SUPPORTED");
-               value = sipVoipSupported;
-       }
-       else if (key == _USB_HOST)
-       {
-               bool usbHostSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_USB_HOST_SUPPORTED, &usbHostSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_USB_HOST_SUPPORTED");
-               value = usbHostSupported;
-       }
-       else if (key == _USB_ACCESSORY)
-       {
-               bool usbAccessorytSupported = false;
-               ret = system_info_get_value_bool(SYSTEM_INFO_KEY_USB_ACCESSORY_SUPPORTED, &usbAccessorytSupported);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "Failed to get the SYSTEM_INFO_KEY_USB_HOST_SUPPORTED");
-               value = usbAccessorytSupported;
-       }
-       else if (key == _INPUT_KEYBOARD)
-       {
-               char* pKeyboardType = null;
-               ret = system_info_get_value_string(SYSTEM_INFO_KEY_KEYBOARD_TYPE, &pKeyboardType);
-               SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_KEYBOARD_TYPE\"failed");
+result
+_SystemInfoImpl::GetSysInfo(const String& key, double& value)
+{
+       return E_OBJ_NOT_FOUND;
+}
 
-               value = false;
-               if(pKeyboardType != null)
-               {
-                       if(strlen(pKeyboardType) > 0)
-                       {
-                               value = true;
-                       }
-               }
-               free(pKeyboardType);
-               return r;
-       }
-       else
-       {
-               r = GetFromRegistry(key, value);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "Failed to get the key[%ls]", key.GetPointer());
-       }
+
+result
+_SystemInfoImpl::GetSysInfo(const String& key, bool& value)
+{
+       result r = E_SUCCESS;
+       String tizenKey = ConvertToTizen(key);
+
+       r = GetFromRegistry(tizenKey, value);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
 
        return E_SUCCESS;
 }
@@ -1149,42 +481,85 @@ result
 _SystemInfoImpl::GetPlatformVersion(String& platformVersion)
 {
        result r = E_SUCCESS;
-       char* pPlatformVersion = null;
-       int ret = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &pPlatformVersion);
-       SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_TIZEN_VERSION_NAME\"failed");
+       String tizenKey(_PLATFORM_VERSION);
+
+       r = GetFromRegistry(tizenKey, platformVersion);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+       return r;
+}
+
+result
+_SystemInfoImpl::GetBuildInfo(String& buildInfo)
+{
+       result r = E_SUCCESS;
+       String tizenKey(_BUID_STRING);
 
-       r = StringUtil::Utf8ToString(pPlatformVersion, platformVersion);
-       SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-       free(pPlatformVersion);
+       r = GetFromRegistry(tizenKey, buildInfo);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
        return r;
 }
 
 result
 _SystemInfoImpl::GetNativeApiVersion(String& nativeApiVersion)
 {
-       return GetFromRegistry(_PLATFORM_NATIVE_API_VERSION, nativeApiVersion);
+       result r = E_SUCCESS;
+       String tizenKey(_PLATFORM_NATIVE_API_VERSION);
+
+       r = GetFromRegistry(tizenKey, nativeApiVersion);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+       return r;
 }
 
 result
 _SystemInfoImpl::GetWebApiVersion(String& webApiVersion)
 {
-       return GetFromRegistry(_PLATFORM_WEB_API_VERSION, webApiVersion);
+       result r = E_SUCCESS;
+       String tizenKey(_PLATFORM_WEB_API_VERSION);
+
+       r = GetFromRegistry(tizenKey, webApiVersion);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+       return r;
 }
 
 result
 _SystemInfoImpl::GetImei(String& imei)
 {
        result r = E_SUCCESS;
-       int error = -1;
-       char* pImei = null;
 
-       error = system_info_get_value_string(SYSTEM_INFO_KEY_MOBILE_DEVICE_ID, &pImei);
-       SysTryReturnResult(NID_SYS, error == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_MOBILE_DEVICE_ID\"failed");
+       ArrayList requestMessage;
+       ArrayList responseMessage;
+
+       unique_ptr<_IpcClient> pIpcClient (new (std::nothrow) _IpcClient());
+       SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
+
+       r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to create IpcClient. [%s]", GetErrorMessage(r));
+
+       requestMessage.Construct();
+       responseMessage.Construct();
+
+       String serviceId(_SYSTEM_SERVICE_ID);
+       String commandId(L"osp.system.command.get.imei.internal");
+
+       requestMessage.Add(serviceId);
+       requestMessage.Add(commandId);
+
+       unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
+       SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message");
+
+       r = pIpcClient->SendRequest(pMsg.get());
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to send ipc message. [%s]", GetErrorMessage(r));
+
+       unique_ptr<String> pResult((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA));
+       unique_ptr<String> pImei((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1));
+
+       SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "It is failed to receive result on IPC response message.");
+       SysTryReturnResult(NID_SYS, pImei != null, E_SYSTEM, "It is failed to receive IMEI value on IPC response message.");
 
-       r = StringUtil::Utf8ToString(pImei, imei);
-       SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
-       free(pImei);
+       SysTryReturnResult(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, E_PRIVILEGE_DENIED, "It is failed to get privilege.");
+       SysTryReturnResult(NID_SYS, *pResult == _SYSTEM_RESULT_OK, E_SYSTEM, "It is failed to get IMEI value.");
 
+       imei = *pImei;
        return r;
 }
 
@@ -1196,10 +571,10 @@ _SystemInfoImpl::GetFromRegistry(const String& key, String& value)
        String valStr;
 
        r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
-       SysTryReturnResult(NID_SYS, !IsFailed(r), r, " RegistryImpl construct Failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " RegistryImpl construct It is failed");
 
        r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
-       SysTryReturnResult(NID_SYS, !IsFailed(r), r, " Registry GetValue  Failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " Registry GetValue  It is failed");
 
        if(valStr == L"true" || valStr == L"false")
        {
@@ -1220,13 +595,13 @@ _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
        _RegistryImpl _reg;
        String valStr;
        r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
-       SysTryReturnResult(NID_SYS, !IsFailed(r), r, " RegistryImpl construct Failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct It is failed");
 
        r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
-       SysTryReturnResult(NID_SYS, !IsFailed(r), r, " Registry GetValue  Failed");
-       SysTryReturnResult(NID_SYS, !IsFailed(r), E_SYSTEM, " Registry GetValue  Failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue  It is failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue  It is failed");
        r = Integer::Parse(valStr, value);
-       SysTryReturnResult(NID_SYS, !IsFailed(r), E_OBJ_NOT_FOUND, " Integer::Parse()  Failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, " Integer::Parse()  It is failed");
        return E_SUCCESS;
 }
 
@@ -1237,11 +612,11 @@ _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
        _RegistryImpl _reg;
        String valStr;
        r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
-       SysTryReturnResult(NID_SYS, !IsFailed(r), r, " RegistryImpl construct Failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct It is failed");
 
        r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
-       SysTryReturnResult(NID_SYS, !IsFailed(r), r, " Registry GetValue Failed");
-       SysTryReturnResult(NID_SYS, !IsFailed(r), E_SYSTEM, " Registry GetValue  Failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue It is failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue  It is failed");
        if(valStr == L"true")
        {
                value = true;
index 66d8033..1da7491 100644 (file)
@@ -7,8 +7,8 @@ namespace Tizen { namespace System
 static const wchar_t* _COMMUNICATION_DISPATCHER_IPC_ID = L"osp.app.ipcserver.communicationdispatcher";
 static const wchar_t* _SYSTEM_SERVICE_ID = L"osp.system.service";
 static const wchar_t* _SYSTEM_COMMAND_CHANGE_TIME = L"osp.system.command.change.time";
-static const wchar_t* _SYSTEM_COMMAND_CHANGE_BRIGHTNESS = L"osp.system.command.change.brightness";
-static const wchar_t* _SYSTEM_COMMAND_RESTORE_BRIGHTNESS = L"osp.system.command.restore.brightness";
+static const wchar_t* _SYSTEM_COMMAND_CHANGE_BRIGHTNESS = L"osp.system.command.power.change.brightness";
+static const wchar_t* _SYSTEM_COMMAND_RESTORE_BRIGHTNESS = L"osp.system.command.power.restore.brightness";
 static const wchar_t* _SYSTEM_COMMAND_GET_IMEI= L"osp.system.command.get.imei";
 static const wchar_t* _SYSTEM_RESULT_OK = L"osp.system.result.ok";
 static const wchar_t* _SYSTEM_RESULT_ERROR = L"osp.system.result.error";
index a2d9713..5dfdba5 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #include <new>
-#include <devman_haptic.h>
+#include <unique_ptr.h>
 
 #include <FBaseSysLog.h>
 #include <FBaseResult.h>
 
 namespace Tizen { namespace System
 {
-namespace
-{
-static const haptic_dev_idx INDEX_SYSTEM_VIBRATOR = DEV_IDX_ALL;
-static const unsigned int MODE_SYSTEM_VIBRATION = 0;
-static const int LEVEL_SYSTEM_VIBRATION = -1;
-static const long INVALID_PERIOD = 0L;
-static const int INVALID_COUNT = -1;
-static const int INVALID_LEVEL = -1;
-
-inline bool
-IsNegative(const int value)
-{
-       return value < 0;
-}
+static const int MAX_SIZE_OF_VIBRATION_BUFFER = 64 * 1024; // Immersion lib guide value. 64kbytes
 
-template <typename T> inline bool
-IsCreated(const T* pT)
+_VibratorImpl::_VibratorImpl(void)
+       : __handle(null)
+       , __effectHandle(null)
 {
-       return pT != null;
-}
 
-template <typename T> inline void
-SafeDelete(T*& rpT)
-{
-       if (IsCreated(rpT))
-       {
-               delete rpT;
-               rpT = null;
-       }
 }
 
-result
-InitializeVibrator(Handle& handle)
+_VibratorImpl::~_VibratorImpl(void)
 {
-       result r = E_SUCCESS;
-
-       Handle deviceHandle = device_haptic_open(INDEX_SYSTEM_VIBRATOR, MODE_SYSTEM_VIBRATION);
-       if (IsNegative(deviceHandle))
+       if (__handle != null)
        {
-               SysAssertf(false, "device_haptic_open() failed. [index:%d, mode:%d, result:%d]", INDEX_SYSTEM_VIBRATOR, MODE_SYSTEM_VIBRATION, deviceHandle);
-
-               r = E_SYSTEM;
-               SysLogException(NID_SYS, r, "[%s] Vibrator initialize operation has failed. [result:%d]", GetErrorMessage(r), deviceHandle);
-               return r;
-       }
-
-       handle = deviceHandle;
-
-       return r;
-}
-
-result
-FinalizeVibrator(Handle& handle)
-{
-       result r = E_SUCCESS;
+               Stop();
+               int deviceResult = haptic_close(__handle);
 
-       if (handle != INVALID_HANDLE)
-       {
-               int deviceResult = device_haptic_close(handle);
-               if (IsNegative(deviceResult))
+               if (deviceResult != HAPTIC_ERROR_NONE)
                {
-                       SysAssertf(false, "device_haptic_close() failed. [handle:%d, result:%d]", handle, deviceResult);
-
-                       r = E_SYSTEM;
-                       SysLogException(NID_SYS, r, "[%s] Vibrator finalize operation has failed. [result:%d]", GetErrorMessage(r), deviceResult);
-                       return r;
+                       SysLogException(NID_SYS, E_SYSTEM,
+                               "[E_SYSTEM] Vibrator finalize operation has failed. [handle:%d, result:%d]", __handle, deviceResult);
                }
-
-               handle = INVALID_HANDLE;
        }
-
-       return r;
 }
 
 result
-StartVibration(const Handle handle, const long onPeriod, const int level)
+_VibratorImpl::Construct(void)
 {
-       result r = E_SUCCESS;
-       int aLevel = (level == 0) ? LEVEL_SYSTEM_VIBRATION : level;
-       SysLog(NID_SYS, "Vibrator Action level: %d", aLevel);
-
-       int deviceResult = device_haptic_play_monotone_with_detail_feedback_level(handle, onPeriod, (level == 0) ? LEVEL_SYSTEM_VIBRATION : level);
-       if (IsNegative(deviceResult))
-       {
-               SysAssertf(false, "device_haptic_play_monotone_with_detail_feedback_level() failed. [handle:%d, duration:%ld, level:%d, result:%d]", handle, onPeriod, level, deviceResult);
+       SysTryReturnResult(NID_SYS, __handle == null, E_DEVICE_FAILED, "_VibratorImpl was already constructed.");
 
-               r = E_SYSTEM;
-               SysLogException(NID_SYS, r, "[%s] Vibration start operation has failed. [handle:%d, duration:%ld, level:%d, result:%d]", GetErrorMessage(r), handle, onPeriod, level, deviceResult);
-               return r;
-       }
+       int ret = haptic_open(HAPTIC_DEVICE_ALL, &__handle);
 
-       return r;
+        SysTryReturnResult(NID_SYS, ret == HAPTIC_ERROR_NONE,E_SYSTEM,
+                        "[E_SYSTEM] Vibrator initialize operation has failed. [result:%d]", ret);
+       SysLog(NID_SYS, "vibrator created handle = %d", __handle);
+       return E_SUCCESS;
 }
 
+
 result
-StopVibration(const Handle handle)
+_VibratorImpl::Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount)
 {
-       result r = E_SUCCESS;
+       SysTryReturnResult(NID_SYS, __handle != null, E_DEVICE_FAILED, "_VibratorImpl was not constructed.");
 
-       int deviceResult = device_haptic_stop_play(handle);
-       if (IsNegative(deviceResult))
+       result r = E_SUCCESS;
+       int errorCode = 0;
+       haptic_state_e state;
+       errorCode = haptic_get_effect_state(__handle, __effectHandle, &state);
+       
+       if ((haptic_error_e)errorCode == HAPTIC_ERROR_NONE)
        {
-               SysAssertf(false, "device_haptic_stop_play() failed. [handle:%d, result:%d]", handle, deviceResult);
-
-               r = E_SYSTEM;
-               SysLogException(NID_SYS, r, "[%s] Vibration stop operation has failed. [handle:%d, result:%d]", GetErrorMessage(r), handle, deviceResult);
-               return r;
+               if (state == HAPTIC_STATE_PLAYING)
+               {
+                       r = Stop();
+                       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It failed to stop previous vibration.");
+               }
        }
 
-       return r;
-}
-} // Anonymous
+       int numberOfElement = length / sizeof(IntensityDurationVibrationPattern);
+       std::unique_ptr<haptic_effect_element_s[]> pPatterns(new (std::nothrow) haptic_effect_element_s[numberOfElement * sizeof(haptic_effect_element_s)]);
+       SysTryReturnResult(NID_SYS, pPatterns != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It failed to allocate memory");
 
+        for (int i = 0; i < numberOfElement; i++)
+        {
+               SysTryReturnResult(NID_SYS, patterns[i].duration >= 0, E_INVALID_ARG, 
+                                               "[E_INVALID_ARG] The %dth pattern is the invalid duration[%d].", i, patterns[i].duration);              
+               pPatterns[i].haptic_duration = patterns[i].duration;
 
-const _VibratorImpl::VibrationInformation _VibratorImpl::__INVALID_VIBRATION_INFORMATION = {
-       INVALID_PERIOD, // on period
-       INVALID_PERIOD, // off period
-       INVALID_COUNT,  // count
-       INVALID_LEVEL,  // level
-       false,          // is vibrating?
-       true,           // is finished?
-};
+               SysTryReturnResult(NID_SYS, patterns[i].intensity >= -1 && patterns[i].intensity <= 100, E_INVALID_ARG,
+                                               "[E_INVALID_ARG] The %dth pattern is the invalid intensity[%d].", i, patterns[i].intensity);
+               pPatterns[i].haptic_level = (patterns[i].intensity == -1) ? HAPTIC_FEEDBACK_AUTO : (haptic_feedback_e)patterns[i].intensity;
+        }
 
-_VibratorImpl::_VibratorImpl(void)
-       : __handle(INVALID_HANDLE)
-       , __pTimer(null)
-       , __vibrationInformation(_VibratorImpl::__INVALID_VIBRATION_INFORMATION)
-{
+       int sizeOfBuf = MAX_SIZE_OF_VIBRATION_BUFFER;
+       std::unique_ptr<unsigned char[]> pEffectBuffer(new (std::nothrow) unsigned char[sizeOfBuf]);
+       SysTryReturnResult(NID_SYS, pEffectBuffer != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It failed to allocate memory");
 
-}
+       errorCode = haptic_create_effect(pEffectBuffer.get(), sizeOfBuf, pPatterns.get(), numberOfElement);     
+        r = ConvertErrorCode(errorCode);
+        SysTryReturnResult(NID_SYS, r == E_SUCCESS, r,"[%s] It failed to start vibrator.",GetErrorMessage(r));
 
-_VibratorImpl::~_VibratorImpl(void)
-{
-       Destruct();
+        SysLog(NID_SYS, "The number of patterns %d, repeate count %d", numberOfElement, repeatCount);
+        errorCode = haptic_vibrate_buffer_with_detail(__handle, pEffectBuffer.get(), (haptic_iteration_e)repeatCount, HAPTIC_FEEDBACK_5, HAPTIC_PRIORITY_MIN, &__effectHandle);
+        r = ConvertErrorCode(errorCode);
+        SysTryReturnResult(NID_SYS, r == E_SUCCESS, r,"[%s] It failed to start vibrator.",GetErrorMessage(r));
+        return r;
 }
 
+
 result
-_VibratorImpl::Construct(void)
+_VibratorImpl::Start(long onPeriod, long offPeriod, int count, int level)
 {
-       SysAssertf(__handle == INVALID_HANDLE, "_VibratorImpl was already constructed. [handle:%d]", __handle);
-
+       SysTryReturnResult(NID_SYS, __handle != null, E_DEVICE_FAILED, "_VibratorImpl was not constructed.");
 
        result r = E_SUCCESS;
-
-       Tizen::Base::Runtime::Timer* pTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
-       if (!IsCreated(pTimer))
-       {
-               r = E_OUT_OF_MEMORY;
-               SysLogException(NID_SYS, r, "[%s] Timer allocation failed.", GetErrorMessage(r));
-               return r;
-       }
-
-       r = pTimer->Construct(*this);
-       if (IsFailed(r))
-       {
-               SafeDelete(pTimer);
-               return r;
-       }
-
-       r = InitializeVibrator(__handle);
-       if (IsFailed(r))
-       {
-               SafeDelete(pTimer);
-               return r;
-       }
-
-       __pTimer = pTimer;
-
+       int errorCode = 0;
+        haptic_state_e state;
+        errorCode = haptic_get_effect_state(__handle, __effectHandle, &state);
+       
+        if ((haptic_error_e)errorCode == HAPTIC_ERROR_NONE)
+        {
+                if (state == HAPTIC_STATE_PLAYING)
+                {
+                        r = Stop();
+                        SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It failed to stop previous vibration.");
+                }
+        }
+
+       haptic_effect_element_s pattern[2];
+       
+       pattern[0].haptic_duration = onPeriod;
+       pattern[0].haptic_level = (level == 0) ? HAPTIC_FEEDBACK_AUTO : (haptic_feedback_e)level;
+
+       pattern[1].haptic_duration = offPeriod;
+       pattern[1].haptic_level = HAPTIC_FEEDBACK_0;    
+
+       int sizeOfBuf = MAX_SIZE_OF_VIBRATION_BUFFER;
+       std::unique_ptr<unsigned char[]> pEffectBuffer(new (std::nothrow) unsigned char[sizeOfBuf]);
+       SysTryReturnResult(NID_SYS, pEffectBuffer != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It failed to allocate memory");
+
+       errorCode = haptic_create_effect(pEffectBuffer.get(), sizeOfBuf, pattern, sizeof(pattern) / sizeof(haptic_effect_element_s));
+       r = ConvertErrorCode(errorCode);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r,"[%s] It failed to start vibrator.",GetErrorMessage(r));
+
+        SysLog(NID_SYS, "onPeriod %d, offPeriod %d, count %d, level = %d", onPeriod, offPeriod, count, level);
+       errorCode = haptic_vibrate_buffer_with_detail(__handle, pEffectBuffer.get(), (haptic_iteration_e)count, HAPTIC_FEEDBACK_5, HAPTIC_PRIORITY_MIN, &__effectHandle);
+       r = ConvertErrorCode(errorCode);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r,"[%s] It failed to start vibrator.",GetErrorMessage(r));
        return r;
 }
 
-void
-_VibratorImpl::Destruct(void)
-{
-       if (!__vibrationInformation.isFinished)
-       {
-               Stop();
-       }
-
-       SafeDelete(__pTimer);
-
-       if (__handle != INVALID_HANDLE)
-       {
-               FinalizeVibrator(__handle);
-       }
-}
 
 result
-_VibratorImpl::Start(long onPeriod, long offPeriod, int count, int level)
+_VibratorImpl::Stop(void)
 {
-       SysAssertf(__handle != INVALID_HANDLE, "_VibratorImpl was not constructed.");
-
-
-       // If (is vibrating)
-       //     Stop current vibration immediately
-       //
-       // Prepare vibration information
-       //
-       // Start vibration(=> This vibration just one repeat)
-       //
-       // Start repetition timer(=> Remaining vibration be started by timer)
-       //
-       // Modify vibration information
-       result r = E_SUCCESS;
+       SysTryReturnResult(NID_SYS, __handle != null, E_FAILURE, "_VibratorImpl was not constructed.");
 
-       if (!__vibrationInformation.isFinished)
-       {
-               r = Stop();
-               if (IsFailed(r))
-               {
-                       return r;
-               }
+       int deviceResult = haptic_stop_all_effects(__handle);
+        SysTryReturnResult(NID_SYS, deviceResult == HAPTIC_ERROR_NONE,E_SYSTEM,
+                "[E_SYSTEM] Vibration stop operation has failed. [result:%d]", deviceResult);
+       SysLog(NID_SYS, "vibrator stopped handle = %d", __handle);
+       __effectHandle = null;
 
-               __vibrationInformation = _VibratorImpl::__INVALID_VIBRATION_INFORMATION;
-       }
-
-       __vibrationInformation.onPeriod = onPeriod;
-       __vibrationInformation.offPeriod = offPeriod;
-       __vibrationInformation.count = count;
-       __vibrationInformation.level = level;
-
-       r = StartVibration(__handle, __vibrationInformation.onPeriod, __vibrationInformation.level);
-       if (IsFailed(r))
-       {
-               __vibrationInformation = _VibratorImpl::__INVALID_VIBRATION_INFORMATION;
-               return r;
-       }
-
-       r = __pTimer->Start(__vibrationInformation.onPeriod);
-       if (IsFailed(r))
-       {
-               r = E_DEVICE_FAILED;
-               SysLogException(NID_SYS, r, "[%s] Repetition timer starting failed.", GetErrorMessage(r));
-               StopVibration(__handle);
-               __vibrationInformation = _VibratorImpl::__INVALID_VIBRATION_INFORMATION;
-               return r;
-       }
-
-       __vibrationInformation.isVibrating = true;
-       __vibrationInformation.isFinished = false;
-       __vibrationInformation.count--;
-
-       return r;
+       return E_SUCCESS;
 }
 
 result
-_VibratorImpl::Stop(void)
+_VibratorImpl::ConvertErrorCode(int errorCode)
 {
-       SysAssertf(__handle != INVALID_HANDLE, "_VibratorImpl was not constructed.");
-
-
-       // If (is not vibrating)
-       // {
-       //     return
-       // }
-       //
-       // Cancel timer(=> for block another repetition)
-       //
-       // Stop current vibration
-       //
-       // Initialize vibration information
-       result r = E_SUCCESS;
-
-       if (__vibrationInformation.isFinished)
+       switch ((haptic_error_e)errorCode)
        {
-               r = E_DEVICE_FAILED;
-               SysLogException(NID_SYS, r, "[%s] Vibrator was already stopped.", GetErrorMessage(r));
-               return r;
+       case HAPTIC_ERROR_NONE: return E_SUCCESS;
+       case HAPTIC_ERROR_INVALID_PARAMETER: return E_INVALID_ARG;
+       default: return E_DEVICE_FAILED;
        }
-
-       r = __pTimer->Cancel();
-       SysTryLog(NID_SYS, !IsFailed(r), "[%s] This canceling started just after timer has expired.", GetErrorMessage(r));
-
-       r = StopVibration(__handle);
-       if (IsFailed(r))
-       {
-               return r;
-       }
-
-       __vibrationInformation = _VibratorImpl::__INVALID_VIBRATION_INFORMATION;
-
-       return r;
 }
 
+
 _VibratorImpl*
 _VibratorImpl::GetInstance(Vibrator& vibrator)
 {
@@ -327,73 +200,4 @@ _VibratorImpl::GetInstance(const Vibrator& vibrator)
        return vibrator.__pVibratorImpl;
 }
 
-void
-_VibratorImpl::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
-{
-       // If (is end of repetition)
-       // {
-       //     Initialize vibration information
-       //     return
-       // }
-       //
-       // If (is end of vibration)
-       // {
-       //     Start waiting
-       //     return
-       // }
-       //
-       // If (is end of waiting)
-       // {
-       //     Start vibration
-       //     return
-       // }
-       if (__vibrationInformation.count == 0)
-       {
-               __vibrationInformation = _VibratorImpl::__INVALID_VIBRATION_INFORMATION;
-               return;
-       }
-
-
-       result r = E_SUCCESS;
-
-       if (__vibrationInformation.isVibrating)
-       {
-               // off period
-               __vibrationInformation.isVibrating = false;
-
-               r = timer.Start(__vibrationInformation.offPeriod);
-               if (IsFailed(r))
-               {
-                       SysLog(NID_SYS, "Vibration waiting failed.");
-                       goto CATCH;
-               }
-       }
-       else
-       {
-               // on period
-               r = StartVibration(__handle, __vibrationInformation.onPeriod, __vibrationInformation.level);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
-
-               r = __pTimer->Start(__vibrationInformation.onPeriod);
-               if (IsFailed(r))
-               {
-                       SysLog(NID_SYS, "Vibration re-starting failed.");
-                       StopVibration(__handle);
-                       goto CATCH;
-               }
-
-               __vibrationInformation.isVibrating = true;
-               __vibrationInformation.count--;
-       }
-
-       return;
-
-CATCH:
-       SysLogException(NID_UIX, r, "[%s] Critical error occurred! Vibration was stopped.", GetErrorMessage(r));
-       __vibrationInformation = _VibratorImpl::__INVALID_VIBRATION_INFORMATION;
-}
-
 } } // Tizen::System
index 82eb426..1c3b5a1 100644 (file)
@@ -1,4 +1,4 @@
-       //
+//
 // Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 #define _FSYSTEM_INTERNAL_ALARM_IMPL_H_
 
 #include <FBaseColHashMap.h>
+#include <FBaseDateTime.h>
 #include <FBaseInteger.h>
 #include <FBaseRtEvent.h>
-#include <FSysAlarm.h>
-
-#include <FIo_IIpcClientEventListener.h>
-
-namespace Tizen { namespace Base
-{
-
-namespace Collection {
-class ArrayList;
-}
-}}
+#include <FBaseResult.h>
 
-namespace Tizen { namespace Io
-{
-class _IpcClient;
-}}
+#include <FSysAlarm.h>
 
 namespace Tizen { namespace System
 {
 
 class _OSP_EXPORT_ _AlarmImpl
        : public Tizen::Base::Object
-       , public Tizen::Io::_IIpcClientEventListener
 {
 public:
        _AlarmImpl(Alarm* pAlarm);
-       
-       result Construct(void);
 
        virtual ~_AlarmImpl();
 
+public:
+       result Construct(void);
+
        result Set(const Tizen::Base::DateTime& startTime, int period, const Tizen::Base::DateTime* pEndTime);
 
        result Cancel(void);
@@ -70,41 +58,34 @@ public:
        result SetAlarmEventListener(IAlarmEventListener* pListener);
 
        void OnAlarmExpired(int alarmId);
-       
-       void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
-       
-       void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
-
-       Tizen::Io::_IpcClient* GetIpcClient(void);
 
        static _AlarmImpl* GetInstance(Alarm* pAlarm);
 
        static const _AlarmImpl* GetInstance(const Alarm* pAlarm);
 
+
+public:
+       Tizen::Base::Integer    __alarmId;
+
 private:
        _AlarmImpl(const _AlarmImpl& alarmImpl);
 
        _AlarmImpl& operator =(const _AlarmImpl& alarmImpl);
 
 private:
-       Tizen::Io::_IpcClient*  __pIpcClient;
-
        Tizen::Base::Integer    __period;
 
-       Tizen::Base::Integer*   __pAlarmId;
-
        Tizen::Base::DateTime   __startTime;
 
        Tizen::Base::DateTime*  __pEndTime;
 
+       bool                    __isSetEndTime;
+
        Tizen::Base::Runtime::Event* __pEvent;
 
        Alarm*                  __pAlarm;
-
-       
 };
 
-
-} } // Tizen::Sys
+} } // Tizen::System
 
 #endif //_FSYSTEM_INTERNAL_ALARM_IMPL_H_
index 38d9324..5936af9 100644 (file)
@@ -57,11 +57,20 @@ public:
        static result   RestoreScreenBrightness(void);
        static result   SetScreenBrightness(int brightness);
        static result   SetBatteryEventListener(IBatteryEventListener* pListener);
+
        static void     SetChargingEventListener(IChargingEventListener& listener);
+       static result   AddChargingEventListener(IChargingEventListener& listener, bool isSet = false);
+       static result   RemoveChargingEventListener(IChargingEventListener& listener);
+
        static void     SetScreenEventListener(IScreenEventListener& listener);
+       static result   AddScreenEventListener(IScreenEventListener& listener, bool isSet = false);
+       static result   RemoveScreenEventListener(IScreenEventListener& listener);
        static result   TurnScreenOff(void);
        static result   TurnScreenOn(void);
 
+       static result   AddBootEventListener(IBootEventListener& listener);
+       static result   RemoveBootEventListener(IBootEventListener& listener);
+
        static result   PowerControl(int deviceId, int level);
        static bool     IsActive(void);
 
index 32e6a22..f2a64b7 100644 (file)
@@ -26,7 +26,6 @@
 #include <FSysRuntimeInfo.h>
 #include <FSysIRuntimeInfoGetIntAsyncResultListener.h>
 #include <FSysIRuntimeInfoGetLonglongAsyncResultListener.h>
-#include <alarm.h>
 
 namespace Tizen { namespace System
 {
index 7430acf..dfa563c 100644 (file)
@@ -66,7 +66,7 @@ public:
 
        static result ResetToFactoryDefault(void);
 private:
-       static void InitSettingManager(void);
+       static void InitSettingClient(void);
 
 };
 
index 7ee221c..1493b0a 100644 (file)
 #include <FBaseColIList.h>
 #include <FSysSystemInfo.h>
 
-#include <system_info.h>
-#include <device.h>
-#include <pthread.h>
 
 namespace Tizen { namespace System
 {
 
-class IDeviceEventListener;
-class IBatteryEventListener;
-class IChargingEventListener;
-class IScreenEventListener;
-
 class _OSP_EXPORT_ _SystemInfoImpl
 {
 public:
@@ -69,6 +61,8 @@ public:
 
        static result GetWebApiVersion(Tizen::Base::String& webApiVersion);
 
+       static result GetBuildInfo(Tizen::Base::String& buildInfo);
+
        static _SystemInfoImpl* GetInstance(SystemInfo& systeminfo);
        
        static const _SystemInfoImpl* GetInstance(const SystemInfo& systeminfo);
@@ -79,6 +73,8 @@ private:
        static result GetFromRegistry(const Tizen::Base::String& key, int& value);
 
        static result GetFromRegistry(const Tizen::Base::String& key, bool& value);
+
+       static Tizen::Base::String ConvertToTizen(const Tizen::Base::String& key);
 };
 
 } } // Tizen::System
index 6e913d2..3672165 100644 (file)
@@ -22,6 +22,7 @@
 
 #ifndef _FSYSTEM_INTERNAL_VIBRATOR_IMPL_H_
 #define _FSYSTEM_INTERNAL_VIBRATOR_IMPL_H_
+#include <haptic/haptic.h>
 
 #include <FOspConfig.h>
 #include <FBaseDataType.h>
@@ -35,7 +36,6 @@ class Vibrator;
 
 class _OSP_EXPORT_ _VibratorImpl
        : public Tizen::Base::Object
-       , public Tizen::Base::Runtime::ITimerEventListener
 {
 public:
        /*
@@ -65,6 +65,34 @@ public:
         */
        result Construct(void);
 
+
+       /**
+        * Vibrates the device with the specified array pattern which has vibration intensity and duration. @n
+        * This method returns the result immediately so that the vibration occurs simultaneously as the device runs. @n
+        * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately. @n
+        * If multiple applications trigger the vibration, the vibrator merges one vibration pattern with another in the overlapped time. @n
+        * If the system alert occurs such as ring vibration and a system event notification, the vibration can be interrupted. @n
+        * If the application is terminated, the vibration is canceled.
+        *
+        * @since 2.1
+        *
+        * @privilege     http://tizen.org/privilege/vibrator
+        *
+        * @return      An error code
+        *
+        * @param[in]   patterns                        An array of @c IntensityDurationVibrationPattern.
+        * @param[in]   length                          The length of @c patterns.
+        * @param[in]   repeatCount                           The number of repeat for pattern. This value has to be between 1 to 100.
+        * @exception   E_SUCCESS           The method is successful.
+        * @exception    E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG       A specified input parameter is invalid.
+        * @exception E_OPERATION_FAILED The device operation has failed.
+        * @remarks The vibration intensity does not apply the change, even if the system default vibration intensity is changed after starting vibration.
+        * @see  IntensityDurationVibrationPattern
+        */
+       result Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount);
+
+
        /*
         * Vibrates the device with the specified pattern and level. @n
         * This method returns the result immediately so that the vibration occurs simultaneously as the device runs.
@@ -104,36 +132,23 @@ public:
         */
        result Stop(void);
 
+       /*
+        * Convert the error code of hapic library to the result
+        */
+       result ConvertErrorCode(int errorCode);
+
        static _VibratorImpl* GetInstance(Vibrator& vibrator);
 
        static const _VibratorImpl* GetInstance(const Vibrator& vibrator);
 
 private:
-       void Destruct(void);
-
        _VibratorImpl(const _VibratorImpl& value);
 
        _VibratorImpl& operator =(const _VibratorImpl& value);
 
-       virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
-
-
 private:
-       Handle __handle;
-       Tizen::Base::Runtime::Timer* __pTimer;
-
-       struct VibrationInformation
-       {
-               long onPeriod;
-               long offPeriod;
-               int count;
-               int level;
-               bool isVibrating;
-               bool isFinished;
-       };
-       VibrationInformation __vibrationInformation;
-
-       static const VibrationInformation __INVALID_VIBRATION_INFORMATION;
+       haptic_device_h __handle;
+       haptic_effect_h __effectHandle;
 };
 } } // Tizen::System
 #endif