view libpurple/media/backend-iface.c @ 29804:93876452633b

Pull in GtkComboBox changes from GTK+3 branch. Refs #1332, since I seem to have just found it. *** Plucked rev c27b04bb38032682dfa343b38090df1c6eea4edd (qulogic@pidgin.im): Use GtkComboBox instead of GtkOptionMenu in the choice request field for GTK+ 2.4 and up. *** Plucked rev d440cb6510a85d0451248d51de56b02a3a60afd2 (qulogic@pidgin.im): Replace the GtkOptionMenu with a GtkComboBox for the privacy options list on GTK+ 2.4 and up. *** Plucked rev c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61 (qulogic@pidgin.im): Replace GtkOptionMenu with GtkComboBox in the saved status editor for GTK+ 2.4 and up. *** Plucked rev fbe77efc06ba98af604ef878b97fd55924daa018 (qulogic@pidgin.im): Replace GtkOptionMenu with GtkComboBox in the gestures plugin for GTK+ 2.4 and up. But that code's commented out, so this is totally untested. *** Plucked rev 9d8f789a57f4477db7d3cfbb9752b7842ff790dd (qulogic@pidgin.im): Add an enumeration to replace a couple hardcoded numbers in the combo box code for saved statuses. *** Plucked rev c27b04bb38032682dfa343b38090df1c6eea4edd (qulogic@pidgin.im): Use GtkComboBox instead of GtkOptionMenu in the choice request field for GTK+ 2.4 and up. *** Plucked rev d440cb6510a85d0451248d51de56b02a3a60afd2 (qulogic@pidgin.im): Replace the GtkOptionMenu with a GtkComboBox for the privacy options list on GTK+ 2.4 and up. *** Plucked rev c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61 (qulogic@pidgin.im): Replace GtkOptionMenu with GtkComboBox in the saved status editor for GTK+ 2.4 and up. *** Plucked rev fbe77efc06ba98af604ef878b97fd55924daa018 (qulogic@pidgin.im): Replace GtkOptionMenu with GtkComboBox in the gestures plugin for GTK+ 2.4 and up. But that code's commented out, so this is totally untested. *** Plucked rev 9d8f789a57f4477db7d3cfbb9752b7842ff790dd (qulogic@pidgin.im): Add an enumeration to replace a couple hardcoded numbers in the combo box code for saved statuses.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 19 Feb 2010 07:29:30 +0000
parents f351e87b7af0
children a4ba3b194ce3
line wrap: on
line source

/**
 * @file backend-iface.c Interface for media backend
 * @ingroup core
 */

/* purple
 *
 * Purple is the legal property of its developers, whose names are too numerous
 * to list here.  Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 */

#include "backend-iface.h"

#include "marshallers.h"

enum {
	S_ERROR,
	CANDIDATES_PREPARED,
	CODECS_CHANGED,
	NEW_CANDIDATE,
	ACTIVE_CANDIDATE_PAIR,
	LAST_SIGNAL
};

static guint purple_media_backend_signals[LAST_SIGNAL] = {0};

static void
purple_media_backend_base_init(gpointer iface)
{
	static gboolean is_initialized = FALSE;

	if (is_initialized)
		return;

	g_object_interface_install_property(iface,
			g_param_spec_string("conference-type",
			"Conference Type",
			"The type of conference that this backend "
			"has been created to provide.",
			NULL,
			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
	g_object_interface_install_property(iface,
			g_param_spec_object("media",
			"Purple Media",
			"The media object that this backend is bound to.",
			PURPLE_TYPE_MEDIA,
			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));

	purple_media_backend_signals[S_ERROR] =
			g_signal_new("error", G_TYPE_FROM_CLASS(iface),
			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
			g_cclosure_marshal_VOID__STRING,
			G_TYPE_NONE, 1, G_TYPE_STRING);
	purple_media_backend_signals[CANDIDATES_PREPARED] =
			g_signal_new("candidates-prepared",
			G_TYPE_FROM_CLASS(iface),
			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
			purple_smarshal_VOID__STRING_STRING,
			G_TYPE_NONE, 2, G_TYPE_STRING,
			G_TYPE_STRING);
	purple_media_backend_signals[CODECS_CHANGED] =
			g_signal_new("codecs-changed",
			G_TYPE_FROM_CLASS(iface),
			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
			g_cclosure_marshal_VOID__STRING,
			G_TYPE_NONE, 1, G_TYPE_STRING);
	purple_media_backend_signals[NEW_CANDIDATE] =
			g_signal_new("new-candidate",
			G_TYPE_FROM_CLASS(iface),
			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
			purple_smarshal_VOID__POINTER_POINTER_OBJECT,
			G_TYPE_NONE, 3, G_TYPE_POINTER,
			G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE);
	purple_media_backend_signals[ACTIVE_CANDIDATE_PAIR] =
			g_signal_new("active-candidate-pair",
			G_TYPE_FROM_CLASS(iface),
			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
			purple_smarshal_VOID__STRING_STRING_OBJECT_OBJECT,
			G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
			PURPLE_TYPE_MEDIA_CANDIDATE,
			PURPLE_TYPE_MEDIA_CANDIDATE);

	is_initialized = TRUE;
}

GType
purple_media_backend_get_type(void)
{
	static GType iface_type = 0;
	if (iface_type == 0) {
		static const GTypeInfo info = {
			sizeof(PurpleMediaBackendIface),
			purple_media_backend_base_init,
			NULL,
			NULL,
			NULL,
			NULL,
			0,
			0,
			NULL,
			NULL
		};

		iface_type = g_type_register_static (G_TYPE_INTERFACE,
				"PurpleMediaBackend", &info, 0);
	}

	return iface_type;
}

gboolean
purple_media_backend_add_stream(PurpleMediaBackend *self,
		const gchar *sess_id, const gchar *who,
		PurpleMediaSessionType type, gboolean initiator,
		const gchar *transmitter,
		guint num_params, GParameter *params)
{
	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->add_stream(self,
			sess_id, who, type, initiator, transmitter,
			num_params, params);
}

void
purple_media_backend_add_remote_candidates(PurpleMediaBackend *self,
		const gchar *sess_id, const gchar *participant,
		GList *remote_candidates)
{
	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND(self));
	PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->add_remote_candidates(self,
			sess_id, participant, remote_candidates);
}

gboolean
purple_media_backend_codecs_ready(PurpleMediaBackend *self,
		const gchar *sess_id)
{
	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->codecs_ready(self,
			sess_id);
}

GList *
purple_media_backend_get_codecs(PurpleMediaBackend *self,
		const gchar *sess_id)
{
	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL);
	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->get_codecs(self,
			sess_id);
}

GList *
purple_media_backend_get_local_candidates(PurpleMediaBackend *self,
		const gchar *sess_id, const gchar *participant)
{
	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL);
	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->
			get_local_candidates(self,
			sess_id, participant);
}

gboolean
purple_media_backend_set_remote_codecs(PurpleMediaBackend *self,
		const gchar *sess_id, const gchar *participant,
		GList *codecs)
{
	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_remote_codecs(
			self, sess_id, participant, codecs);
}

gboolean
purple_media_backend_set_send_codec(PurpleMediaBackend *self,
		const gchar *sess_id, PurpleMediaCodec *codec)
{
	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_send_codec(self,
			sess_id, codec);
}