]> code.citadel.org Git - citadel.git/blob - gaim-citadel/gaim.pkg
25183ce014d2d4773f13777fa7a0add36db4a1cb
[citadel.git] / gaim-citadel / gaim.pkg
1 /* gaim.pkg
2  * Gaim Citadel plugin.
3  *
4  * © 2006 David Given.
5  * This code is licensed under the GPL v2. See the file COPYING in this
6  * directory for the full license text.
7  *
8  * $Id: auth.c 4258 2006-01-29 13:34:44 +0000 (Sun, 29 Jan 2006) dothebart $
9  */
10
11 typedef unsigned int size_t;
12 typedef bool gboolean;
13 typedef long time_t;
14 typedef void* GCallback;
15
16 $typedef int bool;
17 $#include "connection.h"
18 $#include "sslconn.h"
19 $#include "account.h"
20 $#include "conversation.h"
21 $#include "server.h"
22 $#include "notify.h"
23 $#include "util.h"
24
25 $#include "interface.h"
26
27 /* Private entrypoints */
28
29 char* interface_readdata(int fd, GaimSslConnection* gsc);
30 int interface_writedata(int fd, GaimSslConnection* gsc, char* data);
31 int interface_connect(GaimAccount* ga, GaimConnection* gc, char* server, int port);
32 void interface_disconnect(int fd, GaimSslConnection* gsc);
33 void interface_tlson(GaimConnection* gc, GaimAccount* ga, int fd);
34 int interface_timeron(GaimConnection* gc, time_t timeout);
35 void interface_timeroff(GaimConnection* gc, int handle);
36         
37 /* --- connection.h ------------------------------------------------------ */
38
39 typedef enum
40 {
41         GAIM_CONNECTION_HTML       = 0x0001, /**< Connection sends/receives in 'HTML'. */
42         GAIM_CONNECTION_NO_BGCOLOR = 0x0002, /**< Connection does not send/receive
43                                                    background colors.                  */
44         GAIM_CONNECTION_AUTO_RESP  = 0x0004,  /**< Send auto responses when away.       */
45         GAIM_CONNECTION_FORMATTING_WBFO = 0x0008, /**< The text buffer must be formatted as a whole */
46         GAIM_CONNECTION_NO_NEWLINES = 0x0010, /**< No new lines are allowed in outgoing messages */
47         GAIM_CONNECTION_NO_FONTSIZE = 0x0020, /**< Connection does not send/receive font sizes */
48         GAIM_CONNECTION_NO_URLDESC = 0x0040,  /**< Connection does not support descriptions with links */
49         GAIM_CONNECTION_NO_IMAGES = 0x0080  /**< Connection does not support sending of images */
50 } GaimConnectionFlags;
51
52 typedef enum
53 {
54         GAIM_DISCONNECTED = 0, /**< Disconnected. */
55         GAIM_CONNECTED,        /**< Connected.    */
56         GAIM_CONNECTING        /**< Connecting.   */
57
58 } GaimConnectionState;
59
60 void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state);
61 void gaim_connection_set_account(GaimConnection *gc, GaimAccount *account);
62 void gaim_connection_set_display_name(GaimConnection *gc, char *name);
63 GaimConnectionState gaim_connection_get_state(GaimConnection *gc);
64 GaimAccount *gaim_connection_get_account(GaimConnection *gc);
65 char *gaim_connection_get_display_name(GaimConnection *gc);
66 void gaim_connection_update_progress(GaimConnection *gc, char *text,
67                                                                          size_t step, size_t count);
68 void gaim_connection_notice(GaimConnection *gc, char *text);
69 void gaim_connection_error(GaimConnection *gc, char *reason);
70
71 /* --- account.h --------------------------------------------------------- */
72
73 void gaim_account_request_change_password(GaimAccount *account);
74 void gaim_account_request_change_user_info(GaimAccount *account);
75 void gaim_account_set_username(GaimAccount *account, char *username);
76 void gaim_account_set_password(GaimAccount *account, char *password);
77 void gaim_account_set_alias(GaimAccount *account, char *alias);
78 void gaim_account_set_user_info(GaimAccount *account, char *user_info);
79 void gaim_account_set_buddy_icon(GaimAccount *account, char *icon);
80 void gaim_account_set_protocol_id(GaimAccount *account,
81                                                                   char *protocol_id);
82 void gaim_account_set_remember_password(GaimAccount *account, gboolean value);
83 void gaim_account_set_check_mail(GaimAccount *account, gboolean value);
84 void gaim_account_set_auto_login(GaimAccount *account, char *ui,
85                                                                  gboolean value);
86 void gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info);
87 void gaim_account_clear_settings(GaimAccount *account);
88 void gaim_account_set_int(GaimAccount *account, char *name, int value);
89 void gaim_account_set_string(GaimAccount *account, char *name,
90                                                          char *value);
91 void gaim_account_set_bool(GaimAccount *account, char *name,
92                                                    gboolean value);
93 void gaim_account_set_ui_int(GaimAccount *account, char *ui,
94                                                          char *name, int value);
95 void gaim_account_set_ui_string(GaimAccount *account, char *ui,
96                                                                 char *name, char *value);
97 void gaim_account_set_ui_bool(GaimAccount *account, char *ui,
98                                                           char *name, gboolean value);
99 gboolean gaim_account_is_connected(GaimAccount *account);
100 char *gaim_account_get_username(GaimAccount *account);
101 char *gaim_account_get_password(GaimAccount *account);
102 char *gaim_account_get_alias(GaimAccount *account);
103 char *gaim_account_get_user_info(GaimAccount *account);
104 char *gaim_account_get_buddy_icon(GaimAccount *account);
105 char *gaim_account_get_protocol_id(GaimAccount *account);
106 char *gaim_account_get_protocol_name(GaimAccount *account);
107 GaimConnection *gaim_account_get_connection(GaimAccount *account);
108 gboolean gaim_account_get_remember_password(GaimAccount *account);
109 gboolean gaim_account_get_check_mail(GaimAccount *account);
110 gboolean gaim_account_get_auto_login(GaimAccount *account, char *ui);
111 int gaim_account_get_int(GaimAccount *account, char *name, int default_value);
112 char *gaim_account_get_string(GaimAccount *account, char *name, char *default_value);
113 gboolean gaim_account_get_bool(GaimAccount *account, char *name, gboolean default_value);
114 int gaim_account_get_ui_int(GaimAccount *account, char *ui, char *name, int default_value);
115 char *gaim_account_get_ui_string(GaimAccount *account, char *ui, char *name, char *default_value);
116 gboolean gaim_account_get_ui_bool(GaimAccount *account, char *ui, char *name, gboolean default_value);
117
118 /* --- server.h ---------------------------------------------------------- */
119
120 void serv_login(GaimAccount *);
121 void serv_close(GaimConnection *);
122 void serv_touch_idle(GaimConnection *);
123 int  serv_send_im(GaimConnection *, const char *, const char *, GaimConvImFlags);
124 void serv_get_info(GaimConnection *, const char *);
125 void serv_set_idle(GaimConnection *, int);
126 void serv_set_info(GaimConnection *, const char *);
127 void serv_set_away(GaimConnection *, const char *, const char *);
128 void serv_set_away_all(const char *);
129 int  serv_send_typing(GaimConnection *, const char *, int);
130 void serv_change_passwd(GaimConnection *, const char *, const char *);
131 void serv_add_buddy(GaimConnection *, GaimBuddy *);
132 void serv_add_buddies(GaimConnection *, GList *);
133 void serv_remove_buddy(GaimConnection *, GaimBuddy *, GaimGroup *);
134 void serv_remove_buddies(GaimConnection *, GList *, GList *);
135 void serv_remove_group(GaimConnection *, GaimGroup *);
136 void serv_move_buddy(GaimBuddy *, GaimGroup *, GaimGroup *);
137 void serv_rename_group(GaimConnection *, const char *, GaimGroup *, GList *);
138 void serv_add_permit(GaimConnection *, const char *);
139 void serv_add_deny(GaimConnection *, const char *);
140 void serv_rem_permit(GaimConnection *, const char *);
141 void serv_rem_deny(GaimConnection *, const char *);
142 void serv_set_permit_deny(GaimConnection *);
143 void serv_warn(GaimConnection *, const char *, gboolean);
144 void serv_join_chat(GaimConnection *, GHashTable *);
145 void serv_reject_chat(GaimConnection *, GHashTable *);
146 void serv_chat_invite(GaimConnection *, int, const char *, const char *);
147 void serv_chat_leave(GaimConnection *, int);
148 void serv_chat_whisper(GaimConnection *, int, const char *, const char *);
149 int  serv_chat_send(GaimConnection *, int, const char *);
150 void serv_alias_buddy(GaimBuddy *);
151 void serv_got_alias(GaimConnection *gc, const char *who, const char *alias);
152 void serv_got_eviled(GaimConnection *gc, const char *name, int lev);
153 void serv_got_typing(GaimConnection *gc, const char *name, int timeout,
154                                          GaimTypingState state);
155 void serv_set_buddyicon(GaimConnection *gc, const char *filename);
156 void serv_got_typing_stopped(GaimConnection *gc, const char *name);
157 void serv_got_im(GaimConnection *gc, const char *who, const char *msg,
158                                  GaimConvImFlags imflags, time_t mtime);
159 void serv_got_update(GaimConnection *gc, const char *name, gboolean loggedin,
160                                          int evil, time_t signon, time_t idle, int type);
161 void serv_finish_login(GaimConnection *gc);
162 void serv_got_chat_invite(GaimConnection *gc, const char *name,
163                                                   const char *who, const char *message,
164                                                   GHashTable *data);
165 GaimConversation *serv_got_joined_chat(GaimConnection *gc,
166                                                                            int id, const char *name);
167 void serv_got_chat_left(GaimConnection *g, int id);
168 void serv_got_chat_in(GaimConnection *g, int id, const char *who,
169                                           GaimConvChatFlags chatflags, const char *message, time_t mtime);
170 void serv_send_file(GaimConnection *gc, const char *who, const char *file);
171
172 /* --- conversation.h ---------------------------------------------------- */
173
174 typedef enum
175 {
176         GAIM_CONV_UNKNOWN = 0, /**< Unknown conversation type. */
177         GAIM_CONV_IM,          /**< Instant Message.           */
178         GAIM_CONV_CHAT,        /**< Chat room.                 */
179         GAIM_CONV_MISC         /**< A misc. conversation.      */
180
181 } GaimConversationType;
182
183 typedef enum
184 {
185         GAIM_UNSEEN_NONE = 0,  /**< No unseen text in the conversation. */
186         GAIM_UNSEEN_TEXT,      /**< Unseen text in the conversation.    */
187         GAIM_UNSEEN_NICK,      /**< Unseen text and the nick was said.  */
188         GAIM_UNSEEN_EVENT      /**< Unseen events in the conversation.  */
189
190 } GaimUnseenState;
191
192 typedef enum
193 {
194         GAIM_CONV_UPDATE_ADD = 0, /**< The buddy associated with the conversation
195                                        was added.   */
196         GAIM_CONV_UPDATE_REMOVE,  /**< The buddy associated with the conversation
197                                        was removed. */
198         GAIM_CONV_UPDATE_ACCOUNT, /**< The gaim_account was changed. */
199         GAIM_CONV_UPDATE_TYPING,  /**< The typing state was updated. */
200         GAIM_CONV_UPDATE_UNSEEN,  /**< The unseen state was updated. */
201         GAIM_CONV_UPDATE_LOGGING, /**< Logging for this conversation was
202                                        enabled or disabled. */
203         GAIM_CONV_UPDATE_TOPIC,   /**< The topic for a chat was updated. */
204         /*
205          * XXX These need to go when we implement a more generic core/UI event
206          * system.
207          */
208         GAIM_CONV_ACCOUNT_ONLINE,  /**< One of the user's accounts went online.  */
209         GAIM_CONV_ACCOUNT_OFFLINE, /**< One of the user's accounts went offline. */
210         GAIM_CONV_UPDATE_AWAY,     /**< The other user went away.                */
211         GAIM_CONV_UPDATE_ICON,     /**< The other user's buddy icon changed.     */
212         GAIM_CONV_UPDATE_TITLE,
213         GAIM_CONV_UPDATE_CHATLEFT,
214
215         GAIM_CONV_UPDATE_FEATURES /**< The features for a chat have changed */
216
217 } GaimConvUpdateType;
218
219 typedef enum
220 {
221         GAIM_NOT_TYPING = 0,  /**< Not typing.                 */
222         GAIM_TYPING,          /**< Currently typing.           */
223         GAIM_TYPED            /**< Stopped typing momentarily. */
224
225 } GaimTypingState;
226
227 typedef enum
228 {
229         GAIM_MESSAGE_SEND      = 0x0001, /**< Outgoing message.        */
230         GAIM_MESSAGE_RECV      = 0x0002, /**< Incoming message.        */
231         GAIM_MESSAGE_SYSTEM    = 0x0004, /**< System message.          */
232         GAIM_MESSAGE_AUTO_RESP = 0x0008, /**< Auto response.           */
233         GAIM_MESSAGE_COLORIZE  = 0x0010, /**< Colorize nicks.          */
234         GAIM_MESSAGE_NICK      = 0x0020, /**< Contains your nick.      */
235         GAIM_MESSAGE_NO_LOG    = 0x0040, /**< Do not log.              */
236         GAIM_MESSAGE_WHISPER   = 0x0080, /**< Whispered message.       */
237         GAIM_MESSAGE_ERROR     = 0x0200, /**< Error message.           */
238         GAIM_MESSAGE_DELAYED   = 0x0400  /**< Delayed message.         */
239 } GaimMessageFlags;
240
241 typedef enum
242 {
243         GAIM_CBFLAGS_NONE          = 0x0000, /**< No flags                     */
244         GAIM_CBFLAGS_VOICE         = 0x0001, /**< Voiced user or "Participant" */
245         GAIM_CBFLAGS_HALFOP        = 0x0002, /**< Half-op                      */
246         GAIM_CBFLAGS_OP            = 0x0004, /**< Channel Op or Moderator      */
247         GAIM_CBFLAGS_FOUNDER       = 0x0008  /**< Channel Founder              */
248 } GaimConvChatBuddyFlags;
249
250 /* --- prpl.h ------------------------------------------------------------ */
251
252 typedef enum
253 {
254         GAIM_CONV_IM_AUTO_RESP = 0x0001,    /**< Auto response.    */
255         GAIM_CONV_IM_IMAGES    = 0x0002     /**< Contains images.  */
256 } GaimConvImFlags;
257
258 typedef enum
259 {
260         GAIM_CONV_CHAT_WHISPER = 0x0001,    /**< Whispered message.*/
261         GAIM_CONV_CHAT_DELAYED = 0x0002     /**< Delayed message.  */
262
263 } GaimConvChatFlags;
264
265 typedef enum {
266         GAIM_ICON_SCALE_DISPLAY = 0x01,         /**< We scale the icon when we display it */
267         GAIM_ICON_SCALE_SEND = 0x02                     /**< We scale the icon before we send it to the server */
268 } GaimIconScaleRules;
269
270 /* --- blist.h ----------------------------------------------------------- */
271
272 typedef enum
273 {
274         GAIM_BLIST_GROUP_NODE,
275         GAIM_BLIST_CONTACT_NODE,
276         GAIM_BLIST_BUDDY_NODE,
277         GAIM_BLIST_CHAT_NODE,
278         GAIM_BLIST_OTHER_NODE
279
280 } GaimBlistNodeType;
281
282 typedef enum
283 {
284         GAIM_BUDDY_SIGNING_OFF = -1,
285         GAIM_BUDDY_OFFLINE = 0,
286         GAIM_BUDDY_ONLINE,
287         GAIM_BUDDY_SIGNING_ON
288
289 } GaimBuddyPresenceState;
290
291 GaimGroup *gaim_group_new(const char *name);
292 GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy);
293 GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias);
294 const char *gaim_group_get_name(GaimGroup *group); // fake --- added by plugin
295 const char *gaim_buddy_get_alias_only(GaimBuddy *buddy);
296 const char *gaim_buddy_get_contact_alias(GaimBuddy *buddy);
297 const char *gaim_buddy_get_alias(GaimBuddy *buddy);
298 GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name);
299 void gaim_blist_add_buddy(GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node);
300
301 /* --- notify.h ---------------------------------------------------------- */
302
303 typedef enum
304 {
305         GAIM_NOTIFY_MESSAGE = 0, /**< Message notification.         */
306         GAIM_NOTIFY_EMAIL,       /**< Single e-mail notification.   */
307         GAIM_NOTIFY_EMAILS,      /**< Multiple e-mail notification. */
308         GAIM_NOTIFY_FORMATTED,   /**< Formatted text.               */
309         GAIM_NOTIFY_USERINFO,    /**< Formatted userinfo text.      */
310         GAIM_NOTIFY_URI          /**< URI notification or display.  */
311
312 } GaimNotifyType;
313
314 typedef enum
315 {
316         GAIM_NOTIFY_MSG_ERROR   = 0, /**< Error notification.       */
317         GAIM_NOTIFY_MSG_WARNING,     /**< Warning notification.     */
318         GAIM_NOTIFY_MSG_INFO         /**< Information notification. */
319
320 } GaimNotifyMsgType;
321
322 void *gaim_notify_message(void *handle, GaimNotifyMsgType type,
323                                                   const char *title, const char *primary,
324                                                   const char *secondary, GCallback cb,
325                                                   void *user_data);
326 void *gaim_notify_email(void *handle, const char *subject,
327                                                 const char *from, const char *to,
328                                                 const char *url, GCallback cb,
329                                                 void *user_data);
330 void *gaim_notify_emails(void *handle, size_t count, gboolean detailed,
331                                                  const char **subjects, const char **froms,
332                                                  const char **tos, const char **urls,
333                                                  GCallback cb, void *user_data);
334 void *gaim_notify_formatted(void *handle, const char *title,
335                                                         const char *primary, const char *secondary,
336                                                         const char *text, GCallback cb, void *user_data);
337 void *gaim_notify_userinfo(GaimConnection *gc, const char *who,
338                                                    const char *title, const char *primary,
339                                                    const char *secondary, const char *text,
340                                                    GCallback cb, void *user_data);
341 void *gaim_notify_uri(void *handle, const char *uri);
342
343 /* --- util.h ------------------------------------------------------------ */
344
345 void gaim_quotedp_decode (const char *str, char **ret_str, int *ret_len);
346 char *gaim_mime_decode_field (const char *str);
347 const char *gaim_date(void);
348 const char *gaim_date_full(void);
349 time_t gaim_time_build(int year, int month, int day, int hour, int min, int sec);
350 time_t gaim_str_to_time(const char *timestamp, gboolean utc);
351
352 const gchar *gaim_home_dir(void);
353 char *gaim_user_dir(void);
354 void set_gaim_user_dir(const char *dir);
355 int gaim_build_dir(const char *path, int mode);
356 gboolean gaim_program_is_valid(const char *program);
357
358 const char *gaim_normalize(const GaimAccount *account, const char *str);
359 const char *gaim_normalize_nocase(const GaimAccount *account, const char *str);