libpurple/protocols/demo/purpledemoprotocol.c

Tue, 28 Feb 2023 03:23:06 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 28 Feb 2023 03:23:06 -0600
changeset 42105
e431d160e3a1
parent 42009
fb172b78a9ee
child 42126
6dbe216fad28
permissions
-rw-r--r--

Fix leaks in requests

Fixes a leak for images in requests:
```
3,627 bytes in 1 blocks are definitely lost in loss record 35,636 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995723: UnknownInlinedFun (gstrfuncs.c:426)
by 0x4995723: g_memdup2 (gstrfuncs.c:419)
by 0x4D3E534: purple_request_field_image_new (request.c:1677)
by 0x1CA970B1: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:553)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
by 0x581B132: g_action_activate (gaction.c:399)
by 0x51221B6: UnknownInlinedFun (gtkmenutrackeritem.c:842)
by 0x51221B6: gtk_popover_item_activate.lto_priv.0 (gtkmenusectionbox.c:200)
```
and leak of the GObject wrapper for request fields:
```
4 bytes in 1 blocks are possibly lost in loss record 713 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995602: g_strdup (gstrfuncs.c:363)
by 0x488B324: create_list_field (gtkrequest.c:1504)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
56 bytes in 1 blocks are possibly lost in loss record 19,209 of 36,499
at 0x48486AF: realloc (vg_replace_malloc.c:1451)
by 0x498071F: g_realloc (gmem.c:201)
by 0x49592C4: g_data_set_internal (gdataset.c:474)
by 0x488B347: create_list_field (gtkrequest.c:1504)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
614 (192 direct, 422 indirect) bytes in 8 blocks are definitely lost in loss record 33,122 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4997AB5: g_slice_alloc (gslice.c:1074)
by 0x49980EC: g_slice_alloc0 (gslice.c:1100)
by 0x4DDF04B: g_type_create_instance (gtype.c:1913)
by 0x4DC4C1F: g_object_new_internal (gobject.c:2228)
by 0x4DC6247: g_object_new_with_properties (gobject.c:2391)
by 0x4DC6FF0: g_object_new (gobject.c:2037)
by 0x488B2D5: create_list_field (gtkrequest.c:1499)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
```
and a request label:
```
128 bytes in 1 blocks are definitely lost in loss record 27,735 of 36,499
at 0x484378A: malloc (vg_replace_malloc.c:392)
by 0x484870B: realloc (vg_replace_malloc.c:1451)
by 0x498071F: g_realloc (gmem.c:201)
by 0x499A343: g_string_maybe_expand (gstring.c:92)
by 0x499A3BF: g_string_sized_new (gstring.c:116)
by 0x4981BCB: g_markup_escape_text (gmarkup.c:2323)
by 0x4887D8A: pidgin_request_escape (gtkrequest.c:360)
by 0x488CED9: pidgin_request_fields (gtkrequest.c:2105)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
```
and one in the demo protocol:
```
40 bytes in 1 blocks are definitely lost in loss record 15,277 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4AE3017: __vasprintf_internal (vasprintf.c:71)
by 0x49C2E81: UnknownInlinedFun (stdio2.h:169)
by 0x49C2E81: g_vasprintf (gprintf.c:340)
by 0x4998EA0: g_strdup_vprintf (gstrfuncs.c:553)
by 0x4998F5C: g_strdup_printf (gstrfuncs.c:583)
by 0x1CA9584E: purple_demo_protocol_request_input_activate (purpledemoprotocolactions.c:203)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
by 0x581B132: g_action_activate (gaction.c:399)
```

Testing Done:
Ran valgrind and confirmed above leaks were not there after opening Request Input and Request Fields.

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

41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <time.h>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include <glib/gi18n-lib.h>
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpledemoprotocol.h"
41999
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
24
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
25 #include "purpledemoconnection.h"
41459
53a9d24d5be2 Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41285
diff changeset
26 #include "purpledemoprotocolactions.h"
41285
cc3c735c14f4 Split apart demo's PurpleProtocolClient implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41284
diff changeset
27 #include "purpledemoprotocolclient.h"
41284
7b29786ffdc7 Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41281
diff changeset
28 #include "purpledemoprotocolim.h"
41487
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41459
diff changeset
29 #include "purpledemoprotocolmedia.h"
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 struct _PurpleDemoProtocol {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 PurpleProtocol parent;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 };
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 /******************************************************************************
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 * PurpleProtocol Implementation
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 *****************************************************************************/
41999
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
38 static PurpleConnection *
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
39 purple_demo_protocol_create_connection(PurpleProtocol *protocol,
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
40 PurpleAccount *account,
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
41 const char *password,
42009
fb172b78a9ee Replace the account-actions-changed signal with an actions-changed signal on PurpleProtocolActions
Gary Kramlich <grim@reaperworld.com>
parents: 41999
diff changeset
42 G_GNUC_UNUSED GError **error)
41775
82c861678f39 Pass the PurpleProtocol objects to all methods of the class
Gary Kramlich <grim@reaperworld.com>
parents: 41487
diff changeset
43 {
41999
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
44 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
45 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
41999
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
47 return g_object_new(
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
48 PURPLE_DEMO_TYPE_CONNECTION,
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
49 "protocol", protocol,
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
50 "account", account,
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
51 "password", password,
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
52 NULL);
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 static GList *
41775
82c861678f39 Pass the PurpleProtocol objects to all methods of the class
Gary Kramlich <grim@reaperworld.com>
parents: 41487
diff changeset
57 purple_demo_protocol_status_types(G_GNUC_UNUSED PurpleProtocol *protocol,
41968
2fc2db360044 Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41911
diff changeset
58 G_GNUC_UNUSED PurpleAccount *account)
41775
82c861678f39 Pass the PurpleProtocol objects to all methods of the class
Gary Kramlich <grim@reaperworld.com>
parents: 41487
diff changeset
59 {
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PurpleStatusType *type = NULL;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 GList *status_types = NULL;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 type = purple_status_type_new_with_attrs(
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 PURPLE_STATUS_AVAILABLE, "available", NULL,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 TRUE, TRUE, FALSE,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 "message", _("Message"), purple_value_new(G_TYPE_STRING),
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 NULL);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 status_types = g_list_append(status_types, type);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 type = purple_status_type_new_with_attrs(
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 PURPLE_STATUS_AWAY, "away", NULL,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 TRUE, TRUE, FALSE,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 "message", _("Message"), purple_value_new(G_TYPE_STRING),
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 NULL);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 status_types = g_list_append(status_types, type);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
41845
c4e4896c5437 add ivanhoe to Demo plugin
Markus Fischer <ivanhoe@fiscari.de>
parents: 41814
diff changeset
77 type = purple_status_type_new_with_attrs(
c4e4896c5437 add ivanhoe to Demo plugin
Markus Fischer <ivanhoe@fiscari.de>
parents: 41814
diff changeset
78 PURPLE_STATUS_EXTENDED_AWAY, "extended_away", NULL,
c4e4896c5437 add ivanhoe to Demo plugin
Markus Fischer <ivanhoe@fiscari.de>
parents: 41814
diff changeset
79 TRUE, TRUE, FALSE,
c4e4896c5437 add ivanhoe to Demo plugin
Markus Fischer <ivanhoe@fiscari.de>
parents: 41814
diff changeset
80 "message", _("Message"), purple_value_new(G_TYPE_STRING),
c4e4896c5437 add ivanhoe to Demo plugin
Markus Fischer <ivanhoe@fiscari.de>
parents: 41814
diff changeset
81 NULL);
c4e4896c5437 add ivanhoe to Demo plugin
Markus Fischer <ivanhoe@fiscari.de>
parents: 41814
diff changeset
82 status_types = g_list_append(status_types, type);
c4e4896c5437 add ivanhoe to Demo plugin
Markus Fischer <ivanhoe@fiscari.de>
parents: 41814
diff changeset
83
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 type = purple_status_type_new_full(
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 PURPLE_STATUS_OFFLINE, NULL, NULL,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 TRUE, TRUE, FALSE);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 status_types = g_list_append(status_types, type);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 return status_types;
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 /******************************************************************************
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 * GObject Implementation
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 *****************************************************************************/
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 G_DEFINE_DYNAMIC_TYPE_EXTENDED(
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 PurpleDemoProtocol,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 purple_demo_protocol,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 PURPLE_TYPE_PROTOCOL,
41911
201aae92d734 Clean up the G_DEFINE_DYNAMIC_TYPE definitions for protocols
Gary Kramlich <grim@reaperworld.com>
parents: 41845
diff changeset
99 G_TYPE_FLAG_FINAL,
41459
53a9d24d5be2 Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41285
diff changeset
100 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_ACTIONS,
53a9d24d5be2 Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41285
diff changeset
101 purple_demo_protocol_actions_init)
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CLIENT,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 purple_demo_protocol_client_init)
41281
aa8fc0497d6d Add an echo user to the demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41224
diff changeset
104 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_IM,
41284
7b29786ffdc7 Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41281
diff changeset
105 purple_demo_protocol_im_init)
41487
86b6cbbee778 Add a stub VV implementation to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41459
diff changeset
106 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_MEDIA,
41911
201aae92d734 Clean up the G_DEFINE_DYNAMIC_TYPE definitions for protocols
Gary Kramlich <grim@reaperworld.com>
parents: 41845
diff changeset
107 purple_demo_protocol_media_init))
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 static void
41968
2fc2db360044 Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41911
diff changeset
110 purple_demo_protocol_init(G_GNUC_UNUSED PurpleDemoProtocol *protocol) {
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 static void
41968
2fc2db360044 Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41911
diff changeset
114 purple_demo_protocol_class_finalize(G_GNUC_UNUSED PurpleDemoProtocolClass *klass) {
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 static void
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 purple_demo_protocol_class_init(PurpleDemoProtocolClass *klass) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 protocol_class->status_types = purple_demo_protocol_status_types;
41999
91af085cf35b Update the demo protocol plugin to use the new create_connection virtual method
Gary Kramlich <grim@reaperworld.com>
parents: 41968
diff changeset
122 protocol_class->create_connection = purple_demo_protocol_create_connection;
41224
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 /******************************************************************************
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 * Local Exports
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 *****************************************************************************/
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 void
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 purple_demo_protocol_register(GPluginNativePlugin *plugin) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 purple_demo_protocol_register_type(G_TYPE_MODULE(plugin));
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 PurpleProtocol *
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 purple_demo_protocol_new(void) {
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 return g_object_new(
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 PURPLE_DEMO_TYPE_PROTOCOL,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 "id", "prpl-demo",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 "name", "Demo",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 "description", "A protocol plugin with static data to be used in "
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 "screen shots.",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 "icon-name", "im-purple-demo",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 "icon-resource-path", "/im/pidgin/purple/demo/icons",
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 "options", OPT_PROTO_NO_PASSWORD,
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 NULL);
32a7796a2a36 Create a demo protocol plugin that right now just adds contacts and statuses.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 }

mercurial