<commit_before>/*
 *   Copyright 2012 Coherent Theory LLC
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "session.h"
#include "session_p.h"


#include "assetjob.h"
#include "assetoperations.h"
#include "ballotaddassetjob.h"
#include "ballotlistassetsjob.h"
#include "ballotremoveassetjob.h"
#include "channelsjob.h"
#include "changelanguagejob.h"
#include "createballotjob.h"
#include "deleteballotjob.h"
#include "installjob.h"
#include "listballotsjob.h"
#include "participantinfojob.h"
#include "registerjob.h"
#include "searchjob.h"
#include "signonjob.h"

#include <QNetworkAccessManager>
#include <QDebug>
#include <QDir>

using namespace Bodega;

Session::Private::Private(Session *parent)
        : q(parent),
          points(0),
          authenticated(false),
          netManager(new QNetworkAccessManager(q))
{
}

void Session::Private::setPoints(int p)
{
    if (p > -1) {
        points = p;
        emit q->pointsChanged(points);
    }
}

void Session::Private::signOnFinished(SignOnJob *job)
{
    imageUrls = job->imageUrls();
}

void Session::Private::jobFinished(NetworkJob *job)
{
    if (authenticated && !job->authSuccess()) {
        setPoints(0);
        emit q->disconnected();
    }

    if (authenticated != job->authSuccess()) {
        authenticated = !authenticated;
        emit q->authenticated(authenticated);
    }

    if (job->authSuccess()) {
        setPoints(job->points());
    }

    job->deleteLater();
}
<commit_msg>only treat the job as a session job (auth, etc) when there is json<commit_after>/*
 *   Copyright 2012 Coherent Theory LLC
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "session.h"
#include "session_p.h"


#include "assetjob.h"
#include "assetoperations.h"
#include "ballotaddassetjob.h"
#include "ballotlistassetsjob.h"
#include "ballotremoveassetjob.h"
#include "channelsjob.h"
#include "changelanguagejob.h"
#include "createballotjob.h"
#include "deleteballotjob.h"
#include "installjob.h"
#include "listballotsjob.h"
#include "participantinfojob.h"
#include "registerjob.h"
#include "searchjob.h"
#include "signonjob.h"

#include <QNetworkAccessManager>
#include <QDebug>
#include <QDir>

using namespace Bodega;

Session::Private::Private(Session *parent)
        : q(parent),
          points(0),
          authenticated(false),
          netManager(new QNetworkAccessManager(q))
{
}

void Session::Private::setPoints(int p)
{
    if (p > -1) {
        points = p;
        emit q->pointsChanged(points);
    }
}

void Session::Private::signOnFinished(SignOnJob *job)
{
    imageUrls = job->imageUrls();
}

void Session::Private::jobFinished(NetworkJob *job)
{
    if (!job->isJsonResponse()) {
        return;
    }

    if (authenticated && !job->authSuccess()) {
        setPoints(0);
        emit q->disconnected();
    }

    if (authenticated != job->authSuccess()) {
        authenticated = !authenticated;
        emit q->authenticated(authenticated);
    }

    if (job->authSuccess()) {
        setPoints(job->points());
    }

    job->deleteLater();
}

{'fraction_non_alphanumeric': 0.11362617660242044, 'fraction_numerical': 0.008516360376512775, 'mean_word_length': 3.5774358974358975, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '79073', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1342, 'n_words': 422}