protocols/demo/purpledemoprotocolmedia.c

Thu, 11 Apr 2024 21:32:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 11 Apr 2024 21:32:59 -0500
changeset 42692
12506cd6fa96
parent 42652
225762d4e206
child 42709
4d9e01eb0560
permissions
-rw-r--r--

Remove PurpleConnectionUiOps as they are no longer used

Testing Done:
Checked in with the turtles.

Reviewed at https://reviews.imfreedom.org/r/3090/

41487
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
1 /*
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
4 *
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
9 *
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
14 *
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
17 */
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
18
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
19 #include <glib/gi18n-lib.h>
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
20
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
21 #include "purpledemoprotocol.h"
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
22 #include "purpledemoprotocolmedia.h"
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
23
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
24 /******************************************************************************
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
25 * PurpleProtocolMedia Implementation
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
26 *****************************************************************************/
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
27 static PurpleMediaCaps
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
28 purple_demo_protocol_media_get_caps(G_GNUC_UNUSED PurpleProtocolMedia *media,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
29 G_GNUC_UNUSED PurpleAccount *account,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
30 const gchar *who)
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
31 {
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
32 if(purple_strequal(who, "Echo")) {
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
33 return PURPLE_MEDIA_CAPS_AUDIO | PURPLE_MEDIA_CAPS_VIDEO |
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
34 PURPLE_MEDIA_CAPS_AUDIO_VIDEO;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
35 }
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
36
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
37 return PURPLE_MEDIA_CAPS_NONE;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
38 }
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
39
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
40 static gboolean
41968
2fc2db360044 Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41487
diff changeset
41 purple_demo_protocol_media_initiate_session(G_GNUC_UNUSED PurpleProtocolMedia *media,
41487
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
42 PurpleAccount *account,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
43 const gchar *who,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
44 PurpleMediaSessionType type)
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
45 {
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
46 PurpleConnection *connection = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
47 gchar *session_name = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
48 gchar *message = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
49 GDateTime *timestamp = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
50
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
51 connection = purple_account_get_connection(account);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
52
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
53 session_name = g_flags_to_string(PURPLE_MEDIA_TYPE_SESSION_TYPE, type);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
54 message = g_strdup_printf(_("Initiated demo %s session with %s"),
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
55 session_name, who);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
56 timestamp = g_date_time_new_now_utc();
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
57
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
58 purple_serv_got_im(connection, "Echo",
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
59 message, PURPLE_MESSAGE_RECV,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
60 g_date_time_to_unix(timestamp));
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
61
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
62 g_date_time_unref(timestamp);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
63 g_free(message);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
64 g_free(session_name);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
65
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
66 /* TODO: When libpurple gets a backend, we can implement more of this. */
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
67 return FALSE;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
68 }
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
69
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
70 static gboolean
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
71 purple_demo_protocol_media_send_dtmf(G_GNUC_UNUSED PurpleProtocolMedia *protocol_media,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
72 PurpleMedia *media, gchar dtmf,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
73 guint8 volume, guint8 duration)
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
74 {
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
75 PurpleAccount *account = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
76 PurpleConnection *connection = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
77 gchar *message = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
78 GDateTime *timestamp = NULL;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
79
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
80 account = purple_media_get_account(media);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
81 connection = purple_account_get_connection(account);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
82
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
83 message = g_strdup_printf(_("Received DTMF %c at volume %d for %d seconds"),
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
84 dtmf, volume, duration);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
85 timestamp = g_date_time_new_now_utc();
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
86
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
87 purple_serv_got_im(connection, "Echo",
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
88 message, PURPLE_MESSAGE_RECV,
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
89 g_date_time_to_unix(timestamp));
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
90
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
91 g_date_time_unref(timestamp);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
92 g_free(message);
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
93
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
94 return TRUE;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
95 }
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
96
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
97 void
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
98 purple_demo_protocol_media_init(PurpleProtocolMediaInterface *iface) {
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
99 iface->get_caps = purple_demo_protocol_media_get_caps;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
100 iface->initiate_session = purple_demo_protocol_media_initiate_session;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
101 iface->send_dtmf = purple_demo_protocol_media_send_dtmf;
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff changeset
102 }

mercurial