TInt32 IfLogicServiceRespStub::RespGetSession(TUInt64 _uId,CDoid _tGwDoid)
{
    TInt32 nLen = GetLength(_uId)+GetLength(_tGwDoid);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(RESPGETSESSION_TUINT64_CDOID_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_uId);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_tGwDoid);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfUserSessionStub::ReqGetActiveWorkInfo(TInt32 _nJobId,TUInt32 _uRcdId)
{
    TInt32 nLen = GetLength(_nJobId)+GetLength(_uRcdId);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(REQGETACTIVEWORKINFO_TINT32_TUINT32_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_nJobId);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_uRcdId);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfUserSessionStub::ChangePwd(TChar* _pOldPwd,TChar* _pszNewPwd)
{
    TInt32 nLen = GetLength(_pOldPwd)+GetLength(_pszNewPwd);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(CHANGEPWD_TCHAR_PT_TCHAR_PT_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_pOldPwd);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_pszNewPwd);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfUserSessionStub::ReqGetMyWorkList(TUInt32 _uFromTime,TUInt32 _uToTime)
{
    TInt32 nLen = GetLength(_uFromTime)+GetLength(_uToTime);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(REQGETMYWORKLIST_TUINT32_TUINT32_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_uFromTime);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_uToTime);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfConnectingRespStub::RespRegisterService(CDoid* _pDoid,TUInt32 _uServiceId,TInt32 _nRslt)
{
    TInt32 nLen = GetLength(_pDoid)+GetLength(_uServiceId)+GetLength(_nRslt);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(RESPREGISTERSERVICE_CDOID_PT_TUINT32_TINT32_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_pDoid);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_uServiceId);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_nRslt);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfConnectingRespStub::SendRSAPublicKey(TUInt16 _uBits,TUInt16 _isFermat4,OctSeq<TUInt16> _e,OctSeq<TUInt16> _n,TUInt32 _uDyncNr)
{
    TInt32 nLen = GetLength(_uBits)+GetLength(_isFermat4)+GetLength(_e)+GetLength(_n)+GetLength(_uDyncNr);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(SENDRSAPUBLICKEY_TUINT16_TUINT16_OCTSEQ_TPL_BEGIN_TUINT16_TPL_END__OCTSEQ_TPL_BEGIN_TUINT16_TPL_END__TUINT32_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_uBits);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_isFermat4);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_e);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_n);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    nRet = Marshall(pBuffer+nUsed,nLen,_uDyncNr);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfUserSessionStub::ReqGetMenuInfoById(TUInt32 _uMenuId)
{
    TInt32 nLen = GetLength(_uMenuId);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(REQGETMENUINFOBYID_TUINT32_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_uMenuId);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfUserSessionStub::ReqUpdateMenuInfo(TJobInfos& _rJobInfos)
{
    TInt32 nLen = GetLength(_rJobInfos);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(REQUPDATEMENUINFO_TJOBINFOS_REF_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_rJobInfos);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfConnectingRespStub::OnDisconnect(TUInt32 _uReason)
{
    TInt32 nLen = GetLength(_uReason);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(ONDISCONNECT_TUINT32_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_uReason);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
TInt32 IfConnectingRespStub::ConfirmUnregisterService(TUInt32 _uServiceId)
{
    TInt32 nLen = GetLength(_uServiceId);
    CMessageHeader *pMsg = m_pOnwerObj->PrepareMsg(nLen,(CONFIRMUNREGISTERSERVICE_TUINT32_ID),&m_tTarget,1,false);
    if (NULL == pMsg)
    {
        return OUT_OF_MEM;
    }
    TUInt32 nUsed=0;
    TInt32 nRet=0;
    TUChar *pBuffer = pMsg->GetBody();
    nRet = Marshall(pBuffer+nUsed,nLen,_uServiceId);
    if (nRet < SUCCESS)
    {
        return nRet;
    }
    nUsed += nRet;
    nLen-=nRet;
    pMsg->ResetBodyLength(nUsed);
    return m_pOnwerObj->SendMsg(pMsg);
}
STDMETHODIMP CAvatarProfileObject::WriteToDisk(BSTR bstrFilename)
{
	IMarshallBuffer *pbuffer = NULL;

	HRESULT hr = CoCreateInstance(CLSID_MarshallBuffer, NULL, CLSCTX_INPROC_SERVER,
		IID_IMarshallBuffer, (LPVOID*)&pbuffer);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;
	
	hr = Marshall(MARSHALL_BYGUID | MARSHALL_BYVALUE | MARSHALL_TODISK, pbuffer);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

	hr = pbuffer->WriteToDisk(bstrFilename);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

ERROR_ENCOUNTERED:
	SAFERELEASE(pbuffer);

	return hr;
}