Exemplo n.º 1
0
Arquivo: core.cpp Projeto: mpxc/qTox
/**
 * @brief Reinitialized the core.
 * @warning Must be called from the Core thread, with the GUI thread ready to process events.
 */
void Core::reset()
{
    assert(QThread::currentThread() == coreThread);
    QByteArray toxsave = getToxSaveData();
    ready = false;
    killTimers(true);
    deadifyTox();
    emit selfAvatarChanged(QPixmap(":/img/contact_dark.svg"));
    GUI::clearContacts();
    start(toxsave);
}
Exemplo n.º 2
0
void Core::switchConfiguration(const QString& _profile)
{
    QString profile = QFileInfo(_profile).baseName();
    // If we can't get a lock, then another instance is already using that profile
    while (!profile.isEmpty() && !ProfileLocker::lock(profile))
    {
        qWarning() << "Profile "<<profile<<" is already in use, pick another";
        GUI::showWarning(tr("Profile already in use"),
                         tr("Your profile is already used by another qTox instance\n"
                            "Please select another profile"));
        do {
            profile = Settings::getInstance().askProfiles();
        } while (profile.isEmpty());
    }

    if (profile.isEmpty())
        qDebug() << "Core: creating new Id";
    else
        qDebug() << "Core: switching from" << Settings::getInstance().getCurrentProfile() << "to" << profile;

    saveConfiguration();
    saveCurrentInformation(); // part of a hack, see core.h

    ready = false;
    GUI::setEnabled(false);
    clearPassword(ptMain);
    clearPassword(ptHistory);

    toxTimer->stop();
    deadifyTox();

    emit selfAvatarChanged(QPixmap(":/img/contact_dark.svg"));
    emit blockingClearContacts(); // we need this to block, but signals are required for thread safety

    if (profile.isEmpty())
        loadPath = "";
    else
        loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT);

    Settings::getInstance().switchProfile(profile);
    HistoryKeeper::resetInstance();

    start();
}
Exemplo n.º 3
0
Arquivo: core.cpp Projeto: Pik-9/qTox
Core::~Core()
{
    if (coreThread->isRunning())
    {
        if (QThread::currentThread() == coreThread)
            killTimers(false);
        else
            QMetaObject::invokeMethod(this, "killTimers", Qt::BlockingQueuedConnection,
                                      Q_ARG(bool, false));
    }
    coreThread->exit(0);
    while (coreThread->isRunning())
    {
        qApp->processEvents();
        coreThread->wait(500);
    }

    deadifyTox();
}
Exemplo n.º 4
0
Core::~Core()
{
    qDebug() << "Deleting Core";

    saveConfiguration();
    toxTimer->stop();
    coreThread->exit(0);
    while (coreThread->isRunning())
    {
        qApp->processEvents();
        coreThread->wait(500);
    }

    deadifyTox();

    if (videobuf)
    {
        delete[] videobuf;
        videobuf=nullptr;
    }

    Audio::closeInput();
    Audio::closeOutput();
}