Exemple #1
0
void QuetzalChat::doLeave()
{
	PurpleConnection *gc = m_conv->account->gc;
	if (!gc)
		return;
	PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
	if (!info->chat_leave)
		return;
	info->chat_leave(gc, PURPLE_CONV_CHAT(m_conv)->id);
}
Exemple #2
0
void QuetzalChat::setTopic(const QString &topic)
{
	PurpleConnection *gc = m_conv->account->gc;
	if (!gc)
		return;
	PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
	if (!info->set_chat_topic)
		return;
	info->set_chat_topic(gc, PURPLE_CONV_CHAT(m_conv)->id, topic.toUtf8().constData());
}
Exemple #3
0
int QuetzalAccount::sendRawData(const QByteArray &data)
{
	if (!m_account->gc)
		return -1;

	PurplePluginProtocolInfo *prpl = PURPLE_PLUGIN_PROTOCOL_INFO(m_account->gc->prpl);
	if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, send_raw))
		return prpl->send_raw(m_account->gc, data.constData(), data.length());
	return -1;
}
Exemple #4
0
struct groupchat *purple_chat_with(struct im_connection *ic, char *who)
{
	/* No, "of course" this won't work this way. Or in fact, it almost
	   does, but it only lets you send msgs to it, you won't receive
	   any. Instead, we have to click the virtual menu item.
	PurpleAccount *pa = ic->proto_data;
	PurpleConversation *pc;
	PurpleConvChat *pcc;
	struct groupchat *gc;

	gc = imcb_chat_new( ic, "BitlBee-libpurple groupchat" );
	gc->data = pc = purple_conversation_new( PURPLE_CONV_TYPE_CHAT, pa, "BitlBee-libpurple groupchat" );
	pc->ui_data = gc;

	pcc = PURPLE_CONV_CHAT( pc );
	purple_conv_chat_add_user( pcc, ic->acc->user, "", 0, TRUE );
	purple_conv_chat_invite_user( pcc, who, "Please join my chat", FALSE );
	//purple_conv_chat_add_user( pcc, who, "", 0, TRUE );
	*/

	/* There went my nice afternoon. :-( */

	struct purple_data *pd = ic->proto_data;
	PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
	PurplePluginProtocolInfo *pi = prpl->info->extra_info;
	PurpleBuddy *pb = purple_find_buddy(pd->account, who);
	PurpleMenuAction *mi;
	GList *menu;

	void (*callback)(PurpleBlistNode *, gpointer); /* FFFFFFFFFFFFFUUUUUUUUUUUUUU */

	if (!pb || !pi || !pi->blist_node_menu) {
		return NULL;
	}

	menu = pi->blist_node_menu(&pb->node);
	while (menu) {
		mi = menu->data;
		if (purple_menu_cmp(mi->label, "initiate chat") ||
		    purple_menu_cmp(mi->label, "initiate conference")) {
			break;
		}
		menu = menu->next;
	}

	if (menu == NULL) {
		return NULL;
	}

	/* Call the f****r. */
	callback = (void *) mi->callback;
	callback(&pb->node, mi->data);

	return NULL;
}
Exemple #5
0
void QuetzalChat::doJoin()
{
	PurpleConnection *gc = m_conv->account->gc;
	if (!gc)
		return;
	PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
	if (!info->join_chat || !info->chat_info_defaults)
		return;
	GHashTable *comps = info->chat_info_defaults(gc, m_id.toUtf8().constData());
	info->join_chat(gc, comps);
	g_hash_table_destroy(comps);
}
void TestPidginIm::testSendIQ(PurplePluginAction* action) {
	const char* fromName = "test@localhost/QAS";
	const char* toName = "xuewen@localhost/winxp";
	const char* protocol = "prpl-jabber";
	PurpleAccount * account = purple_accounts_find(fromName, protocol);
	if (!account) {
		purple_debug_info("TestQAS Test file", "find accout faile");
		return;
	}

	PurpleConnection * conn = purple_account_get_connection(account);
	PurplePluginProtocolInfo * prpl = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(conn));
	prpl->send_raw(conn, msg, strlen(msg));
	prpl->send_raw(conn, iq, strlen(iq));
}
Exemple #7
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);
}
static int account_join_chat(LuaState *L)
{
    PurpleAccount **account = ms_lua_checkclass(L, "purple.account", 1);
    const char *name         = luaL_checkstring(L, 2);

    g_return_val_if_fail(purple_account_is_connected(*account), 0);

    PurpleConnection *pc = purple_account_get_connection(*account);
    PurpleConversation *conv = purple_find_conversation_with_account(
            PURPLE_CONV_TYPE_CHAT,
            name,
            *account);

    if (conv) {
        purple_conversation_present(conv);
    }
    else {
        conv = purple_conversation_new(
                PURPLE_CONV_TYPE_CHAT,
                *account,
                name);
        purple_conv_chat_left(PURPLE_CONV_CHAT(conv));
    }

    GHashTable *hash;
    PurpleChat *chat = purple_blist_find_chat(*account, name);
    if (chat == NULL) {
        PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(
                purple_connection_get_prpl(pc));
        if (info->chat_info_defaults != NULL)
            hash = info->chat_info_defaults(pc, name);
    } else {
        hash = purple_chat_get_components(chat);
    }

    serv_join_chat(pc, hash);
    if (chat == NULL && hash != NULL)
        g_hash_table_destroy(hash);

    return 0;
}
static void
notify_test_jabber_send_cb(PurplePluginAction *action)
{
       xmlnode* message;
       xmlnode* body;
       message = xmlnode_new("message");
       xmlnode_set_attrib(message, "from", "xuewen@localhost/develop");
       xmlnode_set_attrib(message, "to", "test@localhost");
       xmlnode_set_attrib(message, "type", "chat");

       body = xmlnode_new_child(message, "body");
       const char* body_data = "this is a test stanza";
       body->data = (char*)body_data;
       body->data_sz = strlen(body_data);

       // get a connection and emit it
       GList* connections = purple_connections_get_all();
       GList* connection = g_list_first(connections);
       PurpleConnection * gc_xuewen = 0;
       while(connection) {
               PurpleConnection * gc = (PurpleConnection*) connection->data;
               if (strcmp(gc->display_name, "test@localhost/QAS") == 0)
                       gc_xuewen = gc;
               connection = g_list_next(connection);
       }
/*
       const gchar* id = purple_plugin_get_id(gc_xuewen->prpl);
       if (strcmp(id, prpl-jabber) == 0) {

       }
*/
       PurplePlugin* plugin = purple_connection_get_prpl(gc_xuewen);
       PurplePluginProtocolInfo* info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
       info->send_raw(gc_xuewen, msg, strlen(msg));
       //serv_send_im(gc_xuewen, "test@localhost", "this is a test", PURPLE_MESSAGE_SEND);
}
Exemple #10
0
void BuddyList::add_chat_ok_cb(PurpleRequestFields *fields)
{
  PurpleAccount *account = purple_request_fields_get_account(fields, "account");
  const char *name = purple_request_fields_get_string(fields, "name");
  const char *alias = purple_request_fields_get_string(fields, "alias");
  int selected = purple_request_fields_get_choice(fields, "group");
  GList *list = purple_request_field_choice_get_labels(
      purple_request_fields_get_field(fields, "group"));
  const char *group
    = reinterpret_cast<const char*>(g_list_nth_data(list, selected));
  bool autojoin = purple_request_fields_get_bool(fields, "autojoin");

  bool err = false;
  if (!account) {
    LOG->Message(_("No account specified."));
    err = true;
  }
  else if (!purple_account_is_connected(account)) {
    LOG->Message(_("Selected account is not connected."));
    err = true;
  }
  else {
    PurpleConnection *gc = purple_account_get_connection(account);
    PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(
        purple_connection_get_prpl(gc));
    if (!info->join_chat) {
      LOG->Message(_("This protocol does not support chat rooms."));
      account = NULL;
      err = true;
    }
  }
  if (!name || !name[0]) {
    LOG->Message(_("No buddy name specified."));
    err = true;
  }
  if (!group || !group[0]) {
    LOG->Message(_("No group name specified."));
    err = true;
  }
  if (err) {
    purple_blist_request_add_chat(account, purple_find_group(group), alias, name);
    return;
  }

  PurpleConnection *gc = purple_account_get_connection(account);
  PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(
      purple_connection_get_prpl(gc));
  GHashTable *hash = NULL;
  if (info->chat_info_defaults)
    hash = info->chat_info_defaults(gc, name);

  PurpleChat *chat = purple_chat_new(account, name, hash);

  if (chat) {
    PurpleGroup* g = purple_find_group(group);
    if (!g) {
      g = purple_group_new(group);
      purple_blist_add_group(g, NULL);
    }
    purple_blist_add_chat(chat, g, NULL);
    if (alias && alias[0])
      purple_blist_alias_chat(chat, alias);
    purple_blist_node_set_bool(reinterpret_cast<PurpleBlistNode*>(chat),
        PACKAGE_NAME "-autojoin", autojoin);
  }
}