libpurple/purpleprotocolim.h

Thu, 13 Aug 2020 21:07:35 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 13 Aug 2020 21:07:35 -0500
changeset 40507
77d7bc9e5151
child 40525
96fc115d6c36
permissions
-rw-r--r--

Make PurpleProtocolIM a proper interface

Move PurpleProtocolIM to a proper interface and it's own files

Update the protocols for the PurpleProtocolIM change

Testing Done:
Compiled, verified no new warnings, and tested with a few protocol plugins.

A bunch of the protocols have very weird/mixed syntax. I did what I could to keep it consistent but I'm sure I messed something up there, that said, since their all so inconsistent compared to everything else, I don't consider it a big deal which is why I didn't try to hard to fix it.

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

40507
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 */
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 #if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 # error "only <purple.h> may be included directly"
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #endif
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #ifndef PURPLE_PROTOCOL_IM_H
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #define PURPLE_PROTOCOL_IM_H
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 /**
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 * SECTION:protocolim
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 * @section_id: libpurple-protocolim
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 * @short_description: Protocol Instant Message Interface
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 * @title: ProtocolIM Interface
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 */
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 #include <glib.h>
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 #include <glib-object.h>
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 #include <libpurple/connection.h>
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 #include <libpurple/conversationtypes.h>
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 #define PURPLE_TYPE_PROTOCOL_IM (purple_protocol_im_get_type())
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 G_DECLARE_INTERFACE(PurpleProtocolIM, purple_protocol_im, PURPLE, PROTOCOL_IM,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 GObject)
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 /**
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 * PURPLE_TYPE_PROTOCOL_IM:
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 * The standard _get_type method for #PurpleProtocolIM.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 */
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 /**
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 * PurpleProtocolIMInterface:
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 * @send: This protocol function should return a positive value on
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 * success. If the message is too big to be sent, return
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 * <literal>-E2BIG</literal>. If the account is not connected,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 * return <literal>-ENOTCONN</literal>. If the protocol is unable
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 * to send the message for another reason, return some other
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 * negative value. You can use one of the valid #errno values, or
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 * just big something. If the message should not be echoed to the
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 * conversation window, return 0.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 * @send_typing: If this protocol requires the #PURPLE_IM_TYPING message to be
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 * sent repeatedly to signify that the user is still typing, then
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 * the protocol should return the number of seconds to wait before
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 * sending a subsequent notification. Otherwise the protocol
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 * should return 0.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 * The protocol IM interface that needs to be implemented to send one to one
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 * messages.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 */
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 struct _PurpleProtocolIMInterface {
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 /*< private >*/
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 GTypeInterface parent;
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 /*< public >*/
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 gint (*send)(PurpleProtocolIM *im, PurpleConnection *connection,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 PurpleMessage *msg);
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 guint (*send_typing)(PurpleProtocolIM *im, PurpleConnection *connection,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 const gchar *name, PurpleIMTypingState state);
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 /*< private >*/
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 gpointer reserved[4];
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 };
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 G_BEGIN_DECLS
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 /**
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 * purple_protocol_im_send:
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 * @im: The #PurpleProtocolIM instance.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 * @connection: The #PurpleConnection to use.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 * @msg: The #PurpleMessage to send.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 * Sends @msg out over @connection.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 * Returns: >= 0 on success, or < 0 on error. If 0 is returned the message
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 * should not be output locally.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 */
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 gint purple_protocol_im_send(PurpleProtocolIM *im,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 PurpleConnection *connection,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 PurpleMessage *msg);
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 /**
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 * purple_protocol_im_send_type:
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 * @im: The #PurpleProtocolIM instance.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 * @connection: The #PurpleConversation to use.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 * @name: The name of the user to send a typing notification to.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 * @state: The #PurpleIMTypingState Value.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 * If this protocol requires the #PURPLE_IM_TYPING message to be sent
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 * repeatedly to signify that the user is still typing, then the protocol
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 * should return the number of seconds to wait before sending a subsequent
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 * notification. Otherwise the protocol should return 0.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 *
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 * Returns: A quiet-period, specified in seconds, where Purple will not send
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 * any additional typing notification messages. Most protocols should
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 * return 0, which means that no additional #PURPLE_IM_TYPING messages
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 * need to be sent. If this is 5, for example, then Purple will wait
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 * five seconds, and if the Purple user is still typing then Purple
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 * will send another #PURPLE_IM_TYPING message.
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 */
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 guint purple_protocol_im_send_typing(PurpleProtocolIM *im,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 PurpleConnection *connection,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 const gchar *name,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 PurpleIMTypingState state);
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 G_END_DECLS
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 #endif /* PURPLE_PROTOCOL_IM_H */
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130

mercurial