Exemplo n.º 1
0
gchar *
fb_util_rand_uuid(void)
{
    guint8 buf[50];
    sha1_state_t sha;

    sha1_init(&sha);
    random_bytes(buf, sizeof buf);
    sha1_append(&sha, buf, sizeof buf);
    return sha1_random_uuid(&sha);
}
Exemplo n.º 2
0
static gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
{
	struct msn_handler_data *handler = data;
	struct im_connection *ic = handler->data;
	struct msn_data *md;
	
	if( !g_slist_find( msn_connections, ic ) )
		return FALSE;
	
	md = ic->proto_data;
	
	if( source == -1 )
	{
		imcb_error( ic, "Could not connect to server" );
		imc_logout( ic, TRUE );
		return FALSE;
	}
	
	g_free( handler->rxq );
	handler->rxlen = 0;
	handler->rxq = g_new0( char, 1 );
	
	if( md->uuid == NULL )
	{
		struct utsname name;
		sha1_state_t sha[1];
		
		/* UUID == SHA1("BitlBee" + my hostname + MSN username) */
		sha1_init( sha );
		sha1_append( sha, (void*) "BitlBee", 7 );
		if( uname( &name ) == 0 )
		{
			sha1_append( sha, (void*) name.nodename, strlen( name.nodename ) );
		}
		sha1_append( sha, (void*) ic->acc->user, strlen( ic->acc->user ) );
		md->uuid = sha1_random_uuid( sha );
		memcpy( md->uuid, "b171be3e", 8 ); /* :-P */
	}
	
	if( msn_ns_write( ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) )
	{
		handler->inpa = b_input_add( handler->fd, B_EV_IO_READ, msn_ns_callback, handler );
		imcb_log( ic, "Connected to server, waiting for reply" );
	}
	
	return FALSE;
}
Exemplo n.º 3
0
struct groupchat *jabber_chat_with(struct im_connection *ic, char *who)
{
	struct jabber_data *jd = ic->proto_data;
	struct jabber_chat *jc;
	struct groupchat *c;
	sha1_state_t sum;
	double now = gettime();
	char *uuid, *rjid, *cserv;

	sha1_init(&sum);
	sha1_append(&sum, (uint8_t *) ic->acc->user, strlen(ic->acc->user));
	sha1_append(&sum, (uint8_t *) &now, sizeof(now));
	sha1_append(&sum, (uint8_t *) who, strlen(who));
	uuid = sha1_random_uuid(&sum);

	if (jd->flags & JFLAG_GTALK) {
		cserv = g_strdup("groupchat.google.com");
	} else {
		/* Guess... */
		cserv = g_strdup_printf("conference.%s", jd->server);
	}

	rjid = g_strdup_printf("private-chat-%s@%s", uuid, cserv);
	g_free(uuid);
	g_free(cserv);

	c = jabber_chat_join(ic, rjid, jd->username, NULL);
	g_free(rjid);
	if (c == NULL) {
		return NULL;
	}

	jc = c->data;
	jc->invite = g_strdup(who);

	return c;
}