예제 #1
0
파일: toxbot.c 프로젝트: lugnsk/ToxBot
static void cb_group_invite(Tox *m, int32_t friendnumber, uint8_t type, const uint8_t *group_pub_key, uint16_t length,
                            void *userdata)
{
    if (!friend_is_master(m, friendnumber))
        return;

    char name[TOX_MAX_NAME_LENGTH];
    tox_friend_get_name(m, friendnumber, (uint8_t *) name, NULL);
    size_t len = tox_friend_get_name_size(m, friendnumber, NULL);
    name[len] = '\0';

    int groupnum = -1;

    if (type == TOX_GROUPCHAT_TYPE_TEXT)
        groupnum = tox_join_groupchat(m, friendnumber, group_pub_key, length);
    else if (type == TOX_GROUPCHAT_TYPE_AV)
        groupnum = toxav_join_av_groupchat(m, friendnumber, group_pub_key, length, NULL, NULL);

    if (groupnum == -1) {
        fprintf(stderr, "Invite from %s failed (core failure)\n", name);
        return;
    }

    if (group_add(groupnum, type, NULL) == -1) {
        fprintf(stderr, "Invite from %s failed (group_add failed)\n", name);
        tox_del_groupchat(m, groupnum);
        return;
    }

    printf("Accepted groupchat invite from %s [%d]\n", name, groupnum);
}
예제 #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;
}
예제 #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();
    }
}
예제 #4
0
파일: core.cpp 프로젝트: TheNain38/qTox
int Core::joinGroupchat(int32_t friendnumber, uint8_t type, const uint8_t* friend_group_public_key,uint16_t length) const
{
    if (type == TOX_GROUPCHAT_TYPE_TEXT)
    {
        qDebug() << QString("Trying to join text groupchat invite sent by friend %1").arg(friendnumber);
        return tox_join_groupchat(tox, friendnumber, friend_group_public_key,length);
    }
    else if (type == TOX_GROUPCHAT_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,
                                       &Audio::playGroupAudioQueued, const_cast<Core*>(this));
    }
    else
    {
        qWarning() << "joinGroupchat: Unknown groupchat type "<<type;
        return -1;
    }
}
예제 #5
0
파일: core.cpp 프로젝트: 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();
}