Beispiel #1
0
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);
}
Beispiel #2
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;

    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;
    }

    int groupnum = tox_join_groupchat(m, self->num, (uint8_t *) groupkey, length);

    if (groupnum == -1) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat instance failed to initialize.");
        return;
    }

    if (init_groupchat_win(prompt, m, groupnum) == -1) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
        tox_del_groupchat(m, groupnum);
        return;
    }
}
Beispiel #3
0
void print_invite(Tox *m, int friendnumber, uint8_t *group_public_key, void *userdata)
{
    char msg[256];
    sprintf(msg, "[i] received group chat invite from: %u, auto accepting and joining. group number: %u", friendnumber,
            tox_join_groupchat(m, friendnumber, group_public_key));
    new_lines(msg);
}
Beispiel #4
0
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
    uint8_t *errmsg;

    if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
        errmsg = " * Warning: Too many windows are open.";
        line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
        return;
    }

    uint8_t *groupkey = friends[self->num].pending_groupchat;

    if (groupkey[0] == '\0') {
        errmsg = "No pending group chat invite.";
        line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
        return;
    }

    int groupnum = tox_join_groupchat(m, self->num, groupkey);

    if (groupnum == -1) {
        errmsg = "Group chat instance failed to initialize.";
        line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
        return;
    }

    if (init_groupchat_win(prompt, m, groupnum) == -1) {
        errmsg = "Group chat window failed to initialize.";
        line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
        tox_del_groupchat(m, groupnum);
        return;
    }
}
Beispiel #5
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_join_groupchat(invite->profile->tox,
                                invite->friend_number,
                                invite->data,
                                invite->data_size);
    twc_group_chat_invite_remove(invite);

    return rc;
}
Beispiel #6
0
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;
    }
}
Beispiel #7
0
void CToxProto::OnGroupChatInvite(Tox *tox, int32_t friendNumber, uint8_t type, const uint8_t *data, uint16_t length, void *arg)
{
	CToxProto *proto = (CToxProto*)arg;

	if (type == TOX_GROUPCHAT_TYPE_AV)
	{
		Netlib_Logf(proto->m_hNetlibUser, __FUNCTION__": audio chat is not supported yet");
		return;
	}

	int groupNumber = tox_join_groupchat(tox, friendNumber, data, length);
	if (groupNumber == TOX_ERROR)
	{
		Netlib_Logf(proto->m_hNetlibUser, __FUNCTION__": failed to join to group chat");
		return;
	}

	MCONTACT hContact = proto->AddChatRoom(groupNumber);
	if (!hContact)
	{
		Netlib_Logf(proto->m_hNetlibUser, __FUNCTION__": failed to create group chat");
	}
}
Beispiel #8
0
int Core::joinGroupchat(int32_t friendnumber, const uint8_t* friend_group_public_key) const
{
    qDebug() << QString("Trying to join groupchat invite by friend %1").arg(friendnumber);
    return tox_join_groupchat(tox, friendnumber, friend_group_public_key);
}