PKG_CHECK_MODULES(APPFW_WATCH, capi-appfw-watch-application,
[watch_available=yes], [watch_available=no] )
PKG_CHECK_MODULES(APPCORE_WATCH, appcore-watch)
+PKG_CHECK_MODULES(CYNARA_CLIENT, cynara-client)
if test "x$watch_available" = "xyes"; then
DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DAPPCORE_WATCH_AVAILABLE"
fi
#include <dali/integration-api/debug.h>
#include <fstream>
#include <string.h>
+#include <cynara-client.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <system_info.h>
// INTERNAL INCLUDES
#include <adaptor.h>
namespace
{
unsigned int TIME_OUT_DURATION = 1000;
+const int SMACK_LABEL_LENGTH = 255;
+
+const char* const CYNARA_CHECK_FILE = "/proc/self/attr/current";
+const char* const SCREEN_SHOT_PRIVILEGE = "http://tizen.org/privilege/screenshot";
}
namespace Dali
{
CapturePtr pWorker = new Capture();
- // Second-phase construction
- pWorker->Initialize();
+ if( pWorker->CheckPrivilege( SCREEN_SHOT_PRIVILEGE ) == false )
+ {
+ DALI_LOG_ERROR( "Capture privilege error: permission denied\n" );
+ return NULL;
+ }
return pWorker;
}
{
CapturePtr pWorker = new Capture( cameraActor );
- // Second-phase construction
- pWorker->Initialize();
+ if( pWorker->CheckPrivilege( SCREEN_SHOT_PRIVILEGE ) == false )
+ {
+ DALI_LOG_ERROR( "Capture privilege error: permission denied\n" );
+ return NULL;
+ }
return pWorker;
}
return mFinishedSignal;
}
-void Capture::Initialize()
-{
-}
-
void Capture::CreateSurface( const Vector2& size )
{
DALI_ASSERT_ALWAYS(!mTbmSurface && "mTbmSurface is already created.");
return mNativeImageSourcePtr->EncodeToFile( mPath );
}
+bool Capture::CheckPrivilege( const char* privilege ) const
+{
+ cynara* cynara;
+ int fd = 0;
+ int ret = 0;
+ char subjectLabel[SMACK_LABEL_LENGTH + 1] = "";
+ char uid[10] = { 0, };
+ const char* clientSession = "";
+
+ ret = cynara_initialize( &cynara, NULL );
+ if( ret != CYNARA_API_SUCCESS )
+ {
+ return false;
+ }
+
+ fd = open( CYNARA_CHECK_FILE, O_RDONLY );
+ if( fd < 0 )
+ {
+ cynara_finish( cynara );
+ return false;
+ }
+
+ ret = read( fd, subjectLabel, SMACK_LABEL_LENGTH );
+ if( ret < 0 )
+ {
+ close( fd );
+ cynara_finish( cynara );
+ return false;
+ }
+
+ close( fd );
+
+ snprintf( uid, 10, "%d", getuid() );
+
+ ret = cynara_check( cynara, subjectLabel, clientSession, uid, privilege );
+ if( ret != CYNARA_API_ACCESS_ALLOWED )
+ {
+ cynara_finish( cynara );
+ return false;
+ }
+
+ cynara_finish( cynara );
+
+ return true;
+}
+
} // End of namespace Adaptor
} // End of namespace Internal
Capture();
/**
+ * @PRIVLEVEL_PLATFORM
* @brief Create an initialized Capture.
*
* @SINCE_1_3_4
+ * @PRIVILEGE_CAPTURE
*
* @return A handle to a newly allocated Dali resource.
* @note Projection mode of default cameraActor is Dali::Camera::PERSPECTIVE_PROJECTION
+ * @note If permission denied by privilege occurs, a uninitialized handle is returned
*/
static Capture New();
/**
+ * @PRIVLEVEL_PLATFORM
* @brief Create an initialized Capture.
*
* @SINCE_1_3_4
+ * @PRIVILEGE_CAPTURE
*
* @param[in] cameraActor An initialized CameraActor.
* @return A handle to a newly allocated Dali resource.
+ * @note If permission denied by privilege occurs, a uninitialized handle is returned
*/
static Capture New( Dali::CameraActor cameraActor );