示例#1
0
AIM_RESULT	OnRspGetMemo(AMVoid *pvArg, AIM_RSP_GET_MEMO *pRspGetMemo)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage	*pMsg = AMNULL;
    AMChar		*pBuf = AMNULL;
    AMInt32		iLen = 0;

    AMAssert(AMNULL != pIM && AMNULL != pRspGetMemo);

    DPRINT("IASessionModel_OnGetCntMemo.........................Entering!\n");

    pMsg = IAIMessage_Create();
    if(pRspGetMemo->szContactId)
        IAIMessage_SetCntID(pMsg, pRspGetMemo->szContactId, AMStrlen(pRspGetMemo->szContactId));

    if(0 == pRspGetMemo->iRetCode)//成功
    {
        pMsg->eType = (AIM_MSG_TYPE)GET_CNTMEMO_OK;
        IAIMessage_SetContent(pMsg, pRspGetMemo->szMemo, AMStrlen(pRspGetMemo->szMemo));
    }
    else//失败
    {
        pMsg->eType = (AIM_MSG_TYPE)GET_CNTMEMO_FAIL;
    }

    DPRINT("IASessionModel_OnGetCntMemo.......................%s\n", pMsg->szContent);

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    DPRINT("IASessionModel_OnGetCntMemo.........................OK!\n");

    return eAIM_RESULT_OK;
}
示例#2
0
AMChar	*	BuildSigXMLFromStruct(AIM_SIGNATURE *pSigStruct, const AMChar *szSig)//只是把5个sig造好,没有追加后面的loop/st/ci等设置
{
	AMChar	*	szResultXML = AMNULL;
	AMInt32		iLen = 0, iPos = 0, i=0;
	AMAssert(pSigStruct);
	iLen = sizeof(XML_SIG_TEMPHEAD) + sizeof(XML_SIG_TEMPTAIL) + 3*MAX_INT_NUMBER_LEN;

	iLen += szSig?AMStrlen(szSig):0 + 11;

	for(i=0; i< MAX_SIG_COUNT-1; i++)
		iLen += pSigStruct->szSignature[i]?AMStrlen(pSigStruct->szSignature[i]):0 + 11;//11 for "<Sig></Sig>"

	szResultXML = (AMChar*)AMMalloc(iLen);
	if(!szResultXML)
		return AMNULL;

	AMMemset(szResultXML, 0, iLen);

	AMMemcpy(szResultXML, HeadTag(XML_TAG_SIGOP), sizeof(HeadTag(XML_TAG_SIGOP))-1);

	AMStrcat(szResultXML, HeadTag(XML_TAG_SIG));
	if(szSig)
		AMStrcat(szResultXML, szSig);
	AMStrcat(szResultXML, TailTag(XML_TAG_SIG));
	
	for(i=0; i< MAX_SIG_COUNT-1; i++)
	{
		AMStrcat(szResultXML, HeadTag(XML_TAG_SIG));
		AMStrcat(szResultXML, pSigStruct->szSignature[i]);
		AMStrcat(szResultXML, TailTag(XML_TAG_SIG));
	}

	return szResultXML;
}
示例#3
0
AIM_RESULT	OnRspGetProfile(AMVoid *pvArg, AIM_RSP_GET_PROFILE *pRspGetProfile)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage	*pMsg = 0;
    AMInt32 iContentLen = 0, i = 0, iPos = 0, iLen = 0;;
    pMsg = IAIMessage_Create();
    pMsg->bUnread = AMTRUE;
    pMsg->eType = (AIM_MSG_TYPE)GET_PEER_UDB_PROFILE;
    IAIMessage_SetCntID(pMsg, pRspGetProfile->szContactId, AMStrlen(pRspGetProfile->szContactId));

    iContentLen = pRspGetProfile->iTotalLen + 4 + AMStrlen(pRspGetProfile->szContactId) + sizeof(UID_KEYWROD_ID);
    iContentLen +=  pRspGetProfile->iCount*2;

    pMsg->szContent = (AMChar *)AMMalloc(iContentLen);
    if(AMNULL == pMsg->szContent)
    {
        IAIMessage_Destroy(pMsg);
        return eAIM_RESULT_NOT_READY;
    }
    AMMemset(pMsg->szContent, 0, iContentLen);

    for(i=0; i<pRspGetProfile->iCount; i++)
    {
        if(AMNULL != pRspGetProfile->pszValues[i])
        {
            iLen = AMStrlen(pRspGetProfile->pszKeys[i]);
            AMMemcpy(pMsg->szContent+iPos, pRspGetProfile->pszKeys[i], iLen);
            iPos += iLen;
            pMsg->szContent[iPos++] = '\1';
            iLen = AMStrlen(pRspGetProfile->pszValues[i]);
            AMMemcpy(pMsg->szContent+iPos, pRspGetProfile->pszValues[i], iLen);
            iPos += iLen;
            pMsg->szContent[iPos++] = '\1';
        }
    }

    AMMemcpy(pMsg->szContent+iPos, UID_KEYWROD_ID, sizeof(UID_KEYWROD_ID)-1);//加上"uid\1'contactId'"
    iPos += sizeof(UID_KEYWROD_ID)-1;
    pMsg->szContent[iPos++] = '\1';

    AMStrcat(pMsg->szContent+iPos, pRspGetProfile->szContactId);//不需要尾巴了

    DPRINT("IASessionModel_OnPeerVerifyConfig.................%s\n", pMsg->szContent);

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    return eAIM_RESULT_OK;
}
示例#4
0
AMInt32	_AIMAuth_setSession(AIMAuth *pAuth, const AMChar *szSession)
{
	AMInt32 iLen = 0;
	AMAssert(pAuth && szSession);
	iLen = AMStrlen(szSession);
	AMAssert(iLen);
	
	if(pAuth->szSession)
	{
		AMFree(pAuth->szSession);
		pAuth->szSession = AMNULL;
	}
#if 1	//dynamic
	pAuth->szSession = szSession;
#else
	pAuth->szSession = (AMChar *)AMMalloc(iLen + 1);
	if(!pAuth->szSession)
		return eAIM_RESULT_MALLOC_ERROR;

	AMStrcpy(pAuth->szSession, szSession);
#endif
	pAuth->iStatus = eAUTH_SESSION;

	return eAIM_RESULT_OK;
}
示例#5
0
AIM_RESULT	OnRspChgSignature(AMVoid *pvArg, AIM_RSP_CHG_SIGNATURE *pRspChgSignature)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage	*pMsg = 0;

    AMAssert(AMNULL != pIM && AMNULL != pIM->pAcnt);

    pMsg = IAIMessage_Create();
    pMsg->bUnread = AMTRUE;
    if(!pRspChgSignature->iRetCode)
    {
        pMsg->eType	= (AIM_MSG_TYPE)CHG_SIGNATURE_OK;
        IAIMessage_SetContent(pMsg, pIM->pAcnt->szSignature, AMStrlen(pIM->pAcnt->szSignature));
        DPRINT("IAIM_OnChgSignature..............%s\n", pIM->pAcnt->szSignature);
    }
    else
    {
        pMsg->eType	= (AIM_MSG_TYPE)CHG_SIGNATURE_FAIL;
        DPRINT("IAIM_OnChgSignature...................Faile!\n");
    }

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    return eAIM_RESULT_OK;
}
示例#6
0
AIM_RESULT	OnRspChgSrvMode(AMVoid *pvArg, AIM_RSP_CHG_SRV_MODE *pRspChgSrvMode)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage	*pMsg = AMNULL;

    AMAssert(AMNULL != pIM && AMNULL != pRspChgSrvMode);

    pMsg = IAIMessage_Create();
    if(!pRspChgSrvMode->iRetCode)
    {
        pMsg->eType = (AIM_MSG_TYPE)CHG_SERV_MODE_OK;
        IAIMessage_SetCntID(pMsg, pIM->pAcnt->szID, AMStrlen(pIM->pAcnt->szID));
        DPRINT("IASessionModel_OnHelpChgSrvMode........CHG_SERV_MODE_OK %s, %s\n", pMsg->szContactID, pMsg->szContent);
    }
    else
    {
        pMsg->eType = (AIM_MSG_TYPE)CHG_SERV_MODE_FAIL;
        DPRINT("IASessionModel_OnHelpChgSrvMode........CHG_SERV_MODE_FAIL %d!\n", pRspChgSrvMode->iRetCode);
    }

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    DPRINT("IASessionModel_OnHelpChgSrvMode.........................OK!\n");

    return eAIM_RESULT_OK;
}
示例#7
0
AIM_RESULT	OnNtfHelpLogin(AMVoid *pvArg, AIM_NTF_HELP_LOGIN *pNtfHelpLogin)
{
    IAIMessage	*pMsg = AMNULL;
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);

    AMAssert(AMNULL != pIM && AMNULL != pNtfHelpLogin);

    pMsg = IAIMessage_Create();
    if(!pNtfHelpLogin->iRetCode)
    {
        pMsg->eType = (AIM_MSG_TYPE)HELP_LOGIN_OK;
        IAIMessage_SetCntID(pMsg, pNtfHelpLogin->szParentId, AMStrlen(pNtfHelpLogin->szParentId));

        IAIMessage_SetContent(pMsg, " ", 1);
        pMsg->szContent[0] = '0' + pNtfHelpLogin->uiMulStatus;
        DPRINT("OnNtfHelpLogin................HELP_LOGIN_OK %s, %s!\n", pMsg->szContactID, pMsg->szContent);
    }
    else
    {
        pMsg->eType = (AIM_MSG_TYPE)HELP_LOGIN_FAIL;
        DPRINT("OnNtfHelpLogin................HELP_LOGIN_FAIL! %d\n", pNtfHelpLogin->iRetCode);
    }

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    DPRINT("OnNtfHelpLogin.........................OK!\n");

    return eAIM_RESULT_OK;
}
示例#8
0
IAIMessage*	IAIMessage_Dup(const IAIMessage *pMsg)
{
	IAIMessage *pRet = 0;
	AMAssert(0 != pMsg);
	pRet = IAIMessage_Create();
	if(pMsg->szContactID)
	{
		IAIMessage_SetCntID(pRet, pMsg->szContactID, AMStrlen(pMsg->szContactID));
	}
	if(pMsg->szContent)
	{
		IAIMessage_SetContent(pRet, pMsg->szContent, AMStrlen(pMsg->szContent));
	}
	pRet->_iRid = pMsg->_iRid;
	pRet->iServerTime = pMsg->iServerTime;
	pRet->eType = pMsg->eType;
	return pRet;
}
示例#9
0
static AMInt32 AIMSession_OnSelMsgs(void* pvArg, int iCnt, char **pszValue, char**pszName)
{
	AMPVoid *pvArgs = (AMPVoid *)pvArg;
	AMHandle **pphMsgArray = (AMHandle**)pvArgs[0];
	AMInt32 *piCount = (AMInt32*)pvArgs[1];
	IAIMessage	*pMsg = IAIMessage_Create();

	AMAssert(pphMsgArray && *pphMsgArray && piCount && pMsg);

	pMsg->_iRid = AMAtoi64(pszValue[0]);
	IAIMessage_SetCntID(pMsg, pszValue[1], AMStrlen(pszValue[1]));
	pMsg->eType = AMAtoi(pszValue[2]);
	pMsg->iServerTime = AMAtoi(pszValue[3]);
	IAIMessage_SetContent(pMsg, pszValue[4], AMStrlen(pszValue[4]));
	pMsg->bUnread = AMAtoi(pszValue[5]);
	
	(*pphMsgArray)[(*piCount)++] = pMsg;

	return 0;
}
示例#10
0
static AMInt32 IAccountModel_OnSelAcnt(void* pvAcntor, int iCnt, char **pszValue, char**pszName)
{
	IAccountModel *pAcntModel = (IAccountModel *)pvAcntor;
	AIMAccount *pAcnt = 0;
	AMAssert(0 !=pAcntModel);

	DPRINT("IAccountModel_OnSelAcnt %s ! %s ! %s ! %s ! %s ! %s ! %s\n"
		, pszValue[0], pszValue[1], pszValue[2], pszValue[3], pszValue[4], pszValue[5], pszValue[6]);

	pAcnt = IAccount_Create();

	pAcnt->_iRid =			AMAtoi(pszValue[0]);

	if(0 != IAccount_SetID(pAcnt, pszValue[1], AMStrlen(pszValue[1])))
		return -1;

	pAcnt->uiFlag =	AMAtoi(pszValue[4]);

	if(pAcnt->uiFlag&01 && 0 != AMStrcmp("0", pszValue[2]))
	{
		IAccount_SetToken(pAcnt, pszValue[2], AMStrlen(pszValue[2]));
	}

	if(0 != AMStrcmp("0", pszValue[3]))
	{
		IAccount_SetPhoneNum(pAcnt, pszValue[3]);
	}
	pAcnt->ePresence =		AMAtoi(pszValue[5]);
	pAcnt->iGroupStamp =	AMAtoi(pszValue[6]);
	pAcnt->iContactStamp =	AMAtoi(pszValue[7]);
	pAcnt->iBlackStamp =	AMAtoi(pszValue[8]);
	pAcnt->iRevBlackStamp = AMAtoi(pszValue[9]);

	if(0 != AMStrcmp("0", pszValue[10]))
	{
		IAccount_SetSigXML(pAcnt, pszValue[10], AMStrlen(pszValue[10]));
	}
	push_front_List(&pAcntModel->listAcnt, pAcnt, sizeof(AIMAccount), DYNAMIC);

	return 0;
}
示例#11
0
AIMAccount *		IAccount_dup(const AIMAccount *pAcnt)
{
	AIMAccount *pRet = 0;
	AMAssert(0 != pAcnt);
	pRet = IAccount_Create();
	IAccount_SetNameType(pRet, pAcnt->szName, AMStrlen(pAcnt->szName), pAcnt->eType);

	if(pAcnt->szPwd)
		IAccount_SetPwd(pRet, pAcnt->szPwd, AMStrlen(pAcnt->szPwd));
	if(pAcnt->szToken)
		IAccount_SetToken(pRet, pAcnt->szToken, AMStrlen(pAcnt->szToken));
	if(pAcnt->szPhoneNum)
		IAccount_SetPhoneNum(pRet, pAcnt->szPhoneNum);

	pRet->iGroupStamp = pAcnt->iGroupStamp;
	pRet->iContactStamp = pAcnt->iContactStamp;
	pRet->iBlackStamp = pAcnt->iBlackStamp;
	pRet->iRevBlackStamp = pAcnt->iRevBlackStamp;
	pRet->uiFlag = pAcnt->uiFlag;
	pRet->ePresence = pAcnt->ePresence;
	return pRet;
}
示例#12
0
AIM_RESULT	OnRspGetVerify(AMVoid *pvArg, AIM_RSP_GET_VERIFY *pRspGetVerify)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage	*pMsg = 0;
    AMChar		szBuf[20] = {0};

    AMAssert(NULL != pIM && NULL != pIM->pAcnt);

    pMsg = IAIMessage_Create();
    pMsg->bUnread = AMTRUE;
    pMsg->eType = (AIM_MSG_TYPE)GET_PEER_ADD_VERIFY;
    IAIMessage_SetCntID(pMsg, pRspGetVerify->szContactId, AMStrlen(pRspGetVerify->szContactId));

    _AIMItoa(pRspGetVerify->iRetCode, szBuf);
    IAIMessage_SetContent(pMsg, szBuf, AMStrlen(szBuf));
    DPRINT("IASessionModel_OnPeerVerifyConfig..............%s\n", pMsg->szContent);

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    return eAIM_RESULT_OK;
}
示例#13
0
AMVoid			IAccount_SetPhoneNum(AIMAccount *pAcnt, const AMChar *szPhone)//, AMUInt32 uiPhoneLen)
{
	AMUInt32 uiPhoneLen = 0;
	AMAssert(0 != pAcnt && 0 != szPhone);
	if(pAcnt->szPhoneNum)
	{
		AMFree(pAcnt->szPhoneNum);
		pAcnt->szPhoneNum = 0;
	}
	uiPhoneLen = AMStrlen(szPhone);
	pAcnt->szPhoneNum = (AMChar *)AMMalloc(uiPhoneLen+1);
	AMAssert(0 != pAcnt->szPhoneNum);
	AMMemcpy(pAcnt->szPhoneNum, szPhone, uiPhoneLen);
	pAcnt->szPhoneNum[uiPhoneLen] = 0;
}
示例#14
0
AIM_RESULT	OnRspGetDegree(AMVoid *pvArg, AIM_RSP_GET_DEGREE *pRspGetDegree)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage	*pMsg = AMNULL;
    AMChar		*pBuf = AMNULL;
    AMInt32		iLen = 0;

    AMAssert(AMNULL != pIM && AMNULL != pRspGetDegree);

    DPRINT("IASessionModel_OnGetDegree.........................Entering!\n");

    pMsg = IAIMessage_Create();
    if(pRspGetDegree->szContactId)
        IAIMessage_SetCntID(pMsg, pRspGetDegree->szContactId, AMStrlen(pRspGetDegree->szContactId));

    if(0 == pRspGetDegree->iRetCode)//成功
    {
        pMsg->eType = (AIM_MSG_TYPE)GET_DEGREE_OK;
        pBuf = (AMChar *)AMMalloc(MAX_INT_NUMBER_LEN*3);
        if(AMNULL == pBuf)
        {
            IAIMessage_Destroy(pMsg);
            return eAIM_RESULT_MALLOC_ERROR;
        }
        AMMemset(pBuf, 0, MAX_INT_NUMBER_LEN*3);
        iLen += _AIMItoa(pRspGetDegree->iUserLevel, pBuf);
        pBuf[iLen++] = ',';
        iLen += _AIMItoa(pRspGetDegree->iTotalDegree, pBuf+iLen);
        pBuf[iLen++] = ',';
        iLen += _AIMItoa(pRspGetDegree->iNeedDegree, pBuf+iLen);
        pMsg->szContent	= pBuf;
    }
    else//失败
    {
        DPRINT("IASessionModel_OnGetDegree.......................Fail!\n");
        pMsg->eType = (AIM_MSG_TYPE)GET_DEGREE_FAIL;
    }

    DPRINT("IASessionModel_OnGetDegree.......................%s\n", pMsg->szContent);

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    DPRINT("IASessionModel_OnGetDegree.........................OK!\n");

    return eAIM_RESULT_OK;
}
示例#15
0
AIM_RESULT	OnRspDelContact(AMVoid *pvArg, AIM_RSP_DEL_CONTACT *pRspDelContact)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage *pMsg = AMNULL;
    if(!pRspDelContact->iRetCode && pRspDelContact->szContactId)
    {
        pMsg = IAIMessage_Create();
        pMsg->bUnread = AMTRUE;
        pMsg->eType = (AIM_MSG_TYPE)REMOVE_CNT_SUCESS;

        IAIMessage_SetCntID(pMsg, pRspDelContact->szContactId, AMStrlen(pRspDelContact->szContactId));

        Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);
        IAIMessage_Destroy(pMsg);
    }
    return eAIM_RESULT_OK;
}
示例#16
0
IASession *	IASession_Create(const AMChar *szContactID, IASessionModel *pSesModel)
{
	IASession *pRet = 0;
	AMUInt32	ui = 0, uiLen = 0;
	AMAssert(0 != szContactID);
	pRet = (IASession*)AMMalloc(sizeof(IASession));
	AMMemset(pRet, 0, sizeof(IASession));
	uiLen = AMStrlen(szContactID);
	AMAssert(8 < uiLen);
	pRet->szContactID = (AMChar *)AMMalloc(uiLen + 1);
	for(ui = 0; ui < uiLen; ui++)
		pRet->szContactID[ui] = szContactID[ui];
	pRet->szContactID[uiLen] = 0;

	pRet->pSesModel = pSesModel;

	return pRet;
}
示例#17
0
/*
* Class:     com_alibaba_wireless_imservice_ChatSession
* Method:    nGetContactId
* Signature: (I)[B
*/
JNIEXPORT jbyteArray JNICALL Java_com_alibaba_wireless_imservice_ChatSession_nGetContactId
(JNIEnv *env, jclass cls, jint handle)
{
	IASession *pSes = (IASession*)handle;
	jbyteArray	baryCntID = AMNULL;
	AMInt32 iLen = 0;

	if(0 == pSes || 0 == pSes->szContactID)
		return AMNULL;

	iLen = AMStrlen(pSes->szContactID);

	if(AMNULL == (baryCntID = (*env)->NewByteArray(env, iLen)))
		return AMNULL;
	
	(*env)->SetByteArrayRegion(env, baryCntID, 0, iLen, pSes->szContactID);
	
	return baryCntID;
}
示例#18
0
AIM_RESULT	OnRspDelBlack(AMVoid *pvArg, AIM_RSP_DEL_BLACK *pRspDelBlack)
{
    IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]);
    IAIMessage *pMsg = AMNULL;

    pMsg = IAIMessage_Create();
    pMsg->bUnread = AMTRUE;
    IAIMessage_SetCntID(pMsg, pRspDelBlack->szBlackId, AMStrlen(pRspDelBlack->szBlackId));

    if(!pRspDelBlack->iRetCode)
    {
        pMsg->eType = (AIM_MSG_TYPE)REMOVE_BLK_SUCESS;
    }
    else
    {
        pMsg->eType = (AIM_MSG_TYPE)REMOVE_BLK_FAILED;
    }

    Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg);

    IAIMessage_Destroy(pMsg);

    return eAIM_RESULT_OK;
}