1 #ifndef _PURPLECOMPAT_H_
2 #define _PURPLECOMPAT_H_
3
4 #include <glib.h>
5 #include "version.h"
6
7 #if PURPLE_VERSION_CHECK(3, 0, 0)
8 #include <glib-object.h>
9
10 #define purple_conversation_set_data(conv, key, value) g_object_set_data(G_OBJECT(conv), key, value)
11 #define purple_conversation_get_data(conv, key) g_object_get_data(G_OBJECT(conv), key)
12
13 #define purple_circular_buffer_destroy g_object_unref
14 #define purple_hash_destroy g_object_unref
15 #define purple_message_destroy g_object_unref
16 #define purple_buddy_destroy g_object_unref
17
18 #define PURPLE_TYPE_STRING G_TYPE_STRING
19
20 #define purple_protocol_action_get_connection(action) ((action)->connection)
21
22 #define purple_chat_user_set_alias(cb, alias) g_object_set((cb), "alias", (alias), NULL)
23 #define purple_chat_get_alias(chat) g_object_get_data(G_OBJECT(chat), "alias")
24
25 #else /*!PURPLE_VERSION_CHECK(3, 0, 0)*/
26
27 #include "connection.h"
28
29 #define purple_blist_find_buddy purple_find_buddy
30 #define purple_blist_find_buddies purple_find_buddies
31 #define purple_blist_find_group purple_find_group
32 #define PURPLE_IS_BUDDY PURPLE_BLIST_NODE_IS_BUDDY
33 #define PURPLE_IS_CHAT PURPLE_BLIST_NODE_IS_CHAT
34 #define purple_chat_get_name_only purple_chat_get_name
35 #define purple_chat_set_alias purple_blist_alias_chat
36 #define purple_chat_get_alias(chat) ((chat)->alias)
37 #define purple_buddy_set_server_alias purple_blist_server_alias_buddy
38 static inline void
purple_blist_node_set_transient(PurpleBlistNode * node,gboolean transient)39 purple_blist_node_set_transient(PurpleBlistNode *node, gboolean transient)
40 {
41 PurpleBlistNodeFlags old_flags = purple_blist_node_get_flags(node);
42 PurpleBlistNodeFlags new_flags;
43
44 if (transient)
45 new_flags = old_flags | PURPLE_BLIST_NODE_FLAG_NO_SAVE;
46 else
47 new_flags = old_flags & ~PURPLE_BLIST_NODE_FLAG_NO_SAVE;
48
49 purple_blist_node_set_flags(node, new_flags);
50 }
51
52 #define PURPLE_CMD_FLAG_PROTOCOL_ONLY PURPLE_CMD_FLAG_PRPL_ONLY
53
54 #define PURPLE_TYPE_CONNECTION purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION)
55 #define PURPLE_IS_CONNECTION PURPLE_CONNECTION_IS_VALID
56
57 #define PURPLE_CONNECTION_DISCONNECTED PURPLE_DISCONNECTED
58 #define PURPLE_CONNECTION_CONNECTING PURPLE_CONNECTING
59 #define PURPLE_CONNECTION_CONNECTED PURPLE_CONNECTED
60 #define PURPLE_CONNECTION_FLAG_HTML PURPLE_CONNECTION_HTML
61 #define PURPLE_CONNECTION_FLAG_NO_BGCOLOR PURPLE_CONNECTION_NO_BGCOLOR
62 #define PURPLE_CONNECTION_FLAG_NO_FONTSIZE PURPLE_CONNECTION_NO_FONTSIZE
63 #define PURPLE_CONNECTION_FLAG_NO_IMAGES PURPLE_CONNECTION_NO_IMAGES
64
65 #define purple_request_cpar_from_connection(a) purple_connection_get_account(a), NULL, NULL
66 #define purple_connection_get_protocol purple_connection_get_prpl
67 #define purple_connection_error purple_connection_error_reason
68 #define purple_connection_is_disconnecting(c) FALSE
69 #define purple_connection_set_flags(pc, f) ((pc)->flags = (f))
70 #define purple_connection_get_flags(pc) ((pc)->flags)
71
72 #define PurpleConversationUpdateType PurpleConvUpdateType
73 #define PURPLE_CONVERSATION_UPDATE_TOPIC PURPLE_CONV_UPDATE_TOPIC
74 #define PURPLE_CONVERSATION_UPDATE_UNSEEN PURPLE_CONV_UPDATE_UNSEEN
75 #define PurpleChatConversation PurpleConvChat
76 #define PurpleIMConversation PurpleConvIm
77 #define purple_conversations_find_chat_with_account(id, account) \
78 PURPLE_CONV_CHAT(purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, id, account))
79 #define purple_conversations_find_chat(pc, id) PURPLE_CONV_CHAT(purple_find_chat(pc, id))
80 #define purple_conversations_get_all purple_get_conversations
81 #define purple_conversation_get_connection purple_conversation_get_gc
82 #define purple_chat_conversation_get_id purple_conv_chat_get_id
83 #define purple_conversations_find_im_with_account(name, account) \
84 PURPLE_CONV_IM(purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, account))
85 #define purple_im_conversation_new(account, from) PURPLE_CONV_IM(purple_conversation_new(PURPLE_CONV_TYPE_IM, account, from))
86 #define PURPLE_CONVERSATION(chatorim) ((chatorim) == NULL ? NULL : (chatorim)->conv)
87 #define PURPLE_IM_CONVERSATION(conv) PURPLE_CONV_IM(conv)
88 #define PURPLE_CHAT_CONVERSATION(conv) PURPLE_CONV_CHAT(conv)
89 #define PURPLE_IS_IM_CONVERSATION(conv) (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
90 #define PURPLE_IS_CHAT_CONVERSATION(conv) (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
91 #define purple_chat_conversation_add_user purple_conv_chat_add_user
92 #define purple_chat_conversation_has_left purple_conv_chat_has_left
93 #define purple_chat_conversation_remove_user purple_conv_chat_remove_user
94
95 #define PurpleMessage PurpleConvMessage
96 #define purple_message_set_time(msg, time) ((msg)->when = (time))
97 #define purple_conversation_write_message(conv, msg) \
98 purple_conversation_write(conv, msg->who, msg->what, msg->flags, msg->when); \
99 purple_message_destroy(msg)
100 static inline PurpleMessage *
purple_message_new_outgoing(const gchar * who,const gchar * contents,PurpleMessageFlags flags)101 purple_message_new_outgoing(const gchar *who, const gchar *contents, PurpleMessageFlags flags)
102 {
103 PurpleMessage *message = g_new0(PurpleMessage, 1);
104
105 message->who = g_strdup(who);
106 message->what = g_strdup(contents);
107 message->flags = flags;
108 message->when = time(NULL);
109
110 return message;
111 }
112 static inline void
purple_message_destroy(PurpleMessage * message)113 purple_message_destroy(PurpleMessage *message)
114 {
115 g_free(message->who);
116 g_free(message->what);
117 g_free(message);
118 }
119 #if !PURPLE_VERSION_CHECK(2, 12, 0)
120 # define PURPLE_MESSAGE_REMOTE_SEND 0x10000
121 #endif
122
123 #define PurpleProtocolChatEntry struct proto_chat_entry
124 #define PurpleChatUserFlags PurpleConvChatBuddyFlags
125 #define PURPLE_CHAT_USER_NONE PURPLE_CBFLAGS_NONE
126 #define PURPLE_CHAT_USER_OP PURPLE_CBFLAGS_OP
127 #define PURPLE_CHAT_USER_FOUNDER PURPLE_CBFLAGS_FOUNDER
128 #define PURPLE_CHAT_USER_TYPING PURPLE_CBFLAGS_TYPING
129 #define PURPLE_CHAT_USER_AWAY PURPLE_CBFLAGS_AWAY
130 #define PURPLE_CHAT_USER_HALFOP PURPLE_CBFLAGS_HALFOP
131 #define PURPLE_CHAT_USER_VOICE PURPLE_CBFLAGS_VOICE
132 #define PURPLE_CHAT_USER_TYPING PURPLE_CBFLAGS_TYPING
133 #define PurpleChatUser PurpleConvChatBuddy
134
135 static inline PurpleChatUser *
purple_chat_conversation_find_user(PurpleChatConversation * chat,const char * name)136 purple_chat_conversation_find_user(PurpleChatConversation *chat, const char *name)
137 {
138 PurpleChatUser *cb = purple_conv_chat_cb_find(chat, name);
139
140 if (cb != NULL) {
141 g_dataset_set_data(cb, "chat", chat);
142 }
143
144 return cb;
145 }
146 #define purple_chat_user_get_flags(cb) purple_conv_chat_user_get_flags(g_dataset_get_data((cb), "chat"), (cb)->name)
147 #define purple_chat_user_set_flags(cb, f) purple_conv_chat_user_set_flags(g_dataset_get_data((cb), "chat"), (cb)->name, (f))
148 #define purple_chat_user_set_alias(cb, a) ((cb)->alias = (a))
149
150 #define PurpleIMTypingState PurpleTypingState
151 #define PURPLE_IM_NOT_TYPING PURPLE_NOT_TYPING
152 #define PURPLE_IM_TYPING PURPLE_TYPING
153 #define PURPLE_IM_TYPED PURPLE_TYPED
154
155 #define purple_media_set_protocol_data purple_media_set_prpl_data
156 #if PURPLE_VERSION_CHECK(2, 10, 12)
157 // Handle ABI breakage
158 # define PURPLE_MEDIA_NETWORK_PROTOCOL_TCP PURPLE_MEDIA_NETWORK_PROTOCOL_TCP_PASSIVE
159 #endif
160
161 #undef purple_notify_error
162 #define purple_notify_error(handle, title, primary, secondary, cpar) \
163 purple_notify_message((handle), PURPLE_NOTIFY_MSG_ERROR, (title), \
164 (primary), (secondary), NULL, NULL)
165 #undef purple_notify_warning
166 #define purple_notify_warning(handle, title, primary, secondary, cpar) \
167 purple_notify_message((handle), PURPLE_NOTIFY_MSG_WARNING, (title), \
168 (primary), (secondary), NULL, NULL)
169 #define purple_notify_user_info_add_pair_html purple_notify_user_info_add_pair
170
171 #define PurpleProtocolAction PurplePluginAction
172 #define purple_protocol_action_get_connection(action) ((PurpleConnection *) (action)->context)
173 #define purple_protocol_action_new purple_plugin_action_new
174 #define purple_protocol_get_id purple_plugin_get_id
175
176 #define purple_protocol_got_user_status purple_prpl_got_user_status
177
178 #define purple_account_privacy_deny_add purple_privacy_deny_add
179 #define purple_account_privacy_deny_remove purple_privacy_deny_remove
180 #define purple_account_set_password(account, password, dummy1, dummy2) \
181 purple_account_set_password(account, password);
182 #define purple_account_set_private_alias purple_account_set_alias
183 #define purple_account_get_private_alias purple_account_get_alias
184
185 #define purple_proxy_info_get_proxy_type purple_proxy_info_get_type
186
187 #define purple_serv_got_im serv_got_im
188 #define purple_serv_got_typing serv_got_typing
189 #define purple_serv_got_alias serv_got_alias
190 #define purple_serv_got_chat_in serv_got_chat_in
191 #define purple_serv_got_chat_left serv_got_chat_left
192 #define purple_serv_got_joined_chat(pc, id, name) PURPLE_CONV_CHAT(serv_got_joined_chat(pc, id, name))
193
194 #define purple_status_get_status_type purple_status_get_type
195
196 #define g_timeout_add_seconds purple_timeout_add_seconds
197 #define g_timeout_add purple_timeout_add
198 #define g_source_remove purple_timeout_remove
199
200 #define PurpleXmlNode xmlnode
201 #define purple_xmlnode_new xmlnode_new
202 #define purple_xmlnode_new_child xmlnode_new_child
203 #define purple_xmlnode_from_str xmlnode_from_str
204 #define purple_xmlnode_to_str xmlnode_to_str
205 #define purple_xmlnode_get_child xmlnode_get_child
206 #define purple_xmlnode_get_next_twin xmlnode_get_next_twin
207 #define purple_xmlnode_get_data xmlnode_get_data
208 #define purple_xmlnode_get_attrib xmlnode_get_attrib
209 #define purple_xmlnode_set_attrib xmlnode_set_attrib
210 #define purple_xmlnode_insert_data xmlnode_insert_data
211 #define purple_xmlnode_free xmlnode_free
212
213
214 #endif
215
216 #endif /*_PURPLECOMPAT_H_*/
217