libpurple/protocols/null/nullprpl.c

Fri, 31 Jan 2014 19:01:27 +0530

author
Ankit Vani <a@nevitus.org>
date
Fri, 31 Jan 2014 19:01:27 +0530
branch
soc.2013.gobjectification.plugins
changeset 37038
8832d14d7d0c
parent 37009
05ef6e29ea04
child 37101
8ba9a23354ff
permissions
-rw-r--r--

Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Avoid confusion with the 'options' field

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 *
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
8 * Nullprpl is a mock protocol plugin for Pidgin and libpurple. You can create
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
9 * accounts with it, sign on and off, add buddies, and send and receive IMs,
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
10 * all without connecting to a server!
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
11 *
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
12 * Beyond that basic functionality, nullprpl supports presence and
17451
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 *
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
18 * Nullprpl is intended as an example of how to write a libpurple protocol
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
19 * plugin. It doesn't contain networking code or an event loop, but it does
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
20 * demonstrate how to use the libpurple API to do pretty much everything a
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
21 * protocol might need to do.
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
22 *
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
23 * Nullprpl is also a useful tool for hacking on Pidgin, Finch, and other
17451
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
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
49 /* If you're using this as the basis of a protocol that will be distributed
24332
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
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
55 #include "nullprpl.h"
36657
4a7f5f97d1ec Make sure internal.h is included first
Ankit Vani <a@nevitus.org>
parents: 36653
diff changeset
56
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
57 #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
58 #include "accountopt.h"
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34699
diff changeset
59 #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
60 #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
61 #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
62 #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
63 #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
64 #include "notify.h"
36509
86e882c3cfdf Refactored libpurple according to the changes
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
65 #include "plugins.h"
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
66 #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
67 #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
68 #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
69 #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
70
36663
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
71 /*
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
72 * reference to the protocol instance, used for registering signals, prefs,
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
73 * etc. it is set when the protocol is added in plugin_load and is required
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
74 * for removing the protocol in plugin_unload.
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
75 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
76 static PurpleProtocol *my_protocol = NULL;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
77
36663
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
78 /*
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
79 * list of commands registered by the protocol, used to unregister the commands
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
80 * when the protocol is removed.
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
81 */
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
82 static GSList *cmds = NULL;
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
83
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
84 #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
85 #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
86 #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
87
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
88 typedef 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
89 PurpleConnection *to,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
90 gpointer userdata);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
91
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
92 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
93 GcFunc fn;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
94 PurpleConnection *from;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
95 gpointer userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
96 } GcFuncData;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
97
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
98 /*
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
99 * stores offline messages that haven't been delivered yet. maps username
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
100 * (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
101 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
102 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
103
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
104 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
105 char *from;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
106 char *message;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
107 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
108 PurpleMessageFlags flags;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
109 } GOfflineMessage;
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 /*
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
112 * helpers
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
113 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
114 static PurpleConnection *get_null_gc(const char *username) {
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
115 PurpleAccount *acct = purple_accounts_find(username, "null");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
116 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
117 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
118 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
119 return NULL;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
120 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
121
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
122 static void call_if_nullprotocol(gpointer data, gpointer userdata) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
123 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
124 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
125
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
126 if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), "null"))
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
127 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
128 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
129
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
130 static void foreach_null_gc(GcFunc fn, PurpleConnection *from,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
131 gpointer userdata) {
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
132 GcFuncData gcfdata = { fn, from, userdata };
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
133 g_list_foreach(purple_connections_get_all(), call_if_nullprotocol,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
134 &gcfdata);
17451
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
137
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
138 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
139 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
140
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
141 typedef struct {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
142 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
143 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
144 gpointer userdata;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
145 } ChatFuncData;
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 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
148 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
149 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
150
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
151 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
152 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
153 if (chat)
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
154 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
155 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
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 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
159 int id, gpointer userdata) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
160 PurpleChatConversation *chat = purple_conversations_find_chat(from, id);
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
161 ChatFuncData cfdata = { fn,
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
162 chat,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
163 userdata };
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
164
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
165 g_list_foreach(purple_connections_get_all(), call_chat_func,
17452
3d8aed6247d0 Minor changes:
Richard Laager <rlaager@pidgin.im>
parents: 17451
diff changeset
166 &cfdata);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
167 }
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
170 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
171 gpointer userdata) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
172 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
173 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
174
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
175 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
176 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
177 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
178 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
179
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
180 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
181 !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
182 !strcmp(status_id, NULL_STATUS_OFFLINE)) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
183 purple_debug_info("nullprpl", "%s sees that %s is %s: %s\n",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
184 from_username, to_username, status_id, message);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
185 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
186 (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
187 } else {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
188 purple_debug_error("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
189 "%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
190 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
191 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
192 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
193 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
194
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
195 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
196 gpointer userdata) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
197 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
198 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
199 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
200 }
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
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
203 /*
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
204 * UI callbacks
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
205 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
206 static void null_input_user_info(PurpleProtocolAction *action)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
207 {
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
208 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
209 PurpleAccount *acct = purple_connection_get_account(gc);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
210 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
211 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
212
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
213 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
214 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
215
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
216 /*
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36628
diff changeset
217 * Protocol functions
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
218 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
219 static GList *null_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
220 {
36494
40bae9b0c9fc Updated nullprpl according to the changes
Ankit Vani <a@nevitus.org>
parents: 36486
diff changeset
221 PurpleProtocolAction *action = purple_protocol_action_new(
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
222 _("Set User Info..."), null_input_user_info);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
223 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
224 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
225
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
226 static const char *null_list_icon(PurpleAccount *acct, PurpleBuddy *buddy)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
227 {
25002
40a1b3360a50 Various nullprpl fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24332
diff changeset
228 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
229 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
230
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
231 static char *null_status_text(PurpleBuddy *buddy) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
232 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
233 purple_buddy_get_name(buddy),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
234 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
235
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
236 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
237 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
238 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
239 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
240 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
241
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
242 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
243 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
244 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
245 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
246 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
247
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
248 purple_debug_info("nullprpl", "%s's status text is %s\n",
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
249 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
250 return text;
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 } else {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
253 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
254 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
255 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
256 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
257
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
258 static void null_tooltip_text(PurpleBuddy *buddy,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
259 PurpleNotifyUserInfo *info,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
260 gboolean full) {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
261 PurpleConnection *gc = get_null_gc(purple_buddy_get_name(buddy));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
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 (gc) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
264 /* 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
265 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
266 PurpleStatus *status = purple_presence_get_active_status(presence);
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
267 char *msg = null_status_text(buddy);
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
268 /* TODO: Check whether it's correct to call add_pair_html,
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
269 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
270 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
271 msg);
24865
053ddd0ba317 Small leak fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24862
diff changeset
272 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
273
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
274 if (full) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
275 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
276 if (user_info)
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
277 /* TODO: Check whether it's correct to call add_pair_html,
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
278 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
279 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
280 }
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 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
283 /* 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
284 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
285 }
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
286
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
287 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
288 (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
289 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
290
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
291 static GList *null_status_types(PurpleAccount *acct)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
292 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
293 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
294 PurpleStatusType *type;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
295
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
296 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
297 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
298 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
299
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
300 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
301 NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34991
diff changeset
302 "message", _("Message"), purple_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
303 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
304 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
305
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
306 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
307 NULL_STATUS_AWAY, NULL, TRUE, TRUE, FALSE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34991
diff changeset
308 "message", _("Message"), purple_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
309 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
310 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
311
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
312 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
313 NULL_STATUS_OFFLINE, NULL, TRUE, TRUE, FALSE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34991
diff changeset
314 "message", _("Message"), purple_value_new(G_TYPE_STRING),
25890
26bb4211aa76 Deprecate some functions that aren't really needed
Mark Doliner <markdoliner@pidgin.im>
parents: 25119
diff changeset
315 NULL);
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
316 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
317
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
318 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
319 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
320
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
321 static void blist_example_menu_item(PurpleBlistNode *node, gpointer userdata) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
322 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
323 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
324
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
325 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
326 _("Primary title"),
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
327 _("Secondary title"),
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
328 _("This is the callback for the NullProtocol menu item."),
36838
9dd39a792240 Merged soc.2013.gobjectification branch
Ankit Vani <a@nevitus.org>
parents: 34977 36731
diff changeset
329 NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
330 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
331
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
332 static GList *null_blist_node_menu(PurpleBlistNode *node) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
333 purple_debug_info("nullprpl", "providing buddy list context menu item\n");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
334
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34671
diff changeset
335 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
336 PurpleMenuAction *action = purple_menu_action_new(
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
337 _("NullProtocol example menu item"),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
338 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
339 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
340 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
341 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
342 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
343 return NULL;
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 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
346
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
347 static GList *null_chat_info(PurpleConnection *gc) {
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
348 PurpleProtocolChatEntry *pce; /* defined in protocols.h */
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
349
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
350 purple_debug_info("nullprpl", "returning chat setting 'room'\n");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
351
36555
fc17a4351e63 Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
352 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
353 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
354 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
355 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
356
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
357 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
358 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
359
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
360 static GHashTable *null_chat_info_defaults(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
361 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
362 GHashTable *defaults;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
363
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
364 purple_debug_info("nullprpl", "returning chat default setting "
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
365 "'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
366
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
367 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
368 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
369 return defaults;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30138
diff changeset
370 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
371
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
372 static void null_login(PurpleAccount *acct)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
373 {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
374 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
375 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
376
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
377 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
378
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
379 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
380 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
381 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
382
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
383 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
384 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
385 2); /* total number of steps */
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
386 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
387
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
388 /* tell purple about everyone on our buddy list who's connected */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
389 foreach_null_gc(discover_status, gc, NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
390
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
391 /* notify other nullprotocol accounts */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
392 foreach_null_gc(report_status_change, gc, NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
393
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
394 /* fetch stored offline messages */
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
395 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
396 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
397 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
398 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
399 GOfflineMessage *message = (GOfflineMessage *)offline_messages->data;
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
400 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
401 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
402 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
403 message->mtime);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
404 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
405
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
406 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
407 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
408 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
409 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
410
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
411 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
412 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
413 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
414
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
415 static void null_close(PurpleConnection *gc)
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
416 {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
417 /* notify other nullprotocol accounts */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
418 foreach_null_gc(report_status_change, gc, NULL);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
419 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
420
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
421 static int null_send_im(PurpleConnection *gc, const char *who,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
422 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
423 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
424 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
425 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
426 | PURPLE_MESSAGE_RECV);
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
427 PurpleAccount *to_acct = purple_accounts_find(who, "null");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
428 PurpleConnection *to;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
429
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
430 purple_debug_info("nullprpl", "sending message from %s to %s: %s\n",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
431 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
432
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
433 /* 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
434 if (to_acct &&
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
435 !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
436 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
437 _("Your message was blocked by %s's privacy settings."), who);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
438 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
439 "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
440 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
441 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
442 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
443 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
444 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
445
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
446 /* is the recipient online? */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
447 to = get_null_gc(who);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
448 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
449 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
450
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
451 } 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
452 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
453 GList *messages;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
454
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
455 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
456 "%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
457 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
458 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
459 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
460 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
461 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
462
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
463 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
464 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
465 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
466 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
467
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
468 return 1;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
469 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
470
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
471 static void null_set_info(PurpleConnection *gc, const char *info) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
472 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
473 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
474 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
475
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 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
477 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
478 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
479 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
480 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
481 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
482 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
483 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
484
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
485 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
486 gpointer typing) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
487 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
488 const char *action = typing_state_to_string((PurpleIMTypingState)typing);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
489 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
490 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
491
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
492 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
493 from_username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
494 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
495 * 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
496 (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
497 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
498
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
499 static unsigned int null_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
500 PurpleIMTypingState typing) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
501 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
502 typing_state_to_string(typing));
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
503 foreach_null_gc(notify_typing, gc, (gpointer)typing);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
504 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
505 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
506
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
507 static void null_get_info(PurpleConnection *gc, const char *username) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
508 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
509 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
510 PurpleAccount *acct;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
511
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
512 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
513 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
514
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
515 acct = purple_accounts_find(username, "null");
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
516
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
517 if (!get_null_gc(username)) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
518 char *msg = g_strdup_printf(_("%s is not logged in."), username);
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
519 purple_notify_error(gc, _("User Info"), _("User info not available. "), msg,
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
520 purple_request_cpar_from_account(acct));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
521 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
522 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
523
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
524 if (acct)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
525 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
526 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
527 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
528 /* 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
529 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
530 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
531
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
532 /* 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
533 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
534 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
535 info, /* body */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
536 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
537 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
538 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
539
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
540 static void null_set_status(PurpleAccount *acct, PurpleStatus *status) {
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
541 const char *msg = purple_status_get_attr_string(status, "message");
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
542 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
543 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
544
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
545 foreach_null_gc(report_status_change, get_null_gc(purple_account_get_username(acct)),
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
546 NULL);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
547 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
548
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
549 static void null_set_idle(PurpleConnection *gc, int idletime) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
550 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
551 "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
552 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
553 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
554
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
555 static void null_change_passwd(PurpleConnection *gc, const char *old_pass,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
556 const char *new_pass) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
557 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
558 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
559 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
560
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
561 static void null_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
562 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
563 {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
564 const char *username = purple_account_get_username(purple_connection_get_account(gc));
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
565 PurpleConnection *buddy_gc = get_null_gc(purple_buddy_get_name(buddy));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
566
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
567 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
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
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
570 if (buddy_gc) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
571 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
572
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
573 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
574
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
575 if (purple_blist_find_buddy(buddy_acct, username)) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
576 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
577 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
578 } else {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
579 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
580 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
581 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
582 username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
583 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
584 NULL, /* alias */
32315
2550a39e0285 Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32263
diff changeset
585 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
586 }
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
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
590 static void null_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
591 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
592 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
593 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
594
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
595 purple_debug_info("nullprpl", "adding multiple buddies\n");
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 while (buddy && group) {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
598 null_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
599 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
600 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
601 }
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
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
604 static void null_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
605 PurpleGroup *group)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
606 {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
607 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
608 purple_buddy_get_name(buddy),
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
609 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
610 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
611
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
612 static void null_remove_buddies(PurpleConnection *gc, GList *buddies,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
613 GList *groups) {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
614 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
615 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
616
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
617 purple_debug_info("nullprpl", "removing multiple buddies\n");
17451
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 while (buddy && group) {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
620 null_remove_buddy(gc, (PurpleBuddy *)buddy->data,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
621 (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
622 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
623 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
624 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
625 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
626
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
627 /*
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
628 * nullprotocol uses purple's local whitelist and blacklist, stored in blist.xml, as
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
629 * 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
630 * 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
631 * 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
632 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
633 static void null_add_permit(PurpleConnection *gc, const char *name) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
634 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
635 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
636 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
637
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
638 static void null_add_deny(PurpleConnection *gc, const char *name) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
639 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
640 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
641 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
642
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
643 static void null_rem_permit(PurpleConnection *gc, const char *name) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
644 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
645 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
646 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
647
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
648 static void null_rem_deny(PurpleConnection *gc, const char *name) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
649 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
650 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
651 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
652
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
653 static void null_set_permit_deny(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
654 /* this is for synchronizing the local black/whitelist with the server.
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
655 * for nullprotocol, it's a noop.
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
656 */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
657 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
658
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
659 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
660 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
661 /* tell their chat window that we joined */
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
662 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
663 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
664 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
665 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
666 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
667 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
668 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
669
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
670 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
671 /* add them to our chat window */
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
672 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
673 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
674 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
675 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
676 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
677 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
678 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
679 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
680 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
681
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
682 static void null_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
683 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
684 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
685 int chat_id = g_str_hash(room);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
686 purple_debug_info("nullprpl", "%s is joining chat room %s\n", username, room);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
687
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
688 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
689 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
690
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
691 /* 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
692 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
693 } else {
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
694 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
695 username,
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
696 room);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
697 purple_debug_info("nullprpl", "%s is already in chat room %s\n", username,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
698 room);
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
699 purple_notify_info(gc, _("Join chat"), _("Join chat"), tmp,
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
700 purple_request_cpar_from_connection(gc));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
701 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
702 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
703 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
704
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
705 static void null_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
706 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
707 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
708 const char *username = purple_account_get_username(purple_connection_get_account(gc));
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
709 PurpleConnection *invited_by_gc = get_null_gc(invited_by);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
710 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
711 "%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
712 username,
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
713 _("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
714 room);
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
715
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
716 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
717 "%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
718 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
719
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
720 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
721 _("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
722 _("Chat invitation rejected"),
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
723 message,
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
724 purple_request_cpar_from_connection(gc));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
725 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
726 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
727
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
728 static char *null_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
729 const char *room = g_hash_table_lookup(components, "room");
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
730 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
731 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
732 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
733
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
734 static void null_chat_invite(PurpleConnection *gc, int id,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
735 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
736 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
737 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
738 const char *room = purple_conversation_get_name(PURPLE_CONVERSATION(chat));
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
739 PurpleAccount *to_acct = purple_accounts_find(who, "null");
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
740
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
741 purple_debug_info("nullprpl", "%s is inviting %s to join chat room %s\n",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
742 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
743
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
744 if (to_acct) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
745 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
746 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
747 char *tmp = g_strdup_printf("%s is already in chat room %s.", who, room);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
748 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
749 "%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
750 "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
751 who, room, username);
34977
42e9e59fbf0f win32: fix build problems
Ankit Vani <a@nevitus.org>
parents: 34894
diff changeset
752 purple_notify_info(gc, _("Chat invitation"), _("Chat invitation"), tmp,
34979
14c09cce55e1 Fix whitespaces in nullprpl
Ankit Vani <a@nevitus.org>
parents: 34977
diff changeset
753 purple_request_cpar_from_conversation(PURPLE_CONVERSATION(to_conv)));
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
754 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
755 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
756 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
757 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
758 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
759 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
760 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
761 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
762 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
763 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
764
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
765 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
766 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
767 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
768 /* tell their chat window that we left */
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
769 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
770 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
771 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
772 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
773 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
774 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
775 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
776
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
777 static void null_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
778 PurpleChatConversation *chat = purple_conversations_find_chat(gc, id);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
779 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
780 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
781 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
782
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
783 /* 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
784 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
785 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
786
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
787 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
788 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
789 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
790 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
791 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
792 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
793 PurpleConnection *to;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
794
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
795 /* parse args */
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
796 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
797 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
798
32190
7881925d0929 Don't use strlen() when you're just checking whether a string is
Mark Doliner <markdoliner@pidgin.im>
parents: 32189
diff changeset
799 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
800 *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
801 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
802 } 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
803 *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
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 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
806
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
807 from_username = purple_account_get_username(purple_conversation_get_account(conv));
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
808 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
809 from_username, to_username,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
810 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
811
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
812 chat_user = purple_chat_conversation_find_user(PURPLE_CHAT_CONVERSATION(conv), to_username);
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
813 to = get_null_gc(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
814
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
815 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
816 /* 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
817 *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
818 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
819 } 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
820 *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
821 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
822 } else {
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
823 /* 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
824 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
825 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
826 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER,
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
827 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
828 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
829
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
830 /* send the whisper */
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
831 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
832 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
833
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
834 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
835 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
836 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
837
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
838 static void null_chat_whisper(PurpleConnection *gc, int id, const char *who,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
839 const char *message) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
840 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
841 PurpleChatConversation *chat = purple_conversations_find_chat(gc, id);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
842 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
843 "%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
844 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
845 message);
17451
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 /* 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
848 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
849 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
850 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
851
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
852 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
853 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
854 const char *message = (const char *)userdata;
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
855 PurpleConnection *to_gc = get_null_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
856
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
857 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
858 "%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
859 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
860 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
861 time(NULL));
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
862 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
863
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
864 static int null_chat_send(PurpleConnection *gc, int id, 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
865 PurpleMessageFlags flags) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
866 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
867 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
868
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
869 if (chat) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
870 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
871 "%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
872 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
873
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
874 /* 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
875 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
876 return 0;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
877 } else {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
878 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
879 "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
880 "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
881 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
882 return -1;
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 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
885
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
886 static void null_register_user(PurpleAccount *acct) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
887 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
888 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
889 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
890
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
891 static void null_alias_buddy(PurpleConnection *gc, const char *who,
17451
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 *alias) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
893 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
894 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
895 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
896
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
897 static void null_group_buddy(PurpleConnection *gc, const char *who,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
898 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
899 const char *new_group) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
900 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
901 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
902 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
903
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
904 static void null_rename_group(PurpleConnection *gc, const char *old_name,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
905 PurpleGroup *group, GList *moved_buddies) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
906 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
907 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
908 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
909 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
910
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
911 static void null_convo_closed(PurpleConnection *gc, const char *who) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
912 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
913 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
914 }
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 /* normalize a username (e.g. remove whitespace, add default domain, etc.)
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
917 * for nullprotocol, this is a noop.
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
918 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
919 static const char *null_normalize(const PurpleAccount *acct,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
920 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
921 return NULL;
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
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
924 static void null_set_buddy_icon(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
925 PurpleStoredImage *img) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
926 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
927 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
928 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
929 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
930
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
931 static void null_remove_group(PurpleConnection *gc, PurpleGroup *group) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
932 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
933 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
934 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
935 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
936
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
937
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
938 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
939 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
940 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
941 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
942 char *msg;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
943
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
944 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
945
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
946 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
947 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
948 else
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
949 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
950
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
951 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
952 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
953 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
954 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
955 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
956
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
957 static void null_set_chat_topic(PurpleConnection *gc, int id,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
958 const char *topic) {
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
959 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
960 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
961
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
962 if (!chat)
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
963 return;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
964
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
965 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
966 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
967 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
968
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
969 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
970 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
971 (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
972 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
973
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
974 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
975 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
976
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
977 static gboolean null_finish_get_roomlist(gpointer roomlist) {
34991
63c14353a0f4 Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents: 34979
diff changeset
978 purple_roomlist_set_in_progress(PURPLE_ROOMLIST(roomlist), FALSE);
63c14353a0f4 Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents: 34979
diff changeset
979 g_object_unref(roomlist);
63c14353a0f4 Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents: 34979
diff changeset
980
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
981 return FALSE;
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
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
984 static PurpleRoomlist *null_roomlist_get_list(PurpleConnection *gc) {
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32623
diff changeset
985 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
986 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
987 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
988 PurpleRoomlistField *field;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
989 GList *chats;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
990 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
991
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
992 purple_debug_info("nullprpl", "%s asks for room list; returning:\n", username);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
993
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
994 /* 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
995 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
996 "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
997 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
998
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
999 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
1000 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
1001
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1002 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
1003
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1004 /* 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
1005 * 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
1006 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
1007 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
1008 PurpleRoomlistRoom *room;
34872
3b6a783817b9 Refactored nullprpl to use the GObjectified purple API
Ankit Vani <a@nevitus.org>
parents: 34868
diff changeset
1009 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
1010 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
1011
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1012 /* 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
1013 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
1014 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
1015
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1016 /* 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
1017 * of this function and none of the conversations are being deleted
29977
94b2a6686bfb nullprpl: Whitespace
Paul Aurich <darkrain42@pidgin.im>
parents: 29795
diff changeset
1018 * 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
1019 seen_ids = g_list_prepend(seen_ids, (char *)name); /* no, it's new. */
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1020 purple_debug_info("nullprpl", "%s (%d), ", name, id);
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1021
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1022 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
1023 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
1024 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
1025 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
1026 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1027
24862
852378e0c5b5 Various nullprpl fixes. This stemmed from a complaint from a user in
Paul Aurich <darkrain42@pidgin.im>
parents: 24332
diff changeset
1028 g_list_free(seen_ids);
36849
cd2f92ba0543 Merged soc.2013.gobjectification branch
Ankit Vani <a@nevitus.org>
parents: 34991 36839
diff changeset
1029 purple_timeout_add(1 /* ms */, null_finish_get_roomlist, g_object_ref(roomlist));
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1030 return roomlist;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1031 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1032
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1033 static void null_roomlist_cancel(PurpleRoomlist *list) {
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1034 PurpleAccount *account = purple_roomlist_get_account(list);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1035 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
1036 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
1037 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1038
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1039 static void null_roomlist_expand_category(PurpleRoomlist *list,
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1040 PurpleRoomlistRoom *category) {
32263
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1041 PurpleAccount *account = purple_roomlist_get_account(list);
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1042 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
1043 purple_account_get_username(account),
02baf4631f3b Update nullprpl for various API changes.
Andrew Victor <andrew.victor@mxit.com>
parents: 32190
diff changeset
1044 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
1045 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1046
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1047 static gboolean null_offline_message(const PurpleBuddy *buddy) {
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1048 purple_debug_info("nullprpl",
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1049 "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
1050 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
1051 return TRUE;
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1052 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1053
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1054 /*
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1055 * Initialize the protocol instance. see protocol.h for more information.
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1056 */
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1057 static void
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1058 null_protocol_init(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
1059 {
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1060 PurpleAccountUserSplit *split;
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1061 PurpleAccountOption *option;
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1062
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1063 protocol->id = "prpl-null";
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1064 protocol->name = "Null - Testing Protocol";
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1065 protocol->options = OPT_PROTO_NO_PASSWORD | OPT_PROTO_CHAT_TOPIC;
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1066 protocol->icon_spec = purple_buddy_icon_spec_new(
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1067 "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
1068 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
1069 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
1070 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
1071 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
1072 10000, /* max_filesize */
36663
c61b6dbc1f03 Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents: 36657
diff changeset
1073 PURPLE_ICON_SCALE_DISPLAY /* scale_rules */
36609
637155f87448 Refactored the protocols to use purple_buddy_icon_spec_new()
Ankit Vani <a@nevitus.org>
parents: 36589
diff changeset
1074 );
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1075
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1076 /* see accountopt.h for information about user splits and protocol options */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1077 split = purple_account_user_split_new(
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1078 _("Example user split"), /* text shown to user */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1079 "default", /* default value */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1080 '@'); /* field separator */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1081 option = purple_account_option_string_new(
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1082 _("Example option"), /* text shown to user */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1083 "example", /* pref name */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1084 "default"); /* default value */
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1085
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1086 protocol->user_splits = g_list_append(NULL, split);
37038
8832d14d7d0c Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents: 37009
diff changeset
1087 protocol->account_options = g_list_append(NULL, option);
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1088 }
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1089
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1090 /*
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1091 * Initialize the protocol class and interfaces.
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1092 * see protocol.h for more information.
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1093 */
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1094
36683
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1095 static void
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1096 null_protocol_class_init(PurpleProtocolClass *klass)
852cb2830a0a Refactor nullprotocol to use instance init
Ankit Vani <a@nevitus.org>
parents: 36679
diff changeset
1097 {
36731
38de3f22e864 Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents: 36729
diff changeset
1098 klass->login = null_login;
38de3f22e864 Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents: 36729
diff changeset
1099 klass->close = null_close;
38de3f22e864 Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents: 36729
diff changeset
1100 klass->status_types = null_status_types;
38de3f22e864 Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents: 36729
diff changeset
1101 klass->list_icon = null_list_icon;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1102 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1103
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1104 static void
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1105 null_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1106 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1107 client_iface->get_actions = null_get_actions;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1108 client_iface->status_text = null_status_text;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1109 client_iface->tooltip_text = null_tooltip_text;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1110 client_iface->blist_node_menu = null_blist_node_menu;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1111 client_iface->convo_closed = null_convo_closed;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1112 client_iface->normalize = null_normalize;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1113 client_iface->offline_message = null_offline_message;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1114 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1115
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1116 static void
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1117 null_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1118 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1119 server_iface->register_user = null_register_user;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1120 server_iface->set_info = null_set_info;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1121 server_iface->get_info = null_get_info;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1122 server_iface->set_status = null_set_status;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1123 server_iface->set_idle = null_set_idle;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1124 server_iface->change_passwd = null_change_passwd;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1125 server_iface->add_buddy = null_add_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1126 server_iface->add_buddies = null_add_buddies;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1127 server_iface->remove_buddy = null_remove_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1128 server_iface->remove_buddies = null_remove_buddies;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1129 server_iface->alias_buddy = null_alias_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1130 server_iface->group_buddy = null_group_buddy;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1131 server_iface->rename_group = null_rename_group;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1132 server_iface->set_buddy_icon = null_set_buddy_icon;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1133 server_iface->remove_group = null_remove_group;
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1134 }
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1135
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1136 static void
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1137 null_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1138 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1139 im_iface->send = null_send_im;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1140 im_iface->send_typing = null_send_typing;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1141 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1142
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1143 static void
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1144 null_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface)
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1145 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1146 chat_iface->info = null_chat_info;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1147 chat_iface->info_defaults = null_chat_info_defaults;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1148 chat_iface->join = null_join_chat;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1149 chat_iface->reject = null_reject_chat;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1150 chat_iface->get_name = null_get_chat_name;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1151 chat_iface->invite = null_chat_invite;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1152 chat_iface->leave = null_chat_leave;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1153 chat_iface->whisper = null_chat_whisper;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1154 chat_iface->send = null_chat_send;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1155 chat_iface->set_topic = null_set_chat_topic;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1156 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1157
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1158 static void
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1159 null_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1160 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1161 privacy_iface->add_permit = null_add_permit;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1162 privacy_iface->add_deny = null_add_deny;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1163 privacy_iface->rem_permit = null_rem_permit;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1164 privacy_iface->rem_deny = null_rem_deny;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1165 privacy_iface->set_permit_deny = null_set_permit_deny;
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1166 }
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1167
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1168 static void
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1169 null_protocol_roomlist_iface_init(PurpleProtocolRoomlistIface *roomlist_iface)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1170 {
36941
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1171 roomlist_iface->get_list = null_roomlist_get_list;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1172 roomlist_iface->cancel = null_roomlist_cancel;
cceec84ec859 Fix nullprotocol
Ankit Vani <a@nevitus.org>
parents: 36862
diff changeset
1173 roomlist_iface->expand_category = null_roomlist_expand_category;
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1174 }
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1175
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1176 /*
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1177 * define the null protocol type. this macro defines
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1178 * null_protocol_register_type(PurplePlugin *) which is called in plugin_load()
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1179 * to register this type with the type system, and null_protocol_get_type()
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1180 * which returns the registered GType.
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1181 */
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1182 PURPLE_DEFINE_TYPE_EXTENDED(
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1183 NullProtocol, null_protocol, PURPLE_TYPE_PROTOCOL, 0,
36721
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1184
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1185 PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1186 null_protocol_client_iface_init)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1187
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1188 PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1189 null_protocol_server_iface_init)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1190
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1191 PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1192 null_protocol_im_iface_init)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1193
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1194 PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1195 null_protocol_chat_iface_init)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1196
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1197 PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE,
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1198 null_protocol_privacy_iface_init)
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1199
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1200 PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE,
22db8c40260d Refactored nullprotocol to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36700
diff changeset
1201 null_protocol_roomlist_iface_init)
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1202 );
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
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 PurplePluginInfo *
36486
b5167dc125f5 Plugins can return an error when failing to load
Ankit Vani <a@nevitus.org>
parents: 36482
diff changeset
1205 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
1206 {
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1207 return purple_plugin_info_new(
36985
9faafe43603e Rename protocol plugin IDs to prpl-*
Ankit Vani <a@nevitus.org>
parents: 36941
diff changeset
1208 "id", "prpl-null",
36638
5f6dcd83e8c1 Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
1209 "name", "Null Protocol",
36482
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1210 "version", DISPLAY_VERSION,
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1211 "category", N_("Protocol"),
fbddfc86848d Renamed purple-version to purple-abi. Removed abi-version from docs
Ankit Vani <a@nevitus.org>
parents: 36481
diff changeset
1212 "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
1213 "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
1214 "website", PURPLE_WEBSITE,
36505
60c161851325 Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents: 36494
diff changeset
1215 "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
1216
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1217 /* If you're using this protocol plugin as the basis of a plugin that will
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1218 * be distributed separately from libpurple, do not include these flags. */
36653
4084c34c051d Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
1219 "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
4084c34c051d Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents: 36638
diff changeset
1220 PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1221 NULL
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1222 );
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1223 }
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1224
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
1225 static gboolean
36486
b5167dc125f5 Plugins can return an error when failing to load
Ankit Vani <a@nevitus.org>
parents: 36482
diff changeset
1226 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
1227 {
36679
488eec308b4c Forgot to move a few things
Ankit Vani <a@nevitus.org>
parents: 36678
diff changeset
1228 PurpleCmdId id;
488eec308b4c Forgot to move a few things
Ankit Vani <a@nevitus.org>
parents: 36678
diff changeset
1229
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1230 /* register the NULL_TYPE_PROTOCOL type in the type system. this function
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1231 * is defined by PURPLE_DEFINE_TYPE_EXTENDED. */
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1232 null_protocol_register_type(plugin);
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1233
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1234 /* add the protocol to the core */
36628
3d43ca8d69ee Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents: 36613
diff changeset
1235 my_protocol = purple_protocols_add(NULL_TYPE_PROTOCOL, error);
3d43ca8d69ee Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents: 36613
diff changeset
1236 if (!my_protocol)
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1237 return FALSE;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1238
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1239 purple_debug_info("nullprpl", "starting up\n");
36678
ed9d10d8e45a Removed base_finalize from protocols. There is no reason why it should be needed.
Ankit Vani <a@nevitus.org>
parents: 36677
diff changeset
1240
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1241 /* get ready to store offline messages */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1242 goffline_messages = g_hash_table_new_full(g_str_hash, /* hash fn */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1243 g_str_equal, /* key comparison fn */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1244 g_free, /* key free fn */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1245 NULL); /* value free fn */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1246
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1247 /* register whisper chat command, /msg */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1248 id = purple_cmd_register("msg",
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1249 "ws", /* args: recipient and message */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1250 PURPLE_CMD_P_DEFAULT, /* priority */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1251 PURPLE_CMD_FLAG_CHAT,
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1252 "null",
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1253 send_whisper,
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1254 "msg &lt;username&gt; &lt;message&gt;: send a private message, aka a whisper",
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1255 NULL); /* userdata */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1256
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1257 /* add /msg command to the commands list */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1258 cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id));
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1259
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1260 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
1261 }
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1262
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
1263 static gboolean
36486
b5167dc125f5 Plugins can return an error when failing to load
Ankit Vani <a@nevitus.org>
parents: 36482
diff changeset
1264 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
1265 {
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1266 /* unregister the commands */
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1267 while (cmds) {
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1268 PurpleCmdId id = GPOINTER_TO_UINT(cmds->data);
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1269 purple_cmd_unregister(id);
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1270 cmds = g_slist_delete_link(cmds, cmds);
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1271 }
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1272
37009
05ef6e29ea04 Rename nullprotocol back to nullprpl
Ankit Vani <a@nevitus.org>
parents: 36985
diff changeset
1273 purple_debug_info("nullprpl", "shutting down\n");
36678
ed9d10d8e45a Removed base_finalize from protocols. There is no reason why it should be needed.
Ankit Vani <a@nevitus.org>
parents: 36677
diff changeset
1274
36677
081733748bbc Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents: 36664
diff changeset
1275 /* remove the protocol from the core */
36628
3d43ca8d69ee Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents: 36613
diff changeset
1276 if (!purple_protocols_remove(my_protocol, error))
36589
4a12e889d1fd Refactored nullprotocol (renamed from nullprpl) to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36583
diff changeset
1277 return FALSE;
17451
02adeb73ed3b this patch adds nullprpl, a mock protocol plugin, to the libpurple/protocols
Ryan Barrett <ryanbarrett@users.sourceforge.net>
parents:
diff changeset
1278
36453
75bb4001a25f Refactored nullprpl to build with the new plugin API. This is not final.
Ankit Vani <a@nevitus.org>
parents: 34872
diff changeset
1279 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
1280 }
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
1281
36700
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1282 /* initialize the plugin */
6e948576476e Refactored nullprotocol to use the new macro
Ankit Vani <a@nevitus.org>
parents: 36683
diff changeset
1283 PURPLE_PLUGIN_INIT(null, plugin_query, plugin_load, plugin_unload);

mercurial