📄 push.c
字号:
#ifdef WAE_DEBUG
URL_DEBUG_PRINT("Start Push_Get_PushListStruct");
#endif
if( pvListElement != NULL )
{
pvElementContent = SDL_GetListElementContent( pvListElement );
if( pvElementContent != NULL )
{
pPushListStruct = (PUSHLISTSTRUCT*)pvElementContent;
return (void*)pPushListStruct;
}
}
return NULL;
} /* end of ME_Push_Get_PushListStruct */
/*========================================================================
ME_Push_BuildContent
==========================================================================
Purpose: Call parsing functions and build content for an SI or an SL.
Params: void* pPushBody, UINT iBodyDataLen, iType
Return: pPushContentStruct
=========================================================================*/
void* ME_Push_BuildContent(void* pBodyData, UINT32 iBodyDataLen, void* vsHeaderDef,
UINT8 iPortType, UINT8 iViewID, UINT8 iNewChannelId)
{
PUSHCONTENTSTRUCT* pPushContent = NULL;
SLCONTENTSTRUCT* pSLContent = NULL;
SICONTENTSTRUCT* pSIContent = NULL;
BYTE* pSLTemp = NULL;
BYTE* pSITemp = NULL;
pELEMENTTYPE pElem,pSi,pSl = NULL;
BYTE* pbBody = NULL;
BYTE* pbEnd = NULL;
pHEADERDEF pHeaderDef = NULL;
UINT8 iType;
BOOL fError = FALSE;
pHEADERELEMENT pElement = NULL;
WSPPARAMETERS* pParameters = NULL;
pDECSTR pStruct = NULL;
INT16 iCharset = 0;
UINT8 iLevel = 0;
#ifdef WAE_DEBUG
URL_DEBUG_PRINT("ME_Push_BuildContent");
#endif
pHeaderDef=(pHEADERDEF)vsHeaderDef;
pbBody=(BYTE*)pBodyData;
pbEnd=pbBody+iBodyDataLen;
pElement=WSP_GetHeaderWK(1,Field_Content_Type,pHeaderDef->pHeadList);
iType=(UINT8)WSP_GetContentTypeByte(pElement,&fError,&pParameters);
if (fError)
{
return NULL;
}
if (pParameters != NULL)
{
iCharset = pParameters->iCharset;
iLevel = pParameters->iLevel;
WSP_DeleteParameters(&pParameters);
}
switch(iType)
{
case 46:
iType = SI;
break;
case 48:
iType = SL;
break;
default:
return NULL;
}
pPushContent = NEWSTRUCT(PUSHCONTENTSTRUCT);
if (pPushContent==NULL)
{
return NULL;
}
switch (iType)
{
case SI:
/* Parse the SI */
pStruct=Si_BuildStructure (pbBody,pbEnd,iCharset,iLevel,iViewID);
if (pStruct != NULL)
{
pSi=Si_GetSi (pStruct);
pElem=Si_GetIndication(pSi);
if (pElem != NULL)
{
pSIContent = NEWSTRUCT(SICONTENTSTRUCT);
if (pSIContent==NULL)
{
return NULL;
}
pPushContent->iType = SI;
pPushContent->iId = 0;
pPushContent->iPortType = iPortType;
pPushContent->iNewChannelId = iNewChannelId;
pSIContent->iStatus = PUSH_NEW;
pSIContent->pbUrl=Si_GetHref(pElem);
pSIContent->pwchMessage=Si_GetIndicationText(pStruct,pElem);
pSIContent->pwchSIid=Si_GetSiId(pElem);
pSIContent->iAction=Si_GetAction(pElem);
pSITemp = (BYTE*)ME_Push_GetXInitiatorURI(vsHeaderDef);
if (pSITemp != NULL)
pSIContent->pbInitUri = B_CopyByteString (pSITemp, -1);
else
pSIContent->pbInitUri = NULL;
if (pSIContent->pwchSIid == NULL)
{
if (pSIContent->iAction == SI_DELETE)
{
return NULL;
}
if (pSIContent->pbUrl != NULL)
{
pSIContent->pwchSIid = wip_byte2wchar(pSIContent->pbUrl);
}
}
pSIContent->iCreated=Si_GetCreated(pElem);
pSIContent->iExpires=Si_GetExpires(pElem);
pPushContent->content.pSIContentStruct=pSIContent;
Si_DeleteStructure (&pStruct);
return (void*)pPushContent;
}
}
break;
case SL:
/* Parse the SL */
pStruct=Sl_BuildStructure(pbBody,pbEnd,iCharset,iLevel,iViewID);
if (pStruct != NULL)
{
pSLContent = NEWSTRUCT(SLCONTENTSTRUCT);
if (pSLContent==NULL)
{
return NULL;
}
pSl=Sl_GetSl(pStruct);
pSLContent->pbUrl=Sl_GetHref(pSl);
if (pSLContent->pbUrl != NULL)
{
pPushContent->iType = SL;
pPushContent->iId = 0;
pPushContent->iPortType = iPortType;
pPushContent->iNewChannelId = iNewChannelId;
pSLContent->iStatus = PUSH_NEW;
pSLContent->iAction=Sl_GetAction(pSl);
pSLTemp = (BYTE*)ME_Push_GetXInitiatorURI(vsHeaderDef);
if (pSLTemp != NULL)
pSLContent->pbInitUri = B_CopyByteString (pSLTemp, -1);
else
pSLContent->pbInitUri = NULL;
pPushContent->content.pSLContentStruct = pSLContent;
Sl_DeleteStructure (&pStruct);
return (void*)pPushContent;
}
}
break;
}
DEALLOC(&pPushContent);
return NULL;
} /* end of ME_Push_BuildContent */
/*========================================================================
ME_Push_GetNextPPListElem
==========================================================================
Purpose: Gets next postponed (PP) Push in Push list. If pvPushListStruct
equals NULL, the first PP push in list is retrieved. If NULL is
returned, no more PP pushes exist in list.
Params: pvPushList, pvPushListStruct
Return: pPushListStruct or NULL
=========================================================================*/
void* ME_Push_GetNextPPListElem( void* pvPushList, void* pvPushListStruct, UINT8 iType )
{
PUSHLISTSTRUCT* pPushListStruct=NULL;
void* pvListElement = NULL;
void* pvElementContent = NULL;
#ifdef WAE_DEBUG
URL_DEBUG_PRINT("Start Push_GetNextPPListElem");
#endif
pvPushListStruct = (PUSHLISTSTRUCT*)pvPushListStruct;
if( pvPushList != NULL )
{
pvListElement = SDL_GetNextListElement( pvPushList, NULL );
while ( pvListElement != NULL )
{
pvElementContent = SDL_GetListElementContent( pvListElement );
if( pvElementContent != NULL )
{
pPushListStruct = (PUSHLISTSTRUCT*)pvElementContent;
if ( pvPushListStruct == NULL ) /* NULL case */
{
while ( pvListElement != NULL )
{
pvElementContent = SDL_GetListElementContent( pvListElement );
if( pvElementContent != NULL )
{
pPushListStruct = (PUSHLISTSTRUCT*)pvElementContent;
if (pPushListStruct->iPushType == iType)
if ( (pPushListStruct->iStatus == PUSH_POSTPONED) || (pPushListStruct->iStatus == PUSH_POSTPONED_READ))
return (void*)pPushListStruct;
}
pvListElement = SDL_GetNextListElement( pvPushList, pvListElement );
}
}
if ( pPushListStruct == pvPushListStruct) /* found the start element */
{
pvListElement = SDL_GetNextListElement( pvPushList, pvListElement );
while ( pvListElement != NULL )
{
pvElementContent = SDL_GetListElementContent( pvListElement );
if( pvElementContent != NULL )
{
pPushListStruct = (PUSHLISTSTRUCT*)pvElementContent;
if (pPushListStruct->iPushType == iType)
if ( (pPushListStruct->iStatus == PUSH_POSTPONED) || (pPushListStruct->iStatus == PUSH_POSTPONED_READ))
return (void*)pPushListStruct;
}
pvListElement = SDL_GetNextListElement( pvPushList, pvListElement );
}
}
}
if ( pvListElement!=NULL)
{
pvListElement = SDL_GetNextListElement( pvPushList, pvListElement );
}
}
}
return NULL;
} /* end of ME_Push_GetNextPPListElem */
/*========================================================================
ME_Push_Create_Elem
==========================================================================
Purpose: Creates a pPushListStruct element from a pPushContentStruct.
Params: pvPushContentStruct
Return: pPushListStruct
=========================================================================*/
void* ME_Push_Create_Elem( void* pvPushContentStruct )
{
PUSHLISTSTRUCT* pPushListStruct=NULL;
PUSHCONTENTSTRUCT* pPushContentStruct=NULL;
UINT16 iLen = 0;
#ifdef WAE_DEBUG
URL_DEBUG_PRINT("Start Push_GetNextPPListElem");
#endif
if( pvPushContentStruct != NULL )
{
pPushListStruct=NEWSTRUCT(PUSHLISTSTRUCT);
if (pPushListStruct==NULL)
{
return NULL;
}
pPushContentStruct = (PUSHCONTENTSTRUCT*)pvPushContentStruct;
pPushListStruct->iPushType = pPushContentStruct->iType;
pPushListStruct->iLLPushId = pPushContentStruct->iId;
pPushListStruct->iPortType = pPushContentStruct->iPortType;
if (pPushContentStruct->iType == SI)
{
pPushListStruct->iAction = pPushContentStruct->content.pSIContentStruct->iAction;
pPushListStruct->iCreated = pPushContentStruct->content.pSIContentStruct->iCreated;
pPushListStruct->iExpires = pPushContentStruct->content.pSIContentStruct->iExpires;
pPushListStruct->iStatus = pPushContentStruct->content.pSIContentStruct->iStatus;
if (pPushContentStruct->content.pSIContentStruct->pwchSIid != NULL)
{
iLen=STRINGLENGTH(pPushContentStruct->content.pSIContentStruct->pwchSIid);
pPushListStruct->pwchPushId = NEWARRAY(WCHAR,iLen+1);
if (pPushListStruct->pwchPushId==NULL)
{
return NULL;
}
COPYSTRINGN(pPushListStruct->pwchPushId,pPushContentStruct->content.pSIContentStruct->pwchSIid,iLen);
/* Set termination char */
pPushListStruct->pwchPushId[iLen]=0;
}
else
pPushListStruct->pwchPushId = NULL;
}
else /* type is Service Loading */
{
pPushListStruct->iAction = pPushContentStruct->content.pSLContentStruct->iAction;
pPushListStruct->iStatus = pPushContentStruct->content.pSLContentStruct->iStatus;
pPushListStruct->pwchPushId = wip_byte2wchar(pPushContentStruct->content.pSLContentStruct->pbUrl);
pPushListStruct->iExpires = 0;
pPushListStruct->iCreated = 0;
}
return (void*)pPushListStruct;
}
return NULL;
} /* end of ME_Push_Create_Elem */
/*========================================================================
ME_Push_Remove_List
==========================================================================
Purpose: Removes the entire Push List and deallocates struct data
Params: pvPushList
Return: -
=========================================================================*/
void ME_Push_Remove_List( void* pvPushList )
{
PUSHLISTSTRUCT* pPushListStruct = NULL;
void* pvListElement = NULL;
void* pvElementContent = NULL;
#ifdef WAE_DEBUG
URL_DEBUG_PRINT("Start Push_Remove_List");
#endif
if( pvPushList != NULL )
{
pvListElement = SDL_GetNextListElement( pvPushList, NULL );
while ( pvListElement != NULL )
{
pvElementContent = SDL_GetListElementContent( pvListElement );
if( pvElementContent != NULL )
{
pPushListStruct = (PUSHLISTSTRUCT*)pvElementContent;
SDL_DeleteListElement (pvPushList, pvListElement);
DEALLOC (&(pPushListStruct->pwchPushId));
DEALLOC (&pPushListStruct);
}
pvListElement = SDL_GetNextListElement(pvPushList,NULL );
}
SDL_DeleteList(&pvPushList);
}
} /* end of ME_Push_Remove_List */
/*========================================================================
ME_Push_ParseHeader
==========================================================================
Purpose: Parse the Push Header. Returns a pHEADERDEF
Params: pvPushHeader, iHeaderLength
Return: pHEADERDEF
=========================================================================*/
void* ME_Push_ParseHeader( void* vsPushHeader, UINT32 iLen )
{
pHEADERDEF pHeaderDef = NULL;
BYTE* pbPushHeader = (BYTE*)vsPushHeader;
BOOL fError = FALSE;
/* Preparse header */
pHeaderDef=WSP_PreParseHeaders(pbPushHeader,iLen,&fError);
if ((fError)||(pHeaderDef==NULL))
{
/* Error in pre-parse - remove all data and return NULL */
WSP_EmptyHeaderList(pHeaderDef);
pHeaderDef=NULL;
return NULL;
}
return (void*)pHeaderDef;
} /* end ME_Push_ParseHeader */
/*========================================================================
ME_Push_GetPushFlag
==========================================================================
Purpose: Retrieves the Push Flag from the Push Header.
Params: vsHeaderDef
Return: UINT8
=========================================================================*/
UINT8 ME_Push_GetPushFlag( void* vsHeaderDef )
{
pHEADERDEF pHeaderDef = NULL;
pHEADERELEMENT pElement = NULL;
if (vsHeaderDef!=NULL)
{
pHeaderDef = (pHEADERDEF)vsHeaderDef;
pElement=WSP_GetHeaderWK(1,Field_Push_Flag,pHeaderDef->pHeadList);
return WSP_GetPushFlag(pElement);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -