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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
AIM_RESULT OnRspChgVerify(AMVoid *pvArg, AIM_RSP_CHG_VERIFY *pRspChgVerify) { IAIMessage *pMsg = AMNULL; IAIM *pIM = (IAIM*)(((AMPVoid*)pvArg)[1]); pMsg = IAIMessage_Create(); pMsg->bUnread = AMTRUE; if(0 == pRspChgVerify->iRetCode) { pMsg->eType = (AIM_MSG_TYPE)CHG_VERIFY_OK; } else { pMsg->eType = (AIM_MSG_TYPE)CHG_VERIFY_FAILE; } IAIMessage_SetContent(pMsg, "0", 1); pMsg->szContent[0] = '0' + pIM->pAcnt->iVerifyType; Adapter_OnIncomingSysMsg(pIM->pSesModel, pMsg, pvArg); IAIMessage_Destroy(pMsg); return eAIM_RESULT_OK; }