/********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * * Copyright 2002-2004 Wilmer van der Gaast and others * \********************************************************************/ /* * nogaim * * Gaim without gaim - for BitlBee * * This file contains functions called by the Gaim IM-modules. It's written * from scratch for BitlBee and doesn't contain any code from Gaim anymore * (except for the function names). * * Copyright 2002-2004 Wilmer van der Gaast */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License with the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define BITLBEE_CORE #include "nogaim.h" #include #include static char *proto_away_alias[7][5] = { { "Away from computer", "Away", "Extended away", NULL }, { "NA", "N/A", "Not available", NULL }, { "Busy", "Do not disturb", "DND", "Occupied", NULL }, { "Be right back", "BRB", NULL }, { "On the phone", "Phone", "On phone", NULL }, { "Out to lunch", "Lunch", "Food", NULL }, { NULL } }; static char *proto_away_alias_find( GList *gcm, char *away ); static int remove_chat_buddy_silent( struct conversation *b, char *handle ); GSList *connections; #ifdef WITH_PLUGINS gboolean load_plugin(char *path) { void (*init_function) (void); GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY); if(!mod) { log_message(LOGLVL_ERROR, "Can't find `%s', not loading", path); return FALSE; } if(!g_module_symbol(mod,"init_plugin",(gpointer *) &init_function)) { log_message(LOGLVL_WARNING, "Can't find function `init_plugin' in `%s'\n", path); return FALSE; } init_function(); return TRUE; } void load_plugins(void) { GDir *dir; GError *error = NULL; dir = g_dir_open(global.conf->plugindir, 0, &error); if (dir) { const gchar *entry; char *path; while ((entry = g_dir_read_name(dir))) { path = g_build_filename(global.conf->plugindir, entry, NULL); if(!path) { log_message(LOGLVL_WARNING, "Can't build path for %s\n", entry); continue; } load_plugin(path); g_free(path); } g_dir_close(dir); } } #endif /* nogaim.c */ GList *protocols = NULL; void register_protocol (struct prpl *p) { protocols = g_list_append(protocols, p); } struct prpl *find_protocol(const char *name) { GList *gl; for (gl = protocols; gl; gl = gl->next) { struct prpl *proto = gl->data; if(!g_strcasecmp(proto->name, name)) return proto; } return NULL; } /* nogaim.c */ void nogaim_init() { extern void msn_init(); extern void oscar_init(); extern void byahoo_init(); extern void jabber_init(); #ifdef WITH_MSN msn_init(); #endif #ifdef WITH_OSCAR oscar_init(); #endif #ifdef WITH_YAHOO byahoo_init(); #endif #ifdef WITH_JABBER jabber_init(); #endif #ifdef WITH_PLUGINS load_plugins(); #endif } GSList *get_connections() { return connections; } int proto_away( struct gaim_connection *gc, char *away ) { GList *m, *ms; char *s; if( !away ) away = ""; ms = m = gc->prpl->away_states( gc ); while( m ) { if( *away ) { if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) break; } else { if( g_strcasecmp( m->data, "Available" ) == 0 ) break; if( g_strcasecmp( m->data, "Online" ) == 0 ) break; } m = m->next; } if( m ) { gc->prpl->set_away( gc, m->data, *away ? away : NULL ); } else { s = proto_away_alias_find( ms, away ); if( s ) { gc->prpl->set_away( gc, s, away ); if( set_getint( gc->irc, "debug" ) ) serv_got_crap( gc, "Setting away state to %s", s ); } else gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); } g_list_free( ms ); return( 1 ); } static char *proto_away_alias_find( GList *gcm, char *away ) { GList *m; int i, j; for( i = 0; *proto_away_alias[i]; i ++ ) { for( j = 0; proto_away_alias[i][j]; j ++ ) if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 ) break; if( !proto_away_alias[i][j] ) /* If we reach the end, this row */ continue; /* is not what we want. Next! */ /* Now find an entry in this row which exists in gcm */ for( j = 0; proto_away_alias[i][j]; j ++ ) { m = gcm; while( m ) { if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 ) return( proto_away_alias[i][j] ); m = m->next; } } } return( NULL ); } /* multi.c */ struct gaim_connection *new_gaim_conn( struct aim_user *user ) { struct gaim_connection *gc; account_t *a; gc = g_new0( struct gaim_connection, 1 ); gc->prpl = user->prpl; g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user. * This fixes daemon mode breakage where IRC doesn't point to the currently active connection. */ gc->irc=user->irc; connections = g_slist_append( connections, gc ); user->gc = gc; gc->user = user; // Find the account_t so we can set its gc pointer for( a = gc->irc->accounts; a; a = a->next ) if( ( struct aim_user * ) a->gc == user ) { a->gc = gc; break; } return( gc ); } void destroy_gaim_conn( struct gaim_connection *gc ) { account_t *a; /* Destroy the pointer to this connection from the account list */ for( a = gc->irc->accounts; a; a = a->next ) if( a->gc == gc ) { a->gc = NULL; break; } connections = g_slist_remove( connections, gc ); g_free( gc->user ); g_free( gc ); } void set_login_progress( struct gaim_connection *gc, int step, char *msg ) { serv_got_crap( gc, "Logging in: %s", msg ); } /* Errors *while* logging in */ void hide_login_progress( struct gaim_connection *gc, char *msg ) { serv_got_crap( gc, "Login error: %s", msg ); } /* Errors *after* logging in */ void hide_login_progress_error( struct gaim_connection *gc, char *msg ) { serv_got_crap( gc, "Logged out: %s", msg ); } void serv_got_crap( struct gaim_connection *gc, char *format, ... ) { va_list params; char text[1024], buf[1024], acc_id[33]; char *msg; account_t *a; va_start( params, format ); g_vsnprintf( text, sizeof( text ), format, params ); va_end( params ); if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 && do_iconv( "UTF8", set_getstr( gc->irc, "charset" ), text, buf, 0, 1024 ) != -1 ) msg = buf; else msg = text; if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) strip_html( msg ); /* Try to find a different connection on the same protocol. */ for( a = gc->irc->accounts; a; a = a->next ) if( a->prpl == gc->prpl && a->gc != gc ) break; /* If we found one, add the screenname to the acc_id. */ if( a ) g_snprintf( acc_id, 32, "%s(%s)", gc->prpl->name, gc->username ); else g_snprintf( acc_id, 32, "%s", gc->prpl->name ); irc_usermsg( gc->irc, "%s - %s", acc_id, msg ); } static gboolean send_keepalive( gpointer d ) { struct gaim_connection *gc = d; if( gc->prpl && gc->prpl->keepalive ) gc->prpl->keepalive( gc ); return TRUE; } void account_online( struct gaim_connection *gc ) { user_t *u; /* MSN servers sometimes redirect you to a different server an
<chapter id="quickstart">
<title>Quickstart</title>

<para>
Welcome to BitlBee, your IRC gateway to ICQ, MSN, AOL, Jabber, Yahoo! and Twitter.
</para>

<para>
The center of BitlBee is the control channel, <emphasis>&amp;bitlbee</emphasis>. Two users will always be there, <emphasis>you</emphasis> (where "you" is the nickname you are using) and the system user, <emphasis>root</emphasis>.
</para>

<para>
You need register so that all your IM settings (passwords, contacts, etc) can be saved on the BitlBee server. It's important that you pick a good password so no one else can access your account. Register with this password using the <emphasis>register</emphasis> command: <emphasis>register &lt;password&gt;</emphasis> (without the brackets!).
</para>

<para>
Be sure to remember your password. The next time you connect to the BitlBee server you will need to <emphasis>identify &lt;password&gt;</emphasis> so that you will be recognised and logged in to all the IM services automatically.
</para>

<para>
When finished, type <emphasis>help quickstart2</emphasis> to continue.
</para>

<sect1 id="quickstart2">
<title>Add and Connect To your IM Account(s)</title>
<!-- quickstart2 -->
<para>
<emphasis>Step Two: Add and Connect To your IM Account(s).</emphasis>
</para>

<para>
To add an account to the account list you will need to use the <emphasis>account add</emphasis> command: <emphasis>account add &lt;protocol&gt; &lt;username&gt; &lt;password&gt; [&lt;server&gt;]</emphasis>.
</para>

<para>
For instance, suppose you have a Jabber account at jabber.org with handle <emphasis>bitlbee@jabber.org</emphasis> with password <emphasis>QuickStart</emphasis>, you would:
</para>

<ircexample>
	<ircline nick="you">account add jabber bitlbee@jabber.org QuickStart</ircline>
	<ircline nick="root">Account successfully added</ircline>
</ircexample>

<para>
Other available IM protocols are msn, oscar, yahoo and twitter. OSCAR is the protocol used by ICQ and AOL. For more information about the <emphasis>account add</emphasis> command, see <emphasis>help account add</emphasis>.
</para>

<para>
When you are finished adding your account(s) use the <emphasis>account on</emphasis> command to enable all your accounts, type <emphasis>help quickstart3</emphasis> to continue.
</para>

</sect1>

<sect1 id="quickstart3">
<title>Step Four: Managing Contact Lists: Add, Remove and Rename</title>

<para>
Now you might want to add some contacts, to do this we will use the <emphasis>add</emphasis> command. It needs two arguments: a connection ID (which can be a number (try <emphasis>account list</emphasis>), protocol name or (part of) the screenname) and the user's handle. It is used in the following way: <emphasis>add &lt;connection&gt; &lt;handle&gt;</emphasis>
</para>

<ircexample>
	<ircline nick="you">add 0 r2d2@example.com</ircline>
	<ircaction