Exemple #1
0
void Core::sendGroupMessage(int groupId, const QString& message)
{
    QList<CString> cMessages = splitMessage(message);

    for (auto &cMsg :cMessages)
    {
        int ret = tox_group_message_send(tox, groupId, cMsg.data(), cMsg.size());
        if (ret == -1)
            emit groupSentResult(groupId, message, ret);
    }
}
Exemple #2
0
void Core::sendGroupAction(int groupId, const QString& message)
{
    QList<CString> cMessages = splitMessage(message, MAX_GROUP_MESSAGE_LEN);

    for (auto &cMsg :cMessages)
    {
        int ret = tox_group_action_send(tox, groupId, cMsg.data(), cMsg.size());

        if (ret == -1)
            emit groupSentResult(groupId, message, ret);
    }
}
Exemple #3
0
void Core::sendGroupMessageWithType(int groupId, const QString& message, TOX_MESSAGE_TYPE type)
{
    QStringList cMessages = splitMessage(message, MAX_GROUP_MESSAGE_LEN);

    for (auto& part : cMessages) {
        ToxString cMsg(part);
        TOX_ERR_CONFERENCE_SEND_MESSAGE error;
        bool ok = tox_conference_send_message(tox, groupId, type, cMsg.data(), cMsg.size(), &error);
        if (ok && error == TOX_ERR_CONFERENCE_SEND_MESSAGE_OK) {
            return;
        }

        qCritical() << "Fail of tox_conference_send_message";
        switch (error) {
        case TOX_ERR_CONFERENCE_SEND_MESSAGE_CONFERENCE_NOT_FOUND:
            qCritical() << "Conference not found";
            return;

        case TOX_ERR_CONFERENCE_SEND_MESSAGE_FAIL_SEND:
            qCritical() << "Conference message failed to send";
            return;

        case TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION:
            qCritical() << "No connection";
            return;

        case TOX_ERR_CONFERENCE_SEND_MESSAGE_TOO_LONG:
            qCritical() << "Meesage too long";
            return;

        default:
            break;
        }

        emit groupSentResult(groupId, message, -1);
    }
}