comparison libpurple/protocols/mxit/roster.c @ 31500:80bbed4cb649

* extended the profile information shown for pending invites - avatar image - status message - invite image
author pieter.loubser@mxit.com
date Fri, 01 Apr 2011 13:50:10 +0000
parents aa74632c869d
children 2e4ac25df4ba
comparison
equal deleted inserted replaced
31499:a769e6da0a8e 31500:80bbed4cb649
562 562
563 for ( i = 0; i < g_slist_length( list ); i++ ) { 563 for ( i = 0; i < g_slist_length( list ); i++ ) {
564 buddy = g_slist_nth_data( list, i ); 564 buddy = g_slist_nth_data( list, i );
565 565
566 if ( !purple_buddy_get_protocol_data( buddy ) ) { 566 if ( !purple_buddy_get_protocol_data( buddy ) ) {
567 const gchar *alias = purple_buddy_get_alias( buddy ); 567 const gchar* alias = purple_buddy_get_alias( buddy );
568 const gchar *name = purple_buddy_get_name( buddy ); 568 const gchar* name = purple_buddy_get_name( buddy );
569 569
570 /* this buddy should be removed, because we did not receive him in our roster update from MXit */ 570 /* this buddy should be removed, because we did not receive him in our roster update from MXit */
571 purple_debug_info( MXIT_PLUGIN_ID, "Removed 'old' buddy from the blist '%s' (%s)\n", alias, name ); 571 purple_debug_info( MXIT_PLUGIN_ID, "Removed 'old' buddy from the blist '%s' (%s)\n", alias, name );
572 purple_blist_remove_buddy( buddy ); 572 purple_blist_remove_buddy( buddy );
573 } 573 }
590 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_auth '%s'\n", invite->contact->username ); 590 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_auth '%s'\n", invite->contact->username );
591 591
592 /* send a allow subscription packet to MXit */ 592 /* send a allow subscription packet to MXit */
593 mxit_send_allow_sub( invite->session, invite->contact->username, invite->contact->alias ); 593 mxit_send_allow_sub( invite->session, invite->contact->username, invite->contact->alias );
594 594
595 /* remove the invite from our internal invites list */
596 invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
597
595 /* freeup invite object */ 598 /* freeup invite object */
596 if ( invite->contact->msg ) 599 if ( invite->contact->msg )
597 g_free( invite->contact->msg ); 600 g_free( invite->contact->msg );
601 if ( invite->contact->statusMsg )
602 g_free( invite->contact->statusMsg );
603 if ( invite->contact->profile )
604 g_free( invite->contact->profile );
598 g_free( invite->contact ); 605 g_free( invite->contact );
599 g_free( invite ); 606 g_free( invite );
600 } 607 }
601 608
602 609
611 618
612 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_deny '%s'\n", invite->contact->username ); 619 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_deny '%s'\n", invite->contact->username );
613 620
614 /* send a deny subscription packet to MXit */ 621 /* send a deny subscription packet to MXit */
615 mxit_send_deny_sub( invite->session, invite->contact->username ); 622 mxit_send_deny_sub( invite->session, invite->contact->username );
623
624 /* remove the invite from our internal invites list */
625 invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
616 626
617 /* freeup invite object */ 627 /* freeup invite object */
618 if ( invite->contact->msg ) 628 if ( invite->contact->msg )
619 g_free( invite->contact->msg ); 629 g_free( invite->contact->msg );
630 if ( invite->contact->statusMsg )
631 g_free( invite->contact->statusMsg );
632 if ( invite->contact->profile )
633 g_free( invite->contact->profile );
620 g_free( invite->contact ); 634 g_free( invite->contact );
621 g_free( invite ); 635 g_free( invite );
622 } 636 }
623 637
624 638
637 651
638 invite = g_new0( struct contact_invite, 1 ); 652 invite = g_new0( struct contact_invite, 1 );
639 invite->session = session; 653 invite->session = session;
640 invite->contact = contact; 654 invite->contact = contact;
641 655
656 /* add the invite to our internal invites list */
657 invite->session->invites = g_list_append( invite->session->invites, invite->contact );
658
642 /* (reference: "libpurple/account.h") */ 659 /* (reference: "libpurple/account.h") */
643 purple_account_request_authorization( session->acc, contact->username, NULL, contact->alias, contact->msg, FALSE, mxit_cb_buddy_auth, mxit_cb_buddy_deny, invite ); 660 purple_account_request_authorization( session->acc, contact->username, NULL, contact->alias, contact->msg, FALSE, mxit_cb_buddy_auth, mxit_cb_buddy_deny, invite );
661 }
662
663
664 /*------------------------------------------------------------------------
665 * Return the contact object for a mxit invite
666 *
667 * @param session The MXit session object
668 * @param username The username of the contact
669 * @return The contact object for the inviting user
670 */
671 struct contact* get_mxit_invite_contact( struct MXitSession* session, const char* username )
672 {
673 struct contact* con = NULL;
674 struct contact* match = NULL;
675 int i;
676
677 /* run through all the invites and try and find the match */
678 for ( i = 0; i < g_list_length( session->invites ); i++ ) {
679 con = g_list_nth_data( session->invites, i );
680 if ( strcmp( con->username, username ) == 0 ) {
681 /* invite found */
682 match = con;
683 break;
684 }
685 }
686
687 return match;
644 } 688 }
645 689
646 690
647 /*------------------------------------------------------------------------ 691 /*------------------------------------------------------------------------
648 * Return TRUE if this is a MXit Chatroom contact. 692 * Return TRUE if this is a MXit Chatroom contact.