fd6486e89f780170c650d848c0b3a6c25730d579
[platform/core/security/drm-service-core-tizen.git] / include / drm-oem-sapps.h
1 /*
2  * drm-service-core-sapps
3  *
4  * Copyright (c) 2000 - 2010 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:Sunggun Jung <sunggun.jung@samsung.com>
7  * 
8  */
9
10 #ifndef __DRM_OEM_SAPPS_H__
11 #define __DRM_OEM_SAPPS_H__
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #include <time.h>
18
19 /* Return values from Samsung Apps DRM APIs */
20  #define DRM_SAPPS_SUCCESS 0        /**<success */
21  #define DRM_SAPPS_LIC_VALID 1       /**<License is valid */
22  #define DRM_SAPPS_LIC_SUSPEND 2       /**<License is valid but for future use */
23  
24  /* All the failure cases will have a negative value */   
25  #define DRM_SAPPS_INVALID_ARG -1000      /**<invalid argument*/
26  #define DRM_SAPPS_PARSING_ERROR -999      /**<parsing contents or rights error*/
27  #define DRM_SAPPS_DB_ERROR -998        /**<data base error */
28  #define DRM_SAPPS_INSUFFICIENT_MEMORY -997      /**<memory error */
29  #define DRM_SAPPS_INTERNAL_ERROR -996      /**<processing error */
30  #define DRM_SAPPS_FILE_ERROR -995       /**<file error */
31
32  /* License specific errors */
33  #define DRM_SAPPS_LIC_EXPIRED_DATETIME -994     /**<Datetime License is expired */
34  #define DRM_SAPPS_LIC_EXPIRED_COUNT -993     /**<Count License is expired */
35  #define DRM_SAPPS_LIC_NO_LICENCE -992      /**<No License */
36  #define DRM_SAPPS_LIC_IMEI_MISMATCH -991     /**<IMEI is mismatching */
37  #define DRM_SAPPS_LIC_PNUM_MISMATCH -990     /**<PNUM is mismatching */
38  
39  #define DRM_SAPPS_UNKNOWN_ERROR -1     /**<dummy error value */
40
41 /* License Information */
42 typedef struct {
43         unsigned int IsLicenseValid;    /**<whether license is valid or not */
44         unsigned int OrgCount;                  /**<Original Count */
45         unsigned int CurCount;                  /**<Current Count */
46         struct tm starttime;                    /**<starttime in the format of struct tm */
47         struct tm endtime;                              /**<endtime in the format of struct tm */
48         struct tm securetime;                   /**<securetime in the format of struct tm */
49 } drm_sapps_license_info;
50
51 typedef struct _drm_sapps_license_list{
52         struct _drm_sapps_license_list*   pnext;
53         drm_sapps_license_info    LicenseInfo;
54 } drm_sapps_license_list;
55 /**
56 * @internal
57 * @defgroup DRM-SAPPS drm-sapps
58 * @{  
59 */
60
61 /**   
62  *  An application can request generate request for getting License.
63  * 
64  * @param[in]           pRespBuf                        Response Data String of the Purchase Request ( Null terminator string ) 
65  * @param[in]           respBufLen              pResBuf Length
66  * @param[in][out]      pReqBuf                 License Request Data
67  * @param[in][out]      pReqBufLen              IN : pReqBuf Length, OUT : Rights Request Data String Size ( including null terminator )
68  * @param[in][out]      pLicenseUrl             License Acquisition URL Data
69  * @param[in][out]      pLicenseUrlLen  IN : pLicenseUrl Length, OUT : Rights Issuer Server URL Data String Size (  including null terminator )
70  * @return                                              This function   returns 1 on success or 0 on failure.
71  * @remarks     
72  * @see                                                 drm_sdc_generate_purchase_request
73  * @since         
74  */
75 int drm_oem_sapps_generate_license_request(const char *pRespBuf, unsigned int respBufLen, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen);
76
77 /**   
78  *  An application can get SAD license which is encrypted.
79  * 
80  * @param[in]           pRespBuf                        Response Data String of the Rights Request ( Null terminator string ) 
81  * @param[in]           respBufLen              pResBuf Length
82  * @return                                              This function returns 1 on success or 0 on failure.
83  * @remarks     
84  * @see         
85  * @since         
86  */
87  int drm_oem_sapps_register_license(const char *pRespBuf, unsigned int respBufLen);
88
89 /**   
90  * API for checks whether the app drm file or not
91  * 
92  * @param[in]   pDcfPath        File path that to be checked whether the app drm file or not
93  * @param[in]   dcfPathLen      File path length that to be checked whether the app drm file or not
94  * @return  This function can return any of the following codes
95  * SADC_NOTSADCFILE_ERROR = 0x0640
96  * SADC_PARAMETER_ERROR = 0X0660
97  * SADC_FILE_READ_ERROR = 0x0703
98  * SADC_MEMAlOC_ERROR = 0x0662 
99  * @remarks
100  * @remarks
101  * @see
102  * @since         
103  */
104  int drm_oem_sapps_is_drm_file(const char *pDcfPath, int dcfPathLen);
105
106 /**   
107  *  An application can get decrypted contents(Apps) which is encrypted.
108  * 
109  * @param[in]           pSADCFilepath   SDC DRM File Path               
110  * @param[in]           sadcFileLen             SDC DRM File length     
111  * @param[in]           pDecryptedFile  Decrypted File Path
112  * @param[in]           decryptedFileLen        Decrypted File length
113  * @return
114  * SADC_SUCCESS = 0
115  * SADC_PARAMETER_ERROR = 0X0660
116  * SADC_GET_FILEHEADER_ERROR = 0x0703
117  * SADC_GET_CEK_ERROR = 0x0704
118  * SADC_DECRYPT_PACKAGE_ERROR = 0x0705
119  * @remarks     
120  * @see         
121  * @since         
122  */
123 //Decrypt DRM File
124  int drm_oem_sapps_decrypt_package ( const char *pSADCFilepath, int sadcFileLen, const char *pDecryptedFile, int decryptedFileLen );
125
126 /**   
127  * API for checks whether the app drm file or not
128  * 
129  * @param[in]   pDcfPath        File path that to be checked whether the app drm file or not
130  * @param[in]   dcfPathLen      File path length that to be checked whether the app drm file or not
131  * @return  This function can return any of the following codes
132  * SADC_SUCCESS = 0
133  * SADC_NOTSADCFILE_ERROR = 0x0640
134  * SADC_PARAMETER_ERROR = 0X0660
135  * SADC_FILE_READ_ERROR = 0x0703
136  * SADC_MEMAlOC_ERROR = 0x0662 
137  * @remarks
138  * @remarks
139  * @see
140  * @since         
141  */
142  int drm_oem_sapps_is_drm_app(const char *pszCid, int cidLen);
143
144  int drm_oem_sapps_uninstall_license(const char *szCid, int cidLen);
145
146 /**   
147  *  An application can get file Header Info ( CID, License URL )
148  * 
149  * @param[in]           pSADCFilepath   file path of Samsung Apps DRM contents 
150  * @param[out]  cid                             contents id of Samsung Apps DRM 
151  * @param[in]           cidLength                       Length of CID. 
152  * @param[out]  riurl                           Right Issuer URL 
153  * @param[in]           riurlLength             Length of Right Issuer URL
154  * @return              This function returns 1 on success or 0 on failure.
155  * @remarks     
156  * @see
157  * @since
158  */
159  int drm_oem_sapps_get_file_header( const char *pSADCFilepath, char *cid, unsigned int cidLength, char *riurl, unsigned int riurlLength );
160
161 /**   
162  *  An application can request purchase request for getting License.
163  * 
164  * @param[in]           pSADCFilepath   File path of Samsung Apps DRM contents 
165  * @param[out]  pReqBuf                 Purchase Request Data
166  * @param[in][out]      pReqBufLen              IN : pReqBuf Length, OUT : Purchase Request Data String Size ( including null terminator )
167  * @param[out]  pLicenseUrl             License Acquisition URL Data
168  * @param[in][out]      pLicenseUrlLen  IN : pLicenseUrl Length, OUT : License Server URL Data String Size (  including null terminator )
169  * @return                                              This function returns 1 on success or 0 on failure.
170  * @remarks     
171  * @see                         DrmSdcGenerateLicenseRequest
172  * @since         
173  */
174  int drm_oem_sapps_generate_purchase_request ( const char *pSADCFilepath, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen );
175
176 /**   
177  *  An application can check contents(Apps) which has a  valid licence.
178  * 
179  * @param[in]  szCid  Content ID(CID) of the Samsung Apps contents
180  * @return      This function can return any of the following codes
181  * DRM_SAPPS_SUCCESS = 0                 <success 
182  * DRM_SAPPS_LIC_VALID = 1       <License is valid 
183  * DRM_SAPPS_LIC_SUSPEND = 2     <License is valid but for future use 
184  * DRM_SAPPS_INVALID_ARG = -1000        <invalid argument
185  * DRM_SAPPS_PARSING_ERROR = -999               <parsing contents or rights error
186  * DRM_SAPPS_DB_ERROR = -998             <data base error 
187  * DRM_SAPPS_INSUFFICIENT_MEMORY = -997   <memory error 
188  * DRM_SAPPS_INTERNAL_ERROR = -996      <processing error
189  * DRM_SAPPS_FILE_ERROR = -995    <file error
190  * DRM_SAPPS_LIC_EXPIRED_DATETIME = -994         <Datetime License is expired
191  * DRM_SAPPS_LIC_EXPIRED_COUNT = -993     <Count License is expired 
192  * DRM_SAPPS_LIC_NO_LICENCE = -992       <No License
193  * DRM_SAPPS_LIC_IMEI_MISMATCH = -991     <IMEI is mismatching 
194  * DRM_SAPPS_LIC_PNUM_MISMATCH = -990     <PNUM is mismatching 
195  * DRM_SAPPS_UNKNOWN_ERROR = -1 <dummy error value 
196  * @remarks 
197  * @see                 drm_sdc_get_file_header
198  * @since         
199  */
200  int drm_oem_sapps_has_valid_license ( const char *szCid );
201
202 /**   
203  *  An application can update license of Samsung Apps contents.
204  * 
205  * @param[in]  szCid  Content ID(CID) of the Samsung Apps contents
206  * @return  This function can return any of the following codes
207  * DRM_SAPPS_SUCCESS = 0        <success 
208  * DRM_SAPPS_LIC_VALID = 1      <License is valid 
209  * DRM_SAPPS_LIC_SUSPEND = 2    <License is valid but for future use 
210  * DRM_SAPPS_INVALID_ARG = -1000   <invalid argument
211  * DRM_SAPPS_PARSING_ERROR = -999      <parsing contents or rights error
212  * DRM_SAPPS_DB_ERROR = -998        <data base error 
213  * DRM_SAPPS_INSUFFICIENT_MEMORY = -997      <memory error 
214  * DRM_SAPPS_INTERNAL_ERROR = -996     <processing error
215  * DRM_SAPPS_FILE_ERROR = -995       <file error
216  * DRM_SAPPS_LIC_EXPIRED_DATETIME = -994    <Datetime License is expired
217  * DRM_SAPPS_LIC_EXPIRED_COUNT = -993    <Count License is expired 
218  * DRM_SAPPS_LIC_NO_LICENCE = -992      <No License
219  * DRM_SAPPS_LIC_IMEI_MISMATCH = -991    <IMEI is mismatching 
220  * DRM_SAPPS_LIC_PNUM_MISMATCH = -990    <PNUM is mismatching 
221  * DRM_SAPPS_UNKNOWN_ERROR = -1    <dummy error value 
222  * @remarks  This API must be called before rendering Samsung Apps contents
223  * @see   
224  * @since         
225  */
226  int drm_oem_sapps_consume_license( const char *szCid );
227
228 /**   
229  *  An application can get license information for Samsung Apps content with given CID.
230  * 
231  * @param[in]   szCid                                   Content ID(CID) of the Samsung Apps contents
232  * @param[out]  LicenseInfoList                         License information list
233  * @return  This function can return any of the following codes
234  * DRM_SAPPS_SUCCESS = 0        <success 
235  * DRM_SAPPS_LIC_VALID = 1      <License is valid 
236  * DRM_SAPPS_LIC_SUSPEND = 2    <License is valid but for future use 
237  * DRM_SAPPS_INVALID_ARG = -1000   <invalid argument
238  * DRM_SAPPS_PARSING_ERROR = -999      <parsing contents or rights error
239  * DRM_SAPPS_DB_ERROR = -998        <data base error 
240  * DRM_SAPPS_INSUFFICIENT_MEMORY = -997      <memory error 
241  * DRM_SAPPS_INTERNAL_ERROR = -996     <processing error
242  * DRM_SAPPS_FILE_ERROR = -995       <file error
243  * DRM_SAPPS_LIC_EXPIRED_DATETIME = -994    <Datetime License is expired
244  * DRM_SAPPS_LIC_EXPIRED_COUNT = -993    <Count License is expired 
245  * DRM_SAPPS_LIC_NO_LICENCE = -992      <No License
246  * DRM_SAPPS_LIC_IMEI_MISMATCH = -991    <IMEI is mismatching 
247  * DRM_SAPPS_LIC_PNUM_MISMATCH = -990    <PNUM is mismatching 
248  * DRM_SAPPS_UNKNOWN_ERROR = -1    <dummy error value 
249  * @remarks  
250  * @see   
251  * @since         
252  */
253  int drm_oem_sapps_get_license_info( const char *szCid ,drm_sapps_license_list **LicenseInfoList );
254
255 /**   
256  *  An application frees license information list for Samsung Apps contents.
257  * 
258  * @param[in]   pLicenseInfoList                                        License information list pointer
259  * @return  
260  * @remarks  This should be called after using LicenseInfoList recevied in drm_oem_sapps_get_license_info.
261  * @remarks  Memory is allocated for LicenseInfoList in drm_oem_sapps_get_license_info that need to be freed by calling drm_oem_sapps_free_license_info
262  * @see   drm_oem_sapps_get_license_info
263  * @since         
264  */
265  void drm_oem_sapps_free_license_info(drm_sapps_license_list **pLicenseInfoList);
266 /**
267 *@}
268 */ /* Doxygen : addtogroup*/
269
270 #ifdef __cplusplus
271 }
272 #endif
273
274 #endif