Exemplo n.º 1
0
static void handle_conference_invite(Tox *tox, uint32_t friend_number, TOX_CONFERENCE_TYPE type, const uint8_t *cookie,
		size_t length, void *user_data) {
	printf ("GOT CHAN INVITE %s (%d)\n", cookie, length);
	TOX_ERR_CONFERENCE_JOIN err = 0;
	int chan = tox_conference_join(tox, friend_number, cookie, length, &err);
	printf ("Joined channel %d %d\n", chan, err);
}
Exemplo n.º 2
0
/**
 * Accept a group chat invite. Remove and free the invite. Returns group chat
 * number. -1 on failure.
 */
int
twc_group_chat_invite_join(struct t_twc_group_chat_invite *invite)
{
    int rc;
    TOX_ERR_CONFERENCE_JOIN err = TOX_ERR_CONFERENCE_JOIN_OK;
    switch (invite->group_chat_type)
    {
        case TOX_CONFERENCE_TYPE_TEXT:
            rc =
                tox_conference_join(invite->profile->tox, invite->friend_number,
                                    invite->data, invite->data_size, &err);
            break;
#ifdef TOXAV_ENABLED
        case TOX_CONFERENCE_TYPE_AV:
            rc = toxav_join_av_groupchat(invite->profile->tox,
                                         invite->friend_number, invite->data,
                                         invite->data_size, NULL, NULL);
            break;
#endif
        default:
            rc = -1;
            break;
    }

    twc_group_chat_invite_remove(invite);

    if (err != TOX_ERR_CONFERENCE_JOIN_OK)
        return -1;
    return rc;
}
Exemplo n.º 3
0
/**
 * @brief Accept a groupchat invite.
 * @param friendnumber Id of friend in friend list.
 * @param type Chat type (TEXT or AV).
 * @param friend_group_public_key Received via the `conference_invite` event.
 * @param length The size of @friend_group_public_key.
 *
 * @return Conference number on success, UINT32_MAX on failure.
 */
uint32_t Core::joinGroupchat(int32_t friendnumber, uint8_t type,
                             const uint8_t* friend_group_public_key, uint16_t length) const
{
    if (type == TOX_CONFERENCE_TYPE_TEXT)
    {
        qDebug() << QString("Trying to join text groupchat invite sent by friend %1").arg(friendnumber);
        TOX_ERR_CONFERENCE_JOIN error;
        uint32_t groupId = tox_conference_join(tox, friendnumber, friend_group_public_key, length, &error);
        if (parseConferenceJoinError(error))
            return groupId;
        else
            return std::numeric_limits<uint32_t>::max();
    }
    else if (type == TOX_CONFERENCE_TYPE_AV)
    {
        qDebug() << QString("Trying to join AV groupchat invite sent by friend %1").arg(friendnumber);
        return toxav_join_av_groupchat(tox, friendnumber, friend_group_public_key, length,
                                       CoreAV::groupCallCallback,
                                       const_cast<Core*>(this));
    }
    else
    {
        qWarning() << "joinGroupchat: Unknown groupchat type "<<type;
        return std::numeric_limits<uint32_t>::max();
    }
}
Exemplo n.º 4
0
static void handle_conference_invite(Tox *tox, uint32_t friend_number, Tox_Conference_Type type, const uint8_t *cookie,
                                     size_t length, void *user_data)
{
    State *state = (State *)user_data;

    fprintf(stderr, "handle_conference_invite(#%u, %u, %d, uint8_t[%u], _)\n",
            state->id, friend_number, type, (unsigned)length);
    fprintf(stderr, "tox%u joining conference\n", state->id);

    {
        Tox_Err_Conference_Join err;
        state->conference = tox_conference_join(tox, friend_number, cookie, length, &err);
        ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK, "failed to join a conference: err = %d", err);
        fprintf(stderr, "tox%u Joined conference %u\n", state->id, state->conference);
        state->joined = true;
    }
}
Exemplo n.º 5
0
Arquivo: core.cpp Projeto: mpxc/qTox
/**
 * @brief Accept a groupchat invite.
 * @param friendId Id of friend in friend list.
 * @param type Chat type (TEXT or AV).
 * @param friendGroupPK Received via the `conference_invite` event.
 * @param length The size of @friend_group_public_key.
 *
 * @return Conference number on success, UINT32_MAX on failure.
 */
uint32_t Core::joinGroupchat(int32_t friendId, uint8_t type, const uint8_t* friendGroupPK,
                             uint16_t length) const
{
    switch (type) {
    case TOX_CONFERENCE_TYPE_TEXT: {
        qDebug() << QString("Trying to join text groupchat invite sent by friend %1").arg(friendId);
        TOX_ERR_CONFERENCE_JOIN error;
        uint32_t groupId = tox_conference_join(tox, friendId, friendGroupPK, length, &error);
        return parseConferenceJoinError(error) ? groupId : std::numeric_limits<uint32_t>::max();
    }

    case TOX_CONFERENCE_TYPE_AV: {
        qDebug() << QString("Trying to join AV groupchat invite sent by friend %1").arg(friendId);
        return toxav_join_av_groupchat(tox, friendId, friendGroupPK, length,
                                       CoreAV::groupCallCallback, const_cast<Core*>(this));
    }

    default:
        qWarning() << "joinGroupchat: Unknown groupchat type " << type;
    }

    return std::numeric_limits<uint32_t>::max();
}
Exemplo n.º 6
0
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
    if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Warning: Too many windows are open.");
        return;
    }

    const char *groupkey = Friends.list[self->num].group_invite.key;
    uint16_t length = Friends.list[self->num].group_invite.length;
    uint8_t type = Friends.list[self->num].group_invite.type;

    if (!Friends.list[self->num].group_invite.pending) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending group chat invite.");
        return;
    }

    if (type != TOX_CONFERENCE_TYPE_TEXT) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Toxic does not support audio groups.");
        return;
    }

    TOX_ERR_CONFERENCE_JOIN err;

    uint32_t groupnum = tox_conference_join(m, self->num, (uint8_t *) groupkey, length, &err);

    if (err != TOX_ERR_CONFERENCE_JOIN_OK) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat instance failed to initialize (error %d)", err);
        return;
    }

    if (init_groupchat_win(prompt, m, groupnum, type) == -1) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
        tox_conference_delete(m, groupnum, NULL);
        return;
    }

}