diff options
Diffstat (limited to 'protocols/jabber/jabber.c')
-rw-r--r-- | protocols/jabber/jabber.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index e7be63fd..b0651a59 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -31,6 +31,8 @@ #include "xmltree.h" #include "bitlbee.h" #include "jabber.h" +#include "md5.h" +#include "base64.h" static void jabber_init( account_t *acc ) { @@ -59,6 +61,8 @@ static void jabber_init( account_t *acc ) s->flags |= ACC_SET_OFFLINE_ONLY; } +static void jabber_generate_id_hash( struct jabber_data *jd ); + static void jabber_login( account_t *acc ) { struct im_connection *ic = imcb_new( acc ); @@ -199,6 +203,30 @@ static void jabber_login( account_t *acc ) I think this shouldn't break anything. */ imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL ); } + + jabber_generate_id_hash( jd ); +} + +static void jabber_generate_id_hash( struct jabber_data *jd ) +{ + md5_state_t id_hash; + md5_byte_t binbuf[16]; + char *s; + + md5_init( &id_hash ); + md5_append( &id_hash, (unsigned char *) jd->username, strlen( jd->username ) ); + md5_append( &id_hash, (unsigned char *) jd->server, strlen( jd->server ) ); + s = set_getstr( &jd->ic->acc->set, "resource" ); + md5_append( &id_hash, (unsigned char *) s, strlen( s ) ); + random_bytes( binbuf, 16 ); + md5_append( &id_hash, binbuf, 16 ); + md5_finish( &id_hash, binbuf ); + + s = base64_encode( binbuf, 9 ); + jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s ); + g_free( s ); + + printf( "%s\n", jd->cached_id_prefix ); } static void jabber_logout( struct im_connection *ic ) |