soc.2008.vv: 3ea12720: Notify the user which type of media sess...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Thu Jun 12 00:05:42 EDT 2008


-----------------------------------------------------------------
Revision: 3ea12720c49208a3497af97b9e58211f2015e479
Ancestor: bf98d5aa636e703a012f08daaa1fd2a7cfff716c
Author: maiku at soc.pidgin.im
Date: 2008-06-12T03:59:26
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/3ea12720c49208a3497af97b9e58211f2015e479

Modified files:
        libpurple/media.c libpurple/media.h
        libpurple/protocols/jabber/jingle.c pidgin/gtkmedia.c

ChangeLog: 

Notify the user which type of media session the remote user wants to initiate.

-------------- next part --------------
============================================================
--- libpurple/media.c	1a7c1d7a9854f561ed97f2a5287d5c7852cfa4f4
+++ libpurple/media.c	6baab475a93fbf18033bd094da2eb440473f79b2
@@ -83,6 +83,7 @@ enum {
 	ACCEPTED,
 	HANGUP,
 	REJECT,
+	GOT_REQUEST,
 	GOT_HANGUP,
 	GOT_ACCEPT,
 	NEW_CANDIDATE,
@@ -172,6 +173,10 @@ purple_media_class_init (PurpleMediaClas
 					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
+	purple_media_signals[GOT_REQUEST] = g_signal_new("got-request", G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+					 g_cclosure_marshal_VOID__VOID,
+					 G_TYPE_NONE, 0);
 	purple_media_signals[GOT_HANGUP] = g_signal_new("got-hangup", G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
@@ -321,6 +326,21 @@ purple_media_from_fs(FsMediaType type, F
 	return result;
 }
 
+PurpleMediaStreamType
+purple_media_get_overall_type(PurpleMedia *media)
+{
+	GList *values = g_hash_table_get_values(media->priv->sessions);
+	PurpleMediaStreamType type = PURPLE_MEDIA_NONE;
+
+	for (; values; values = values->next) {
+		PurpleMediaSession *session = values->data;
+		type |= session->type;
+	}
+
+	g_list_free(values);
+	return type;
+}
+
 static PurpleMediaSession*
 purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
 {
@@ -528,6 +548,12 @@ void
 }
 
 void
+purple_media_got_request(PurpleMedia *media)
+{
+	g_signal_emit(media, purple_media_signals[GOT_REQUEST], 0);
+}
+
+void
 purple_media_got_hangup(PurpleMedia *media)
 {
 	g_signal_emit(media, purple_media_signals[GOT_HANGUP], 0);
============================================================
--- libpurple/media.h	6cf4598565cc39063e289cf4a16d04a60bbf0cfc
+++ libpurple/media.h	87fdbabf95c2d826f6f3966a23a8e71a704de998
@@ -77,6 +77,8 @@ PurpleMediaStreamType purple_media_from_
 FsStreamDirection purple_media_to_fs_stream_direction(PurpleMediaStreamType type);
 PurpleMediaStreamType purple_media_from_fs(FsMediaType type, FsStreamDirection direction);
 
+PurpleMediaStreamType purple_media_get_overall_type(PurpleMedia *media);
+
 GList *purple_media_get_session_names(PurpleMedia *media);
 
 void purple_media_get_elements(PurpleMedia *media, GstElement **audio_src, GstElement **audio_sink,
@@ -97,6 +99,7 @@ void purple_media_hangup(PurpleMedia *me
 void purple_media_accept(PurpleMedia *media);
 void purple_media_reject(PurpleMedia *media);
 void purple_media_hangup(PurpleMedia *media);
+void purple_media_got_request(PurpleMedia *media);
 void purple_media_got_hangup(PurpleMedia *media);
 void purple_media_got_accept(PurpleMedia *media);
 
============================================================
--- libpurple/protocols/jabber/jingle.c	e2165ba40b7bec7d8ab3fcd39ccfaa237e188471
+++ libpurple/protocols/jabber/jingle.c	1c72fb1782aacb1ee127774ab6d4765598148945
@@ -1335,6 +1335,8 @@ jabber_jingle_session_handle_session_ini
 	}
 	jabber_iq_send(jabber_jingle_session_create_ack(js, packet));
 	jabber_iq_send(jabber_jingle_session_create_session_info(session, "ringing"));
+
+	purple_media_got_request(jabber_jingle_session_get_media(session));
 }
 
 void
============================================================
--- pidgin/gtkmedia.c	875b88881a1f72f3da9d05294922696d56fdc06a
+++ pidgin/gtkmedia.c	81319589b895f2420e379baa06b3a6d569f95e31
@@ -427,6 +427,29 @@ static void
 }
 
 static void
+pidgin_media_got_request_cb(PurpleMedia *media, PidginMedia *gtkmedia)
+{
+	PurpleMediaStreamType type = purple_media_get_overall_type(media);
+	gchar *message;
+
+	if (type & PURPLE_MEDIA_AUDIO && type & PURPLE_MEDIA_VIDEO) {
+		message = g_strdup_printf(_("%s wishes to start an audio/video session with you."),
+					  purple_media_get_screenname(media));
+	} else if (type & PURPLE_MEDIA_AUDIO) {
+		message = g_strdup_printf(_("%s wishes to start an audio session with you."),
+					  purple_media_get_screenname(media));
+	} else if (type & PURPLE_MEDIA_VIDEO) {
+		message = g_strdup_printf(_("%s wishes to start a video session with you."),
+					  purple_media_get_screenname(media));
+	} else {
+		return;
+	}
+
+	pidgin_media_emit_message(gtkmedia, message);
+	g_free(message);
+}
+
+static void
 pidgin_media_got_hangup_cb(PurpleMedia *media, PidginMedia *gtkmedia)
 {
 	pidgin_media_emit_message(gtkmedia, _("The call has been terminated."));
@@ -470,6 +493,8 @@ pidgin_media_set_property (GObject *obje
 				G_CALLBACK(pidgin_media_hangup_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "reject",
 				G_CALLBACK(pidgin_media_reject_cb), media);
+			g_signal_connect(G_OBJECT(media->priv->media), "got-request",
+				G_CALLBACK(pidgin_media_got_request_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "got-hangup",
 				G_CALLBACK(pidgin_media_got_hangup_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "got-accept",


More information about the Commits mailing list