pidgin/pidginnotifiable.c

Tue, 13 May 2025 14:29:06 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 13 May 2025 14:29:06 -0500
changeset 43251
8bd7eee2f178
parent 43072
a59a119b74f5
permissions
-rw-r--r--

Create a Privacy preference page with the send typing notification preference

This only controls whether or not the conversation window will send typing
notifications, plugins can still do this on their own.

Testing Done:
Used ngrep to verify if the irc typing messages were being sent or not. Also manually modified the settings file and verified the ui update and vice versa.

Bugs closed: PIDGIN-17450

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

42757
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "pidginnotifiable.h"
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 /******************************************************************************
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 * GInterface implementation
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 *****************************************************************************/
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 G_DEFINE_INTERFACE(PidginNotifiable, pidgin_notifiable, G_TYPE_INVALID)
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 static void
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 pidgin_notifiable_default_init(PidginNotifiableInterface *iface) {
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 GParamSpec *pspec = NULL;
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 /**
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 * PidginNotifiable:needs-attention:
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 * Whether or not this needs attention.
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 * Since: 3.0
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 */
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 pspec = g_param_spec_boolean(
43072
a59a119b74f5 Remove nick and blurb from Pidgin properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42757
diff changeset
44 "needs-attention", NULL, NULL,
42757
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 FALSE,
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 g_object_interface_install_property(iface, pspec);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 /**
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 * PidginNotifiable:notification-count:
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 * The number of notifications.
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 *
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 * Since: 3.0
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 */
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 pspec = g_param_spec_uint(
43072
a59a119b74f5 Remove nick and blurb from Pidgin properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42757
diff changeset
57 "notification-count", NULL, NULL,
42757
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 0, G_MAXUINT, 0,
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 g_object_interface_install_property(iface, pspec);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 }
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 /******************************************************************************
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 * Public API
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 *****************************************************************************/
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 gboolean
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 pidgin_notifiable_get_needs_attention(PidginNotifiable *notifiable) {
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 gboolean ret = FALSE;
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 g_return_val_if_fail(PIDGIN_IS_NOTIFIABLE(notifiable), FALSE);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 g_object_get(G_OBJECT(notifiable), "needs-attention", &ret, NULL);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 return ret;
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 }
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 guint
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 pidgin_notifiable_get_notification_count(PidginNotifiable *notifiable) {
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 guint ret = 0;
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_return_val_if_fail(PIDGIN_IS_NOTIFIABLE(notifiable), 0);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 g_object_get(G_OBJECT(notifiable), "notification-count", &ret, NULL);
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 return ret;
7c639ab519a1 Create PidginNotifiable interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 }

mercurial