void BBMBPS::processContactUpdate(bbmsp_event_t *event) { bbmsp_presence_update_types_t updateType; bbmsp_contact_t *contact; std::string updateString = "onupdate "; bbmsp_event_contact_changed_get_contact(event, &contact); if (bbmsp_event_contact_changed_get_presence_update_type(event, &updateType) == BBMSP_SUCCESS) { switch (updateType) { case BBMSP_DISPLAY_NAME: updateString += "displayname " + getFullContact(contact); break; case BBMSP_DISPLAY_PICTURE: updateString += "displaypicture " + getFullContact(contact); break; case BBMSP_PERSONAL_MESSAGE: updateString += "personalmessage " + getFullContact(contact); break; case BBMSP_STATUS: updateString += "status " + getFullContact(contact); break; case BBMSP_INSTALL_APP: return; case BBMSP_UNINSTALL_APP: return; case BBMSP_INVITATION_RECEIVED: return; } m_pParent->NotifyEvent(updateString); } }
/** * Called when a new contact event is received from the BBMSP library. */ void handle_contact_event( bbmsp_event_t* bbmsp_event, int event_type ) { trace( "processing contact event" ); bbmsp_result_t result = BBMSP_FAILURE; //Full contact list has been retrieved. if( event_type == BBMSP_SP_EVENT_CONTACT_LIST_FULL ) { if( bbmsp_event_contact_list_register_event() == BBMSP_FAILURE ) { trace( "bbmsp_event_contact_list_register_event() failure" ); } //we got the entire contact list bbmsp_contact_list_t *list; result = bbmsp_event_contact_list_get_full_contact_list( bbmsp_event, &list ); trace( "bbmsp_event_contact_list_get_full_contact_list %i", result ); contact_size = bbmsp_contact_list_get_size( list ); trace( "bbmsp_contact_list_get_size %i", contact_size ); contact_list = (bbmsp_contact_t**) malloc(sizeof(bbmsp_contact_t*) *contact_size); result = bbmsp_contact_list_get_all_contacts( list, contact_list ); trace( "bbmsp_contact_list_get_all_contacts %i", result ); pthread_mutex_lock( &amutex ); contactsCreated = false; //Dispatch event to ActionScript, which then calls getContactList() to retrieve the contact list. FREDispatchStatusEventAsync(context, (const uint8_t *)"contact", (const uint8_t *)"contact_list"); while( !contactsCreated ) { pthread_cond_wait( &acond, &amutex ); } pthread_mutex_unlock( &amutex ); free( contact_list ); } else if( event_type == BBMSP_SP_EVENT_CONTACT_CHANGED ) { //contact was changed bbmsp_contact_t* contact = 0; bbmsp_contact_create(&contact); result = bbmsp_event_contact_changed_get_contact(bbmsp_event, &contact); trace( "bbmsp_event_contact_changed_get_contact %i", result ); bbmsp_presence_update_types_t updateType; if(bbmsp_event_contact_changed_get_presence_update_type(bbmsp_event, &updateType) == BBMSP_SUCCESS) { trace( "updateType %i", updateType ); if( updateType & BBMSP_INSTALL_APP ) { trace( "adding contact" ); pthread_mutex_lock( &amutex ); bbmsp_contact_create( &contactToAdd ); bbmsp_contact_copy( contactToAdd, contact ); contactAdded = false; //Dispatch event to ActionScript, which then calls getAddedContact() to get the added contact. FREDispatchStatusEventAsync(context, (const uint8_t *)"contact", (const uint8_t *)"contact_added"); while( !contactAdded ) { pthread_cond_wait( &acond, &amutex ); } bbmsp_contact_destroy( &contactToAdd ); pthread_mutex_unlock( &amutex ); } if( updateType & BBMSP_DISPLAY_NAME ) { addContactUpdate( contact, BBMSP_DISPLAY_NAME ); FREDispatchStatusEventAsync(context, ( uint8_t* )"contact", (const uint8_t*)"contact_update"); } if( updateType & BBMSP_DISPLAY_PICTURE ) { addContactUpdate( contact, BBMSP_DISPLAY_PICTURE ); FREDispatchStatusEventAsync(context, ( uint8_t* )"contact", (const uint8_t*)"contact_update"); } if( updateType & BBMSP_PERSONAL_MESSAGE ) { addContactUpdate( contact, BBMSP_PERSONAL_MESSAGE ); FREDispatchStatusEventAsync(context, ( uint8_t* )"contact", (const uint8_t*)"contact_update"); } if( updateType & BBMSP_STATUS ) { addContactUpdate( contact, BBMSP_STATUS ); FREDispatchStatusEventAsync(context, ( uint8_t* )"contact", (const uint8_t*)"contact_update"); } if( updateType & BBMSP_UNINSTALL_APP ) { addContactUpdate( contact, BBMSP_UNINSTALL_APP ); FREDispatchStatusEventAsync(context, ( uint8_t* )"contact", (const uint8_t*)"contact_update"); } } } }