aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/nogaim.h
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/nogaim.h')
-rw-r--r--protocols/nogaim.h231
1 files changed, 111 insertions, 120 deletions
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index bae4489f..59f9e870 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -5,7 +5,8 @@
\********************************************************************/
/*
- * nogaim
+ * nogaim, soon to be known as im_api. Not a separate product (unless
+ * someone would be interested in such a thing), just a new name.
*
* Gaim without gaim - for BitlBee
*
@@ -14,7 +15,7 @@
*
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
* (and possibly other members of the Gaim team)
- * Copyright 2002-2004 Wilmer van der Gaast <wilmer@gaast.net>
+ * Copyright 2002-2007 Wilmer van der Gaast <wilmer@gaast.net>
*/
/*
@@ -43,28 +44,30 @@
#include "md5.h"
#include "sha.h"
-
#define BUF_LEN MSG_LEN
#define BUF_LONG ( BUF_LEN * 2 )
#define MSG_LEN 2048
#define BUF_LEN MSG_LEN
-#define SELF_ALIAS_LEN 400
#define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */
#define WEBSITE "http://www.bitlbee.org/"
-#define IM_FLAG_AWAY 0x0020
#define GAIM_AWAY_CUSTOM "Custom"
-#define OPT_CONN_HTML 0x00000001
-#define OPT_LOGGED_IN 0x00010000
-#define OPT_LOGGING_OUT 0x00020000
+/* Sharing flags between all kinds of things. I just hope I won't hit any
+ limits before 32-bit machines become extinct. ;-) */
+#define OPT_LOGGED_IN 0x00000001
+#define OPT_LOGGING_OUT 0x00000002
+#define OPT_AWAY 0x00000004
+#define OPT_DOES_HTML 0x00000010
+#define OPT_TYPING 0x00000100 /* Some pieces of code make assumptions */
+#define OPT_THINKING 0x00000200 /* about these values... Stupid me! */
/* ok. now the fun begins. first we create a connection structure */
-struct gaim_connection
+struct im_connection
{
account_t *acc;
- guint32 flags;
+ u_int32_t flags;
/* each connection then can have its own protocol-specific data */
void *proto_data;
@@ -79,159 +82,147 @@ struct gaim_connection
GSList *deny;
int permdeny;
- char username[64];
char displayname[128];
- char password[32];
-
char *away;
int evil;
- gboolean wants_to_die; /* defaults to FALSE */
/* BitlBee */
irc_t *irc;
- struct conversation *conversations;
+ struct groupchat *conversations;
};
-/* struct buddy_chat went away and got merged with this. */
-struct conversation {
- struct gaim_connection *gc;
+struct groupchat {
+ struct im_connection *ic;
/* stuff used just for chat */
- GList *in_room;
- GList *ignored;
- int id;
-
- /* BitlBee */
- struct conversation *next;
- char *channel;
- char *title;
- char joined;
- void *data;
+ GList *in_room;
+ GList *ignored;
+
+ /* BitlBee */
+ struct groupchat *next;
+ char *channel;
+ char *title;
+ char joined;
+ void *data;
};
struct buddy {
char name[80];
char show[BUDDY_ALIAS_MAXLEN];
- int present;
+ int present;
int evil;
time_t signon;
time_t idle;
- int uc;
+ int uc;
guint caps; /* woohoo! */
void *proto_data; /* what a hack */
- struct gaim_connection *gc; /* the connection it belongs to */
+ struct im_connection *ic; /* the connection it belongs to */
};
struct prpl {
int options;
const char *name;
- void (* acc_init) (account_t *);
+ /* Added this one to be able to add per-account settings, don't think
+ it should be used for anything else. */
+ void (* init) (account_t *);
+ /* These should all be pretty obvious. */
void (* login) (account_t *);
- void (* keepalive) (struct gaim_connection *);
- void (* close) (struct gaim_connection *);
+ void (* keepalive) (struct im_connection *);
+ void (* logout) (struct im_connection *);
- int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away);
- void (* set_away) (struct gaim_connection *, char *state, char *message);
- void (* get_away) (struct gaim_connection *, char *who);
- int (* send_typing) (struct gaim_connection *, char *who, int typing);
+ int (* buddy_msg) (struct im_connection *, char *to, char *message, int flags);
+ void (* set_away) (struct im_connection *, char *state, char *message);
+ void (* get_away) (struct im_connection *, char *who);
+ int (* send_typing) (struct im_connection *, char *who, int flags);
- void (* add_buddy) (struct gaim_connection *, char *name);
- void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group);
- void (* remove_buddy) (struct gaim_connection *, char *name, char *group);
- void (* add_permit) (struct gaim_connection *, char *name);
- void (* add_deny) (struct gaim_connection *, char *name);
- void (* rem_permit) (struct gaim_connection *, char *name);
- void (* rem_deny) (struct gaim_connection *, char *name);
- void (* set_permit_deny)(struct gaim_connection *);
+ /* For now BitlBee doesn't really handle groups, just set it to NULL. */
+ void (* add_buddy) (struct im_connection *, char *name, char *group);
+ void (* remove_buddy) (struct im_connection *, char *name, char *group);
- void (* set_info) (struct gaim_connection *, char *info);
- void (* get_info) (struct gaim_connection *, char *who);
- void (* alias_buddy) (struct gaim_connection *, char *who); /* save/store buddy's alias on server list/roster */
+ /* Block list stuff. */
+ void (* add_permit) (struct im_connection *, char *who);
+ void (* add_deny) (struct im_connection *, char *who);
+ void (* rem_permit) (struct im_connection *, char *who);
+ void (* rem_deny) (struct im_connection *, char *who);
+ /* Doesn't actually have UI hooks. */
+ void (* set_permit_deny)(struct im_connection *);
- /* Group chat stuff. */
- void (* join_chat) (struct gaim_connection *, GList *data);
- void (* chat_invite) (struct gaim_connection *, int id, char *who, char *message);
- void (* chat_leave) (struct gaim_connection *, int id);
- int (* chat_send) (struct gaim_connection *, int id, char *message);
- int (* chat_open) (struct gaim_connection *, char *who);
+ /* Request profile info. Free-formatted stuff, the IM module gives back
+ this info via imcb_log(). */
+ void (* get_info) (struct im_connection *, char *who);
+ void (* set_my_name) (struct im_connection *, char *name);
+ void (* set_name) (struct im_connection *, char *who, char *name);
- /* DIE! */
- char *(* get_status_string) (struct gaim_connection *gc, int stat);
+ /* Group chat stuff. */
+ void (* chat_invite) (struct groupchat *, char *who, char *message);
+ void (* chat_leave) (struct groupchat *);
+ void (* chat_msg) (struct groupchat *, char *message, int flags);
+ struct groupchat *
+ (* chat_with) (struct im_connection *, char *who);
+ struct groupchat *
+ (* chat_join) (struct im_connection *, char *room, char *nick, char *password);
- GList *(* away_states)(struct gaim_connection *gc);
+ GList *(* away_states)(struct im_connection *ic);
/* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */
int (* handle_cmp) (const char *who1, const char *who2);
};
-#define UC_UNAVAILABLE 1
-
-/* JABBER */
-#define UC_AWAY (0x02 | UC_UNAVAILABLE)
-#define UC_CHAT 0x04
-#define UC_XA (0x08 | UC_UNAVAILABLE)
-#define UC_DND (0x10 | UC_UNAVAILABLE)
-
-G_MODULE_EXPORT GSList *get_connections();
-G_MODULE_EXPORT struct prpl *find_protocol(const char *name);
-G_MODULE_EXPORT void register_protocol(struct prpl *);
-
-/* nogaim.c */
-int bim_set_away( struct gaim_connection *gc, char *away );
-int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags );
-int bim_chat_msg( struct gaim_connection *gc, int id, char *msg );
-
-void bim_add_allow( struct gaim_connection *gc, char *handle );
-void bim_rem_allow( struct gaim_connection *gc, char *handle );
-void bim_add_block( struct gaim_connection *gc, char *handle );
-void bim_rem_block( struct gaim_connection *gc, char *handle );
-
+/* im_api core stuff. */
void nogaim_init();
+G_MODULE_EXPORT GSList *get_connections();
+G_MODULE_EXPORT struct prpl *find_protocol( const char *name );
+G_MODULE_EXPORT void register_protocol( struct prpl * );
+
+/* Connection management. */
+G_MODULE_EXPORT struct im_connection *imcb_new( account_t *acc );
+G_MODULE_EXPORT void imcb_free( struct im_connection *ic );
+G_MODULE_EXPORT void imcb_connected( struct im_connection *ic );
+G_MODULE_EXPORT void imc_logout( struct im_connection *ic, int allow_reconnect );
+
+/* Communicating with the user. */
+G_MODULE_EXPORT void imcb_log( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
+G_MODULE_EXPORT void imcb_error( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
+G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont );
+G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname );
+
+/* Buddy management */
+G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, char *handle, char *group );
+G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group );
+G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle );
+G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname );
+
+/* Buddy activity */
+G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
+/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
+G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at );
+G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags );
+
+/* Groupchats */
+G_MODULE_EXPORT void imcb_chat_invited( struct im_connection *ic, char *handle, char *who, char *msg, GList *data );
+G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle );
+G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle );
+G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason );
+G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at );
+G_MODULE_EXPORT void imcb_chat_removed( struct groupchat *c );
+struct groupchat *chat_by_channel( char *channel );
+
+/* Actions, or whatever. */
+int imc_set_away( struct im_connection *ic, char *away );
+int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
+int imc_chat_msg( struct groupchat *c, char *msg, int flags );
+
+void imc_add_allow( struct im_connection *ic, char *handle );
+void imc_rem_allow( struct im_connection *ic, char *handle );
+void imc_add_block( struct im_connection *ic, char *handle );
+void imc_rem_block( struct im_connection *ic, char *handle );
+
+/* Misc. stuff */
char *set_eval_away_devoice( set_t *set, char *value );
-
gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
void cancel_auto_reconnect( struct account *a );
-/* multi.c */
-G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( account_t *acc );
-G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc );
-G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg );
-G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg );
-G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg );
-G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
-G_MODULE_EXPORT void account_online( struct gaim_connection *gc );
-G_MODULE_EXPORT void signoff( struct gaim_connection *gc );
-
-/* dialogs.c */
-G_MODULE_EXPORT void do_error_dialog( struct gaim_connection *gc, char *msg, char *title );
-G_MODULE_EXPORT void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont );
-
-/* list.c */
-G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname );
-G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle );
-G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc );
-
-G_MODULE_EXPORT void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname );
-
-/* buddy_chat.c */
-G_MODULE_EXPORT void add_chat_buddy( struct conversation *b, char *handle );
-G_MODULE_EXPORT void remove_chat_buddy( struct conversation *b, char *handle, char *reason );
-
-/* prpl.c */
-G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *handle, const char *realname );
-
-/* server.c */
-G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );
-G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
-G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type );
-G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data );
-G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle );
-G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime );
-G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id );
-
-struct conversation *conv_findchannel( char *channel );
-
#endif