본문 바로가기

Others/tizen

Tizen::Content::ContentSearch 사용하기

반응형


Bada 때 Osp::Content::ContentSeach 라는 class가 해당 class가 Tizen:: 으로 만 바뀌고, 
기존의 기능을 대부분 지원 하는 것 같습니다.




ContentSearch phone 내의 이미지 파일, 오디오 파일, 비디오 파일 등 의 컨텐츠들 중에서 특정 검색 조건에 해당하는 컨텐츠들을 찾아서 리스트를 만드는 class 입니다.

관련 class들은 아래와 같습니다.
ContentInfo                       - Content 에 대한 정보를 담고 있는 class
ContentSearchResult      - ContentSearch 를 수행한 결과물을 담는 class
RemoteContentSearch    - Online 상의 Content를 검색하는 class 
                                          ( Bada 와 연계되는 Web disk 같은 곳에서 검색하는 것 일 겁니다.)

이 search class를 확인하기 위해 아래와 같이 코드를 작성하였습니다.
 
Contents searching 수행 code 입니다.

bool ContentsList::Initialize( Tizen::Ui::Controls::IconList &IconList,Tizen::Base::String & contentsPath)
{

	int totalPage=0,totalCount =0;
	result rSearch;

	Tizen::Content::ContentSearch search;
	rSearch = search.Construct(Tizen::Content::CONTENT_TYPE_IMAGE);

	Tizen::Base::Collection::IList* pContentInfoList = search.SearchN(1,5,totalPage,totalCount);

	if(IsFailed(GetLastResult()))
	{
		return false;
	}

	Tizen::Content::ContentSearchResult *pResult=null;
	Tizen::Graphics::Bitmap* pThumbImg = null;

	for(int i=0;i < pContentInfoList->GetCount();i++)
	{
		pResult = (Tizen::Content::ContentSearchResult*)pContentInfoList->GetAt(i);
		if(pResult)
		{
			pThumbImg = pResult->GetContentInfo()->GetThumbnailN();
			if(pThumbImg==null)
			{
				pResult->GetContentInfo()->MakeThumbnail(pResult->GetContentInfo()->GetContentPath());
				pThumbImg = pResult->GetContentInfo()->GetThumbnailN();
				if(pThumbImg ==null) continue;
			}
			IconList.AddItem( null, pThumbImg,pThumbImg);
			delete pThumbImg;

		}
	}

	pContentInfoList->RemoveAll(true);
	delete pContentInfoList;

	return true;

}
-

열씸히 header파일들 뒤져가면서 위와 같이 코딩을 했는데,수행하면서 runtime error가 발생합니다.에러의 내용은 E_PRIVILEGE_DENIED The application does not have the privilege to call this method. 

우선 이 E_PRIVILEGE_DENIED 의 정체애 대해서 알아봤습니다.

PRIVILEGE 란? 
Bada Platform 내의 resource들에 대한 사용권한을 설정하는 것입니다.
이는 application 제작시 manifest.xml 에 포함을 시키고, 이를 통해 setting이 됩니다.
그럼 왜 Phone 내의 resource들에 대해 이런 복잡한 절차를 거치도록 되어있는가?

추측하기에 이는 사생활 보호와 사용자 보호를 위한 내용이라 볼 수 있습니다. 
우선 manifest에 등록이 되어있어야 resource를 사용할 수 있기 때문에, 개발자가 사용자 몰래 특정 리소스를 사용하는 것을
방지하게 됩니다. 예를 들면 image viewer라는 프로그램을 짜는데 Call 기능은 아마도 거의 필요치 않을 것입니다.
그런데 이를 privilege에 등록 한다면, 뭔가 의심을 해볼 수 있으리라 생각됩니다.
또는 app스토어에서 분류목적으로도 사용할 수 도 있다고 생각됩니다.

그렇다 치고, 결국 manifest.xml 에 등록 안된 모듈을 사용할경우 시스템이
 E_PRIVILEGE_DENIED 라는 에러를 발생시키게 됩니다.

manifest파일에 어떻게 privilege를 등록 하는 가 하는 이슈가 한가지 더 나오게 되는데요.
이는 developer.bada.com 에 My Applications 에 가보면,

Step1. Generate your application profile 에  
Generate a New Application Profile 을 보실 수 있을 것입니다. 
이 application Generation 과정을 거치고 나면, 내가 개발하려고 하는 어플리케이션의 최종 manifest.xml 을 다운 받을 수 있습니다.

<?xml version="1.0" encoding="utf-8"?>
<Manifest>
    <Id>93bt1p123e</Id>
    <Secret>9C645DDBA19C71BAD1204DA4DAA7A0B9</Secret>
    <Privileges>
    </Privileges>
    <DeviceProfile>
        <APIVersion>1.0</APIVersion>
        <CPU>ARM11</CPU>
        <MinimumHeapSize>200</MinimumHeapSize>
        <Accelerator3D>OpenGL-ES 1.1</Accelerator3D>
        <Accelerator3D>OpenGL-ES 2.0</Accelerator3D>
        <BluetoothProfile>OPP</BluetoothProfile>
        <WifiMode>Ad-hoc</WifiMode>
        <Sensor>GPS</Sensor>
        <Sensor>Accelerometer</Sensor>
        <InputDevice>Touch</InputDevice>
        <ScreenSize>480x800</ScreenSize>
    </DeviceProfile>
</Manifest>




contents search 예제에 보면, 아래와 같은  코드를 볼 수 있는데요.
Category 를 작성하고 이를 search의  whereExpr에 입력 하는 코드가 있습니다.

contentSearch.SearchN(pageNo,countPerPage, totalPage, totalCount, whereExpr);
 // Step2: Retrieve the category list
	IList* pValueList = contentSearch.GetValueListN(L"Category");

	if (IsFailed(GetLastResult()))
			return r;
		
	String* pCategory = (String*)pValueList->GetAt(0);

	// Step3: Make a SQL where clause
	String whereExpr = L"Category='";
	whereExpr.Append(*pCategory);
	whereExpr.Append(L"'");



Columnname

Type

Description

ContentType

String

Content type (CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO,

CONTENT_TYPE_VIDEO,CONTENT_TYPE_OTHER)

To search for all types of content, use CONTENT_TYPE_ALL.

ContentFileName

String

Content file name

ContentName

String

User-defined content name

ContentSize

Longlong

Content size (bytes)

Category

String

Name used to group content using logical categorization,such as “Casual games” or “Action games”

Author

String

Content creator

DateTime

Datetime

Content creation time

TheToString()method of Osp::Base::DateTimeis used when it is provided as the search condition. The DateTimerange begins from “01/01/1970 00:00:00”.

Keyword

String

User‟s tags

Provider

String

Content provider

Rating

String

Rating information

LocationTag

String

Locationtag, such as “Coex” or “Starbucks”

Latitude

Double

Coordinates of latitude

Longitude

Double

Coordinates of longitude

Altitude

Double

Coordinates of altitude

Title

String

Audio or video title

Artist

String

Audio or video artist

Genre

String

Audio or video genre

Composer

String

Audio composer

ReleaseYear

Int

Audio release year

Album

String

Content album


'Others > tizen' 카테고리의 다른 글

EFL: event flow control (이벤트 흐름 제어)  (0) 2016.08.25
CLI (Command Line Inteface) 를 이용한 build  (0) 2015.11.30
tpk install, 설치  (0) 2014.05.28