source: svn/newcon3bcm2_21bu/dst/app/src/Function/App_Fnc_Rating.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 39.2 KB
Line 
1/****************************************************************************
2* NAME: App_Fnc_Rating.c
3*----------------------------------------------------------------------------
4* Copyright (c) DIGITAL STREAM Technology Inc.
5*----------------------------------------------------------------------------
6* CREATED_BY: Do Gon Lee
7* CREATION_DATE: 2009/08/26
8* $Author: foxhunt $
9* $Revision: 1.0 $
10* $Date: 2009/08/26 09:12:22 $
11*----------------------------------------------------------------------------
12* PURPOSE:
13* -
14*****************************************************************************/
15
16/*_____ I N C L U D E __________________________________________*/
17
18#include "App_Main.h"
19
20#if SUPPORT_RATING
21
22#include "App_Fnc_Common.h"
23
24#include "App_Fnc_Rating.h"
25#include "App_Fnc_RRT.h"
26
27#include "App_Fnc_Audio.h"
28#include "App_Fnc_Video.h"
29
30#include "App_Fnc_ChTune.h"
31
32#include "App_Res_Resources.h"
33
34
35
36
37
38/*_____ D E F I N I T I O N ____________________________________*/
39
40#if COMMENT
41____DbgPrint____(){}
42#endif
43
44DHL_MODULE("@f_rat", 0);
45
46
47
48
49
50#if COMMENT
51____Config____(){}
52#endif
53
54#define USE_PASSIVE_OSD_MGR 0
55        /* cafrii 060915 add
56                 ¿¹Àü OSD MGRÀ» »ç¿ëÇÑ °æ¿ì¶ó¸é 1..
57                 OSD MGRÀ» ¼öÁ¤ÇßÀ¸¹Ç·Î ÇÊ¿ä ¾øÀ½. */
58
59
60
61
62
63#if COMMENT
64____Types____(){}
65#endif
66
67typedef struct
68{
69        int rf;
70        int region;
71        int n_dim;
72        int dim[5], val[5];
73
74} FakeRatingInfo;
75
76
77#if COMMENT
78____Variables____(){}
79#endif
80
81#if APP_PORTING
82bool g_App_VChipLock;
83        /* master block flag */
84#endif  /* #if APP_PORTING */
85
86static BOOL s_bRatingBlockOn = FALSE;
87        /* ÇöÀç block »óÅÂÀÎÁö ¾Æ´ÑÁö¸¦ ³ªÅ¸³»´Â »óꝼö
88                 Block OSD´Â priority¿¡ ¹Ð·Á¼­ ´«¿¡ º¸ÀÌÁö ¾ÊÀ» ¼öµµ ÀÖ´Ù. (Info banner µî..)
89                 ±×·¸´õ¶óµµ ÇöÀç block Á¶°ÇÀ̸é ÀÌ block flag´Â TRUE°¡ µÈ´Ù. */
90       
91/* static BOOL s_bUseMissingRatingBlock=FALSE; */
92        /* g_766RatingData º¯¼ö¿¡ ÀÌ MRÁ¤º¸°¡ ÀÖÁö¸¸
93                 º°µµ·Î ³»ºÎ º¯¼ö¸¦ °ü¸®ÇÏÀÚ. */
94
95BOOL g_bUseRatingRegion4AsRegion1 = 0;
96        /* Program Rating Info¿¡ ´ëÇØ¼­
97                 rating 1À̸é region 4¸¦ region 1ó·³ °£ÁÖ..
98                 RRT´Â °ü·Ã ¾øÀ½. */
99
100BOOL g_bRatingPasswordMatched;
101        /* block OSD¿¡¼­ passwd°¡ ¸ÂÀ¸¸é ±× ÀÌÈĺÎÅÍ´Â blockÀÌ ¾ÈµÇ¹Ç·Î
102                 ±â¾ïÇØ¾ß ÇÑ´Ù. */
103                 
104BOOL g_bRatingResetPassword = FALSE;
105  /* user password¸¦ ÃʱâÈ­ ½Ã۱â À§ÇÑ supercodeÀÇ flag
106     password°¡ supercodeÀÏ °æ¿ì TRUE
107   */
108
109static UINT16 s_RatingBlockCode[64];
110        /* rating blockÀÌ µÇ¾úÀ» ¶§ blockµÈ rating code string ÀúÀå */
111
112static DHL_OS_SEMA_ID s_ratingBlockSema4;
113        /* rating block checkÇÏ´Â ÇÔ¼ö¿¡¼­ »ç¿ëÇÏ´Â mutex */
114
115UINT8 g_App_RatingPassword[4];
116
117UINT8 g_766RatingConfig[6]; 
118        /*
119                 766 Rating (Region 1 or 2) ¸¦ ¾î¶»°Ô ÀúÀåÇϴ°¡´Â app specific.
120                 AppRating_Update766TableÀÇ ¿¹´Â Philips specificÀ¸·Î Host¿¡¼­ ¾Æ·¡¿Í °°Àº ÇüÅ·Î
121                 º¸³»¿Ô±â ¶§¹®¿¡ ±×·¸°Ô ÀúÀåÇÑ °ÍÀÓ.
122        */
123       
124BOOL g_bRatingBlockOSD;
125        /* from AppRating_DrawBlockOSD() */
126       
127// BlockµÈ »óÅ¿¡¼­ User°¡ PIN ÀÔ·ÂÀ» ÅëÇØ blockÀ» unlockÇßÀ»¶§, ÀçºÎÆÃ Àü±îÁö´Â
128// block µÇÁö ¾Êµµ·Ï ÇϱâÀ§ÇÑ º¯¼ö.
129static BOOL b_UserPINMatched=FALSE;     
130       
131
132static struct
133{
134        BOOL VChipLock;                         // on/off
135        UINT8 passwd[4];                                // PIN
136        UINT8 rating_usea[2];
137        UINT8 rating_children;
138        UINT8 rating_mpaa;
139        UINT8 rating_canada_eng;
140        UINT8 rating_canada_fre;
141        UINT8 rating_age_limit;
142} p_rating_nvm_param;
143
144#define INFO(x) (p_rating_nvm_param.x)
145
146
147/*_____ F U N C T I O N ________________________________________*/
148
149#if COMMENT
150____Get_Rating_Info___(){}
151#endif
152
153/* Å×½ºÆ®¸¦ À§ÇÑ ¸ñÀûÀ¸·Î.. */
154FakeRatingInfo g_FakeRatingInfo;
155
156static void SetFakeRrtData(int rf, int region, int d1, int d2, int d3, int d4, int d5)
157{
158        int n_dim;
159       
160        if (rf <= 0) {  /* disable fake rating feature */
161                g_FakeRatingInfo.rf = 0;
162                return;
163        }
164        g_FakeRatingInfo.rf = rf;
165        g_FakeRatingInfo.region = region;
166       
167        /* dn °ª¿¡ -1À» ÁöÁ¤ÇÏ¸é ±× ÀÌÈÄÀÇ argument´Â ¸ðµÎ ¹«½ÃÇÑ´Ù. */
168       
169        n_dim = 0;
170       
171        if (d1 < 0) goto label_exit;
172        g_FakeRatingInfo.dim[n_dim] = (d1>>8)&0xff;
173        g_FakeRatingInfo.val[n_dim] = (d1&0xff);
174        n_dim++;
175
176        if (d2 < 0) goto label_exit;
177        g_FakeRatingInfo.dim[n_dim] = (d2>>8)&0xff;
178        g_FakeRatingInfo.val[n_dim] = (d2&0xff);
179        n_dim++;
180
181        if (d3 < 0) goto label_exit;
182        g_FakeRatingInfo.dim[n_dim] = (d3>>8)&0xff;
183        g_FakeRatingInfo.val[n_dim] = (d3&0xff);
184        n_dim++;
185
186        if (d4 < 0) goto label_exit;
187        g_FakeRatingInfo.dim[n_dim] = (d4>>8)&0xff;
188        g_FakeRatingInfo.val[n_dim] = (d4&0xff);
189        n_dim++;
190
191        if (d5 < 0) goto label_exit;
192        g_FakeRatingInfo.dim[n_dim] = (d5>>8)&0xff;
193        g_FakeRatingInfo.val[n_dim] = (d5&0xff);
194        n_dim++;
195
196label_exit:
197        g_FakeRatingInfo.n_dim = n_dim;
198}
199
200
201/******************************************************************************************
202FUNCTION:
203  - RatingResetPassword
204
205Purpose:
206  -
207******************************************************************************************/
208BOOL RatingResetPassword()
209{
210        dprint(3, "Rating reset password by Supercode : %s\n", g_bRatingResetPassword?"TRUE":"FALSE");
211        return g_bRatingResetPassword;
212}
213
214
215/******************************************************************************************
216FUNCTION:
217  - AppRating_SetMasterBlock
218
219Purpose:
220  -
221******************************************************************************************/
222void AppRating_SetMasterBlock(BOOL bSet, BOOL bSaveNvRam)
223{
224#if APP_PORTING
225        if (bSet != g_App_VChipLock)
226        {
227                g_App_VChipLock = bSet ? 1 : 0;
228               
229                if (bSaveNvRam)
230                        App_WriteEEPROMByte(OFFSET_SYSFILE_bBlock, g_App_VChipLock);
231               
232                AppRating_CheckRatingBlock(0);
233        }
234#else
235        if (bSet != p_rating_nvm_param.VChipLock)
236        {
237                p_rating_nvm_param.VChipLock = bSet ? 1 : 0;
238               
239                if (bSaveNvRam)
240                        App_NVM_SaveModuleParam(eAPP_NVR_RATING, &p_rating_nvm_param);
241               
242                AppRating_CheckRatingBlock(0);
243        }
244#endif  /* #if APP_PORTING */
245}
246
247BOOL AppRating_GetMasterBlock()
248{
249        return p_rating_nvm_param.VChipLock;
250}
251
252
253/******************************************************************************************
254FUNCTION:
255  - AppRating_CheckIfPasswordMatch
256
257Purpose:
258  -
259******************************************************************************************/
260BOOL AppRating_CheckIfPasswordMatch(UINT8 *pPasswd, BOOL bapply)
261{
262        UINT8 App_RatingSuperPassword[] = {'7','7','6','2'}; // super code
263        UINT8 App_RatingResetPassword[] = {'0','0','0','0'}; // reset password
264         // TO DO : header¿¡ Á¤ÀǵǾî ÀÖ´Â .passwd·Î ÃʱâÈ­ µÇµµ·Ï ÇØ¾ß ÇÑ´Ù.
265       
266#if 1
267        // exception handling. temp by foxhunt 2010.06.10
268        if(*p_rating_nvm_param.passwd == 0)
269                AppRating_SetRatingPassword(App_RatingResetPassword, TRUE);
270#endif
271       
272       
273        App_NVM_LoadModuleParam(eAPP_NVR_RATING, &p_rating_nvm_param);
274        // load pin number form /mnt/flash/DB/pin_num file
275        //DHL_DEV_FlashReadExt(0, eDHL_FlashExt_PinNum, p_rating_nvm_param.passwd, sizeof(p_rating_nvm_param.passwd));
276        dprint(3, "Input Rating Password : [%c %c %c %c]\n", 
277                pPasswd[0], pPasswd[1], pPasswd[2], pPasswd[3]); 
278        dprint(3, "\n\nNvRam Saved Rating Password : [ %c %c %c %c ]\n\n\n", 
279                p_rating_nvm_param.passwd[0], p_rating_nvm_param.passwd[1], 
280                p_rating_nvm_param.passwd[2], p_rating_nvm_param.passwd[3]);
281       
282        if(memcmp(pPasswd, p_rating_nvm_param.passwd, 4) == 0)
283        {
284                if(bapply)
285                        g_bRatingPasswordMatched = TRUE;
286                return TRUE;    /* matched */
287        }
288        else
289        {
290                int i;
291                for(i=0; i<4; i++)
292                {
293                        if (pPasswd[i] != App_RatingSuperPassword[i])
294                                return FALSE;
295                }
296               
297                if(bapply)
298                        g_bRatingPasswordMatched = TRUE;
299                return TRUE;    /* matched */
300        } 
301}
302
303
304/******************************************************************************************
305FUNCTION:
306  - AppRating_SetRatingPassword
307
308Purpose:
309  - »õ·Î¿î Password¸¦ ÀúÀå.
310  - ÃÖÃÊ ºÎÆÃ½Ã¿¡ pasword¸¦ set ÇÒ ¶§ ºÎ¸¦ ¼öµµ ÀÖ¾î¾ß ÇϹǷÎ, ÀÌ ÇÔ¼ö ³»¿¡¼­´Â
311  password°¡ match µÇ´ÂÁö üũÇÏÁö´Â ¾Ê´Â´Ù.
312******************************************************************************************/
313void AppRating_SetRatingPassword(UINT8 *pPasswd, BOOL bSaveNvRam)
314{
315        /* iskang 071126. add. user pinº¯°æ¿¡ ÀÖ¾î 2143µµ ¾µ¼ö ÀÖ°ÔÇÑ´Ù.. */
316        /* if (AppRating_CheckIfPasswordMatch(pPasswd, TRUE) == FALSE)
317                { */
318                dprint(2, "set rating passwd \n");
319               
320                memcpy(p_rating_nvm_param.passwd, pPasswd, 4);
321                if (bSaveNvRam) {
322                        App_NVM_SaveModuleParam(eAPP_NVR_RATING, &p_rating_nvm_param);
323                        //DHL_DEV_FlashWriteExt(0, eDHL_FlashExt_PinNum, p_rating_nvm_param.passwd, sizeof(p_rating_nvm_param.passwd));
324                        // saved pin number to /mnt/flash/DB/pin_num
325                        App_NVM_SaveModuleParam(eAPP_NVR_RATING, &p_rating_nvm_param);
326                }
327        /*} */
328}
329
330
331
332
333
334#if COMMENT
335________(){}
336#endif
337
338/******************************************************************************************
339FUNCTION:
340  - AppRating_Update766Table
341
342Purpose:
343  -
344Note: refer to Check766RatingBlock
345******************************************************************************************/
346void AppRating_Update766Table(UINT8 *d, BOOL bSaveNvRam)
347{
348        /* BOOL bChanged = FALSE; */
349       
350        if (memcmp(d, g_766RatingConfig, 6) != 0) /* if different */
351        {
352                memcpy(g_766RatingConfig, d, 6);
353
354                dprint(2, "766 rating condition changed.\n");
355#if APP_PORTING
356                if (bSaveNvRam) {
357                        dprint(2, "  save rating condition to nvram\n");
358                        App_WriteEEPROMByte(OFFSET_SYSFILE_USEA, d[0]);
359                        App_WriteEEPROMByte(OFFSET_SYSFILE_USEA+1, d[1]);
360                        App_WriteEEPROMByte(OFFSET_SYSFILE_CHILDREN, d[2]);
361                        App_WriteEEPROMByte(OFFSET_SYSFILE_MPAA, d[3]);
362                        App_WriteEEPROMByte(OFFSET_SYSFILE_CANADA_ENG, d[4]);
363                        App_WriteEEPROMByte(OFFSET_SYSFILE_CANADA_FRE, d[5]);
364                }
365#else
366                p_rating_nvm_param.rating_usea[0] = d[0];
367                p_rating_nvm_param.rating_usea[1] = d[1];
368                p_rating_nvm_param.rating_children = d[2];
369                p_rating_nvm_param.rating_mpaa = d[3];
370                p_rating_nvm_param.rating_canada_eng= d[4];
371                p_rating_nvm_param.rating_canada_fre= d[5];
372               
373                if (bSaveNvRam) {
374                        dprint(2, "  save rating condition to nvram\n");
375                        App_NVM_SaveModuleParam(eAPP_NVR_RATING, &p_rating_nvm_param);
376                }
377#endif  /* #if APP_PORTING */
378                AppRating_CheckRatingBlock(0);
379        }
380        else
381                dprint(2, "Rating 766 condition same\n");
382}
383
384UINT8 *AppRating_Get766Table()
385{       
386        g_766RatingConfig[0] = p_rating_nvm_param.rating_usea[0];
387        g_766RatingConfig[1] = p_rating_nvm_param.rating_usea[1];
388        g_766RatingConfig[2] = p_rating_nvm_param.rating_children;
389        g_766RatingConfig[3] = p_rating_nvm_param.rating_mpaa;
390        g_766RatingConfig[4] = p_rating_nvm_param.rating_canada_eng;
391        g_766RatingConfig[5] = p_rating_nvm_param.rating_canada_fre;
392       
393        return g_766RatingConfig;
394}
395
396/******************************************************************************************
397FUNCTION:
398  - AppRating_Update766Table
399
400Purpose:
401  - EIA 766 Rating Á¤º¸°¡ block µÇ´ÂÁö¸¦ üũÇÑ´Ù. block À̸é TRUE¸¦ ¸®ÅÏ.
402Note:
403                        d[0]: RATING766_US_Entire_Audience,
404                                bit   7   6   5   4    3    2    1   0
405                                    14-D PG PG-V PG-S PG-L PG-D  G  None
406                        d[1]:
407                                bit  7   6    5    4    3    2    1   0
408                                    MA  MA-V MA-S MA-L 14  14-V 14-S 14-L
409                       
410                        d[2]: RATING766_US_Children,
411                                bit  2     1     0
412                                     Y7   Y7-FV  Y
413                               
414                        d[3]: RATING766_US_MPAA,
415                                bit  7   6   5   4   3   2   1   0
416                                    NR   X NC17  R  PG13 PG  G  NA
417                                   
418                        d[4]: RATING766_CANADA_English,
419                        d[5]: RATING766_CANADA_French,
420******************************************************************************************/
421BOOL Check766RatingBlock(DMW_Rating766 *r766)
422{
423        UINT8 *rrt;
424        BOOL bBlock = FALSE;
425
426        rrt = AppRating_Get766Table();
427       
428        #define IF_SET_BLOCK(cond, msg) \
429                (((cond) && bBlock==FALSE) ? (DHL_OS_Printf(msg), bBlock=TRUE) : 0)
430       
431        if (r766->type == RATING766_US_MPAA) 
432        {
433                if (r766->value == 1)
434                        IF_SET_BLOCK(rrt[3] & 0x01, "[RRT] blocked by US MPAA-N/A\n");
435                else if (r766->value == 2)
436                        IF_SET_BLOCK(rrt[3] & 0x02, "[RRT] blocked by US MPAA-G\n");
437                else if (r766->value == 3)
438                        IF_SET_BLOCK(rrt[3] & 0x04, "[RRT] blocked by US MPAA-PG\n");
439                else if (r766->value == 4)
440                        IF_SET_BLOCK(rrt[3] & 0x08, "[RRT] blocked by US MPAA-PG-13\n");
441                else if (r766->value == 5)
442                        IF_SET_BLOCK(rrt[3] & 0x10, "[RRT] blocked by US MPAA-R\n");
443                else if (r766->value == 6)
444                        IF_SET_BLOCK(rrt[3] & 0x20, "[RRT] blocked by US MPAA-NC-17\n");
445                else if (r766->value == 7)
446                        IF_SET_BLOCK(rrt[3] & 0x40, "[RRT] blocked by US MPAA-X\n");
447                else if (r766->value == 8)
448                        IF_SET_BLOCK(rrt[3] & 0x80, "[RRT] blocked by US MPAA-NR\n");
449        }
450       
451        else if (r766->type == RATING766_US_Children)
452        {
453                if (r766->value == 1) { /* TV-Y */
454                        if (1)
455                                IF_SET_BLOCK(rrt[2] & 0x01, "[RRT] blocked by US TV-Y\n");
456                }
457                else if (r766->value == 2) {    /* TV-Y7 */
458                        if (r766->FV)
459                                IF_SET_BLOCK(rrt[2] & 0x02, "[RRT] blocked by US TV-Y7-FV\n");
460                        if (1)
461                                IF_SET_BLOCK(rrt[2] & 0x04, "[RRT] blocked by US TV-Y7-ALL\n");
462                }
463        }
464       
465        else if (r766->type == RATING766_US_Entire_Audience) 
466        {
467                if (r766->value == 1) { /* TV-None */
468                        if (1)
469                                IF_SET_BLOCK(rrt[0] & 0x01, "[RRT] blocked by US TV-None\n");
470                }
471                else if (r766->value == 2) {    /* TV-G */
472                        if (1)
473                                IF_SET_BLOCK(rrt[0] & 0x02, "[RRT] blocked by US TV-G\n");
474                }
475                else if (r766->value == 3) {    /* TV-PG */
476                        if (r766->D)
477                                IF_SET_BLOCK(rrt[0] & 0x04, "[RRT] blocked by US TV-PG-D\n");
478                        if (r766->L)
479                                IF_SET_BLOCK(rrt[0] & 0x08, "[RRT] blocked by US TV-PG-L\n");
480                        if (r766->S)
481                                IF_SET_BLOCK(rrt[0] & 0x10, "[RRT] blocked by US TV-PG-S\n");
482                        if (r766->V)
483                                IF_SET_BLOCK(rrt[0] & 0x20, "[RRT] blocked by US TV-PG-V\n");
484                        if (1)
485                                IF_SET_BLOCK(rrt[0] & 0x40, "[RRT] blocked by US TV-PG-ALL\n");
486                }
487                else if (r766->value == 4) {    /* TV-14 */
488                        if (r766->D)
489                                IF_SET_BLOCK(rrt[0] & 0x80, "[RRT] blocked by US TV-14-D\n");
490                        if (r766->L)
491                                IF_SET_BLOCK(rrt[1] & 0x01, "[RRT] blocked by US TV-14-L\n");
492                        if (r766->S)
493                                IF_SET_BLOCK(rrt[1] & 0x02, "[RRT] blocked by US TV-14-S\n");
494                        if (r766->V)
495                                IF_SET_BLOCK(rrt[1] & 0x04, "[RRT] blocked by US TV-14-V\n");
496                        if (1)
497                                IF_SET_BLOCK(rrt[1] & 0x08, "[RRT] blocked by US TV-14-ALL\n");
498                }
499                else if (r766->value == 5) {    /* TV-MA */
500                        if (r766->L)
501                                IF_SET_BLOCK(rrt[1] & 0x10, "[RRT] blocked by US TV-MA-L\n");
502                        if (r766->S)
503                                IF_SET_BLOCK(rrt[1] & 0x20, "[RRT] blocked by US TV-MA-S\n");
504                        if (r766->V)
505                                IF_SET_BLOCK(rrt[1] & 0x40, "[RRT] blocked by US TV-MA-V\n");
506                        if (1)
507                                IF_SET_BLOCK(rrt[1] & 0x80, "[RRT] blocked by US TV-MA-ALL\n");
508                }
509        }
510       
511        else if (r766->type == RATING766_CANADA_English) 
512        {
513               
514        }
515
516        else if (r766->type == RATING766_CANADA_French) 
517        {
518               
519        }
520       
521        return bBlock; 
522}
523
524
525/******************************************************************************************
526FUNCTION:
527  - CheckRatingBlock
528
529Purpose:
530  - Rating blockÀÌ µÇ´ÂÁö üũÇϰí block ÀÎ °æ¿ì block Á¶°ÇÀÌ µÇ´Â ¸Þ½ÃÁö¸¦ ¸®ÅÏÇÑ´Ù.
531  region 5, region 1 ¼ø¼­´ë·Î °Ë»çÇÑ´Ù.
532  - ½ÇÁ¦·Î AV mute, OSD draw ±â´É µîÀº ¼öÇàÇÏÁö ¾Ê´Â´Ù. bufSize´Â character ´ÜÀ§.
533  byteSizeÀÇ 1/2 ÀÌ´Ù.
534  - return TRUE if blocked
535******************************************************************************************/
536BOOL CheckRatingBlock(DMW_Rating5 *pRating, UINT16 *pRatingMessage, int bufSize)
537{
538        STATUS status;
539        int i,l;
540        char temp_base[64]={0,};        /* »çÀÌÁ 64À¸·Î ÇÑÀÌÀ¯´Â RRTÀ̸§À» ¾ò¾î¿À´Â
541                                                                                                                ´Ù¸¥ °÷¿¡¼­ 64À¸·Î Çϱ⠶§¹®¿¡..->Ưº°ÇÑ ÀÌÀ¯ ¾øÀ½. */
542        BOOL bBlocked = FALSE;
543        BOOL bMissingRating = TRUE;
544                /* óÀ½¿¡ missing rating true·Î Çϰí
545                         Áß°£¿¡ ratingÀÌ Çϳª¶óµµ ¹ß°ßµÇ¸é missing ratingÀÌ false°¡ µÈ´Ù. */
546       
547        if (p_rating_nvm_param.VChipLock == FALSE) {    /* master blockÀÌ ²¨Áø °æ¿ì */
548                dprint(2, "[RRT] master block option off\n");
549                return FALSE;
550        }
551#if 0
552        /* cafrii 060724 ÀÏ´Ü ¸·´Â´Ù. spec ºÒºÐ¸í. */
553        else if (g_bRatingPasswordMatched) {    /* password°¡ Á¤È®È÷ ÀÔ·ÂµÈ °æ¿ì */
554                dprint(2, "[RRT] password matched\n");
555                return FALSE;
556        }
557#endif
558
559        if (pRating == NULL || pRating->region_count == 0)
560                goto label_missing_rating;      /* missing rating ó¸® */
561               
562#if SUPPORT_DRRT
563        {
564                bBlocked = DMW_EPG_CheckRatingBlockByRRT(pRating, NULL);
565
566                /* blockÀÌ ¾ÈµÇ¸é region 1À¸·Î ³Ñ¾î°¥ °ÍÀ̹ǷÎ
567                         region 5¿¡¼­ÀÇ Missing Rating (No Rating) ¿©ºÎ´Â Áß¿äÇÏÁö ¾Ê´Ù. */
568
569                if (bBlocked) {
570                        status = DMW_EPG_GetRatingStringByRRT(pRating, pRatingMessage, bufSize);
571                        if (status) {
572                                dprint(0, "!! cannot get RRT5 rating message, err %d\n", status);
573                                pRatingMessage[0] = 0;
574                        }
575                        return TRUE;
576                }
577        }
578#endif
579        /* region 5¿¡¼­ blockÀÌ ¾ÈµÇ¾úÀ¸¹Ç·Î region 1¿¡¼­ ¼öÇà.
580                 iskang 080623.
581                 rating region¿¡ µ¶¸³ÀûÀÎ dimensionTV, MPAA°¡ µ¿½Ã¿¡ ¿Ã°æ¿ì¸¦
582          ´ëºñÇÏ¿© dimension¼ö¸¸Å­ °Ë»öÇÑ´Ù. ÇöÀç MAX_DIM->2,
583        */
584        for (i=0; i<pRating->region_count && !bBlocked; i++) 
585        {
586                if (pRating->region[i].region_id==0x01 ||
587                        (g_bUseRatingRegion4AsRegion1 && pRating->region[i].region_id == 0x04)) 
588                {
589                        DMW_Rating766 r766[RRT1_MAX_DIM];
590                        char tmp[30];
591                       
592                        DMW_EPG_ConvertToRating766Info(&pRating->region[i], r766);
593                       
594                        for(l=0;l<pRating->region[i].num_dimensions;l++)
595                        {
596                                if (r766[l].type == RATING766_US_Entire_Audience ||
597                                        r766[l].type == RATING766_US_Children ||
598                                        r766[l].type == RATING766_US_MPAA)
599                                {
600                                        bMissingRating = FALSE; 
601                                        /* ÀÏ´Ü Rating Á¤º¸°¡ Á¸ÀçÇϸé block ¿©ºÎ¿¡ °ü°è¾øÀÌ
602                                                 ´õÀÌ»ó Missing ratingÀº ¾Æ´Ï´Ù. */
603                                        bBlocked = Check766RatingBlock(&r766[l]);       /* »ç¿ëÀÚ°¡ ¼³Á¤ÇÑ ratingÁ¤º¸ °Ë»ö */
604                                        /* dimÀº Check766RatingBlock¾Ë¾Æ¼­ äũ.. */
605                                       
606                                               
607                                        if (bBlocked) {
608                                                DMW_EPG_Rating766String(&r766[l], tmp);
609                                                if (strlen(tmp) > bufSize)
610                                                        tmp[bufSize-1] = 0;
611                                                               
612                                                if(strstr(temp_base, tmp)==NULL) {
613                                                       
614                                                        if(strlen(temp_base) != 0) {
615                                                                strcat(temp_base, ", ");
616                                                        }       
617                                               
618                                                        strcat(temp_base, tmp);
619                                                }
620                                        }
621                                }
622                        }
623                       
624                        /* °Ë»öµÈ rating¹®ÀÚ¿­ÀÌ ÀÖ´Ù¸é.. */
625                        if( strlen(temp_base)==0)       /* strcmp(temp_base,Null)==0 ) */
626                                return FALSE;   /* missing rate¿Í´Â ´Ù¸£´Ù. */
627                        else
628                        {
629                                UniStrFromAscii(pRatingMessage, temp_base);
630                                return TRUE;
631                        }
632                               
633                }
634               
635        }
636
637        if (bMissingRating)
638                goto label_missing_rating;
639       
640        return FALSE;
641
642label_missing_rating:
643        /* ¸¸¾à missing ratingÀ» ¾î¶»°Ô ó¸®ÇÒ °ÍÀÎÁö¿¡ ´ëÇÑ ruleÀÌ ÀÖÀ¸¸é ¿©±â¼­ ó¸®. */
644
645        return FALSE;
646}
647
648
649/******************************************************************************************
650FUNCTION:
651  - DoRatingBlockOnOff
652
653Purpose:
654  - rating block check¸¦ ÇÑ´Ù.
655   a. program event°¡ º¯°æµÇ¾úÀ» ¶§
656   b. master block optionÀÌ º¯°æµÇ¾úÀ» ¶§
657   c. rrt tableÀÌ º¯°æµÇ¾úÀ» ¶§
658  - check°á°ú blockÀÌ °É¸®¸é TRUE¸¦ ¸®ÅÏ
659******************************************************************************************/
660static UINT16 *DoRatingBlockOnOff(DMW_Rating5 *pRating)
661{
662        BOOL bBlock = FALSE;
663        UINT16 temp[64];
664
665        /* dprint(2, "[RRT] Check Rating Block..\n"); */
666
667        if (s_ratingBlockSema4)
668                DHL_OS_TakeSemaphore(s_ratingBlockSema4, DHL_TIMEOUT_FOREVER);
669
670        bBlock = CheckRatingBlock(pRating, temp, 64);
671       
672       
673        if(g_bRatingPasswordMatched) {
674                //password°¡ matchingµÇ¾úÀ¸¹Ç·Î blockÀ» °É¾îÁÙ Çʿ䰡 ¾øÀ½.
675                //ÀÌ¹Ì °É¸° blockµµ Ç®¾îÁÜ.
676                if(s_bRatingBlockOn) {
677                       
678                        DCC_SetFeeding608(TRUE);        /* aux cc enable!! */
679                        AppRating_AVBlockOnOff(FALSE);
680                       
681                        s_bRatingBlockOn = FALSE;
682                }
683                else {
684                       
685                }
686        }
687        else if (s_bRatingBlockOn)      /* ÀÌ¹Ì rating blockÀÌ °É·Á ÀÖ´Â °æ¿ì. */
688        {
689                if (bBlock) {
690                        /* block -> block */
691                        /* update block message */
692                        UniStrCopy(s_RatingBlockCode, temp);
693                }
694                else {
695                        /* block -> unblock */
696                        /* iskang 080306.
697                                 DTV(BOX) rating block offµÇ¸é line21 insertionÀ» ÇÑ´Ù.  */
698#if 1//APP_PORTING
699                        DCC_SetFeeding608(TRUE);        /* aux cc enable!! */
700#endif  /* #if APP_PORTING */
701                        AppRating_AVBlockOnOff(FALSE);         
702                        s_bRatingBlockOn = FALSE;
703                }
704        }
705        else
706        {
707                if (bBlock) {
708                        /* unblock -> block */
709                        /* iskang 080306.
710                                 DTV(BOX) rating block onµÇ¸é line21 insertionÀ» ÇÏÁö ¾Ê´Â´Ù. */
711#if 1//APP_PORTING
712                        DCC_SetFeeding608(FALSE);       /* aux cc disable!! */
713#endif  /* #if APP_PORTING */
714                        AppRating_AVBlockOnOff(TRUE);
715                        UniStrCopy(s_RatingBlockCode, temp);
716                        s_bRatingBlockOn = TRUE;        /* OSD On/Off¸¦ ÀǹÌÇÏ´Â°Ô ¾Æ´Ô. */
717                }
718                else {
719                        /* unblock -> unblock */
720                        /* do nothing */
721                }
722        }
723        if (s_ratingBlockSema4)
724                DHL_OS_GiveSemaphore(s_ratingBlockSema4);
725
726        if(!s_bRatingBlockOn) return NULL;
727       
728        return s_RatingBlockCode;
729}
730       
731
732/******************************************************************************************
733FUNCTION:
734  - GetRatingDebugCode
735
736Purpose:
737  - for debugging
738  - buffer should have enough space
739******************************************************************************************/
740void GetRatingDebugCode(DMW_Rating5 *rating, char region_1[], char region_5[])
741{
742
743        region_1[0] = 0;
744        region_5[0] = 0;
745
746        if (rating->region_count > 0) 
747        {
748                UINT16 tmp[80] = {0, };
749                if (DMW_EPG_GetRatingStringByRRT(rating, tmp, 80) == statusOK) {
750                        char *ks = NULL;
751                        ks = (char *)DMW_ConvUc2Ks(tmp, -1);
752                        if (ks) {
753                                strcpy(region_5, ks);
754                                DMW_FreeKsString(ks);
755                        }
756                }
757               
758                if (AppRating_GetR12RatingString(rating, region_1) == FALSE)
759                        region_1[0] = 0;       
760        }
761}
762
763
764
765
766
767#if COMMENT
768_____APIs_____(){}
769#endif
770
771/******************************************************************************************
772FUNCTION:
773  - AppRating_AVBlockOnOff
774
775Purpose:
776  - Blocking µÈ È­¸éÀ» Unblocking ÇÒ ¶§ »ç¿ë     On_Off -> FALSE
777         a. TRUE : Blocking
778         b. FALSE : Unblocing
779******************************************************************************************/
780
781void AppRating_AVBlockOnOff(BOOL bOn)
782{
783        if (bOn) {
784                App_VideoSetBlank(TRUE, APP_VIDEO_MUTE_RBLOCK);
785                App_AudioMute(TRUE, APP_AUDIO_MUTE_RBLOCK);     /* APP_AUDIO_MUTE_BLOCK); */
786        } 
787        else {
788                App_VideoSetBlank(FALSE, APP_VIDEO_MUTE_RBLOCK);
789                App_AudioMute(FALSE, APP_AUDIO_MUTE_RBLOCK);    /* APP_AUDIO_MUTE_BLOCK); */
790        }
791}
792
793BOOL AppRating_IsBlockOn()
794{
795        return s_bRatingBlockOn;
796}
797
798
799/******************************************************************************************
800FUNCTION:
801  - AppRating_GetR12RatingString
802
803Purpose:
804  - Region 1/2ÀÇ string¸¸ ÃßÃâÇÏ´Â ÇÔ¼ö
805        - caller°¡ str ¹öÆÛ ÇÒ´çÀÇ Ã¥ÀÓÀÌ ÀÖÀ½. Å©±â´Â 20 ¹ÙÀÌÆ® ÀÌ»ó..
806Note: cafrii 070711 add
807******************************************************************************************/
808BOOL AppRating_GetR12RatingString(DMW_Rating5 *rating, char *str)
809{
810        int i,k;
811        char temp_str[64]={0,},s[64]={0,};
812        DMW_Rating766 r766[RRT1_MAX_DIM];
813       
814        memset(r766, 0 ,sizeof(DMW_Rating766)*RRT1_MAX_DIM);
815       
816        /* region 5 ÀÌ¿ÜÀÇ rating string */
817        for (i=0; i<rating->region_count; i++) 
818        {
819                if (rating->region[i].region_id == 0x01 ||
820                        (g_bUseRatingRegion4AsRegion1 && rating->region[i].region_id == 0x04)) /* Korea for test */
821                {       
822               
823                        DMW_EPG_ConvertToRating766Info(&rating->region[i], r766);
824
825                        /* cafrii 081217 bugfix!! */
826                        for (k=0; k<RRT1_MAX_DIM; k++)
827                        /* for(k=0;k<rating->region[i].num_dimensions;k++) */
828                        {
829                                if (r766[k].type == RATING766_US_Entire_Audience ||
830                                        r766[k].type == RATING766_US_Children ||
831                                        r766[k].type == RATING766_US_MPAA ||
832                                        r766[k].type == RATING766_CANADA_English ||
833                                        r766[k].type == RATING766_CANADA_French)
834                                {
835                                        /* iskang 081022. r766[k]¿¡¼­ k°¡ RRT1_MAX_DIMº¸´Ù Å©¸é
836                                                r766[k]´Â ÀÇ¹Ì ¾ø´Â °ªÀÌ´Ù. */
837                                        /*
838                                        if(k>=RRT1_MAX_DIM)
839                                                break;
840                                        */
841                                       
842                                        memset(s,0,sizeof(char)*64);
843                                        DMW_EPG_Rating766String(&r766[k], s);
844                                        if(strstr(temp_str, s)==NULL) {
845                                               
846                                                if(strlen(temp_str)+strlen(s) >=63)
847                                                        break;
848                                               
849                                                if(strlen(temp_str) != 0) {
850                                                        strcat(temp_str, ", ");
851                                                }       
852                                                strcat(temp_str,s);
853                                        }
854                                }
855                        }
856                       
857                        strcpy(str,temp_str);           
858                        if(strlen(str)==0)      /* strcmp(str,Null)==0) */
859                                return FALSE;
860                        else
861                                return TRUE;
862                }
863        }
864        return FALSE;
865}
866
867
868/******************************************************************************************
869FUNCTION:
870  - AppRating_GetCurRatingStr
871
872Purpose:
873  - InfoBanner¿¡ program rating Á¤º¸¸¦ Ãâ·ÂÇÒ ¶§ »ç¿ë
874        - ÇöÀç program¿¡ region 1°ú retion 5 µÑ ´Ù Æ÷ÇԵǾî ÀÖ´Ù¸é region 5¸¦ ¿ì¼±Çؼ­ º¸¿©ÁØ´Ù.
875        - strSize´Â character sizeÀÌ´Ù. (byte size°¡ ¾Æ´Ô)
876                ex> UINT16 str[10] À̸é strSize´Â 10 À̾î¾ß ÇÔ.
877******************************************************************************************/
878BOOL AppRating_GetCurRatingStr(UINT16 *str, int strSize)
879{
880        DMW_Rating5 rating;
881        /* int i; */
882        BOOL bRet;
883        STATUS status;
884
885        if (!str) 
886                return FALSE;
887
888        str[0] = 0;
889       
890        /* ÇöÀç RATIGN BLOCKÀÌ °É·ÁÀÖÀ¸¸é °É·ÁÀÖ´Â code¸¦ ±×´ë·Î »ç¿ë. */
891       
892        if (AppRating_IsBlockOn()) {
893                UniStrNCopy(str, s_RatingBlockCode, strSize);
894                str[strSize - 1] = 0;
895                return TRUE;
896        }
897
898        bRet = AppRating_GetRatingInfo(&rating);
899                /* ratingInfo´Â ¿©·¯°³ÀÇ region Á¤º¸¸¦ Æ÷ÇÔÇÑ´Ù. */
900
901        if (bRet == FALSE || rating.region_count == 0) {
902                dprint(2, "  No Rating info..\n");
903                return FALSE;
904        }
905
906        /* region 5 Á¤º¸ÀÇ rating string */
907        status = DMW_EPG_GetRatingStringByRRT(&rating, str, strSize);
908
909        if (status) {
910                dprint(2, "  cannot get region5 rating string\n");
911                /* return FALSE; */
912                /* cafrii 060724 remove!
913                         region 5 ÀÌ¿ÜÀÇ °æ¿ì ¹«½ÃÇÏ¸é ¾ÈµÊ.. ¾Æ·¡¿¡¼­ °è¼Ó ÁøÇà.. */
914        }
915
916        /* cafrii 070711 change
917                 À§¿¡¼­ ¸¸µé¾î ³õÀº Äڵ带 Ȱ¿ëÇÏÀÚ. */
918        if (1) 
919        {
920                char tmp[30];
921                if (AppRating_GetR12RatingString(&rating, tmp))
922                {
923                        if (strlen(tmp) > strSize)
924                                tmp[strSize] = 0;
925                        UniStrFromAscii(str, tmp);
926                        return TRUE;
927                }
928        }
929       
930        return FALSE;
931}       
932
933
934/******************************************************************************************
935FUNCTION:
936  - AppRating_GetRatingInfo
937
938Purpose:
939  - ÇöÀç ä³ÎÀÇ ÇöÀç ¹æ¼ÛÁßÀÎ ÇÁ·Î±×·¥ÀÇ Rating Á¤º¸¸¦ °¡Á®¿Â´Ù.
940  - called when : rating üũÇÏ´Â ¼ø°£¿¡ ÇöÀç ÇÁ·Î±×·¥ÀÇ ratingÀ» º¸¿©ÁÙ¶§ (info banner)
941******************************************************************************************/
942BOOL AppRating_GetRatingInfo(DMW_Rating5 *pRating)
943{
944        int k;
945        sttSection_t flat_stt;
946        STATUS status;
947        UINT32 stt_age;         /* how many seconds elapsed since last stt capture */
948        DST_CURCHANNEL ChannelInfo;
949
950        if (pRating == NULL)
951                return FALSE;
952
953        pRating->region_count = 0;
954
955        /******************
956        * fake rating ±â´É
957        */
958
959        App_Ucm_GetCurChInfo(&ChannelInfo);
960       
961        if (g_FakeRatingInfo.rf && g_FakeRatingInfo.rf == ChannelInfo.nRF &&
962                g_FakeRatingInfo.n_dim > 0)
963        {
964                dprint(1, "!! simulate Fake Rating information\n");
965               
966                pRating->region_count = 1;
967                pRating->region[0].region_id = g_FakeRatingInfo.region;
968                pRating->region[0].num_dimensions = g_FakeRatingInfo.n_dim;
969               
970                dprint(2, "fake: region %d, %d dims\n", g_FakeRatingInfo.region, g_FakeRatingInfo.n_dim);
971               
972                for (k=0; k<g_FakeRatingInfo.n_dim; k++) {
973                        pRating->region[0].dimension[k].index = g_FakeRatingInfo.dim[k];
974                        pRating->region[0].dimension[k].value = g_FakeRatingInfo.val[k];
975                        dprint(2, "fake:  [%d] dim idx %d, val %d\n", k, 
976                                                g_FakeRatingInfo.dim[k], g_FakeRatingInfo.val[k]);
977                }
978                goto label_success;
979                /* return TRUE; */
980        }
981
982        /******************
983        * EIT Rating Á¤º¸
984        */
985        status = Dmc_EpgGetEstimatedSttSection(ChannelInfo.nRF, &flat_stt, &stt_age);
986       
987        if (status) {
988                dprint(1, "!! GetRating err, cannot get stt time in rf %d\n", ChannelInfo.nRF);
989        }
990        else
991        {
992                if (stt_age > 3) {
993                        dprint(1, "!! warning: stt is %d seconds old\n", stt_age);
994                }
995
996                status = DMW_EPG_GetRatingInfoByRF(ChannelInfo.nRF, ChannelInfo.nSourceId, 
997                                                        flat_stt.system_time, pRating);
998                if (status)
999                        dprint(1, "!! GetRating err %d, %s\n", status, DMW_CDB_ErrString(status));
1000                else {
1001                        goto label_success;
1002                }
1003        }
1004       
1005        /******************
1006        * PMT Rating Á¤º¸
1007        */
1008        status = DMW_EPG_GetRatingInfoInPMT(pRating);
1009        if (status) {
1010                dprint(1, "!! GetRating from pmt err %d, %s\n", status, DMW_CDB_ErrString(status));
1011                return FALSE;
1012        }
1013       
1014
1015label_success:
1016
1017        if (1) {
1018                int i, k;
1019                char buf[80];
1020
1021                dprint(1, "  Rating info: %d regions\n", pRating->region_count);
1022                for (i=0; i<pRating->region_count; i++)
1023                {
1024                        buf[0] = 0;
1025                        for (k=0; k<pRating->region[i].num_dimensions; k++)
1026                        {
1027                                if (k > 5) break;       /* º¸ÅëÀº dimension °¹¼ö°¡ ¸¹Áö ¾ÊÁö¸¸, Ȥ½Ã ¸ð¸£´Ï.. */
1028                                sprintf(buf+strlen(buf), "%x:%x ",
1029                                        pRating->region[i].dimension[k].index,
1030                                        pRating->region[i].dimension[k].value);
1031                        }
1032                        dprint(1, "    [rgn %d] %d dims, %s\n", 
1033                                        pRating->region[i].region_id,
1034                                        pRating->region[i].num_dimensions, buf);
1035                }
1036        }
1037       
1038        return TRUE;
1039}
1040
1041
1042/******************************************************************************************
1043FUNCTION:
1044  - AppRating_GetRatingInfo_R5R1
1045
1046Purpose:
1047  - ÇöÀç ratingÁ¤º¸¸¦ ¾ò¾î¿Â´Ù.
1048  - region5, region1ÀÇ ¼ø¼­·Î ¾ò¾î Á¶ÇÕÇÑ´Ù.
1049Note: iskang 070820
1050******************************************************************************************/
1051BOOL AppRating_GetRatingInfo_R5R1(char *strRating)
1052{
1053        DMW_Rating5 rating;
1054        char CharTemp[64];
1055        char Null[32];
1056        BOOL HasRegion5 = FALSE, HasRegion1 = FALSE;
1057       
1058        AppRating_CheckRatingBlock(0);
1059       
1060        AppRating_GetRatingInfo(&rating);
1061        memset(Null,0,sizeof(char)*32);
1062        memset(CharTemp,0,sizeof(char)*64);
1063       
1064        /* rating Á¤º¸ Á¶ÇÕ... */
1065        if (rating.region_count > 0) 
1066        {
1067                char region_1[32], region_5[32];
1068                UINT16 tmp[32] = {0, };
1069               
1070                memset(region_1, 0, sizeof(char)*32);
1071                memset(region_5, 0, sizeof(char)*32);
1072               
1073                /* GetRatingDebugCode(&rating, region_1, region_5); */
1074               
1075                /* 1.region 5 */
1076                if (DMW_EPG_GetRatingStringByRRT(&rating, tmp, 32) == statusOK) {
1077                        char *ks = NULL;
1078                        ks = (char *)DMW_ConvUc2Ks(tmp, -1);
1079                        if (ks) {
1080                                strcpy(region_5, ks);
1081                                DMW_FreeKsString(ks);
1082                        }
1083                       
1084                        if(strcmp(region_5,Null)==0)
1085                                HasRegion5 = FALSE;
1086                        else
1087                        {
1088                                sprintf(CharTemp,region_5);
1089                                HasRegion5 = TRUE;
1090                        }       
1091                }
1092               
1093                /*2.region 1 */
1094                if (AppRating_GetR12RatingString(&rating, region_1) == FALSE)
1095                        region_1[0] = 0;       
1096                else
1097                {
1098                        if(HasRegion5)
1099                                strcat(CharTemp,", ");
1100                               
1101                        if(strcmp(region_1,Null) ==0)
1102                                HasRegion1 = FALSE;
1103                        else
1104                        {
1105                                if(strstr(CharTemp,region_1)==NULL)
1106                                strcat(CharTemp,region_1);
1107                                HasRegion1 = TRUE;
1108                        }
1109                }
1110                /*DHL_OS_Printf("\n --- GetRating info ---\n");
1111                        DHL_OS_Printf("  --> R1,2 (%s), R5 (%s)\n", region_1, region_5);
1112                        DHL_OS_Printf("  --> CharTemp (%s)\n\n", CharTemp); */
1113                strcpy(strRating,CharTemp);
1114               
1115                /* rating.region_count > 0À̳ª ratingÁ¤º¸°¡ ¾øÀ¸¸é... */
1116                if(HasRegion1 == FALSE && HasRegion5 == FALSE)
1117                        return FALSE;
1118                else
1119                        return TRUE;
1120        }
1121        return FALSE;
1122}
1123
1124
1125/******************************************************************************************
1126FUNCTION:
1127  - CheckRatingBlockProc
1128
1129Purpose:
1130  -
1131******************************************************************************************/
1132UINT16 *AppRating_DoRatingBlock()
1133{
1134        DMW_Rating5 rating;
1135       
1136        dprint(1, "[RRT] Check Rating Block\n");
1137       
1138        AppRating_GetRatingInfo(&rating);
1139
1140        /* cafrii 070801 add
1141                 debug Á¤º¸ Ç¥½Ã..
1142                 µð¹ö±ë Çϴµ¥´Â Æí¸®ÇÏÁö¸¸, ÀÌ Äڵ嶧¹®¿¡ ½Ã½ºÅÛÀÌ Áװųª ÇÏ¸é ¾ÈµÊ.
1143                 ¿©·¯ ½ºÆ®¸²À» Å×½ºÆ® ÇØ º¸ÀÚ. */
1144        if (rating.region_count > 0) {
1145                char region_1[80], region_5[80];
1146                GetRatingDebugCode(&rating, region_1, region_5);
1147                dprint(2, "  ----> R1/2 (%s), R5 (%s)\n", region_1, region_5);
1148        }
1149       
1150        /* rating check´Â missing ratingµµ Æ÷ÇÔÇϹǷΠrating info¸¦ ¾òÁö ¸øÇصµ
1151                 check´Â ÇØ¾ßÇÑ´Ù.
1152                 rating Á¤º¸°¡ ¾øÀ¸¸é region °¹¼ö°¡ 0À¸·Î Àü´ÞµÈ´Ù. */
1153        return DoRatingBlockOnOff(&rating);
1154}
1155
1156
1157/******************************************************************************************
1158FUNCTION:
1159  - AppRating_CheckRatingBlock
1160
1161Purpose:
1162  - ÇöÀç ½ÃûÁßÀΠä³ÎÀÇ Rating Á¤º¸¸¦ °¡Á®¿Í¼­ block ¿©ºÎ¸¦ üũÇϰí blockÀ» µ¿ÀÛ½ÃŲ´Ù.
1163  - µû¶ó¼­ ÀÌ ÇÔ¼ö°¡ È£ÃâÀÌ µÇ´Â °÷ :
1164   a. blocking option º¯°æ½Ã -> user remocon task or background polling task
1165   b. »õ·Î¿î RRT°¡ ¼ö½ÅµÈ °æ¿ì -> Epg event task
1166   c. Program event°¡ º¯°æµÈ °æ¿ì -> Epg event task
1167   d. ä³Î µðÄÚµùÀÌ ½ÃÀÛ µÇ°í ÀÏÁ¤ ½Ã°£ÀÌ Áö³­ ÈÄ -> maybe timer task?
1168   - »ç¿ëÀÚ°¡ PIN ÀÔ·ÂÀ» ÅëÇØ blockÀ» ÇØÁ¦Çϸé reboot Àü¿¡´Â blockÀ» °ÉÁö ¾Ê´Â´Ù.
1169******************************************************************************************/
1170void AppRating_CheckRatingBlock(UINT32 nDelayMs)
1171{
1172        if(AppRating_GetUserPinMatched() == FALSE) {
1173                DMG_SetUserDefined(UD_ID_CHK_RATING, nDelayMs, 0);
1174        }
1175}
1176
1177void AppRating_CancelCheckRatingBlock()
1178{
1179        DMG_KillTimer(TIMER_ID_CHK_RRT);
1180}
1181
1182
1183/******************************************************************************************
1184FUNCTION:
1185  - AppRating_NotifyOsdToken
1186
1187Purpose:
1188  -
1189Note: cafrii 060714 add
1190******************************************************************************************/
1191void AppRating_NotifyOsdToken(BOOL bAvail)
1192{
1193        /* ÀÌ callbackÀÌ ºÒ¸± ¶§¿¡´Â osd mgrÀÇ mute°¡ lock µÈ »óÅ¿¡¼­ ºÒ¸°´Ù. */
1194        dprint(1, "[Rating] token %s\n", bAvail ? "avail" : "removed");
1195       
1196        if (bAvail)
1197        {
1198                /* note!
1199                         draw¸¦ ÇÏ´Â °ÍÀÌ ¾Æ´Ï¶ó ´Ù½Ã Çѹø üũ¸¦ Çϵµ·Ï ÇÏÀÚ.. */
1200                AppRating_CheckRatingBlock(0);
1201        }
1202        else
1203        {
1204                /* cafrii 061010 add osd action mutex protect */
1205#if APP_PORTING
1206                if (AppGrp_StartOsdAction(APP_OSD_RBLOCK, FALSE)) {
1207                        AppRating_EraseBlockOSD();
1208                        AppGrp_EndOsdAction(APP_OSD_RBLOCK);
1209                }
1210#endif  /* #if APP_PORTING */
1211        }
1212}
1213
1214
1215/******************************************************************************************
1216FUNCTION:
1217  - AppRating_DrawBlockOSD
1218
1219Purpose:
1220  -
1221Note: ³»ºÎÀûÀ¸·Î block osd°¡ ÀÖ´ÂÁö º°µµ·Î °ü¸® ÇØ¾ß ÇÑ´Ù.
1222******************************************************************************************/
1223void AppRating_DrawBlockOSD(UINT16 *msg)
1224{
1225#if 1
1226        /* cafrii 060718 test */
1227        UINT8 *ks, dummy[2];
1228        int len;
1229
1230        if (msg == NULL) {
1231                dummy[0] = dummy[1] = 0;
1232                msg = (UINT16 *)dummy;
1233        }
1234
1235        len = UniStrLen(msg);
1236        ks = (UINT8 *)DMW_ConvUc2Ks(msg, len);
1237
1238        dprint(2, "DrawBlockOSD: [%s]\n", ks);
1239
1240        DMW_FreeKsString(ks);
1241#endif // #if 1
1242
1243        App_ForceDisableFreeze();
1244
1245        /* ½ÇÁ¦ OSDÀÇ draw ½ÃÁ¡°ú OSD flag set ½ÃÁ¡ÀÇ Â÷ÀÌ¿¡ ÀÇÇØ »ý±æ ¼ö ÀÖ´Â ¹®Á¦´Â
1246                 caller°¡ Àß Ã³¸®ÇØ¾ß ÇÑ´Ù. */
1247
1248//      App_OSD_DrawRatingBlockBanner(msg);
1249
1250        g_bRatingBlockOSD = 1;
1251}
1252
1253
1254/******************************************************************************************
1255FUNCTION:
1256  - AppRating_EraseBlockOSD
1257
1258Purpose:
1259  -
1260******************************************************************************************/
1261void AppRating_EraseBlockOSD(void)
1262{
1263        if (g_bRatingBlockOSD)
1264        {
1265                //App_OSD_EraseRatingBlockBanner();
1266               
1267                g_bRatingBlockOSD = 0;
1268        }
1269        else
1270                dprint(2, "[Rating] osd not on screen\n");
1271}
1272
1273
1274/******************************************************************************************
1275FUNCTION:
1276  - AppRating_BlockForceOff
1277
1278Purpose:
1279  - ä³Î º¯°æ µîÀÇ ÀÛ¾÷À¸·Î ÀÎÇØ¼­ blockÀ» off ½Ãų °æ¿ì »ç¿ë.
1280******************************************************************************************/
1281void AppRating_BlockForceOff(void)      /* BOOLEAN bPasswdMatch) */
1282{
1283        if (s_bRatingBlockOn) 
1284        {
1285                if (s_ratingBlockSema4)
1286                        DHL_OS_TakeSemaphore(s_ratingBlockSema4, DHL_TIMEOUT_FOREVER);
1287#if 1//APP_PORTING
1288                DCC_SetFeeding608(TRUE);        /* aux cc enable!! */
1289#endif  /* #if APP_PORTING */
1290                /* neverdai comment 081103 block off¸¦ Çϸ鼭 line21 cc insert¸¦ enableÇØ¾ß ÇÔ. */
1291                AppRating_AVBlockOnOff(FALSE);
1292#if APP_PORTING
1293                if (AppGrp_StartOsdAction(APP_OSD_RBLOCK, FALSE)) {
1294                        AppRating_EraseBlockOSD();
1295                        AppGrp_EndOsdAction(APP_OSD_RBLOCK);                   
1296                }
1297                /* ÇöÀç È­¸é¿¡´Â ¾Èº¸ÀÌ´õ¶óµµ tokenÀ» ÇØÀçÇÒ Çʿ䰡 ÀÖ´Ù. */
1298                AppGrp_ReleaseToken(APP_OSD_RBLOCK);
1299#endif  /* #if APP_PORTING */
1300
1301                if(DMG_IsMenuOn(MID_RATING)) {
1302                        DMG_MenuExit(MID_RATING);
1303                }
1304                s_bRatingBlockOn = FALSE;
1305
1306                AppRating_AVBlockOnOff(FALSE);
1307
1308                /* if(!bPasswdMatch)
1309                                s_bRatingBlockOn = FALSE; */
1310
1311                if (s_ratingBlockSema4)
1312                        DHL_OS_GiveSemaphore(s_ratingBlockSema4);
1313        }
1314}
1315
1316void AppRating_SetUserPinMatched(BOOL set_value)
1317{
1318        b_UserPINMatched = set_value;
1319}
1320
1321BOOL AppRating_GetUserPinMatched()
1322{
1323        return b_UserPINMatched;
1324}
1325
1326
1327
1328
1329
1330#if COMMENT
1331____debug____(){}
1332#endif
1333
1334/******************************************************************************************
1335FUNCTION:
1336  - rating_pswdmatch
1337
1338Purpose:
1339  -
1340******************************************************************************************/
1341static void rating_pswdmatch(BOOL bMatched)
1342{
1343        /* ÇöÀç password match »óŸ¦ fake..
1344                 VChip ¸Þ´º¿¡ Çѹø µé¾î°¬´Ù ³ª¿À¸é rating Å×½ºÆ®°¡ ºÒ°¡´É ÇϹǷÎ.. */
1345        dprint(2, "now, active as if password %s\n", bMatched ? "matched" : "unmatched");
1346       
1347        g_bRatingPasswordMatched = bMatched;
1348}
1349
1350
1351/******************************************************************************************
1352FUNCTION:
1353  - rating_show
1354
1355Purpose:
1356  -
1357******************************************************************************************/
1358static void rating_show(void)
1359{
1360        DMW_Rating5 rating;
1361
1362        AppRating_GetRatingInfo(&rating);
1363
1364        /* debug Á¤º¸ Ç¥½Ã.. */
1365        if (rating.region_count > 0) {
1366                char region_1[80], region_5[80];
1367                GetRatingDebugCode(&rating, region_1, region_5);
1368                dprint(2, "  ----> R1,2 (%s), R5 (%s)\n", region_1, region_5);
1369        }
1370        else
1371                dprint(2, "  no rating info\n");
1372}
1373
1374
1375/******************************************************************************************
1376FUNCTION:
1377  - rating_help
1378
1379Purpose:
1380  -
1381******************************************************************************************/
1382static void rating_help(void)
1383{
1384        DHL_OS_Printf("\trating_enable [1:enable] [1:save]: enable/disable rating lock\n");
1385        DHL_OS_Printf("\trating_fake [rf] [region] [dim:val] [dim:val].. : simulate rating\n");
1386        DHL_OS_Printf("\trating_check [delay_ms]: triggeer rating check\n");
1387        DHL_OS_Printf("\trating_avmute [1:mute]: mute audio/video for block\n");
1388        DHL_OS_Printf("\trating_show: show current program's rating info\n");
1389}
1390
1391
1392
1393
1394
1395#if COMMENT
1396____Init____(){}
1397#endif
1398
1399/******************************************************************************************
1400FUNCTION:
1401  - AppRating_InitBlock
1402
1403Purpose:
1404  -
1405******************************************************************************************/
1406void AppRating_InitBlock()
1407{
1408        App_NVM_LoadModuleParam(eAPP_NVR_RATING, &p_rating_nvm_param);
1409       
1410        s_bRatingBlockOn = FALSE;
1411
1412        if(!s_ratingBlockSema4) {
1413                s_ratingBlockSema4 = DHL_OS_CreateMutexSemaphore("Rating Block Sema4");
1414        }
1415       
1416        /* App_EraseBlockOSD(); */
1417        AppRating_AVBlockOnOff(FALSE);
1418        AppRating_SetUserPinMatched(FALSE);
1419       
1420        DHL_DBG_RegisterFunctionSymbol("rating_enable", (void *)AppRating_SetMasterBlock);
1421        DHL_DBG_RegisterFunctionSymbol("rating_fake", (void *)SetFakeRrtData);
1422        DHL_DBG_RegisterFunctionSymbol("rating_check", (void *)AppRating_CheckRatingBlock);
1423        DHL_DBG_RegisterFunctionSymbol("rating_avmute", (void *)AppRating_AVBlockOnOff);
1424        DHL_DBG_RegisterFunctionSymbol("rating_show", (void *)rating_show);
1425        DHL_DBG_RegisterFunctionSymbol("rating_pswdmatch", (void *)rating_pswdmatch);
1426        DHL_DBG_RegisterFunctionSymbol("rating_help", (void *)rating_help);
1427       
1428        DHL_DBG_RegisterVarSymbol(DHL_VAR_SYM_ARGS(g_bUseRatingRegion4AsRegion1));
1429}
1430
1431
1432
1433
1434
1435#if COMMENT
1436__Get_Default_Param__(){}
1437#endif
1438
1439
1440static void p_format_rating_param()
1441{
1442        p_rating_nvm_param.VChipLock=FALSE;
1443        p_rating_nvm_param.passwd[0]=0;
1444        p_rating_nvm_param.passwd[1]=0;
1445        p_rating_nvm_param.passwd[2]=0;
1446        p_rating_nvm_param.passwd[3]=0;
1447        p_rating_nvm_param.rating_usea[0]=0;
1448        p_rating_nvm_param.rating_usea[1]=0;
1449        p_rating_nvm_param.rating_children=0;
1450        p_rating_nvm_param.rating_mpaa=0;
1451        p_rating_nvm_param.rating_canada_eng=0;
1452        p_rating_nvm_param.rating_canada_fre=0;
1453        p_rating_nvm_param.rating_age_limit=0;
1454       
1455        App_NVM_SaveModuleParam(eAPP_NVR_RATING, &p_rating_nvm_param);
1456}
1457
1458
1459void App_RatingParamInit(void)
1460{
1461        App_NVM_RegisterModule(eAPP_NVR_RATING, sizeof(p_rating_nvm_param), p_format_rating_param);
1462}
1463
1464
1465
1466#endif /* SUPPORT_RATING */
1467
1468
1469/* end of file */
Note: See TracBrowser for help on using the repository browser.