#include <unique_ptr.h>
#include <errno.h>
#include <string.h>
+#include <package_manager.h>
#include <shortcut.h>
#include <FBaseSysLog.h>
#include <FShellAppWidgetPopupProvider.h>
#include <FShellAppWidgetFrame.h>
#include <FShellAppWidgetPopup.h>
-
#include <FShellIAppWidgetProviderFactory.h>
#include <FShellIAppWidgetPopupProviderFactory.h>
-#include <FShell_IAppWidgetTouchEventListener.h>
#include <FShell_TemplateUtil.h>
-
+#include <FShell_IAppWidgetTouchEventListener.h>
#include "FShell_AppWidgetManagerProxy.h"
#include "FShell_AppWidgetProviderManagerImpl.h"
-
#include "FShell_AppWidgetProviderInfoImpl.h"
namespace Tizen { namespace Shell
{
SysLog(NID_SHELL, "Enter.");
+
+ result r = CheckCertificate(Tizen::App::App::GetInstance()->GetAppId(), appId);
+ SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] VerifyCertification is failed.", GetErrorMessage(r));
+
// if( appId == App::App::GetInstance()->GetAppId())
// {
// //TODO: optimizing for local request
}
}
+bool
+_AppWidgetProviderManagerImpl::IsSamePackage(const Tizen::App::AppId& appId1, const Tizen::App::AppId& appId2)
+{
+ String PackageId1 = _PackageManagerImpl::GetPackageIdByAppId(appId1);
+ String PackageId2 = _PackageManagerImpl::GetPackageIdByAppId(appId2);
+
+ return ( PackageId1 == PackageId2);
+}
+
+result
+_AppWidgetProviderManagerImpl::CheckCertificate(const Tizen::App::AppId& localAppId, const Tizen::App::AppId& remoteAppId)
+{
+ if( IsSamePackage( localAppId, remoteAppId))
+ {
+ return E_SUCCESS;
+ }
+
+ // for FtApp
+ static const String PKGID_FTAPP = L"2s4jm6firv";
+ if( _PackageManagerImpl::GetPackageIdByAppId(localAppId) == PKGID_FTAPP )
+ {
+ return E_SUCCESS;
+ }
+
+ package_manager_compare_result_type_e res;
+
+ std::unique_ptr<char[]> pLocalAppId(_StringConverter::CopyToCharArrayN(localAppId));
+ std::unique_ptr<char[]> pRemoteAppId(_StringConverter::CopyToCharArrayN(remoteAppId));
+
+ int ret = package_manager_compare_app_cert_info(pLocalAppId.get(), pRemoteAppId.get(), &res);
+ SysTryReturnResult(NID_SHELL, ret == 0, E_SYSTEM, "Failed to check the certificate: %d", ret);
+ SysTryReturnResult(NID_SHELL, res == PACAKGE_MANAGER_COMPARE_MATCH, E_CERTIFICATE_VERIFICATION_FAILED, "Both applications are not signed with the same certificate: %d", res);
+
+ return E_SUCCESS;
+}
+
result
_AppWidgetProviderManagerImpl::AddAppWidget(const Tizen::App::AppId& providerAppId, const Tizen::Base::String& providerName, const Tizen::Base::String& text, const Tizen::Base::String& userInfo)
{
- result r = _AccessController::CheckUserPrivilege(_PRV_APPWIDGETPROVIDER_INSTALL);
+ result r = _AccessController::CheckUserPrivilege(_PRV_SHORTCUT_INSTALL);
SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
SysTryReturnResult(NID_SHELL, providerAppId.IsEmpty()==false, E_INVALID_ARG, "The providerAppId is empty.");
SysTryReturnResult(NID_SHELL, providerAppId.GetLength() < NATIVE_APP_MAX_APPID_LENGTH, E_INVALID_ARG, "The providerAppId is too long (Maximum %d bytes).", NATIVE_APP_MAX_APPID_LENGTH);
SysTryReturnResult(NID_SHELL, Tizen::App::_Aul::IsInstalled(providerAppId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", providerAppId.GetPointer());
+ r = CheckCertificate(Tizen::App::App::GetInstance()->GetAppId(), providerAppId);
+ SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] VerifyCertification is failed.", GetErrorMessage(r));
+
String providerId;
if( providerAppId.StartsWith(L"com.samsung", 0) == true )
{
}
else
{
- String localPackageId = _PackageManagerImpl::GetPackageIdByAppId(Tizen::App::App::GetInstance()->GetAppId());
- String appwidgetProviderPackageId = _PackageManagerImpl::GetPackageIdByAppId(providerAppId);
- if( localPackageId != appwidgetProviderPackageId)
- {
- SysLog(NID_SHELL, "[E_INVALID_OPERATION] but allowed to test");
- //TODO:return E_INVALID_OPERATION
- }
providerId = providerAppId + "." + providerName;
}
std::unique_ptr<char[]> pIcon(_StringConverter::CopyToCharArrayN(iconPath));
int ret = add_to_home_livebox(pProviderId.get(), pName.get(), LIVEBOX_TYPE_DEFAULT, pContent.get(), pIcon.get(), -1.0l, true, AddAppWidgetCallback, this);
- SysTryReturnResult(NID_SHELL, ret != -ENOTCONN, E_CONNECTION_FAILED, "[E_CONNECTION_FAILED] failed to add_to_home_livebox");
- SysTryReturnResult(NID_SHELL, ret == 0, E_SYSTEM, "[E_SYSTEM] failed to add_to_home_livebox (%s)", strerror(r));
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_CONNECTION_FAILED, "[E_CONNECTION_FAILED] failed to add_to_home_livebox");
+ SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "[E_SYSTEM] failed to add_to_home_livebox (%s)", strerror(r));
return E_SUCCESS;
}
return contains;
}
-//void
-//_AppWidgetProviderManagerImpl::TerminateAppIfInvalidState()
-//{
-// if( __messageReceived == false )
-// {
-// Tizen::App::App::GetInstance()->Terminate();
-// }
-//}
-
void
_AppWidgetProviderManagerImpl::OnAppControlRequestReceived(RequestId reqId, const String& operationId, const String* pUri, const String* pMimeType, const IMap* pArgs)
{
SysAssertf( pArgs, "[E_SYSTEN] pArgs should not be null.");
SysAssertf( pArgs->GetCount() > 0, "[E_SYSTEN] pArgs should have one more key-values.");
-// __messageReceived = true;
-
SysLog(NID_SHELL, "operationId(%ls), argc(%d)", operationId.GetPointer(), pArgs->GetCount());
const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_INSTANCE_ID));
const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_INSTANCE_ID));
SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "[E_FAILURE] pId is null.");
- /*String *pName = dynamic_cast<String*>(pArgs->GetAt(1));
- SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "[E_FAILURE] pName is null");
-
- String *pParam = dynamic_cast<String*>(pArgs->GetAt(2));
- SysTryReturnResult(NID_SHELL, pParam, E_FAILURE, "[E_FAILURE] pName is null");
-
- SysLog(NID_SHELL, "id(%ls), name(%d)", pInstanceId->GetPointer(), pName->GetPointer());*/
-
- /*if( operationId == APPWIDGET_ON_ADD )
- {
- int w = 0;
- int h = 0;
- String* pValue = dynamic_cast<String*>(pArgs->GetAt(2));
- SysTryReturnResult(NID_SHELL, pValue, E_FAILURE, "[E_FAILURE]");
- Integer::Parse(*pValue, w);
-
- pValue = dynamic_cast<String*>(pArgs->GetAt(3));
- SysTryReturnResult(NID_SHELL, pValue, E_FAILURE, "[E_FAILURE]");
- Integer::Parse(*pValue, h);
-
- this->__pAppWidgetEventListener->OnAppWidgetAdded(*pId, width, height, pArgs);
- }*/
-
if (operationId == APPWIDGET_ON_RESIZE)
{
int width = 0;
*/
#include <unique_ptr.h>
+
#include <shortcut.h>
+
#include <FBaseSysLog.h>
#include <FShellShortcutManager.h>
#include <FShellIShortcutRequestListener.h>
+
#include <FApp_Types.h>
#include <FApp_AppInfo.h>
#include <FBase_StringConverter.h>
int type = (uriData.IsEmpty())? LAUNCH_BY_PACKAGE : LAUNCH_BY_URI;
int ret = add_to_home_shortcut(pAppId.get(), pName.get(), type, pUriData.get(), pIcon.get(), allowDuplication, NULL, this);
- SysTryReturnResult(NID_SHELL, ret == 0, E_SYSTEM, "Failed to add_to_home_shortcut");
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_SUCCESS, "It's failed to add_to_home_shortcut, but regarded as success.");
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_MEMORY, E_OUT_OF_MEMORY, "It's failed to add_to_home_shortcut.");
+ SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "Failed to add_to_home_shortcut");
return E_SUCCESS;
}
std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(displayName));
int ret = add_to_home_remove_shortcut(pAppId.get(), pName.get(), "", null, this);
- SysTryReturnResult(NID_SHELL, ret == 0, E_SYSTEM, "Failed to add_to_home_remove_shortcut");
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_SUCCESS, "It's failed to add_to_home_remove_shortcut, but regarded as success.");
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_MEMORY, E_OUT_OF_MEMORY, "It's failed to add_to_home_remove_shortcut.");
+ SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "It's failed to add_to_home_remove_shortcut, with reason (%d)");
return E_SUCCESS;
}
return __pShortcutManagerImpl->RemoveShortcutRequestListener(listener);
}
+
}} // Tizen::Shell