Ejemplo n.º 1
0
void ChatForm::onFileRecvRequest(ToxFile file)
{
    if (file.friendId != f->getFriendID())
        return;

    Widget::getInstance()->newFriendMessageAlert(file.friendId);

    QString name;
    ToxId friendId = f->getToxId();
    if (friendId != previousId)
    {
        name = f->getDisplayedName();
        previousId = friendId;
    }

    ChatMessage::Ptr msg = ChatMessage::createFileTransferMessage(name, file, false, QDateTime::currentDateTime());
    insertChatMessage(msg);

    ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
    assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
    FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());

    // there is auto-accept for that conact
    if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty())
    {
        tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
    }
    else if (Settings::getInstance().getAutoSaveEnabled())
    {   //global autosave to global directory
        tfWidget->autoAcceptTransfer(Settings::getInstance().getGlobalAutoAcceptDir());
    }

    Widget::getInstance()->updateFriendActivity(f);
}
Ejemplo n.º 2
0
void ChatForm::onFileRecvRequest(ToxFile file)
{
    if (file.friendId != f->getFriendID())
        return;

    Widget* w = Widget::getInstance();
    if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow())
    {
        w->newMessageAlert(f->getFriendWidget());
        f->setEventFlag(true);
        f->getFriendWidget()->updateStatusLight();
    }

    QString name;
    ToxId friendId = f->getToxId();
    if (friendId != previousId)
    {
        name = f->getDisplayedName();
        previousId = friendId;
    }

    ChatMessage::Ptr msg = ChatMessage::createFileTransferMessage(name, file, false, QDateTime::currentDateTime());
    insertChatMessage(msg);

    if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty()
            || Settings::getInstance().getAutoSaveEnabled())
    {
        ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
        assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
        FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
        tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
    }
}
Ejemplo n.º 3
0
void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
{
    if (FriendId != f->getFriendID())
        return;

    qDebug() << "onAvInvite";

    callId = CallId;
    callButton->disconnect();
    videoButton->disconnect();
    if (video)
    {
        callConfirm = new CallConfirmWidget(videoButton);
        if (isVisible())
            callConfirm->show();

        connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
        connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);

        callButton->setObjectName("grey");
        callButton->setToolTip("");
        videoButton->setObjectName("yellow");
        videoButton->setToolTip(tr("Accept video call"));
        connect(videoButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
    }
    else
    {
        callConfirm = new CallConfirmWidget(callButton);
        if (isVisible())
            callConfirm->show();

        connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
        connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);

        callButton->setObjectName("yellow");
        callButton->setToolTip(tr("Accept audio call"));
        videoButton->setObjectName("grey");
        videoButton->setToolTip("");
        connect(callButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
    }
    callButton->style()->polish(callButton);
    videoButton->style()->polish(videoButton);

    insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime()));

    Widget* w = Widget::getInstance();
    if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow())
    {
        w->newMessageAlert(f->getFriendWidget());
        f->setEventFlag(true);
        f->getFriendWidget()->updateStatusLight();
    }
}
Ejemplo n.º 4
0
void ChatForm::onAvInvite(uint32_t FriendId, bool video)
{
    if (FriendId != f->getFriendID())
        return;

    qDebug() << "onAvInvite";
    disableCallButtons();
    insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()),
                                                         ChatMessage::INFO,
                                                         QDateTime::currentDateTime()));
    /* AutoAcceptCall is set for this friend */
    if ((video && Settings::getInstance().getAutoAcceptCall(f->getToxId()).testFlag(Settings::AutoAcceptCall::Video)) ||
       (!video && Settings::getInstance().getAutoAcceptCall(f->getToxId()).testFlag(Settings::AutoAcceptCall::Audio)))
    {
        uint32_t friendId = f->getFriendID();
        qDebug() << "automatic call answer";
        QMetaObject::invokeMethod(coreav, "answerCall", Qt::QueuedConnection, Q_ARG(uint32_t, friendId));
        onAvStart(friendId,video);
    }
    else
    {
        if (video)
        {
            callConfirm = new CallConfirmWidget(videoButton, *f);
            videoButton->setObjectName("yellow");
            videoButton->setToolTip(tr("Accept video call"));
            videoButton->style()->polish(videoButton);
            connect(videoButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
        }
        else
        {
            callConfirm = new CallConfirmWidget(callButton, *f);
            callButton->setObjectName("yellow");
            callButton->setToolTip(tr("Accept audio call"));
            callButton->style()->polish(callButton);
            connect(callButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
        }

        if (f->getFriendWidget()->chatFormIsSet(false))
            callConfirm->show();

        connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
        connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);

        Widget::getInstance()->newFriendMessageAlert(FriendId, false);
        Audio& audio = Audio::getInstance();
        audio.startLoop();
        audio.playMono16Sound(QStringLiteral(":/audio/ToxicIncomingCall.pcm"));
    }
}
Ejemplo n.º 5
0
void ChatForm::startFileSend(ToxFile file)
{
    if (file.friendId != f->getFriendID())
        return;

    QString name;
    if (!previousId.isActiveProfile())
    {
        Core* core = Core::getInstance();
        name = core->getUsername();
        previousId = core->getSelfId();
    }

    insertChatMessage(ChatMessage::createFileTransferMessage(name, file, true, QDateTime::currentDateTime()));
}
Ejemplo n.º 6
0
void ChatForm::onAvRejected(uint32_t FriendId, int)
{
    if (FriendId != f->getFriendID())
        return;

    qDebug() << "onAvRejected";

    delete callConfirm;
    callConfirm = nullptr;

    enableCallButtons();

    insertChatMessage(ChatMessage::createChatInfoMessage(tr("Call rejected"), ChatMessage::INFO, QDateTime::currentDateTime()));

    hideNetcam();
}
Ejemplo n.º 7
0
void ChatForm::onAvInvite(uint32_t FriendId, bool video)
{
    if (FriendId != f->getFriendID())
        return;

    qDebug() << "onAvInvite";

    disableCallButtons();
    if (video)
    {
        callConfirm = new CallConfirmWidget(videoButton, *f);
        videoButton->setObjectName("yellow");
        videoButton->setToolTip(tr("Accept video call"));
        videoButton->style()->polish(videoButton);
        connect(videoButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
    }
    else
    {
        callConfirm = new CallConfirmWidget(callButton, *f);
        callButton->setObjectName("yellow");
        callButton->setToolTip(tr("Accept audio call"));
        callButton->style()->polish(callButton);
        connect(callButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
    }

    if (f->getFriendWidget()->chatFormIsSet(false))
        callConfirm->show();

    connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
    connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);

    insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()),
                                                         ChatMessage::INFO,
                                                         QDateTime::currentDateTime()));

    Widget::getInstance()->newFriendMessageAlert(FriendId, false);
    Audio& audio = Audio::getInstance();
    audio.startLoop();
    audio.playMono16Sound(":audio/ToxicIncomingCall.pcm");
}