libpurple/protocols/null/nullprpl.c

Thu, 10 Jun 2021 23:40:54 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 10 Jun 2021 23:40:54 -0500
changeset 40945
bbeb2e98ea5b
parent 40885
87f6241da196
child 40948
2c312f084d84
permissions
-rw-r--r--

Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT

Testing Done:
Ran an instance and verified my enabled accounts connected and everything else was queried successfully.

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

17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1 /**
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
2 * purple
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
3 *
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
6 * source distribution.
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
7 *
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
8 * Nullprpl is a mock protocol plugin for Pidgin and libpurple. You can create
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
9 * accounts with it, sign on and off, add buddies, and send and receive IMs,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
10 * all without connecting to a server!
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
11 *
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
12 * Beyond that basic functionality, nullprpl supports presence and
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
13 * away/available messages, offline messages, user info, typing notification,
37148
50f361d39a1e Merged default branch
Ankit Vani <a@nevitus.org>
parents: 37146 36098
diff changeset
14 * privacy allow/block lists, chat rooms, room lists, and protocol
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
15 * icons and emblems. Notable missing features are file transfer and account
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
16 * registration and authentication.
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
17 *
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
18 * Nullprpl is intended as an example of how to write a libpurple protocol
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
19 * plugin. It doesn't contain networking code or an event loop, but it does
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
20 * demonstrate how to use the libpurple API to do pretty much everything a
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
21 * protocol might need to do.
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
22 *
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
23 * Nullprpl is also a useful tool for hacking on Pidgin, Finch, and other
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
24 * libpurple clients. It's a full-featured protocol plugin, but doesn't depend
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
25 * on an external server, so it's a quick and easy way to exercise test new
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
26 * code. It also allows you to work while you're disconnected.
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
27 *
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
28 * This program is free software; you can redistribute it and/or modify
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
29 * it under the terms of the GNU General Public License as published by
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
30 * the Free Software Foundation; either version 2 of the License, or
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
31 * (at your option) any later version.
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
32 *
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
33 * This program is distributed in the hope that it will be useful,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
36 * GNU General Public License for more details.
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
37 *
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
38 * You should have received a copy of the GNU General Public License
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
39 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19832
diff changeset
40 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
41 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
42
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
43 #include <stdarg.h>
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
44 #include <string.h>
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
45 #include <time.h>
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
46
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
47 #include <glib.h>
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40087
diff changeset
48 #include <glib/gi18n-lib.h>
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
49
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
50 #include <gplugin.h>
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
51 #include <gplugin-native.h>
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
52
39877
4bc87b3dbca4 Get the null prpl working again and build it by default but don't install it
Gary Kramlich <grim@reaperworld.com>
parents: 39760
diff changeset
53 #include <purple.h>
24332
9c7586a57e1b Add a comment documenting the internal.h situation for people using nullprpl
Richard Laager <rlaager@pidgin.im>
parents: 24231
diff changeset
54
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
55 #include "nullprpl.h"
36657
4a7f5f97d1ec Make sure internal.h is included first
Ankit Vani <a@nevitus.org>
parents: 36653
diff changeset
56
40865
82e45cd837fa Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
57 struct _NullProtocol {
82e45cd837fa Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
58 PurpleProtocol parent;
82e45cd837fa Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
59 };
82e45cd837fa Migrate gg, novel, null, sametime, silc, and zephyr to using G_DECLARE_FINAL_TYPE for their protocol objects
Gary Kramlich <grim@reaperworld.com>
parents: 40813
diff changeset
60
36663
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
61 /*
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
62 * reference to the protocol instance, used for registering signals, prefs,
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
63 * etc. it is set when the protocol is added in plugin_load and is required
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
64 * for removing the protocol in plugin_unload.
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
65 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
66 static PurpleProtocol *my_protocol = NULL;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
67
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
68 #define NULL_STATUS_ONLINE "online"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
69 #define NULL_STATUS_AWAY "away"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
70 #define NULL_STATUS_OFFLINE "offline"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
71
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
72 typedef void (*GcFunc)(PurpleConnection *from,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
73 PurpleConnection *to,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
74 gpointer userdata);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
75
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
76 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
77 GcFunc fn;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
78 PurpleConnection *from;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
79 gpointer userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
80 } GcFuncData;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
81
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
82 /*
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
83 * stores offline messages that haven't been delivered yet. maps username
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
84 * (char *) to GList * of GOfflineMessages. initialized in plugin_load.
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
85 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
86 GHashTable* goffline_messages = NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
87
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
88 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
89 char *from;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
90 char *message;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
91 time_t mtime;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
92 PurpleMessageFlags flags;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
93 } GOfflineMessage;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
94
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
95 /*
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
96 * helpers
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
97 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
98 static PurpleConnection *get_null_gc(const char *username) {
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
99 PurpleAccount *acct = purple_accounts_find(username, "null");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
100 if (acct && purple_account_is_connected(acct))
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
101 return purple_account_get_connection(acct);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
102 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
103 return NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
104 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
105
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
106 static void call_if_nullprotocol(gpointer data, gpointer userdata) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
107 PurpleConnection *gc = (PurpleConnection *)(data);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
108 GcFuncData *gcfdata = (GcFuncData *)userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
109
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 37163 38266
diff changeset
110 if (purple_strequal(purple_account_get_protocol_id(purple_connection_get_account(gc)), "null"))
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
111 gcfdata->fn(gcfdata->from, gc, gcfdata->userdata);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
112 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
113
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
114 static void foreach_null_gc(GcFunc fn, PurpleConnection *from,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
115 gpointer userdata) {
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
116 GcFuncData gcfdata = { fn, from, userdata };
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
117 g_list_foreach(purple_connections_get_all(), call_if_nullprotocol,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
118 &gcfdata);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
119 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
120
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
121
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
122 typedef void(*ChatFunc)(PurpleConversation *from, PurpleConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
123 int id, const char *room, gpointer userdata);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
124
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
125 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
126 ChatFunc fn;
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
127 PurpleConversation *from_chat;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
128 gpointer userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
129 } ChatFuncData;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
130
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
131 static void call_chat_func(gpointer data, gpointer userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
132 PurpleConnection *to = (PurpleConnection *)data;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
133 ChatFuncData *cfdata = (ChatFuncData *)userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
134
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
135 int id = purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(cfdata->from_chat));
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
136 PurpleConversation *chat = purple_conversations_find_chat(to, id);
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
137 if (chat)
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
138 cfdata->fn(cfdata->from_chat, chat, id,
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
139 purple_conversation_get_name(chat), cfdata->userdata);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
140 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
141
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
142 static void foreach_gc_in_chat(ChatFunc fn, PurpleConnection *from,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
143 int id, gpointer userdata) {
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
144 PurpleConversation *chat = purple_conversations_find_chat(from, id);
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
145 ChatFuncData cfdata = { fn,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
146 chat,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
147 userdata };
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
148
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
149 g_list_foreach(purple_connections_get_all(), call_chat_func,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
150 &cfdata);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
151 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
152
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
153
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
154 static void discover_status(PurpleConnection *from, PurpleConnection *to,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
155 gpointer userdata) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
156 const char *from_username = purple_account_get_username(purple_connection_get_account(from));
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
157 const char *to_username = purple_account_get_username(purple_connection_get_account(to));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
158
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
159 if (purple_blist_find_buddy(purple_connection_get_account(from), to_username)) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
160 PurpleStatus *status = purple_account_get_active_status(purple_connection_get_account(to));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
161 const char *status_id = purple_status_get_id(status);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
162 const char *message = purple_status_get_attr_string(status, "message");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
163
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31595
diff changeset
164 if (purple_strequal(status_id, NULL_STATUS_ONLINE) ||
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31595
diff changeset
165 purple_strequal(status_id, NULL_STATUS_AWAY) ||
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31595
diff changeset
166 purple_strequal(status_id, NULL_STATUS_OFFLINE)) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
167 purple_debug_info("nullprpl", "%s sees that %s is %s: %s\n",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
168 from_username, to_username, status_id, message);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
169 purple_protocol_got_user_status(purple_connection_get_account(from), to_username, status_id,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
170 (message) ? "message" : NULL, message, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
171 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
172 purple_debug_error("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
173 "%s's buddy %s has an unknown status: %s, %s",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
174 from_username, to_username, status_id, message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
175 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
176 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
177 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
178
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
179 static void report_status_change(PurpleConnection *from, PurpleConnection *to,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
180 gpointer userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
181 purple_debug_info("nullprpl", "notifying %s that %s changed status\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
182 purple_account_get_username(purple_connection_get_account(to)), purple_account_get_username(purple_connection_get_account(from)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
183 discover_status(to, from, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
184 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
185
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
186
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
187 /*
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
188 * UI callbacks
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
189 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
190 static void null_input_user_info(PurpleProtocolAction *action)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
191 {
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
192 PurpleConnection *gc = action->connection;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
193 PurpleAccount *acct = purple_connection_get_account(gc);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
194 purple_debug_info("nullprpl", "showing 'Set User Info' dialog for %s\n",
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
195 purple_account_get_username(acct));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
196
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
197 purple_account_request_change_user_info(acct);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
198 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
199
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
200 /*
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36628
diff changeset
201 * Protocol functions
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
202 */
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
203 static GList *
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
204 null_get_actions(PurpleProtocolClient *client, PurpleConnection *gc) {
36494
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
205 PurpleProtocolAction *action = purple_protocol_action_new(
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
206 _("Set User Info..."), null_input_user_info);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
207 return g_list_append(NULL, action);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
208 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
209
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
210 static const char *null_list_icon(PurpleAccount *acct, PurpleBuddy *buddy)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
211 {
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
212 return "null";
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
213 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
214
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
215 static GList *
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
216 null_protocol_get_account_options(PurpleProtocol *protocol) {
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
217 PurpleAccountOption *option;
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
218
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
219 option = purple_account_option_string_new(
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
220 _("Example option"), /* text shown to user */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
221 "example", /* pref name */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
222 "default"); /* default value */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
223
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
224 return g_list_append(NULL, option);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
225 }
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
226
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
227 static PurpleBuddyIconSpec *
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
228 null_protocol_get_buddy_icon_spec(PurpleProtocol *protocol) {
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
229 return purple_buddy_icon_spec_new(
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
230 "png,jpg,gif", /* format */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
231 0, /* min_width */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
232 0, /* min_height */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
233 128, /* max_width */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
234 128, /* max_height */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
235 10000, /* max_filesize */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
236 PURPLE_ICON_SCALE_DISPLAY /* scale_rules */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
237 );
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
238 }
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
239
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
240 static GList *
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
241 null_protocol_get_user_splits(PurpleProtocol *protocol) {
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
242 PurpleAccountUserSplit *split;
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
243
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
244 split = purple_account_user_split_new(
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
245 _("Example user split"), /* text shown to user */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
246 "default", /* default value */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
247 '@'); /* field separator */
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
248
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
249 return g_list_append(NULL, split);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
250 }
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
251
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
252 static char *
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
253 null_status_text(PurpleProtocolClient *client, PurpleBuddy *buddy) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
254 purple_debug_info("nullprpl", "getting %s's status text for %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
255 purple_buddy_get_name(buddy),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
256 purple_account_get_username(purple_buddy_get_account(buddy)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
257
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
258 if (purple_blist_find_buddy(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy))) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
259 PurplePresence *presence = purple_buddy_get_presence(buddy);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
260 PurpleStatus *status = purple_presence_get_active_status(presence);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
261 const char *name = purple_status_get_name(status);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
262 const char *message = purple_status_get_attr_string(status, "message");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
263
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
264 char *text;
32189
3af8d41121b6 Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents: 32188
diff changeset
265 if (message && *message)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
266 text = g_strdup_printf("%s: %s", name, message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
267 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
268 text = g_strdup(name);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
269
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
270 purple_debug_info("nullprpl", "%s's status text is %s\n",
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
271 purple_buddy_get_name(buddy), text);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
272 return text;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
273
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
274 } else {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
275 purple_debug_info("nullprpl", "...but %s is not logged in\n", purple_buddy_get_name(buddy));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
276 return g_strdup("Not logged in");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
277 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
278 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
279
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
280 static void
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
281 null_tooltip_text(PurpleProtocolClient *client, PurpleBuddy *buddy,
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
282 PurpleNotifyUserInfo *info, gboolean full)
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
283 {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
284 PurpleConnection *gc = get_null_gc(purple_buddy_get_name(buddy));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
285
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
286 if (gc) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
287 /* they're logged in */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
288 PurplePresence *presence = purple_buddy_get_presence(buddy);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
289 PurpleStatus *status = purple_presence_get_active_status(presence);
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
290 char *msg = null_status_text(client, buddy);
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
291 /* TODO: Check whether it's correct to call add_pair_html,
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
292 or if we should be using add_pair_plaintext */
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
293 purple_notify_user_info_add_pair_html(info, purple_status_get_name(status),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
294 msg);
24865
053ddd0ba317 Small leak fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24862
diff changeset
295 g_free(msg);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
296
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
297 if (full) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
298 const char *user_info = purple_account_get_user_info(purple_connection_get_account(gc));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
299 if (user_info)
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
300 /* TODO: Check whether it's correct to call add_pair_html,
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
301 or if we should be using add_pair_plaintext */
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
302 purple_notify_user_info_add_pair_html(info, _("User info"), user_info);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
303 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
304
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
305 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
306 /* they're not logged in */
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 31595
diff changeset
307 purple_notify_user_info_add_pair_plaintext(info, _("User info"), _("not logged in"));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
308 }
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
309
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
310 purple_debug_info("nullprpl", "showing %s tooltip for %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
311 (full) ? "full" : "short", purple_buddy_get_name(buddy));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
312 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
313
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
314 static GList *null_status_types(PurpleAccount *acct)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
315 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
316 GList *types = NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
317 PurpleStatusType *type;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
318
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
319 purple_debug_info("nullprpl", "returning status types for %s: %s, %s, %s\n",
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
320 purple_account_get_username(acct),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
321 NULL_STATUS_ONLINE, NULL_STATUS_AWAY, NULL_STATUS_OFFLINE);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
322
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
323 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
324 NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34991
diff changeset
325 "message", _("Message"), purple_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
326 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
327 types = g_list_prepend(types, type);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
328
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
329 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
330 NULL_STATUS_AWAY, NULL, TRUE, TRUE, FALSE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34991
diff changeset
331 "message", _("Message"), purple_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
332 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
333 types = g_list_prepend(types, type);
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
334
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
335 type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE,
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
336 NULL_STATUS_OFFLINE, NULL, TRUE, TRUE, FALSE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34991
diff changeset
337 "message", _("Message"), purple_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
338 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
339 types = g_list_prepend(types, type);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
340
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
341 return g_list_reverse(types);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
342 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
343
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
344 static void blist_example_menu_item(PurpleBlistNode *node, gpointer userdata) {
22709
6bd336964410 Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
345 purple_debug_info("nullprpl", "example menu item clicked on user %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
346 purple_buddy_get_name(PURPLE_BUDDY(node)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
347
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
348 purple_notify_info(NULL, /* plugin handle or PurpleConnection */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
349 _("Primary title"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
350 _("Secondary title"),
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
351 _("This is the callback for the NullProtocol menu item."),
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
352 NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
353 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
354
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
355 static GList *
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
356 null_blist_node_menu(PurpleProtocolClient *client, PurpleBlistNode *node) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
357 purple_debug_info("nullprpl", "providing buddy list context menu item\n");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
358
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34671
diff changeset
359 if (PURPLE_IS_BUDDY(node)) {
39483
ab4728087d87 Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents: 39481
diff changeset
360 PurpleActionMenu *action = purple_action_menu_new(
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
361 _("NullProtocol example menu item"),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
362 PURPLE_CALLBACK(blist_example_menu_item),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
363 NULL, /* userdata passed to the callback */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
364 NULL); /* child menu items */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
365 return g_list_append(NULL, action);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
366 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
367 return NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
368 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
369 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
370
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
371 static GList *
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
372 null_chat_info(PurpleProtocolChat *protocol_chat, PurpleConnection *gc) {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
373 PurpleProtocolChatEntry *pce; /* defined in protocols.h */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
374
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
375 purple_debug_info("nullprpl", "returning chat setting 'room'\n");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
376
36555
fc17a4351e63 Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
377 pce = g_new0(PurpleProtocolChatEntry, 1);
40087
a8c6a80325dc Fix an accelerator in a string in libpurple. Accelerators are for UI's,
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 39918
diff changeset
378 pce->label = _("Chat room");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
379 pce->identifier = "room";
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
380 pce->required = TRUE;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
381
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
382 return g_list_append(NULL, pce);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
383 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
384
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
385 static GHashTable *
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
386 null_chat_info_defaults(PurpleProtocolChat *protocol_chat,
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
387 PurpleConnection *gc, const gchar *room)
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
388 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
389 GHashTable *defaults;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
390
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
391 purple_debug_info("nullprpl", "returning chat default setting "
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
392 "'room' = 'default'\n");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
393
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
394 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
395 g_hash_table_insert(defaults, "room", g_strdup("default"));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
396 return defaults;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
397 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
398
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
399 static void null_login(PurpleAccount *acct)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
400 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
401 PurpleConnection *gc = purple_account_get_connection(acct);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
402 GList *offline_messages;
39918
1c8e11f9274f Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39896
diff changeset
403 GList *all_offline_messages;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
404
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
405 purple_debug_info("nullprpl", "logging in %s\n", purple_account_get_username(acct));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
406
36055
33978dc8ef6f Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35813
diff changeset
407 purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_IMAGES);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
408
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
409 purple_connection_update_progress(gc, _("Connecting"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
410 0, /* which connection step this is */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
411 2); /* total number of steps */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
412
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
413 purple_connection_update_progress(gc, _("Connected"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
414 1, /* which connection step this is */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
415 2); /* total number of steps */
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
416 purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
417
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
418 /* tell purple about everyone on our buddy list who's connected */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
419 foreach_null_gc(discover_status, gc, NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
420
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
421 /* notify other nullprotocol accounts */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
422 foreach_null_gc(report_status_change, gc, NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
423
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
424 /* fetch stored offline messages */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
425 purple_debug_info("nullprpl", "checking for offline messages for %s\n",
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
426 purple_account_get_username(acct));
39918
1c8e11f9274f Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39896
diff changeset
427 all_offline_messages = offline_messages = g_hash_table_lookup(
1c8e11f9274f Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39896
diff changeset
428 goffline_messages, purple_account_get_username(acct));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
429 while (offline_messages) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
430 GOfflineMessage *message = (GOfflineMessage *)offline_messages->data;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
431 purple_debug_info("nullprpl", "delivering offline message to %s: %s\n",
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
432 purple_account_get_username(acct), message->message);
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35005
diff changeset
433 purple_serv_got_im(gc, message->from, message->message, message->flags,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
434 message->mtime);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
435 offline_messages = g_list_next(offline_messages);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
436
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
437 g_free(message->from);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
438 g_free(message->message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
439 g_free(message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
440 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
441
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
442 g_hash_table_remove(goffline_messages, purple_account_get_username(acct));
39918
1c8e11f9274f Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39896
diff changeset
443 g_list_free(all_offline_messages);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
444 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
445
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
446 static void null_close(PurpleConnection *gc)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
447 {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
448 /* notify other nullprotocol accounts */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
449 foreach_null_gc(report_status_change, gc, NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
450 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
451
40507
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
452 static int null_send_im(PurpleProtocolIM *im, PurpleConnection *gc,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
453 PurpleMessage *msg)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
454 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
455 const char *from_username = purple_account_get_username(purple_connection_get_account(gc));
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36084
diff changeset
456 const gchar *who = purple_message_get_recipient(msg);
36076
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36055
diff changeset
457 PurpleMessageFlags receive_flags;
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
458 PurpleAccount *to_acct = purple_accounts_find(who, "null");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
459 PurpleConnection *to;
36076
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36055
diff changeset
460 const gchar *message = purple_message_get_contents(msg);
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36055
diff changeset
461
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36055
diff changeset
462 receive_flags = ((purple_message_get_flags(msg) & ~PURPLE_MESSAGE_SEND) | PURPLE_MESSAGE_RECV);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
463
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
464 purple_debug_info("nullprpl", "sending message from %s to %s: %s\n",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
465 from_username, who, message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
466
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
467 /* is the sender blocked by the recipient's privacy settings? */
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
468 if (to_acct &&
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
469 !purple_account_privacy_check(to_acct, purple_account_get_username(purple_connection_get_account(gc)))) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
470 char *msg = g_strdup_printf(
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
471 _("Your message was blocked by %s's privacy settings."), who);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
472 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
473 "discarding; %s is blocked by %s's privacy settings\n",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
474 from_username, who);
34868
faa5b053f310 Replaced purple_conversation_helper_present_error() with simpler purple_conversation_present_error()
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
475 purple_conversation_present_error(who, purple_connection_get_account(gc), msg);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
476 g_free(msg);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
477 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
478 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
479
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
480 /* is the recipient online? */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
481 to = get_null_gc(who);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
482 if (to) { /* yes, send */
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35005
diff changeset
483 purple_serv_got_im(to, from_username, message, receive_flags, time(NULL));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
484
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
485 } else { /* nope, store as an offline message */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
486 GOfflineMessage *offline_message;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
487 GList *messages;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
488
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
489 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
490 "%s is offline, sending as offline message\n", who);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
491 offline_message = g_new0(GOfflineMessage, 1);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
492 offline_message->from = g_strdup(from_username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
493 offline_message->message = g_strdup(message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
494 offline_message->mtime = time(NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
495 offline_message->flags = receive_flags;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
496
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
497 messages = g_hash_table_lookup(goffline_messages, who);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
498 messages = g_list_append(messages, offline_message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
499 g_hash_table_insert(goffline_messages, g_strdup(who), messages);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
500 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
501
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
502 return 1;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
503 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
504
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
505 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
506 null_set_info(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
507 const gchar *info)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
508 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
509 purple_debug_info("nullprpl", "setting %s's user info to %s\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
510 purple_account_get_username(purple_connection_get_account(gc)), info);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
511 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
512
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
513 static const char *typing_state_to_string(PurpleIMTypingState typing) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
514 switch (typing) {
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
515 case PURPLE_IM_NOT_TYPING: return "is not typing";
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
516 case PURPLE_IM_TYPING: return "is typing";
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
517 case PURPLE_IM_TYPED: return "stopped typing momentarily";
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
518 default: return "unknown typing state";
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
519 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
520 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
521
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
522 static void notify_typing(PurpleConnection *from, PurpleConnection *to,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
523 gpointer typing) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
524 const char *from_username = purple_account_get_username(purple_connection_get_account(from));
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
525 const char *action = typing_state_to_string((PurpleIMTypingState)typing);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
526 purple_debug_info("nullprpl", "notifying %s that %s %s\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
527 purple_account_get_username(purple_connection_get_account(to)), from_username, action);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
528
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35005
diff changeset
529 purple_serv_got_typing(to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
530 from_username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
531 0, /* if non-zero, a timeout in seconds after which to
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
532 * reset the typing status to PURPLE_IM_NOT_TYPING */
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
533 (PurpleIMTypingState)typing);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
534 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
535
40507
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
536 static unsigned int null_send_typing(PurpleProtocolIM *im,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
537 PurpleConnection *gc, const char *name,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
538 PurpleIMTypingState typing)
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
539 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
540 purple_debug_info("nullprpl", "%s %s\n", purple_account_get_username(purple_connection_get_account(gc)),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
541 typing_state_to_string(typing));
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
542 foreach_null_gc(notify_typing, gc, (gpointer)typing);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
543 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
544 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
545
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
546 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
547 null_get_info(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
548 const gchar *username)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
549 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
550 const char *body;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
551 PurpleNotifyUserInfo *info = purple_notify_user_info_new();
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
552 PurpleAccount *acct;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
553
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
554 purple_debug_info("nullprpl", "Fetching %s's user info for %s\n", username,
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
555 purple_account_get_username(purple_connection_get_account(gc)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
556
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
557 acct = purple_accounts_find(username, "null");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
558
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
559 if (!get_null_gc(username)) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
560 char *msg = g_strdup_printf(_("%s is not logged in."), username);
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
561 purple_notify_error(gc, _("User Info"), _("User info not available. "), msg,
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
562 purple_request_cpar_from_account(acct));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
563 g_free(msg);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
564 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
565
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
566 if (acct)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
567 body = purple_account_get_user_info(acct);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
568 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
569 body = _("No user info.");
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 31595
diff changeset
570 /* TODO: Check whether it's correct to call add_pair_html,
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 31595
diff changeset
571 or if we should be using add_pair_plaintext */
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
572 purple_notify_user_info_add_pair_html(info, "Info", body);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
573
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
574 /* show a buddy's user info in a nice dialog box */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
575 purple_notify_userinfo(gc, /* connection the buddy info came through */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
576 username, /* buddy's username */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
577 info, /* body */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
578 NULL, /* callback called when dialog closed */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
579 NULL); /* userdata for callback */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
580 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
581
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
582 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
583 null_set_status(PurpleProtocolServer *protocol_server, PurpleAccount *acct,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
584 PurpleStatus *status)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
585 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
586 const char *msg = purple_status_get_attr_string(status, "message");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
587 purple_debug_info("nullprpl", "setting %s's status to %s: %s\n",
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
588 purple_account_get_username(acct), purple_status_get_name(status), msg);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
589
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
590 foreach_null_gc(report_status_change, get_null_gc(purple_account_get_username(acct)),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
591 NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
592 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
593
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
594 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
595 null_set_idle(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
596 gint idletime)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
597 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
598 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
599 "purple reports that %s has been idle for %d seconds\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
600 purple_account_get_username(purple_connection_get_account(gc)), idletime);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
601 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
602
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
603 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
604 null_change_passwd(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
605 const gchar *old_pass, const gchar *new_pass)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
606 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
607 purple_debug_info("nullprpl", "%s wants to change their password\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
608 purple_account_get_username(purple_connection_get_account(gc)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
609 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
610
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
611 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
612 null_add_buddy(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
613 PurpleBuddy *buddy, PurpleGroup *group, const gchar *message)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
614 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
615 const char *username = purple_account_get_username(purple_connection_get_account(gc));
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
616 PurpleConnection *buddy_gc = get_null_gc(purple_buddy_get_name(buddy));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
617
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
618 purple_debug_info("nullprpl", "adding %s to %s's buddy list\n", purple_buddy_get_name(buddy),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
619 username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
620
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
621 if (buddy_gc) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
622 PurpleAccount *buddy_acct = purple_connection_get_account(buddy_gc);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
623
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
624 discover_status(gc, buddy_gc, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
625
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
626 if (purple_blist_find_buddy(buddy_acct, username)) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
627 purple_debug_info("nullprpl", "%s is already on %s's buddy list\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
628 username, purple_buddy_get_name(buddy));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
629 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
630 purple_debug_info("nullprpl", "asking %s if they want to add %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
631 purple_buddy_get_name(buddy), username);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
632 purple_account_request_add(buddy_acct,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
633 username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
634 NULL, /* local account id (rarely used) */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
635 NULL, /* alias */
32315
2550a39e0285 Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32263
diff changeset
636 message); /* message */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
637 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
638 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
639 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
640
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
641 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
642 null_add_buddies(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
643 GList *buddies, GList *groups, const gchar *message)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
644 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
645 GList *buddy = buddies;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
646 GList *group = groups;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
647
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
648 purple_debug_info("nullprpl", "adding multiple buddies\n");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
649
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
650 while (buddy && group) {
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
651 null_add_buddy(protocol_server, gc, PURPLE_BUDDY(buddy->data),
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
652 PURPLE_GROUP(group->data), message);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
653 buddy = g_list_next(buddy);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
654 group = g_list_next(group);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
655 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
656 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
657
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
658 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
659 null_remove_buddy(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
660 PurpleBuddy *buddy, PurpleGroup *group)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
661 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
662 purple_debug_info("nullprpl", "removing %s from %s's buddy list\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
663 purple_buddy_get_name(buddy),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
664 purple_account_get_username(purple_connection_get_account(gc)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
665 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
666
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
667 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
668 null_remove_buddies(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
669 PurpleConnection *gc, GList *buddies, GList *groups)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
670 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
671 GList *buddy = buddies;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
672 GList *group = groups;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
673
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
674 purple_debug_info("nullprpl", "removing multiple buddies\n");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
675
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
676 while (buddy && group) {
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
677 null_remove_buddy(protocol_server, gc, PURPLE_BUDDY(buddy->data),
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
678 PURPLE_GROUP(group->data));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
679 buddy = g_list_next(buddy);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
680 group = g_list_next(group);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
681 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
682 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
683
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
684 /*
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
685 * nullprotocol uses purple's local whitelist and blacklist, stored in blist.xml, as
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
686 * its authoritative privacy settings, and uses purple's logic (specifically
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
687 * purple_privacy_check(), from privacy.h), to determine whether messages are
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
688 * allowed or blocked.
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
689 */
40521
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
690 static void null_add_permit(PurpleProtocolPrivacy *privacy,
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
691 PurpleConnection *gc, const char *name)
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
692 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
693 purple_debug_info("nullprpl", "%s adds %s to their allowed list\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
694 purple_account_get_username(purple_connection_get_account(gc)), name);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
695 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
696
40521
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
697 static void null_add_deny(PurpleProtocolPrivacy *privacy,
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
698 PurpleConnection *gc, const char *name)
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
699 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
700 purple_debug_info("nullprpl", "%s adds %s to their blocked list\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
701 purple_account_get_username(purple_connection_get_account(gc)), name);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
702 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
703
40521
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
704 static void null_remove_permit(PurpleProtocolPrivacy *privacy,
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
705 PurpleConnection *gc, const char *name)
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
706 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
707 purple_debug_info("nullprpl", "%s removes %s from their allowed list\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
708 purple_account_get_username(purple_connection_get_account(gc)), name);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
709 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
710
40521
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
711 static void null_remove_deny(PurpleProtocolPrivacy *privacy,
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
712 PurpleConnection *gc, const char *name)
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
713 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
714 purple_debug_info("nullprpl", "%s removes %s from their blocked list\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
715 purple_account_get_username(purple_connection_get_account(gc)), name);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
716 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
717
40521
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
718 static void null_set_permit_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
719 /* this is for synchronizing the local black/whitelist with the server.
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
720 * for nullprotocol, it's a noop.
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
721 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
722 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
723
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
724 static void joined_chat(PurpleConversation *from, PurpleConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
725 int id, const char *room, gpointer userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
726 /* tell their chat window that we joined */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
727 purple_debug_info("nullprpl", "%s sees that %s joined chat room %s\n",
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
728 purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(to)), purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(from)), room);
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
729 purple_chat_conversation_add_user(PURPLE_CHAT_CONVERSATION(to),
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
730 purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(from)),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
731 NULL, /* user-provided join message, IRC style */
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
732 PURPLE_CHAT_USER_NONE,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
733 TRUE); /* show a join message */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
734
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
735 if (from != to) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
736 /* add them to our chat window */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
737 purple_debug_info("nullprpl", "%s sees that %s is in chat room %s\n",
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
738 purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(from)), purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(to)), room);
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
739 purple_chat_conversation_add_user(PURPLE_CHAT_CONVERSATION(from),
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
740 purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(to)),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
741 NULL, /* user-provided join message, IRC style */
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34631
diff changeset
742 PURPLE_CHAT_USER_NONE,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
743 FALSE); /* show a join message */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
744 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
745 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
746
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
747 static void
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
748 null_join_chat(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
749 GHashTable *components)
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
750 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
751 const char *username = purple_account_get_username(purple_connection_get_account(gc));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
752 const char *room = g_hash_table_lookup(components, "room");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
753 int chat_id = g_str_hash(room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
754 purple_debug_info("nullprpl", "%s is joining chat room %s\n", username, room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
755
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
756 if (!purple_conversations_find_chat(gc, chat_id)) {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35005
diff changeset
757 purple_serv_got_joined_chat(gc, chat_id, room);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
758
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
759 /* tell everyone that we joined, and add them if they're already there */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
760 foreach_gc_in_chat(joined_chat, gc, chat_id, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
761 } else {
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
762 char *tmp = g_strdup_printf(_("%s is already in chat room %s."),
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
763 username,
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
764 room);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
765 purple_debug_info("nullprpl", "%s is already in chat room %s\n", username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
766 room);
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
767 purple_notify_info(gc, _("Join chat"), _("Join chat"), tmp,
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
768 purple_request_cpar_from_connection(gc));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
769 g_free(tmp);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
770 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
771 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
772
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
773 static void
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
774 null_reject_chat(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
775 GHashTable *components)
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
776 {
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
777 const char *invited_by = g_hash_table_lookup(components, "invited_by");
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
778 const char *room = g_hash_table_lookup(components, "room");
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
779 const char *username = purple_account_get_username(purple_connection_get_account(gc));
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
780 PurpleConnection *invited_by_gc = get_null_gc(invited_by);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
781 char *message = g_strdup_printf(
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
782 "%s %s %s.",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
783 username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
784 _("has rejected your invitation to join the chat room"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
785 room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
786
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
787 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
788 "%s has rejected %s's invitation to join chat room %s\n",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
789 username, invited_by, room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
790
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
791 purple_notify_info(invited_by_gc,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
792 _("Chat invitation rejected"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
793 _("Chat invitation rejected"),
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
794 message,
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
795 purple_request_cpar_from_connection(gc));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
796 g_free(message);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
797 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
798
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
799 static gchar *
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
800 null_get_chat_name(PurpleProtocolChat *protocol_chat, GHashTable *components) {
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
801 const char *room = g_hash_table_lookup(components, "room");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
802 purple_debug_info("nullprpl", "reporting chat room name '%s'\n", room);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
803 return g_strdup(room);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
804 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
805
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
806 static void
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
807 null_chat_invite(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
808 gint id, const gchar *message, const gchar *who)
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
809 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
810 const char *username = purple_account_get_username(purple_connection_get_account(gc));
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
811 PurpleConversation *chat = purple_conversations_find_chat(gc, id);
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
812 const char *room = purple_conversation_get_name(chat);
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
813 PurpleAccount *to_acct = purple_accounts_find(who, "null");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
814
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
815 purple_debug_info("nullprpl", "%s is inviting %s to join chat room %s\n",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
816 username, who, room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
817
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
818 if (to_acct) {
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
819 PurpleConversation *to_conv = purple_conversations_find_chat(purple_account_get_connection(to_acct), id);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
820 if (to_conv) {
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
821 char *tmp = g_strdup_printf("%s is already in chat room %s.", who, room);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
822 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
823 "%s is already in chat room %s; "
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
824 "ignoring invitation from %s\n",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
825 who, room, username);
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
826 purple_notify_info(gc, _("Chat invitation"), _("Chat invitation"), tmp,
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
827 purple_request_cpar_from_conversation(to_conv));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
828 g_free(tmp);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
829 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
830 GHashTable *components;
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
831 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
832 g_hash_table_replace(components, "room", g_strdup(room));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
833 g_hash_table_replace(components, "invited_by", g_strdup(username));
35501
602747bb4af9 Fix duplicate prefixes
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
834 purple_serv_got_chat_invite(purple_account_get_connection(to_acct), room, username, message, components);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
835 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
836 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
837 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
838
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
839 static void left_chat_room(PurpleConversation *from, PurpleConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
840 int id, const char *room, gpointer userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
841 if (from != to) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
842 /* tell their chat window that we left */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
843 purple_debug_info("nullprpl", "%s sees that %s left chat room %s\n",
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
844 purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(to)), purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(from)), room);
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
845 purple_chat_conversation_remove_user(PURPLE_CHAT_CONVERSATION(to),
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
846 purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(from)),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
847 NULL); /* user-provided message, IRC style */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
848 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
849 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
850
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
851 static void
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
852 null_chat_leave(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
853 gint id)
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
854 {
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
855 PurpleConversation *chat = purple_conversations_find_chat(gc, id);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
856 purple_debug_info("nullprpl", "%s is leaving chat room %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
857 purple_account_get_username(purple_connection_get_account(gc)),
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
858 purple_conversation_get_name(chat));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
859
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
860 /* tell everyone that we left */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
861 foreach_gc_in_chat(left_chat_room, gc, id, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
862 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
863
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
864 static void receive_chat_message(PurpleConversation *from, PurpleConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
865 int id, const char *room, gpointer userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
866 const char *message = (const char *)userdata;
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
867 PurpleConnection *to_gc = get_null_gc(purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(to)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
868
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
869 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
870 "%s receives message from %s in chat room %s: %s\n",
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
871 purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(to)), purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(from)), room, message);
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
872 purple_serv_got_chat_in(to_gc, id, purple_chat_conversation_get_nick(PURPLE_CHAT_CONVERSATION(from)), PURPLE_MESSAGE_RECV, message,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
873 time(NULL));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
874 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
875
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
876 static gint
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
877 null_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
878 gint id, PurpleMessage *msg)
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
879 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
880 const char *username = purple_account_get_username(purple_connection_get_account(gc));
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
881 PurpleConversation *chat = purple_conversations_find_chat(gc, id);
36077
b7328f4317c7 Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
882 const gchar *message = purple_message_get_contents(msg);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
883
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
884 if (chat) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
885 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
886 "%s is sending message to chat room %s: %s\n", username,
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
887 purple_conversation_get_name(chat), message);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
888
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
889 /* send message to everyone in the chat room */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
890 foreach_gc_in_chat(receive_chat_message, gc, id, (gpointer)message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
891 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
892 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
893 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
894 "tried to send message from %s to chat room #%d: %s\n"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
895 "but couldn't find chat room",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
896 username, id, message);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
897 return -1;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
898 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
899 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
900
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
901 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
902 null_register_user(PurpleProtocolServer *protocol_server, PurpleAccount *acct) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
903 purple_debug_info("nullprpl", "registering account for %s\n",
32623
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
904 purple_account_get_username(acct));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
905 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
906
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
907 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
908 null_alias_buddy(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
909 PurpleConnection *gc, const gchar *who,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
910 const gchar *alias)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
911 {
22709
6bd336964410 Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
912 purple_debug_info("nullprpl", "%s sets %s's alias to %s\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
913 purple_account_get_username(purple_connection_get_account(gc)), who, alias);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
914 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
915
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
916 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
917 null_group_buddy(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
918 PurpleConnection *gc, const gchar *who,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
919 const gchar *old_group, const gchar *new_group)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
920 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
921 purple_debug_info("nullprpl", "%s has moved %s from group %s to group %s\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
922 purple_account_get_username(purple_connection_get_account(gc)), who, old_group, new_group);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
923 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
924
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
925 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
926 null_rename_group(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
927 PurpleConnection *gc, const gchar *old_name,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
928 PurpleGroup *group, GList *moved_buddies)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
929 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
930 purple_debug_info("nullprpl", "%s has renamed group %s to %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
931 purple_account_get_username(purple_connection_get_account(gc)), old_name,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
932 purple_group_get_name(group));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
933 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
934
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
935 static void
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
936 null_convo_closed(PurpleProtocolClient *client, PurpleConnection *gc,
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
937 const char *who)
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
938 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
939 purple_debug_info("nullprpl", "%s's conversation with %s was closed\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
940 purple_account_get_username(purple_connection_get_account(gc)), who);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
941 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
942
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
943 /* normalize a username (e.g. remove whitespace, add default domain, etc.)
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
944 * for nullprotocol, this is a noop.
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
945 */
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
946 static const char *
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
947 null_normalize(PurpleProtocolClient *client, PurpleAccount *acct,
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
948 const char *input)
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
949 {
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
950 return input;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
951 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
952
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
953 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
954 null_set_buddy_icon(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
955 PurpleConnection *gc, PurpleImage *img)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
956 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
957 purple_debug_info("nullprpl", "setting %s's buddy icon to %s\n",
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
958 purple_account_get_username(purple_connection_get_account(gc)),
39877
4bc87b3dbca4 Get the null prpl working again and build it by default but don't install it
Gary Kramlich <grim@reaperworld.com>
parents: 39760
diff changeset
959 img ? purple_image_get_path(img) : "(null)");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
960 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
961
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
962 static void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
963 null_remove_group(PurpleProtocolServer *protocol_server, PurpleConnection *gc,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
964 PurpleGroup *group)
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40697
diff changeset
965 {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
966 purple_debug_info("nullprpl", "%s has removed group %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
967 purple_account_get_username(purple_connection_get_account(gc)),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
968 purple_group_get_name(group));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
969 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
970
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
971
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
972 static void set_chat_topic_fn(PurpleConversation *from, PurpleConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
973 int id, const char *room, gpointer userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
974 const char *topic = (const char *)userdata;
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
975 const char *username = purple_account_get_username(purple_conversation_get_account(PURPLE_CONVERSATION(from)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
976 char *msg;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
977
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
978 purple_chat_conversation_set_topic(PURPLE_CHAT_CONVERSATION(to), username, topic);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
979
32189
3af8d41121b6 Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents: 32188
diff changeset
980 if (topic && *topic)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
981 msg = g_strdup_printf(_("%s sets topic to: %s"), username, topic);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
982 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
983 msg = g_strdup_printf(_("%s clears topic"), username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
984
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
985 purple_conversation_write_system_message(to, msg, PURPLE_MESSAGE_NO_LOG);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
986 g_free(msg);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
987 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
988
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
989 static void
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
990 null_set_chat_topic(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
991 gint id, const gchar *topic)
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
992 {
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
993 PurpleConversation *chat = purple_conversations_find_chat(gc, id);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
994 const char *last_topic;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
995
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
996 if (!chat)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
997 return;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
998
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
999 purple_debug_info("nullprpl", "%s sets topic of chat room '%s' to '%s'\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
1000 purple_account_get_username(purple_connection_get_account(gc)),
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
1001 purple_conversation_get_name(chat), topic);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1002
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40865
diff changeset
1003 last_topic = purple_chat_conversation_get_topic(PURPLE_CHAT_CONVERSATION(chat));
38266
7c1706b2bd11 Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
1004 if (purple_strequal(topic, last_topic))
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1005 return; /* topic is unchanged, this is a noop */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1006
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1007 foreach_gc_in_chat(set_chat_topic_fn, gc, id, (gpointer)topic);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1008 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1009
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1010 static gboolean null_finish_get_roomlist(gpointer roomlist) {
34991
63c14353a0f4 Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents: 34979
diff changeset
1011 purple_roomlist_set_in_progress(PURPLE_ROOMLIST(roomlist), FALSE);
63c14353a0f4 Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents: 34979
diff changeset
1012 g_object_unref(roomlist);
63c14353a0f4 Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents: 34979
diff changeset
1013
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1014 return FALSE;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1015 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1016
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1017 static PurpleRoomlist *null_roomlist_get_list(PurpleConnection *gc) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
1018 const char *username = purple_account_get_username(purple_connection_get_account(gc));
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
1019 PurpleRoomlist *roomlist = purple_roomlist_new(purple_connection_get_account(gc));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1020 GList *fields = NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1021 PurpleRoomlistField *field;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1022 GList *chats;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1023 GList *seen_ids = NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1024
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1025 purple_debug_info("nullprpl", "%s asks for room list; returning:\n", username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1026
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1027 /* set up the room list */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1028 field = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "room",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1029 "room", TRUE /* hidden */);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1030 fields = g_list_append(fields, field);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1031
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1032 field = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_INT, "Id", "Id", FALSE);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1033 fields = g_list_append(fields, field);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1034
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1035 purple_roomlist_set_fields(roomlist, fields);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1036
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1037 /* add each chat room. the chat ids are cached in seen_ids so that each room
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1038 * is only returned once, even if multiple users are in it. */
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
1039 for (chats = purple_conversations_get_chats(); chats; chats = g_list_next(chats)) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
1040 PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(chats->data);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1041 PurpleRoomlistRoom *room;
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
1042 const char *name = purple_conversation_get_name(PURPLE_CONVERSATION(chat));
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
1043 int id = purple_chat_conversation_get_id(chat);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1044
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1045 /* have we already added this room? */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1046 if (g_list_find_custom(seen_ids, name, (GCompareFunc)strcmp))
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1047 continue; /* yes! try the next one. */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1048
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1049 /* This cast is OK because this list is only staying around for the life
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1050 * of this function and none of the conversations are being deleted
29977
94b2a6686bfb nullprpl: Whitespace
Paul Aurich <darkrain42@pidgin.im>
parents: 29795
diff changeset
1051 * in that timespan. */
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1052 seen_ids = g_list_prepend(seen_ids, (char *)name); /* no, it's new. */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1053 purple_debug_info("nullprpl", "%s (%d), ", name, id);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1054
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1055 room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, name, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1056 purple_roomlist_room_add_field(roomlist, room, name);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1057 purple_roomlist_room_add_field(roomlist, room, &id);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1058 purple_roomlist_room_add(roomlist, room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1059 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1060
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1061 g_list_free(seen_ids);
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
1062 g_timeout_add(1 /* ms */, null_finish_get_roomlist, g_object_ref(roomlist));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1063 return roomlist;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1064 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1065
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1066 static void null_roomlist_cancel(PurpleRoomlist *list) {
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1067 PurpleAccount *account = purple_roomlist_get_account(list);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1068 purple_debug_info("nullprpl", "%s asked to cancel room list request\n",
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1069 purple_account_get_username(account));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1070 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1071
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1072 static void null_roomlist_expand_category(PurpleRoomlist *list,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1073 PurpleRoomlistRoom *category) {
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1074 PurpleAccount *account = purple_roomlist_get_account(list);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1075 purple_debug_info("nullprpl", "%s asked to expand room list category %s\n",
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1076 purple_account_get_username(account),
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1077 purple_roomlist_room_get_name(category));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1078 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1079
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
1080 static gboolean
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
1081 null_offline_message(PurpleProtocolClient *client, PurpleBuddy *buddy) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1082 purple_debug_info("nullprpl",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1083 "reporting that offline messages are supported for %s\n",
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40521
diff changeset
1084 purple_buddy_get_name(buddy));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1085 return TRUE;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1086 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1087
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1088 /*
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1089 * Initialize the protocol instance. see protocol.h for more information.
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1090 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1091 static void
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1092 null_protocol_init(NullProtocol *self)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1093 {
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1094 }
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1095
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1096 /*
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1097 * Initialize the protocol class and interfaces.
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1098 * see protocol.h for more information.
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1099 */
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1100
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1101 static void
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1102 null_protocol_class_init(NullProtocolClass *klass)
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1103 {
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1104 PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass);
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1105
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1106 protocol_class->login = null_login;
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1107 protocol_class->close = null_close;
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1108 protocol_class->status_types = null_status_types;
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1109 protocol_class->list_icon = null_list_icon;
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1110
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1111 protocol_class->get_account_options = null_protocol_get_account_options;
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1112 protocol_class->get_buddy_icon_spec = null_protocol_get_buddy_icon_spec;
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1113 protocol_class->get_user_splits = null_protocol_get_user_splits;
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1114 }
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1115
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1116 static void
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1117 null_protocol_class_finalize(G_GNUC_UNUSED NullProtocolClass *klass)
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1118 {
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1119 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1120
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1121 static void
39757
4a5ba806d8c9 Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39483
diff changeset
1122 null_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1123 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1124 client_iface->get_actions = null_get_actions;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1125 client_iface->status_text = null_status_text;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1126 client_iface->tooltip_text = null_tooltip_text;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1127 client_iface->blist_node_menu = null_blist_node_menu;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1128 client_iface->convo_closed = null_convo_closed;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1129 client_iface->normalize = null_normalize;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1130 client_iface->offline_message = null_offline_message;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1131 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1132
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1133 static void
39757
4a5ba806d8c9 Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39483
diff changeset
1134 null_protocol_server_iface_init(PurpleProtocolServerInterface *server_iface)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1135 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1136 server_iface->register_user = null_register_user;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1137 server_iface->set_info = null_set_info;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1138 server_iface->get_info = null_get_info;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1139 server_iface->set_status = null_set_status;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1140 server_iface->set_idle = null_set_idle;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1141 server_iface->change_passwd = null_change_passwd;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1142 server_iface->add_buddy = null_add_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1143 server_iface->add_buddies = null_add_buddies;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1144 server_iface->remove_buddy = null_remove_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1145 server_iface->remove_buddies = null_remove_buddies;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1146 server_iface->alias_buddy = null_alias_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1147 server_iface->group_buddy = null_group_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1148 server_iface->rename_group = null_rename_group;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1149 server_iface->set_buddy_icon = null_set_buddy_icon;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1150 server_iface->remove_group = null_remove_group;
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1151 }
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1152
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1153 static void
39757
4a5ba806d8c9 Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39483
diff changeset
1154 null_protocol_im_iface_init(PurpleProtocolIMInterface *im_iface)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1155 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1156 im_iface->send = null_send_im;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1157 im_iface->send_typing = null_send_typing;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1158 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1159
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1160 static void
39757
4a5ba806d8c9 Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39483
diff changeset
1161 null_protocol_chat_iface_init(PurpleProtocolChatInterface *chat_iface)
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1162 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1163 chat_iface->info = null_chat_info;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1164 chat_iface->info_defaults = null_chat_info_defaults;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1165 chat_iface->join = null_join_chat;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1166 chat_iface->reject = null_reject_chat;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1167 chat_iface->get_name = null_get_chat_name;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1168 chat_iface->invite = null_chat_invite;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1169 chat_iface->leave = null_chat_leave;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1170 chat_iface->send = null_chat_send;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1171 chat_iface->set_topic = null_set_chat_topic;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1172 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1173
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1174 static void
39757
4a5ba806d8c9 Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39483
diff changeset
1175 null_protocol_privacy_iface_init(PurpleProtocolPrivacyInterface *privacy_iface)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1176 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1177 privacy_iface->add_permit = null_add_permit;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1178 privacy_iface->add_deny = null_add_deny;
40521
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
1179 privacy_iface->remove_permit = null_remove_permit;
c4269b37a13a Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
1180 privacy_iface->remove_deny = null_remove_deny;
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1181 privacy_iface->set_permit_deny = null_set_permit_deny;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1182 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1183
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1184 static void
39757
4a5ba806d8c9 Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39483
diff changeset
1185 null_protocol_roomlist_iface_init(PurpleProtocolRoomlistInterface *roomlist_iface)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1186 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1187 roomlist_iface->get_list = null_roomlist_get_list;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1188 roomlist_iface->cancel = null_roomlist_cancel;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1189 roomlist_iface->expand_category = null_roomlist_expand_category;
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1190 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1191
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1192 /*
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1193 * define the null protocol type. this macro defines
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1194 * null_protocol_register_type(PurplePlugin *) which is called in plugin_load()
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1195 * to register this type with the type system, and null_protocol_get_type()
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1196 * which returns the registered GType.
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1197 */
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1198 G_DEFINE_DYNAMIC_TYPE_EXTENDED(
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1199 NullProtocol, null_protocol, PURPLE_TYPE_PROTOCOL, 0,
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1200
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1201 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CLIENT,
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1202 null_protocol_client_iface_init)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1203
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1204 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_SERVER,
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1205 null_protocol_server_iface_init)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1206
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1207 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_IM,
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1208 null_protocol_im_iface_init)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1209
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1210 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CHAT,
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1211 null_protocol_chat_iface_init)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1212
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1213 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_PRIVACY,
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1214 null_protocol_privacy_iface_init)
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1215
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1216 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_ROOMLIST,
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1217 null_protocol_roomlist_iface_init));
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1218
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1219 static PurpleProtocol *
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1220 null_protocol_new(void) {
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1221 return PURPLE_PROTOCOL(g_object_new(
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1222 NULL_TYPE_PROTOCOL,
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1223 "id", "prpl-null",
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1224 "name", "Null - Testing Protocol",
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1225 "options", OPT_PROTO_NO_PASSWORD | OPT_PROTO_CHAT_TOPIC,
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1226 NULL));
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1227 }
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1228
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
1229 static GPluginPluginInfo *
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
1230 null_query(GError **error)
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1231 {
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1232 return purple_plugin_info_new(
36985
9faafe43603e Rename protocol plugin IDs to prpl-*
Ankit Vani <a@nevitus.org>
parents: 36941
diff changeset
1233 "id", "prpl-null",
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
1234 "name", "Null Protocol",
36482
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1235 "version", DISPLAY_VERSION,
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1236 "category", N_("Protocol"),
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1237 "summary", N_("Null Protocol Plugin"),
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1238 "description", N_("Null Protocol Plugin"),
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1239 "website", PURPLE_WEBSITE,
36505
60c161851325 Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents: 36494
diff changeset
1240 "abi-version", PURPLE_ABI_VERSION,
36467
52aa83c47311 Replaced purple_plugin_loads_on_query() with purple_plugin_is_internal().
Ankit Vani <a@nevitus.org>
parents: 36463
diff changeset
1241
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1242 /* If you're using this protocol plugin as the basis of a plugin that will
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1243 * be distributed separately from libpurple, do not include these flags. */
36653
4084c34c051d Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
1244 "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
4084c34c051d Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
1245 PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1246 NULL
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1247 );
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1248 }
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1249
36458
a9cccad073e9 Static prpls now work. Added macro PURPLE_PLUGIN_INIT(plugin-name, query-func, load-func, unload-func).
Ankit Vani <a@nevitus.org>
parents: 36457
diff changeset
1250 static gboolean
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
1251 null_load(GPluginPlugin *plugin, GError **error)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1252 {
40800
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1253 PurpleProtocolManager *manager = purple_protocol_manager_get_default();
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1254
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1255 /* register the NULL_TYPE_PROTOCOL type in the type system. this function
39894
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1256 * is defined by G_DEFINE_DYNAMIC_TYPE_EXTENDED. */
7eab91ea30a1 Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39760
diff changeset
1257 null_protocol_register_type(G_TYPE_MODULE(plugin));
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1258
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1259 /* add the protocol to the core */
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40800
diff changeset
1260 my_protocol = null_protocol_new();
40800
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1261 if(!purple_protocol_manager_register(manager, my_protocol, error)) {
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1262 g_clear_object(&my_protocol);
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1263
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1264 return FALSE;
40800
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1265 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1266
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1267 purple_debug_info("nullprpl", "starting up\n");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1268
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1269 /* get ready to store offline messages */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1270 goffline_messages = g_hash_table_new_full(g_str_hash, /* hash fn */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1271 g_str_equal, /* key comparison fn */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1272 g_free, /* key free fn */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1273 NULL); /* value free fn */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1274
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1275 return TRUE;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1276 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1277
36458
a9cccad073e9 Static prpls now work. Added macro PURPLE_PLUGIN_INIT(plugin-name, query-func, load-func, unload-func).
Ankit Vani <a@nevitus.org>
parents: 36457
diff changeset
1278 static gboolean
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
1279 null_unload(GPluginPlugin *plugin, GError **error)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1280 {
40800
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1281 PurpleProtocolManager *manager = purple_protocol_manager_get_default();
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1282
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1283 purple_debug_info("nullprpl", "shutting down\n");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1284
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1285 /* remove the protocol from the core */
40800
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1286 if(!purple_protocol_manager_unregister(manager, my_protocol, error)) {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1287 return FALSE;
40800
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1288 }
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1289
be00e9c87cb7 Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
1290 g_clear_object(&my_protocol);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1291
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1292 return TRUE;
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1293 }
36458
a9cccad073e9 Static prpls now work. Added macro PURPLE_PLUGIN_INIT(plugin-name, query-func, load-func, unload-func).
Ankit Vani <a@nevitus.org>
parents: 36457
diff changeset
1294
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
1295 GPLUGIN_NATIVE_PLUGIN_DECLARE(null);

mercurial