Exemplo n.º 1
0
AIM_RESULT	OnNtfUpdateGroup(AMVoid *pvArg, AIM_NTF_UPDATE_GROUP *pNtfUpdateGroup)
{
    AMInt64 i64GrpId = 0;
    AMChar *szContactId = AMNULL;
    AMInt32 iType = 0;

    if(eAIM_GROUP_ADD == pNtfUpdateGroup->eType)
        iType = CONTACT_ADDED;
    else if(eAIM_GROUP_REMOVE == pNtfUpdateGroup->eType)
        iType = CONTACT_REMOVED;

    IAIMGroup_GetID(pNtfUpdateGroup->hGroup, &i64GrpId);
    IAIMContact_GetID(pNtfUpdateGroup->hContact, (const AMChar **)&szContactId);
    return (AIM_RESULT)JavaCntListener(pvArg, iType, i64GrpId, szContactId);
}
Exemplo n.º 2
0
//请求得到联系人列表
void CWangWangNetLib::RequestGetContactList()
{   
    
    AMHandle *pGrps = AMNULL;
    AMInt32 iCount = 0;
    AMInt64 iGrpId = 0;   
    
    ContactList_t retContactList;
    
    IAIM *pIM = (IAIM *)hIM;
    IAContact * pCnt=AMNULL;
    
    int times=0;
	int retryCount=1000;

    while ((!pIM || !pIM->pCntModel) && (times < retryCount))
    {
        AMSleep(1);
        times++;
    }
    if (times >= retryCount) 
    {
        return;
    }
     
    times=0;
	retryCount=500;
    while (((pIM->pCntModel)->lTopGrp.size  == 0) && (times < retryCount))
    {
        AMSleep(1);
        times++;
    } 
    if (times >= retryCount) 
    {
        return;
    }
    
    if (eAIM_RESULT_OK  != IAIM_GetTopGroups(pIM, &pGrps, &iCount)
        || (pGrps == AMNULL) ) 
    {
            return;
    }
   
    for(int i=0; i<iCount; i++)
    {
        
        IAIMGroup_GetID(pGrps[i], &iGrpId);
            
        AMHandle *phCnts = AMNULL;
        AMInt32 iCount_contacts = 0;
        const AMChar    *szCntName = AMNULL;
            
        IAIMGroup_GetContacts(pGrps[i], AMFALSE, &phCnts, &iCount_contacts);
        
        for(int i=0; i<iCount_contacts; i++) 
        {
            
            IAIMContact_GetID(phCnts[i], &szCntName);
            IAIM_GetContactByID(pIM, szCntName, (AMHandle *)&pCnt);
            
            CContactInfo contactInfo;
            contactInfo.m_strUid = szCntName;
            contactInfo.m_groupId = iGrpId;
            contactInfo.m_strNickName = pCnt->szName;
            retContactList.push_back(contactInfo);
            
        }
        
    }
    
    IAIM_ReleaseTopGroups(pIM, pGrps, iCount);
    
    if (g_pCallback)
    {
        g_pCallback->OnReturnContactList(retContactList,pIM->pAcnt->iContactStamp);
    }
    
	return ;
    
}
Exemplo n.º 3
0
AIM_RESULT	OnNtfUpdateContact(AMVoid *pArg, AIM_NTF_UPDATE_CONTACT *pNtfUpdateContact)
{
    AIM_CONTACT_UPDATE_DATA	*pPresent = 0;
    AMInt32 i=0;
    IAIM *pIM = (IAIM*)(((AMPVoid*)pArg)[1]);
    pPresent = (AIM_CONTACT_UPDATE_DATA*)AMMalloc(sizeof(AIM_CONTACT_UPDATE_DATA) * pNtfUpdateContact->iCount);
    AMMemset(pPresent, 0, sizeof(AIM_CONTACT_UPDATE_DATA) * pNtfUpdateContact->iCount);

    switch(pNtfUpdateContact->eType)
    {
    case eAIM_CONTACT_PRESENCE_FIRST:
        DPRINT("OnNtfUpdateContact..........................Presence First!\n");
        for(i=0; i<pNtfUpdateContact->iCount; i++)
        {
            pPresent[i].ucType = eAIM_CONTACT_PRESENCE;
            IAIMContact_GetPresence(pNtfUpdateContact->phContacts[i], (AIM_PRESENCE*)&pPresent[i].ucStatus);
        }
        break;
    case eAIM_CONTACT_PRESENCE:
        DPRINT("OnNtfUpdateContact..........................Presence!\n");
        for(i=0; i<pNtfUpdateContact->iCount; i++)
        {
            pPresent[i].iFlag = 1;
            pPresent[i].ucType = eAIM_CONTACT_PRESENCE;
            IAIMContact_GetPresence(pNtfUpdateContact->phContacts[i], (AIM_PRESENCE*)&pPresent[i].ucStatus);
        }
        break;
    case eAIM_CONTACT_SIGNATURE:
        DPRINT("OnNtfUpdateContact..........................Signature!\n");
        for(i=0; i<pNtfUpdateContact->iCount; i++)
        {
            pPresent[i].iFlag = 1;
            pPresent[i].ucType = eAIM_CONTACT_SIGNATURE;
            IAIMContact_GetSignature(pNtfUpdateContact->phContacts[i], (const AMChar **)&pPresent[i].szSignature);
        }
        break;
    case eAIM_CONTACT_PORTRAIT:
        DPRINT("OnNtfUpdateContact..........................Portrait!\n");
#ifdef ALIM_SUPPORT_PORTRAIT_NOTIFY	// notify the event
        for(i=0; i<pNtfUpdateContact->iCount; i++)
        {
            pPresent[i].iFlag = 1;
            pPresent[i].ucType = eAIM_CONTACT_PORTRAIT;
        }
#else // get the portrait data. 
        IAIMContact_GetID(pNtfUpdateContact->phContacts	[0], (const AMChar **)&pPresent[0].szID);
        IAIM_GetPortrait(pIM, pPresent[0].szID);

        pNtfUpdateContact->iCount = 0;//如果是头像事件,则不向上发送了
#endif
    default:
        pNtfUpdateContact->iCount = 0;
    }

    for(i=0; i<pNtfUpdateContact->iCount; i++)
    {
        IAIMContact_GetID(pNtfUpdateContact->phContacts	[i], (const AMChar **)&pPresent[i].szID);
    }

    if(pNtfUpdateContact->iCount)
    {
        JavaPreListener(pArg, pPresent, pNtfUpdateContact->iCount);
    }
    AMFree(pPresent);
    return eAIM_RESULT_OK;
}