Mercurial > pidgin
comparison libpurple/media/media.c @ 29201:918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
participant.
author | maiku@pidgin.im |
---|---|
date | Tue, 27 Oct 2009 23:44:34 +0000 |
parents | 8b04812396b9 |
children | ecdf669adac9 |
comparison
equal
deleted
inserted
replaced
29200:8b04812396b9 | 29201:918d4043cc33 |
---|---|
632 void | 632 void |
633 purple_media_end(PurpleMedia *media, | 633 purple_media_end(PurpleMedia *media, |
634 const gchar *session_id, const gchar *participant) | 634 const gchar *session_id, const gchar *participant) |
635 { | 635 { |
636 #ifdef USE_VV | 636 #ifdef USE_VV |
637 GList *iter, *sessions = NULL, *participants = NULL; | |
638 | |
637 g_return_if_fail(PURPLE_IS_MEDIA(media)); | 639 g_return_if_fail(PURPLE_IS_MEDIA(media)); |
638 if (session_id == NULL && participant == NULL) { | 640 |
641 iter = purple_media_get_streams(media, session_id, participant); | |
642 | |
643 /* Free matching streams */ | |
644 for (; iter; iter = g_list_delete_link(iter, iter)) { | |
645 PurpleMediaStream *stream = iter->data; | |
646 | |
647 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
648 0, PURPLE_MEDIA_STATE_END, | |
649 stream->session->id, stream->participant); | |
650 | |
651 media->priv->streams = | |
652 g_list_remove(media->priv->streams, stream); | |
653 | |
654 if (g_list_find(sessions, stream->session) == NULL) | |
655 sessions = g_list_prepend(sessions, stream->session); | |
656 | |
657 if (g_list_find_custom(participants, stream->participant, | |
658 (GCompareFunc)strcmp) == NULL) | |
659 participants = g_list_prepend(participants, | |
660 g_strdup(stream->participant)); | |
661 | |
662 purple_media_stream_free(stream); | |
663 } | |
664 | |
665 iter = media->priv->streams; | |
666 | |
667 /* Reduce to list of sessions to remove */ | |
668 for (; iter; iter = g_list_next(iter)) { | |
669 PurpleMediaStream *stream = iter->data; | |
670 | |
671 sessions = g_list_remove(sessions, stream->session); | |
672 } | |
673 | |
674 /* Free sessions with no streams left */ | |
675 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { | |
676 PurpleMediaSession *session = sessions->data; | |
677 | |
678 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
679 0, PURPLE_MEDIA_STATE_END, | |
680 session->id, NULL); | |
681 | |
682 g_hash_table_remove(media->priv->sessions, session->id); | |
683 purple_media_session_free(session); | |
684 } | |
685 | |
686 iter = media->priv->streams; | |
687 | |
688 /* Reduce to list of participants to remove */ | |
689 for (; iter; iter = g_list_next(iter)) { | |
690 PurpleMediaStream *stream = iter->data; | |
691 GList *tmp; | |
692 | |
693 tmp = g_list_find_custom(participants, | |
694 stream->participant, (GCompareFunc)strcmp); | |
695 | |
696 if (tmp != NULL) { | |
697 g_free(tmp->data); | |
698 participants = g_list_delete_link(participants, tmp); | |
699 } | |
700 } | |
701 | |
702 /* Remove participants with no streams left (just emit the signal) */ | |
703 for (; participants; participants = | |
704 g_list_delete_link(participants, participants)) { | |
705 gchar *participant = participants->data; | |
706 | |
707 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
708 0, PURPLE_MEDIA_STATE_END, | |
709 NULL, participant); | |
710 | |
711 g_free(participant); | |
712 } | |
713 | |
714 /* Free the conference if no sessions left */ | |
715 if (g_hash_table_size(media->priv->sessions) == 0) { | |
639 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | 716 g_signal_emit(media, purple_media_signals[STATE_CHANGED], |
640 0, PURPLE_MEDIA_STATE_END, | 717 0, PURPLE_MEDIA_STATE_END, |
641 NULL, NULL); | 718 NULL, NULL); |
642 g_object_unref(media); | 719 g_object_unref(media); |
720 return; | |
643 } | 721 } |
644 #endif | 722 #endif |
645 } | 723 } |
646 | 724 |
647 void | 725 void |