예제 #1
0
void prplcb_conv_new(PurpleConversation *conv)
{
	if (conv->type == PURPLE_CONV_TYPE_CHAT) {
		struct im_connection *ic = purple_ic_by_pa(conv->account);
		struct groupchat *gc;

		gc = bee_chat_by_title(ic->bee, ic, conv->name);

		if (!gc) {
			gc = imcb_chat_new(ic, conv->name);
			if (conv->title != NULL) {
				imcb_chat_name_hint(gc, conv->title);
			}
		}

		/* don't set the topic if it's just the name */
		if (conv->title != NULL && strcmp(conv->name, conv->title) != 0) {
			imcb_chat_topic(gc, NULL, conv->title, 0);
		}

		conv->ui_data = gc;
		gc->data = conv;

		/* libpurple brokenness: Whatever. Show that we join right away,
		   there's no clear "This is you!" signaling in _add_users so
		   don't even try. */
		imcb_chat_add_buddy(gc, gc->ic->acc->user);
	}
}
예제 #2
0
파일: twitter.c 프로젝트: mrdon/bitlbee
struct groupchat *twitter_groupchat_init(struct im_connection *ic)
{
	char *name_hint;
	struct groupchat *gc;
	struct twitter_data *td = ic->proto_data;
	GSList *l;

	if (td->timeline_gc)
		return td->timeline_gc;

	td->timeline_gc = gc = imcb_chat_new(ic, "twitter/timeline");

	name_hint = g_strdup_printf("%s_%s", td->prefix, ic->acc->user);
	imcb_chat_name_hint(gc, name_hint);
	g_free(name_hint);

	for (l = ic->bee->users; l; l = l->next) {
		bee_user_t *bu = l->data;
		if (bu->ic == ic)
			imcb_chat_add_buddy(gc, bu->handle);
	}
	imcb_chat_add_buddy(gc, ic->acc->user);
	
	return gc;
}
예제 #3
0
static void torchat_parse_groupchat_create(struct im_connection *ic, char *address, char* line)
{
	struct torchat_data *td = ic->proto_data;
	struct groupchat *gc = td->created_groupchat;
	struct torchat_groupchat_data *gcd;

	if (!gc) {
		gc = imcb_chat_new(ic, line);
		gc->data = g_new0(struct torchat_groupchat_data, 1);

		imcb_chat_add_buddy(gc, ic->acc->user);
	}
예제 #4
0
struct groupchat *purple_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password,
                                   set_t **sets)
{
	struct purple_data *pd = ic->proto_data;
	PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
	PurplePluginProtocolInfo *pi = prpl->info->extra_info;
	GHashTable *chat_hash;
	PurpleConversation *conv;
	GList *info, *l;

	if (!pi->chat_info || !pi->chat_info_defaults ||
	    !(info = pi->chat_info(purple_account_get_connection(pd->account)))) {
		imcb_error(ic, "Joining chatrooms not supported by this protocol");
		return NULL;
	}

	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
	                                                  room, pd->account))) {
		purple_conversation_destroy(conv);
	}

	chat_hash = pi->chat_info_defaults(
	        purple_account_get_connection(pd->account), room
	);

	for (l = info; l; l = l->next) {
		struct proto_chat_entry *pce = l->data;

		if (strcmp(pce->identifier, "handle") == 0) {
			g_hash_table_replace(chat_hash, "handle", g_strdup(nick));
		} else if (strcmp(pce->identifier, "password") == 0) {
			g_hash_table_replace(chat_hash, "password", g_strdup(password));
		} else if (strcmp(pce->identifier, "passwd") == 0) {
			g_hash_table_replace(chat_hash, "passwd", g_strdup(password));
		}

		g_free(pce);
	}

	g_list_free(info);

	serv_join_chat(purple_account_get_connection(pd->account), chat_hash);

	g_hash_table_destroy(chat_hash);

	return imcb_chat_new(ic, room);
}
예제 #5
0
파일: purple.c 프로젝트: GRMrGecko/bitlbee
void prplcb_conv_new( PurpleConversation *conv )
{
	if( conv->type == PURPLE_CONV_TYPE_CHAT )
	{
		struct im_connection *ic = purple_ic_by_pa( conv->account );
		struct groupchat *gc;
		
		gc = imcb_chat_new( ic, conv->name );
		conv->ui_data = gc;
		gc->data = conv;
		
		/* libpurple brokenness: Whatever. Show that we join right away,
		   there's no clear "This is you!" signaling in _add_users so
		   don't even try. */
		imcb_chat_add_buddy( gc, gc->ic->acc->user );
	}
}
예제 #6
0
파일: conference.c 프로젝트: jomat/bitlbee
struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password)
{
	struct jabber_chat *jc;
	struct xt_node *node;
	struct groupchat *c;
	char *roomjid;

	roomjid = g_strdup_printf("%s/%s", room, nick);
	node = xt_new_node("x", NULL, NULL);
	xt_add_attr(node, "xmlns", XMLNS_MUC);
	if (password) {
		xt_add_child(node, xt_new_node("password", password, NULL));
	}
	node = jabber_make_packet("presence", NULL, roomjid, node);
	jabber_cache_add(ic, node, jabber_chat_join_failed);

	if (!jabber_write_packet(ic, node)) {
		g_free(roomjid);
		return NULL;
	}

	jc = g_new0(struct jabber_chat, 1);
	jc->name = jabber_normalize(room);

	if ((jc->me = jabber_buddy_add(ic, roomjid)) == NULL) {
		g_free(roomjid);
		g_free(jc->name);
		g_free(jc);
		return NULL;
	}

	/* roomjid isn't normalized yet, and we need an original version
	   of the nick to send a proper presence update. */
	jc->my_full_jid = roomjid;

	c = imcb_chat_new(ic, room);
	c->data = jc;

	return c;
}
예제 #7
0
파일: msn.c 프로젝트: GRMrGecko/bitlbee
static struct groupchat *msn_chat_with( struct im_connection *ic, char *who )
{
	struct msn_switchboard *sb;
	struct groupchat *c = imcb_chat_new( ic, who );
	
	if( ( sb = msn_sb_by_handle( ic, who ) ) )
	{
		debug( "Converting existing switchboard to %s to a groupchat", who );
		return msn_sb_to_chat( sb );
	}
	else
	{
		struct msn_message *m;
		
		/* Create a magic message. This is quite hackish, but who cares? :-P */
		m = g_new0( struct msn_message, 1 );
		m->who = g_strdup( who );
		m->text = g_strdup( GROUPCHAT_SWITCHBOARD_MESSAGE );
		
		msn_sb_write_msg( ic, m );

		return c;
	}
}