libpurple/protocols/null/nullprpl.c

Tue, 27 Aug 2013 04:30:39 +0530

author
Ankit Vani <a@nevitus.org>
date
Tue, 27 Aug 2013 04:30:39 +0530
branch
soc.2013.gobjectification.plugins
changeset 36583
0582190c9382
parent 36555
fc17a4351e63
parent 34894
df5ed3731148
permissions
-rw-r--r--

Merged soc.2013.gobjectification branch

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,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
14 * privacy allow/block lists, chat rooms, whispering, room lists, and protocol
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
20 * demonstrate how to use the libpurple API to do pretty much everything a prpl
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
21 * 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>
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
48
24332
9c7586a57e1b Add a comment documenting the internal.h situation for people using nullprpl
Richard Laager <rlaager@pidgin.im>
parents: 24231
diff changeset
49 /* If you're using this as the basis of a prpl that will be distributed
9c7586a57e1b Add a comment documenting the internal.h situation for people using nullprpl
Richard Laager <rlaager@pidgin.im>
parents: 24231
diff changeset
50 * separately from libpurple, remove the internal.h include below and replace
9c7586a57e1b Add a comment documenting the internal.h situation for people using nullprpl
Richard Laager <rlaager@pidgin.im>
parents: 24231
diff changeset
51 * it with code to include your own config.h or similar. If you're going to
9c7586a57e1b Add a comment documenting the internal.h situation for people using nullprpl
Richard Laager <rlaager@pidgin.im>
parents: 24231
diff changeset
52 * provide for translation, you'll also need to setup the gettext macros. */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
53 #include "internal.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
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
55 #include "account.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
56 #include "accountopt.h"
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34699
diff changeset
57 #include "buddylist.h"
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
58 #include "cmds.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
59 #include "conversation.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
60 #include "connection.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
61 #include "debug.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
62 #include "notify.h"
36509
86e882c3cfdf Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
63 #include "plugins.h"
36543
a8c3fecee2d3 Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents: 36521
diff changeset
64 #include "protocol.h"
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
65 #include "roomlist.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
66 #include "status.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
67 #include "util.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
68 #include "version.h"
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
69
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
70 #define NULLPRPL_ID "prpl-null"
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
71 static PurpleProtocol *_null_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
72
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
73 #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
74 #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
75 #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
76
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
77 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
78 PurpleConnection *to,
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
81 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
82 GcFunc fn;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
83 PurpleConnection *from;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
84 gpointer userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
85 } GcFuncData;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
86
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 * stores offline messages that haven't been delivered yet. maps username
36494
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
89 * (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
90 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
91 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
92
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
93 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
94 char *from;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
95 char *message;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
96 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
97 PurpleMessageFlags flags;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
98 } GOfflineMessage;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
99
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
100 /*
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
101 * helpers
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
102 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
103 static PurpleConnection *get_nullprpl_gc(const char *username) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
104 PurpleAccount *acct = purple_accounts_find(username, NULLPRPL_ID);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
105 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
106 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
107 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
108 return NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
109 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
110
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
111 static void call_if_nullprpl(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
112 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
113 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
114
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
115 if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), NULLPRPL_ID))
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
116 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
117 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
118
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
119 static void foreach_nullprpl_gc(GcFunc 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
120 gpointer userdata) {
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
121 GcFuncData gcfdata = { fn, from, userdata };
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
122 g_list_foreach(purple_connections_get_all(), call_if_nullprpl,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
123 &gcfdata);
17451
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
126
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
127 typedef void(*ChatFunc)(PurpleChatConversation *from, PurpleChatConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
128 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
129
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
130 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
131 ChatFunc fn;
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
132 PurpleChatConversation *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
133 gpointer userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
134 } ChatFuncData;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
135
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
136 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
137 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
138 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
139
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
140 int id = purple_chat_conversation_get_id(cfdata->from_chat);
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
141 PurpleChatConversation *chat = purple_conversations_find_chat(to, id);
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
142 if (chat)
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
143 cfdata->fn(cfdata->from_chat, chat, id,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
144 purple_conversation_get_name(PURPLE_CONVERSATION(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
145 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
146
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
147 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
148 int id, gpointer userdata) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
149 PurpleChatConversation *chat = purple_conversations_find_chat(from, id);
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
150 ChatFuncData cfdata = { fn,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
151 chat,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
152 userdata };
17451
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 g_list_foreach(purple_connections_get_all(), call_chat_func,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
155 &cfdata);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
156 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
157
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
158
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
159 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
160 gpointer userdata) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
161 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
162 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
163
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
164 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
165 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
166 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
167 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
168
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
169 if (!strcmp(status_id, NULL_STATUS_ONLINE) ||
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
170 !strcmp(status_id, NULL_STATUS_AWAY) ||
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
171 !strcmp(status_id, 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
172 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
173 from_username, to_username, status_id, message);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
174 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
175 (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
176 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
177 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
178 "%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
179 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
180 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
181 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
182 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
183
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
184 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
185 gpointer userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
186 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
187 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
188 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
189 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
190
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
191
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
192 /*
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
193 * UI callbacks
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
194 */
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
195 static void nullprpl_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
196 {
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
197 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
198 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
199 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
200 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
201
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
202 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
203 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
204
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
205 /*
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
206 * prpl functions
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
207 */
36494
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
208 static GList *nullprpl_get_actions(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
209 {
36494
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
210 PurpleProtocolAction *action = purple_protocol_action_new(
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
211 _("Set User Info..."), nullprpl_input_user_info);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
212 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
213 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
214
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
215 static const char *nullprpl_list_icon(PurpleAccount *acct, PurpleBuddy *buddy)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
216 {
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
217 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
218 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
219
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
220 static char *nullprpl_status_text(PurpleBuddy *buddy) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
221 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
222 purple_buddy_get_name(buddy),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
223 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
224
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
225 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
226 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
227 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
228 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
229 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
230
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
231 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
232 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
233 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
234 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
235 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
236
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
237 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
238 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
239 return text;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
240
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
241 } else {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
242 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
243 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
244 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
245 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
246
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
247 static void nullprpl_tooltip_text(PurpleBuddy *buddy,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
248 PurpleNotifyUserInfo *info,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
249 gboolean full) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
250 PurpleConnection *gc = get_nullprpl_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
251
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
252 if (gc) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
253 /* 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
254 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
255 PurpleStatus *status = purple_presence_get_active_status(presence);
24865
053ddd0ba317 Small leak fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24862
diff changeset
256 char *msg = nullprpl_status_text(buddy);
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
257 /* 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
258 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
259 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
260 msg);
24865
053ddd0ba317 Small leak fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24862
diff changeset
261 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
262
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
263 if (full) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
264 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
265 if (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
266 /* 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
267 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
268 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
269 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
270
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
271 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
272 /* 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
273 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
274 }
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
275
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
276 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
277 (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
278 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
279
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
280 static GList *nullprpl_status_types(PurpleAccount *acct)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
281 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
282 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
283 PurpleStatusType *type;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
284
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
285 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
286 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
287 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
288
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
289 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
290 NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
291 "message", _("Message"), purple_g_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
292 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
293 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
294
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
295 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
296 NULL_STATUS_AWAY, NULL, TRUE, TRUE, FALSE,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
297 "message", _("Message"), purple_g_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
298 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
299 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
300
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
301 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
302 NULL_STATUS_OFFLINE, NULL, TRUE, TRUE, FALSE,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
303 "message", _("Message"), purple_g_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
304 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
305 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
306
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
307 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
308 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
309
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
310 static void blist_example_menu_item(PurpleBlistNode *node, gpointer userdata) {
22709
6bd336964410 Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
311 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
312 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
313
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
314 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
315 _("Primary title"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
316 _("Secondary title"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
317 _("This is the callback for the nullprpl menu item."));
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
320 static GList *nullprpl_blist_node_menu(PurpleBlistNode *node) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
321 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
322
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34671
diff changeset
323 if (PURPLE_IS_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
324 PurpleMenuAction *action = purple_menu_action_new(
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
325 _("Nullprpl 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
326 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
327 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
328 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
329 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
330 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
331 return NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
332 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
333 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
334
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
335 static GList *nullprpl_chat_info(PurpleConnection *gc) {
36555
fc17a4351e63 Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
336 PurpleProtocolChatEntry *pce; /* defined in protocol.h */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
337
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
338 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
339
36555
fc17a4351e63 Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
340 pce = g_new0(PurpleProtocolChatEntry, 1);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
341 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
342 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
343 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
344
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
345 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
346 }
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 static GHashTable *nullprpl_chat_info_defaults(PurpleConnection *gc,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
349 const char *room) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
350 GHashTable *defaults;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
351
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
352 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
353 "'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
354
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
355 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
356 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
357 return defaults;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
358 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
359
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
360 static void nullprpl_login(PurpleAccount *acct)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
361 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
362 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
363 GList *offline_messages;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
364
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
365 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
366
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
367 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
368 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
369 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
370
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
371 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
372 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
373 2); /* total number of steps */
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
374 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
375
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
376 /* tell purple about everyone on our buddy list who's connected */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
377 foreach_nullprpl_gc(discover_status, gc, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
378
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
379 /* notify other nullprpl accounts */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
380 foreach_nullprpl_gc(report_status_change, gc, NULL);
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 /* 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
383 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
384 purple_account_get_username(acct));
547eacef0b63 Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32618
diff changeset
385 offline_messages = g_hash_table_lookup(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
386 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
387 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
388 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
389 purple_account_get_username(acct), 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
390 serv_got_im(gc, message->from, message->message, message->flags,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
391 message->mtime);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
392 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
393
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
394 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
395 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
396 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
397 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
398
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
399 g_list_free(offline_messages);
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
400 g_hash_table_remove(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
401 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
402
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
403 static void nullprpl_close(PurpleConnection *gc)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
404 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
405 /* notify other nullprpl accounts */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
406 foreach_nullprpl_gc(report_status_change, gc, NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
407 }
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 static int nullprpl_send_im(PurpleConnection *gc, const char *who,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
410 const char *message, PurpleMessageFlags flags)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
411 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
412 const char *from_username = 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
413 PurpleMessageFlags receive_flags = ((flags & ~PURPLE_MESSAGE_SEND)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
414 | PURPLE_MESSAGE_RECV);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
415 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
416 PurpleConnection *to;
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 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
419 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
420
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
421 /* 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
422 if (to_acct &&
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
423 !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
424 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
425 _("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
426 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
427 "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
428 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
429 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
430 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
431 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
432 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
433
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
434 /* is the recipient online? */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
435 to = get_nullprpl_gc(who);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
436 if (to) { /* yes, send */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
437 serv_got_im(to, from_username, message, receive_flags, time(NULL));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
438
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
439 } 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
440 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
441 GList *messages;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
442
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
443 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
444 "%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
445 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
446 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
447 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
448 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
449 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
450
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
451 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
452 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
453 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
454 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
455
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
456 return 1;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
457 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
458
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
459 static void nullprpl_set_info(PurpleConnection *gc, const char *info) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
460 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
461 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
462 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
463
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
464 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
465 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
466 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
467 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
468 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
469 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
470 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
471 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
472
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
473 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
474 gpointer typing) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
475 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
476 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
477 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
478 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
479
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
480 serv_got_typing(to,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
481 from_username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
482 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
483 * 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
484 (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
485 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
486
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
487 static unsigned int nullprpl_send_typing(PurpleConnection *gc, const char *name,
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
488 PurpleIMTypingState typing) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
489 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
490 typing_state_to_string(typing));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
491 foreach_nullprpl_gc(notify_typing, gc, (gpointer)typing);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
492 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
493 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
494
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
495 static void nullprpl_get_info(PurpleConnection *gc, const char *username) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
496 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
497 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
498 PurpleAccount *acct;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
499
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
500 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
501 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
502
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
503 if (!get_nullprpl_gc(username)) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
504 char *msg = g_strdup_printf(_("%s is not logged in."), username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
505 purple_notify_error(gc, _("User Info"), _("User info not available. "), msg);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
506 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
507 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
508
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
509 acct = purple_accounts_find(username, NULLPRPL_ID);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
510 if (acct)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
511 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
512 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
513 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
514 /* 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
515 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
516 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
517
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
518 /* 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
519 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
520 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
521 info, /* body */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
522 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
523 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
524 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
525
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
526 static void nullprpl_set_status(PurpleAccount *acct, PurpleStatus *status) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
527 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
528 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
529 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
530
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
531 foreach_nullprpl_gc(report_status_change, get_nullprpl_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
532 NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
533 }
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 static void nullprpl_set_idle(PurpleConnection *gc, int idletime) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
536 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
537 "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
538 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
539 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
540
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
541 static void nullprpl_change_passwd(PurpleConnection *gc, const char *old_pass,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
542 const char *new_pass) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
543 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
544 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
545 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
546
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
547 static void nullprpl_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
32315
2550a39e0285 Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32263
diff changeset
548 PurpleGroup *group, const char *message)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
549 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
550 const char *username = purple_account_get_username(purple_connection_get_account(gc));
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
551 PurpleConnection *buddy_gc = get_nullprpl_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
552
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
553 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
554 username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
555
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
556 if (buddy_gc) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
557 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
558
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
559 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
560
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
561 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
562 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
563 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
564 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
565 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
566 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
567 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
568 username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
569 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
570 NULL, /* alias */
32315
2550a39e0285 Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32263
diff changeset
571 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
572 }
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 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
575
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
576 static void nullprpl_add_buddies(PurpleConnection *gc, GList *buddies,
32315
2550a39e0285 Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32263
diff changeset
577 GList *groups, const char *message) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
578 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
579 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
580
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
581 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
582
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
583 while (buddy && group) {
32315
2550a39e0285 Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32263
diff changeset
584 nullprpl_add_buddy(gc, (PurpleBuddy *)buddy->data, (PurpleGroup *)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
585 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
586 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
587 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
588 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
589
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
590 static void nullprpl_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
591 PurpleGroup *group)
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 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
594 purple_buddy_get_name(buddy),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
595 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
596 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
597
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
598 static void nullprpl_remove_buddies(PurpleConnection *gc, GList *buddies,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
599 GList *groups) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
600 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
601 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
602
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
603 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
604
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
605 while (buddy && group) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
606 nullprpl_remove_buddy(gc, (PurpleBuddy *)buddy->data,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
607 (PurpleGroup *)group->data);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
608 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
609 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
610 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
611 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
612
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
613 /*
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
614 * nullprpl uses purple's local whitelist and blacklist, stored in blist.xml, as
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
615 * 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
616 * 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
617 * 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
618 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
619 static void nullprpl_add_permit(PurpleConnection *gc, const char *name) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
620 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
621 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
622 }
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 static void nullprpl_add_deny(PurpleConnection *gc, const char *name) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
625 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
626 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
627 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
628
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
629 static void nullprpl_rem_permit(PurpleConnection *gc, const char *name) {
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", "%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
631 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
632 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
633
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
634 static void nullprpl_rem_deny(PurpleConnection *gc, const char *name) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
635 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
636 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
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 static void nullprpl_set_permit_deny(PurpleConnection *gc) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
640 /* this is for synchronizing the local black/whitelist with the server.
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
641 * for nullprpl, it's a noop.
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
642 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
643 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
644
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
645 static void joined_chat(PurpleChatConversation *from, PurpleChatConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
646 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
647 /* 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
648 purple_debug_info("nullprpl", "%s sees that %s joined chat room %s\n",
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
649 purple_chat_conversation_get_nick(to), purple_chat_conversation_get_nick(from), room);
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
650 purple_chat_conversation_add_user(to,
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
651 purple_chat_conversation_get_nick(from),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
652 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
653 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
654 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
655
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
656 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
657 /* 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
658 purple_debug_info("nullprpl", "%s sees that %s is in chat room %s\n",
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
659 purple_chat_conversation_get_nick(from), purple_chat_conversation_get_nick(to), room);
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
660 purple_chat_conversation_add_user(from,
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
661 purple_chat_conversation_get_nick(to),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
662 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
663 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
664 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
665 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
666 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
667
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
668 static void nullprpl_join_chat(PurpleConnection *gc, GHashTable *components) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
669 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
670 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
671 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
672 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
673
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
674 if (!purple_conversations_find_chat(gc, chat_id)) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
675 serv_got_joined_chat(gc, chat_id, room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
676
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
677 /* 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
678 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
679 } else {
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
680 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
681 username,
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
682 room);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
683 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
684 room);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
685 purple_notify_info(gc, _("Join chat"), _("Join chat"), tmp);
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
686 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
687 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
688 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
689
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
690 static void nullprpl_reject_chat(PurpleConnection *gc, 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
691 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
692 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
693 const char *username = 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
694 PurpleConnection *invited_by_gc = get_nullprpl_gc(invited_by);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
695 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
696 "%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
697 username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
698 _("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
699 room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
700
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
701 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
702 "%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
703 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
704
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
705 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
706 _("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
707 _("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
708 message);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
709 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
710 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
711
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
712 static char *nullprpl_get_chat_name(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
713 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
714 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
715 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
716 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
717
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
718 static void nullprpl_chat_invite(PurpleConnection *gc, int id,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
719 const char *message, const char *who) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
720 const char *username = purple_account_get_username(purple_connection_get_account(gc));
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
721 PurpleChatConversation *chat = purple_conversations_find_chat(gc, id);
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
722 const char *room = purple_conversation_get_name(PURPLE_CONVERSATION(chat));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
723 PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
724
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
725 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
726 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
727
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
728 if (to_acct) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
729 PurpleChatConversation *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
730 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
731 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
732 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
733 "%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
734 "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
735 who, room, username);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
736 purple_notify_info(gc, _("Chat invitation"), _("Chat invitation"), tmp);
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
737 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
738 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
739 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
740 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
741 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
742 g_hash_table_replace(components, "invited_by", g_strdup(username));
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
743 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
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 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
747
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
748 static void left_chat_room(PurpleChatConversation *from, PurpleChatConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
749 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
750 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
751 /* 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
752 purple_debug_info("nullprpl", "%s sees that %s left chat room %s\n",
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
753 purple_chat_conversation_get_nick(to), purple_chat_conversation_get_nick(from), room);
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
754 purple_chat_conversation_remove_user(to,
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
755 purple_chat_conversation_get_nick(from),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
756 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
757 }
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
760 static void nullprpl_chat_leave(PurpleConnection *gc, int id) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
761 PurpleChatConversation *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
762 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
763 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
764 purple_conversation_get_name(PURPLE_CONVERSATION(chat)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
765
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
766 /* 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
767 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
768 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
769
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
770 static PurpleCmdRet send_whisper(PurpleConversation *conv, const gchar *cmd,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
771 gchar **args, gchar **error, void *userdata) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
772 const char *to_username;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
773 const char *message;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
774 const char *from_username;
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
775 PurpleChatUser *chat_user;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
776 PurpleConnection *to;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
777
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
778 /* parse args */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
779 to_username = args[0];
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
780 message = args[1];
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
781
32190
7881925d0929 Don't use strlen() when you're just checking whether a string is
Mark Doliner <markdoliner@pidgin.im>
parents: 32189
diff changeset
782 if (!to_username || !*to_username) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
783 *error = g_strdup(_("Whisper is missing recipient."));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
784 return PURPLE_CMD_RET_FAILED;
32190
7881925d0929 Don't use strlen() when you're just checking whether a string is
Mark Doliner <markdoliner@pidgin.im>
parents: 32189
diff changeset
785 } else 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
786 *error = g_strdup(_("Whisper is missing message."));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
787 return PURPLE_CMD_RET_FAILED;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
788 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
789
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
790 from_username = purple_account_get_username(purple_conversation_get_account(conv));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
791 purple_debug_info("nullprpl", "%s whispers to %s in chat room %s: %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
792 from_username, to_username,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
793 purple_conversation_get_name(conv), message);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
794
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
795 chat_user = purple_chat_conversation_find_user(PURPLE_CHAT_CONVERSATION(conv), to_username);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
796 to = get_nullprpl_gc(to_username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
797
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
798 if (!chat_user) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
799 /* this will be freed by the caller */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
800 *error = g_strdup_printf(_("%s is not logged in."), to_username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
801 return PURPLE_CMD_RET_FAILED;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
802 } else if (!to) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
803 *error = g_strdup_printf(_("%s is not in this chat room."), to_username);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
804 return PURPLE_CMD_RET_FAILED;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
805 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
806 /* write the whisper in the sender's chat window */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
807 char *message_to = g_strdup_printf("%s (to %s)", message, to_username);
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
808 purple_conversation_write_message(conv, from_username, message_to,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
809 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
810 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
811 g_free(message_to);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
812
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
813 /* send the whisper */
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
814 serv_chat_whisper(to, purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
815 from_username, message);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
816
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
817 return PURPLE_CMD_RET_OK;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
818 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
819 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
820
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
821 static void nullprpl_chat_whisper(PurpleConnection *gc, int id, const char *who,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
822 const char *message) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
823 const char *username = purple_account_get_username(purple_connection_get_account(gc));
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
824 PurpleChatConversation *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
825 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
826 "%s receives whisper from %s in chat room %s: %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
827 username, who, 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
828 message);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
829
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
830 /* receive whisper on recipient's account */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
831 serv_got_chat_in(gc, id, who, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_WHISPER,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
832 message, time(NULL));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
833 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
834
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
835 static void receive_chat_message(PurpleChatConversation *from, PurpleChatConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
836 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
837 const char *message = (const char *)userdata;
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
838 PurpleConnection *to_gc = get_nullprpl_gc(purple_chat_conversation_get_nick(to));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
839
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
840 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
841 "%s receives message from %s in chat room %s: %s\n",
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
842 purple_chat_conversation_get_nick(to), purple_chat_conversation_get_nick(from), room, message);
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
843 serv_got_chat_in(to_gc, id, purple_chat_conversation_get_nick(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
844 time(NULL));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
845 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
846
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
847 static int nullprpl_chat_send(PurpleConnection *gc, int id, const char *message,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
848 PurpleMessageFlags flags) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
849 const char *username = purple_account_get_username(purple_connection_get_account(gc));
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
850 PurpleChatConversation *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
851
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
852 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
853 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
854 "%s is sending message to chat room %s: %s\n", username,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
855 purple_conversation_get_name(PURPLE_CONVERSATION(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
856
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
857 /* 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
858 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
859 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
860 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
861 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
862 "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
863 "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
864 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
865 return -1;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
866 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
867 }
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 static void nullprpl_register_user(PurpleAccount *acct) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
870 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
871 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
872 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
873
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
874 static void nullprpl_get_cb_info(PurpleConnection *gc, int id, const char *who) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
875 PurpleChatConversation *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
876 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
877 "retrieving %s's info for %s in chat room %s\n", who,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
878 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
879 purple_conversation_get_name(PURPLE_CONVERSATION(chat)));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
880
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
881 nullprpl_get_info(gc, who);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
882 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
883
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
884 static void nullprpl_alias_buddy(PurpleConnection *gc, const char *who,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
885 const char *alias) {
22709
6bd336964410 Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
886 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
887 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
888 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
889
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
890 static void nullprpl_group_buddy(PurpleConnection *gc, const char *who,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
891 const char *old_group,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
892 const char *new_group) {
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", "%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
894 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
895 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
896
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
897 static void nullprpl_rename_group(PurpleConnection *gc, const char *old_name,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
898 PurpleGroup *group, GList *moved_buddies) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
899 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
900 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
901 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
902 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
903
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
904 static void nullprpl_convo_closed(PurpleConnection *gc, const char *who) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
905 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
906 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
907 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
908
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
909 /* normalize a username (e.g. remove whitespace, add default domain, etc.)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
910 * for nullprpl, 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
911 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
912 static const char *nullprpl_normalize(const PurpleAccount *acct,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
913 const char *input) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
914 return NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
915 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
916
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
917 static void nullprpl_set_buddy_icon(PurpleConnection *gc,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
918 PurpleStoredImage *img) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
919 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
920 purple_account_get_username(purple_connection_get_account(gc)),
25745
48b7ebd7fcc7 Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents: 24865
diff changeset
921 img ? purple_imgstore_get_filename(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
922 }
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 static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
925 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
926 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
927 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
928 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
929
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
930
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
931 static void set_chat_topic_fn(PurpleChatConversation *from, PurpleChatConversation *to,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
932 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
933 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
934 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
935 char *msg;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
936
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
937 purple_chat_conversation_set_topic(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
938
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
939 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
940 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
941 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
942 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
943
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
944 purple_conversation_write_message(PURPLE_CONVERSATION(to), username, msg,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
945 PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
946 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
947 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
948 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
949
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
950 static void nullprpl_set_chat_topic(PurpleConnection *gc, int id,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
951 const char *topic) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
952 PurpleChatConversation *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
953 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
954
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
955 if (!chat)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
956 return;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
957
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
958 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
959 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
960 purple_conversation_get_name(PURPLE_CONVERSATION(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
961
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
962 last_topic = purple_chat_conversation_get_topic(chat);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
963 if ((!topic && !last_topic) ||
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
964 (topic && last_topic && !strcmp(topic, last_topic)))
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
965 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
966
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
967 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
968 }
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 static gboolean nullprpl_finish_get_roomlist(gpointer roomlist) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
971 purple_roomlist_set_in_progress((PurpleRoomlist *)roomlist, FALSE);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
972 return FALSE;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
973 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
974
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
975 static PurpleRoomlist *nullprpl_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
976 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
977 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
978 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
979 PurpleRoomlistField *field;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
980 GList *chats;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
981 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
982
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
983 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
984
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
985 /* 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
986 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
987 "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
988 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
989
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
990 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
991 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
992
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
993 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
994
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
995 /* 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
996 * 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
997 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
998 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
999 PurpleRoomlistRoom *room;
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
1000 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
1001 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
1002
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1003 /* 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
1004 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
1005 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
1006
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1007 /* 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
1008 * of this function and none of the conversations are being deleted
29977
94b2a6686bfb nullprpl: Whitespace
Paul Aurich <darkrain42@pidgin.im>
parents: 29795
diff changeset
1009 * 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
1010 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
1011 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
1012
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1013 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
1014 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
1015 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
1016 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
1017 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1018
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1019 g_list_free(seen_ids);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1020 purple_timeout_add(1 /* ms */, nullprpl_finish_get_roomlist, roomlist);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1021 return roomlist;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1022 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1023
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1024 static void nullprpl_roomlist_cancel(PurpleRoomlist *list) {
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1025 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
1026 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
1027 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
1028 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1029
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1030 static void nullprpl_roomlist_expand_category(PurpleRoomlist *list,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1031 PurpleRoomlistRoom *category) {
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1032 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
1033 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
1034 purple_account_get_username(account),
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1035 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
1036 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1037
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1038 /* nullprpl doesn't support file transfer...yet... */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1039 static gboolean nullprpl_can_receive_file(PurpleConnection *gc,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1040 const char *who) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1041 return FALSE;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1042 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1043
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1044 static gboolean nullprpl_offline_message(const PurpleBuddy *buddy) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1045 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
1046 "reporting that offline messages are supported for %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
1047 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
1048 return TRUE;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1049 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1050
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1051
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1052 /*
36543
a8c3fecee2d3 Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents: 36521
diff changeset
1053 * Protocol stuff. 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
1054 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1055
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
1056 static PurpleProtocol protocol =
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1057 {
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1058 NULLPRPL_ID, /* id */
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1059 "Null - Testing protocol", /* name */
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
1060 sizeof(PurpleProtocol), /* struct_size */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1061 OPT_PROTO_NO_PASSWORD | OPT_PROTO_CHAT_TOPIC, /* options */
36494
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
1062 NULL, /* user_splits, initialized in plugin_load() */
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
1063 NULL, /* protocol_options, 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
1064 { /* icon_spec, a PurpleBuddyIconSpec */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1065 "png,jpg,gif", /* format */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1066 0, /* min_width */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1067 0, /* min_height */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1068 128, /* max_width */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1069 128, /* max_height */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1070 10000, /* max_filesize */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1071 PURPLE_ICON_SCALE_DISPLAY, /* scale_rules */
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
1072 },
36494
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
1073 nullprpl_get_actions, /* get_actions */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1074 nullprpl_list_icon, /* list_icon */
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1075 NULL, /* list_emblem */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1076 nullprpl_status_text, /* status_text */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1077 nullprpl_tooltip_text, /* tooltip_text */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1078 nullprpl_status_types, /* status_types */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1079 nullprpl_blist_node_menu, /* blist_node_menu */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1080 nullprpl_chat_info, /* chat_info */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1081 nullprpl_chat_info_defaults, /* chat_info_defaults */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1082 nullprpl_login, /* login */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1083 nullprpl_close, /* close */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1084 nullprpl_send_im, /* send_im */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1085 nullprpl_set_info, /* set_info */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1086 nullprpl_send_typing, /* send_typing */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1087 nullprpl_get_info, /* get_info */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1088 nullprpl_set_status, /* set_status */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1089 nullprpl_set_idle, /* set_idle */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1090 nullprpl_change_passwd, /* change_passwd */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1091 nullprpl_add_buddy, /* add_buddy */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1092 nullprpl_add_buddies, /* add_buddies */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1093 nullprpl_remove_buddy, /* remove_buddy */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1094 nullprpl_remove_buddies, /* remove_buddies */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1095 nullprpl_add_permit, /* add_permit */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1096 nullprpl_add_deny, /* add_deny */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1097 nullprpl_rem_permit, /* rem_permit */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1098 nullprpl_rem_deny, /* rem_deny */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1099 nullprpl_set_permit_deny, /* set_permit_deny */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1100 nullprpl_join_chat, /* join_chat */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1101 nullprpl_reject_chat, /* reject_chat */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1102 nullprpl_get_chat_name, /* get_chat_name */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1103 nullprpl_chat_invite, /* chat_invite */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1104 nullprpl_chat_leave, /* chat_leave */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1105 nullprpl_chat_whisper, /* chat_whisper */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1106 nullprpl_chat_send, /* chat_send */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1107 NULL, /* keepalive */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1108 nullprpl_register_user, /* register_user */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1109 nullprpl_get_cb_info, /* get_cb_info */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1110 nullprpl_alias_buddy, /* alias_buddy */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1111 nullprpl_group_buddy, /* group_buddy */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1112 nullprpl_rename_group, /* rename_group */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1113 NULL, /* buddy_free */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1114 nullprpl_convo_closed, /* convo_closed */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1115 nullprpl_normalize, /* normalize */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1116 nullprpl_set_buddy_icon, /* set_buddy_icon */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1117 nullprpl_remove_group, /* remove_group */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1118 NULL, /* get_cb_real_name */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1119 nullprpl_set_chat_topic, /* set_chat_topic */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1120 NULL, /* find_blist_chat */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1121 nullprpl_roomlist_get_list, /* roomlist_get_list */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1122 nullprpl_roomlist_cancel, /* roomlist_cancel */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1123 nullprpl_roomlist_expand_category, /* roomlist_expand_category */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1124 nullprpl_can_receive_file, /* can_receive_file */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1125 NULL, /* send_file */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1126 NULL, /* new_xfer */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1127 nullprpl_offline_message, /* offline_message */
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1128 NULL, /* whiteboard_protocol_ops */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1129 NULL, /* send_raw */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1130 NULL, /* roomlist_room_serialize */
22071
4c47e360e467 Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22069
diff changeset
1131 NULL, /* unregister_user */
4c47e360e467 Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22069
diff changeset
1132 NULL, /* send_attention */
4c47e360e467 Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22069
diff changeset
1133 NULL, /* get_attention_types */
29977
94b2a6686bfb nullprpl: Whitespace
Paul Aurich <darkrain42@pidgin.im>
parents: 29795
diff changeset
1134 NULL, /* get_account_text_table */
29795
051ad81c3d19 Warning fix
Daniel Atallah <datallah@pidgin.im>
parents: 27361
diff changeset
1135 NULL, /* initiate_media */
051ad81c3d19 Warning fix
Daniel Atallah <datallah@pidgin.im>
parents: 27361
diff changeset
1136 NULL, /* get_media_caps */
31593
063dfdf8faf9 Fix comment order.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
1137 NULL, /* get_moods */
30138
cca9685df785 Add purple_account_[gs]et_public_alias functions, per discussion in d@cpi
Paul Aurich <darkrain42@pidgin.im>
parents: 29977
diff changeset
1138 NULL, /* set_public_alias */
34312
4461d5c1e61c Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32678
diff changeset
1139 NULL, /* get_public_alias */
4461d5c1e61c Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32678
diff changeset
1140 NULL /* get_max_message_size */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1141 };
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1142
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
1143 static PurplePluginInfo *
36486
b5167dc125f5 Plugins can return an error when failing to load
Ankit Vani <a@nevitus.org>
parents: 36482
diff changeset
1144 plugin_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
1145 {
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1146 return purple_plugin_info_new(
36482
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1147 "id", NULLPRPL_ID,
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1148 "name", "Null - Testing Plugin",
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1149 "version", DISPLAY_VERSION,
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1150 "category", N_("Protocol"),
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1151 "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
1152 "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
1153 "website", PURPLE_WEBSITE,
36505
60c161851325 Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents: 36494
diff changeset
1154 "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
1155
52aa83c47311 Replaced purple_plugin_loads_on_query() with purple_plugin_is_internal().
Ankit Vani <a@nevitus.org>
parents: 36463
diff changeset
1156 /* If you're using this as the basis of a protocol plugin that will be
52aa83c47311 Replaced purple_plugin_loads_on_query() with purple_plugin_is_internal().
Ankit Vani <a@nevitus.org>
parents: 36463
diff changeset
1157 * distributed separately from libpurple, do not include these flags.*/
36482
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1158 "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1159 GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY,
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1160 NULL
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1161 );
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1162 }
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1163
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
1164 static gboolean
36486
b5167dc125f5 Plugins can return an error when failing to load
Ankit Vani <a@nevitus.org>
parents: 36482
diff changeset
1165 plugin_load(PurplePlugin *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
1166 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1167 /* see accountopt.h for information about user splits and protocol options */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1168 PurpleAccountUserSplit *split = purple_account_user_split_new(
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1169 _("Example user split"), /* text shown to user */
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1170 "default", /* default value */
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1171 '@'); /* field separator */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1172 PurpleAccountOption *option = purple_account_option_string_new(
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1173 _("Example option"), /* text shown to user */
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1174 "example", /* pref name */
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1175 "default"); /* default value */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1176
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1177 purple_debug_info("nullprpl", "starting up\n");
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1178
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
1179 protocol.user_splits = g_list_append(NULL, split);
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
1180 protocol.protocol_options = g_list_append(NULL, option);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1181
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1182 /* register whisper chat command, /msg */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1183 purple_cmd_register("msg",
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1184 "ws", /* args: recipient and message */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1185 PURPLE_CMD_P_DEFAULT, /* priority */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1186 PURPLE_CMD_FLAG_CHAT,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1187 "prpl-null",
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1188 send_whisper,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1189 "msg &lt;username&gt; &lt;message&gt;: send a private message, aka a whisper",
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
1190 NULL); /* userdata */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1191
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1192 /* 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
1193 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
1194 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
1195 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
1196 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
1197
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
1198 _null_protocol = &protocol;
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1199 purple_protocols_add(_null_protocol);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1200
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1201 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
1202 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1203
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
1204 static gboolean
36486
b5167dc125f5 Plugins can return an error when failing to load
Ankit Vani <a@nevitus.org>
parents: 36482
diff changeset
1205 plugin_unload(PurplePlugin *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
1206 {
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1207 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
1208
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1209 purple_protocols_remove(_null_protocol);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1210
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1211 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
1212 }
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
1213
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
1214 PURPLE_PLUGIN_INIT(null, plugin_query, plugin_load, plugin_unload);

mercurial