--- a/libpurple/protocols/demo/meson.build Thu Aug 11 21:23:28 2022 -0500
+++ b/libpurple/protocols/demo/meson.build Thu Aug 11 21:26:10 2022 -0500
@@ -11,6 +11,8 @@
'purpledemoprotocolclient.h',
'purpledemoprotocolim.c',
'purpledemoprotocolim.h',
+ 'purpledemoprotocolmedia.c', + 'purpledemoprotocolmedia.h', --- a/libpurple/protocols/demo/purpledemocontacts.c Thu Aug 11 21:23:28 2022 -0500
+++ b/libpurple/protocols/demo/purpledemocontacts.c Thu Aug 11 21:26:10 2022 -0500
@@ -128,6 +128,9 @@
purple_demo_protocol_load_icon(account, name);
purple_demo_protocol_load_status(account, group, contact, buddy,
+ if (purple_strequal(name, "Echo")) { + purple_protocol_got_media_caps(account, name); buddies = g_list_delete_link(buddies, buddies);
--- a/libpurple/protocols/demo/purpledemoprotocol.c Thu Aug 11 21:23:28 2022 -0500
+++ b/libpurple/protocols/demo/purpledemoprotocol.c Thu Aug 11 21:26:10 2022 -0500
@@ -24,6 +24,7 @@
#include "purpledemoprotocolactions.h"
#include "purpledemoprotocolclient.h"
#include "purpledemoprotocolim.h"
+#include "purpledemoprotocolmedia.h" #include "purpledemocontacts.h"
@@ -85,6 +86,8 @@
purple_demo_protocol_client_init)
G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_IM,
purple_demo_protocol_im_init)
+ G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_MEDIA, + purple_demo_protocol_media_init) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/demo/purpledemoprotocolmedia.c Thu Aug 11 21:26:10 2022 -0500
@@ -0,0 +1,104 @@
+ * Purple - Internet Messaging Library + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library 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 + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <https://www.gnu.org/licenses/>. +#include <glib/gi18n-lib.h> +#include "purpledemoprotocol.h" +#include "purpledemoprotocolmedia.h" +/****************************************************************************** + * PurpleProtocolMedia Implementation + *****************************************************************************/ +purple_demo_protocol_media_get_caps(G_GNUC_UNUSED PurpleProtocolMedia *media, + G_GNUC_UNUSED PurpleAccount *account, + if(purple_strequal(who, "Echo")) { + return PURPLE_MEDIA_CAPS_AUDIO | PURPLE_MEDIA_CAPS_VIDEO | + PURPLE_MEDIA_CAPS_AUDIO_VIDEO; + return PURPLE_MEDIA_CAPS_NONE; +purple_demo_protocol_media_initiate_session(PurpleProtocolMedia *media, + PurpleAccount *account, + PurpleMediaSessionType type) + PurpleConnection *connection = NULL; + gchar *session_name = NULL; + GDateTime *timestamp = NULL; + connection = purple_account_get_connection(account); + session_name = g_flags_to_string(PURPLE_MEDIA_TYPE_SESSION_TYPE, type); + message = g_strdup_printf(_("Initiated demo %s session with %s"), + timestamp = g_date_time_new_now_utc(); + purple_serv_got_im(connection, "Echo", + message, PURPLE_MESSAGE_RECV, + g_date_time_to_unix(timestamp)); + g_date_time_unref(timestamp); + /* TODO: When libpurple gets a backend, we can implement more of this. */ +purple_demo_protocol_media_send_dtmf(G_GNUC_UNUSED PurpleProtocolMedia *protocol_media, + PurpleMedia *media, gchar dtmf, + guint8 volume, guint8 duration) + PurpleAccount *account = NULL; + PurpleConnection *connection = NULL; + GDateTime *timestamp = NULL; + account = purple_media_get_account(media); + connection = purple_account_get_connection(account); + message = g_strdup_printf(_("Received DTMF %c at volume %d for %d seconds"), + dtmf, volume, duration); + timestamp = g_date_time_new_now_utc(); + purple_serv_got_im(connection, "Echo", + message, PURPLE_MESSAGE_RECV, + g_date_time_to_unix(timestamp)); + g_date_time_unref(timestamp); +purple_demo_protocol_media_init(PurpleProtocolMediaInterface *iface) { + iface->get_caps = purple_demo_protocol_media_get_caps; + iface->initiate_session = purple_demo_protocol_media_initiate_session; + iface->send_dtmf = purple_demo_protocol_media_send_dtmf; --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/demo/purpledemoprotocolmedia.h Thu Aug 11 21:26:10 2022 -0500
@@ -0,0 +1,28 @@
+ * Purple - Internet Messaging Library + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library 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 + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <https://www.gnu.org/licenses/>. +#ifndef PURPLE_DEMO_PROTOCOL_MEDIA_H +#define PURPLE_DEMO_PROTOCOL_MEDIA_H +G_GNUC_INTERNAL void purple_demo_protocol_media_init(PurpleProtocolMediaInterface *iface); +#endif /* PURPLE_DEMO_PROTOCOL_MEDIA_H */