📄 o_tvguardian.c
字号:
/* **************************************************************************************
* Copyright (c) 2005 ZORAN Corporation, All Rights Reserved
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
* File: $Workfile: o_tvguardian.c$
*
* Description:
* ========
* Project definition of the following:
* 1. MSO_TVGUARDIAN_ADVERTISEMENT
* 2. MSO_TVGUARDIAN_ACTIVATION
* 3. MSO_TVGUARDIAN_SETUP
*
****************************************************************************************/
#include "Config.h" // Global Configuration - do not remove!
#ifdef TV_GUARDIAN_ENABLE
#ifdef DEBUG_UI_TRACE
#undef IFTRACE
#define IFTRACE if (gTraceUI)
#include "Debug\DbgMain.h"
#endif //DEBUG_UI_TRACE
#include "include\sysdefs.h"
/***************************************************************************************
* Include files
****************************************************************************************/
#include <stdio.h>
#include <string.h>
#include "Kernel\eventdef.h"
#include "include\math-macro.h"
#include "Playcore\Ps\Ps.h"
#include "CoreAPI\CoreAPI.h"
#include "Library\String_generate.h"
#include "Library\Number.h"
#include "Strings\Strings.h"
#include "Library\Container_misc.h"
#include "Font\fonts.h"
#include "Library\Unicode.h"
#include "GUI\Menu_system\ms_screen.h"
#include "GUI\Menu_system\ms_menu.h"
#include "GUI\Menu_system\ms_component.h"
#include "GUI\Menu_system\ms_container.h"
#include "GUI\Menu_system\ms_display.h"
#include "GUI\Object_class\Text\mso_text.h"
#include "GUI\Object_class\Multiline\mso_multiline_text.h"
#include "GUI\Object_class\Button\mso_button.h"
#include "GUI\Object_class\Vlist\mso_vlist.h"
#include "GUI\Object_class\Choice\mso_choice.h"
#include "GUI\Object_class\Edit\mso_edit.h"
#include "Components\Message\o_message_handler.h"
#include "GUI\Resource\Bitmap\bitmap.h"
#include "Menu\menu_operation_def.h"
#include "Menu_config\menu_config_common.h"
#include "Components\TV_guardian\o_tvguardian.h"
#include "Components\TV_guardian\o_tvguardian_config.h"
#include "Components\Custom\TV_guardian\o_tvguardian_custom.h"
#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif
/***************************************************************************************
* TV Guardian Setup component related named constants.
****************************************************************************************/
/***************************************************************************************
* TV Guardian Advertisement component related named constants.
****************************************************************************************/
/***************************************************************************************
* Private data structures.
****************************************************************************************/
/***************************************************************************************
* Utility functions
****************************************************************************************/
static void _EnableTVGOption(MSO_OBJECT __NEAR* pThis);
static void _GetFormUniStr_TVGRegistrationKey(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam);
/***************************************************************************************
* Operation functions
****************************************************************************************/
/***************************************************************************************
* Operation functions of TV Guardian Component.
****************************************************************************************/
static MS_OP _TVGuardianComponentOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MSO_OBJECT __NEAR* _OTVGUARDIAN_OpenAdvertisement(MSO_CONTAINER __NEAR* pParent);
static MSO_OBJECT __NEAR* _OTVGUARDIAN_OpenActivation(MSO_CONTAINER __NEAR* pParent);
static MSO_OBJECT __NEAR* _OTVGUARDIAN_OpenSetup(MSO_CONTAINER __NEAR* pParent);
static MSO_OBJECT __NEAR* _OTVGUARDIAN_OpenSetupHelp(MSO_CONTAINER __NEAR* pParent);
/***************************************************************************************
* Operation functions of TV Guardian Setup Component.
****************************************************************************************/
static MS_OP _TVGuardianSetupOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _TVGuardianChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _RestChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
/***************************************************************************************
* Operation functions of TV Guardian Activation Component.
****************************************************************************************/
static MS_OP _TVGuardianActivationOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _ActivationCodeEditOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _InvalidCodeTextOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
/***************************************************************************************
* Operation functions of TV Guardian Advertisement Component.
****************************************************************************************/
static MS_OP _TVGuardianAdvertisementOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _TVGuardianMultiLineTextOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
/***************************************************************************************
* Operation functions of TV Guardian Setup Help Component.
****************************************************************************************/
static MS_OP _TVGuardianSetupHelpOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
/***************************************************************************************
* Display functions
****************************************************************************************/
/***************************************************************************************
* Display functions of TV Guardian Setup Component
****************************************************************************************/
static BOOL _TVGuardianComponentFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);
/***************************************************************************************
* Display functions of TV Guardian Activation Component
****************************************************************************************/
static BOOL _ActivationCodeEditFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);
/***************************************************************************************
* Display functions of TV Guardian Advertisement Component
****************************************************************************************/
/***************************************************************************************
* Choice item action functions
****************************************************************************************/
STATIC void _TVGuardianChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
STATIC void _HellDamnOnOffChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
STATIC void _ReligiousOnOffChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
STATIC void _SexualOnOffChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
STATIC void _CCModeChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
STATIC void _CCChannelChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
#include "Components\Custom\TV_guardian\o_tvguardian_custom.c"
#include "Components\TV_guardian\o_tvguardian_config.c"
/***************************************************************************************
* Utility functions
****************************************************************************************/
static void _EnableTVGOption(MSO_OBJECT __NEAR* pThis)
{
if(TVG_MODE_OFF == CoreAPI_GetTVGModeValue())
{
if(MS_IsFocusable(pThis))
{
MS_ClearFocusable(pThis);
MS_DisplayAddObject(pThis);
}
}
else
{
if(!MS_IsFocusable(pThis))
{
MS_SetFocusable(pThis);
MS_DisplayAddObject(pThis);
}
}
}
#pragma argsused
static void _GetFormUniStr_TVGRegistrationKey(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam)
{
#define NUM_REGISTRATION_KEY 21
#define NUM_UNICODE_SPACES 6
#define _8BIT_CHARS 1
UINT8 cBuffOffset = 0;
UINT8 szStr[NUM_REGISTRATION_KEY+1];
cBuffOffset = STR_GenerateOSDMESSAGEString(S_REGISTRATION_KEY, pFormUniStr->mszUniStr, cBuffOffset, UNISTR_LENGTH_MAX);
cBuffOffset = STR_GenerateRepeatChars(UNICODE_SPACE, NUM_UNICODE_SPACES, pFormUniStr->mszUniStr, cBuffOffset, UNISTR_LENGTH_MAX);
CoreAPI_GetTVGRegistrationKey(szStr);
ConvertToUnicode( (UINT16*)szStr, (UINT16*)(&pFormUniStr->mszUniStr[cBuffOffset]),(UNISTR_LENGTH_MAX - cBuffOffset), NULL, _8BIT_CHARS);
// Reformat the unicode string.
OSDR_FormatUniString(pFormUniStr);
}
/***************************************************************************************
* Operation functions
****************************************************************************************/
static MS_OP _TVGuardianComponentOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
MsOp = MS_ComponentBasicOperation(pThis, MsOp, lParam);
// Post-processing
// All user operations in post-processing!!!
switch(MsOp)
{
case MS_OP_MENU_TVG_ADVERTISEMENT:
{
DWORD counter=CoreAPI_GetTVGRemindCounter();
counter--;
if(counter>=0)
CoreAPI_UpdatePlayerSetting(PS_UPDATE_TVG_REMINDCOUNTER, (UINT16) counter);
_OTVGUARDIAN_OpenAdvertisement((MSO_CONTAINER __NEAR*)pThis);
return MS_OP_NONE;
}
case MS_OP_MENU_TVG_ACTIVATIVATE:
_OTVGUARDIAN_OpenActivation((MSO_CONTAINER __NEAR*)pThis);
return MS_OP_NONE;
case MS_OP_MENU_TVG_SETUP:
if(FALSE == MS_IsEmpty((MSO_CONTAINER __NEAR*)pThis))
{
MS_SendOperation(pThis, MS_OP_EMPTY, 0);
MS_DisplayAddObject(pThis);
}
_OTVGUARDIAN_OpenSetup((MSO_CONTAINER __NEAR*)pThis);
return MS_OP_NONE;
case MS_OP_MENU_TVG_SETUP_HELP:
_OTVGUARDIAN_OpenSetupHelp((MSO_CONTAINER __NEAR*)pThis);
return MS_OP_NONE;
default:
break;
}
return MsOp;
}
/***************************************************************************************
* Operation functions of TV Guardian Setup Component.
****************************************************************************************/
/***************************************************************************************
* Function : _TVGuardianSetupOperation
*
* In :
*
* Out :
*
* Desc : MSO_TVGUARDIAN_SETUP user operation function.
****************************************************************************************/
#pragma argsused
static MS_OP _TVGuardianSetupOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
// Pre-processing
switch(MsOp)
{
case MS_OP_OPEN:
{
MSO_OBJECT __NEAR* pButton= MS_CreateAndAddObject((MS_DESCRIPTOR *)&oBackButtonDescriptor,
(MSO_CONTAINER __NEAR *) pThis);
MS_ObjectMove(pButton, (UINT16) AREA_BACK_BUTTON_IN_SETUP_X, (UINT16) AREA_BACK_BUTTON_IN_SETUP_Y);
}
break;
case MS_OP_INIT:
{
MS_ComponentInitFocus((MSO_COMPONENT __NEAR*)pThis);
}
break;
default:
break;
}
return MS_ComponentBasicOperation(pThis, MsOp, lParam);
}
/***************************************************************************************
* Function : _TVGuardianChoiceOperation
*
* In :
*
* Out :
*
* Desc : The TV Guardian choice operation function.
****************************************************************************************/
static MS_OP _TVGuardianChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
MS_OP MsOpInput=MsOp;
MsOp=ChoiceNoExpandingOperation(pThis, MsOp, lParam);
switch(MsOpInput)
{
case MS_OP_ENTER:
MS_SEND_OP_OBJECT((MSO_OBJECT __NEAR*)MS_GetParentPtr(pThis), MS_OP_REFRESH,NULL);
break;
default:
break;
}
return MsOp;
}
static MS_OP _RestChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
MsOp=ChoiceNoExpandingOperation(pThis, MsOp, lParam);
switch(MsOp)
{
case MS_OP_INIT:
case MS_OP_REFRESH:
{
_EnableTVGOption(pThis);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -