<commit_before>/*
 * Copyright 2011 Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at 
 * http://www.apache.org/licenses/LICENSE-2.0
 */

#include "chatagent.h"
#include <TelepathyQt4/Channel>
#include <TelepathyQt4/PendingReady>
#include <TelepathyQt4/TextChannel>
#include <TelepathyQt4/ChannelRequest>
#include <TelepathyQt4/PendingChannelRequest>
#include <TelepathyQt4/PendingChannel>
#include <TelepathyQt4/PendingContacts>
#include <TelepathyQt4/Contact>
#include <TelepathyQt4/ContactManager>
#include <TelepathyQt4/ReceivedMessage>
#include <QDebug>

ChatAgent::ChatAgent(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, QObject *parent)
    : QObject(parent),
      mAccount(account),
      mContact(contact),
      mHandleOwners(Tp::HandleOwnerMap()),
      mExistsChat(false),
      mModel(0),
      mPendingChannelRequest(0)
{
    qDebug() << "ChatAgent::ChatAgent: created for contact " << mContact->id();

    connect(mAccount.data(), SIGNAL(connectionChanged(const Tp::ConnectionPtr&)),
            SLOT(onAccountConnectionChanged(const Tp::ConnectionPtr&)));

    onAccountConnectionChanged(mAccount->connection());
    // todo check contact readyness
}

ChatAgent::ChatAgent(const Tp::AccountPtr &account, const QString &roomName, QObject *parent)
    : QObject(parent),
      mAccount(account),
      mHandleOwners(Tp::HandleOwnerMap()),
      mTextChannel(0),
      mExistsChat(false),
      mModel(0),
      mPendingChannelRequest(0)
{
    qDebug() << "ChatAgent::ChatAgent: created for account " << mAccount->uniqueIdentifier()
             << "for a group chat named " << roomName;

    mPendingChannelRequest = mAccount->ensureTextChatroom(roomName, QDateTime::currentDateTime(), QLatin1String("org.freedesktop.Telepathy.Client.MeeGoIM"));
    if (!mPendingChannelRequest) {
        emit error(tr("Unable to create text channel room %1")
                   .arg(roomName));
        endChat();
        return;
    }

    connect(mPendingChannelRequest,
            SIGNAL(finished(Tp::PendingOperation*)),
            SLOT(onPendingChanelRequestFinished(Tp::PendingOperation*)));
    connect(mPendingChannelRequest,
            SIGNAL(channelRequestCreated(Tp::ChannelRequestPtr)),
            SLOT(onPendingChanelRequestCreated(Tp::ChannelRequestPtr)));
    connect(mAccount.data(), SIGNAL(connectionChanged(const Tp::ConnectionPtr&)),
            SIGNAL(onAccountConnectionChanged(const Tp::ConnectionPtr&)));

    onAccountConnectionChanged(mAccount->connection());
}

ChatAgent::ChatAgent(const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel, QObject *parent)
    : QObject(parent),
      mAccount(account),
      mHandleOwners(Tp::HandleOwnerMap()),
      mTextChannel(channel),
      mExistsChat(true),
      mModel(0),
      mPendingChannelRequest(0)
{
    qDebug() << "ChatAgent::ChatAgent: created for account " << mAccount->uniqueIdentifier()
             << "with an existing channel " << channel->objectPath();

    handleReadyChannel();
    emit isConferenceChanged();

    connect(mAccount.data(), SIGNAL(connectionChanged(const Tp::ConnectionPtr&)),
            SIGNAL(onAccountConnectionChanged(const Tp::ConnectionPtr&)));

    onAccountConnectionChanged(mAccount->connection());
}

ChatAgent::~ChatAgent()
{
    qDebug() << "ChatAgent::~ChatAgent: destroyed for contact " << mContact->id();

    // todo deallocate whatever is needed
    endChat();
}<commit_msg>Fixed slot connection in ChatAgent<commit_after>/*
 * Copyright 2011 Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at 
 * http://www.apache.org/licenses/LICENSE-2.0
 */

#include "chatagent.h"
#include <TelepathyQt4/Channel>
#include <TelepathyQt4/PendingReady>
#include <TelepathyQt4/TextChannel>
#include <TelepathyQt4/ChannelRequest>
#include <TelepathyQt4/PendingChannelRequest>
#include <TelepathyQt4/PendingChannel>
#include <TelepathyQt4/PendingContacts>
#include <TelepathyQt4/Contact>
#include <TelepathyQt4/ContactManager>
#include <TelepathyQt4/ReceivedMessage>
#include <QDebug>

ChatAgent::ChatAgent(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, QObject *parent)
    : QObject(parent),
      mAccount(account),
      mContact(contact),
      mHandleOwners(Tp::HandleOwnerMap()),
      mExistsChat(false),
      mModel(0),
      mPendingChannelRequest(0)
{
    qDebug() << "ChatAgent::ChatAgent: created for contact " << mContact->id();

    connect(mAccount.data(), SIGNAL(connectionChanged(const Tp::ConnectionPtr&)),
            SLOT(onAccountConnectionChanged(const Tp::ConnectionPtr&)));

    onAccountConnectionChanged(mAccount->connection());
    // todo check contact readyness
}

ChatAgent::ChatAgent(const Tp::AccountPtr &account, const QString &roomName, QObject *parent)
    : QObject(parent),
      mAccount(account),
      mHandleOwners(Tp::HandleOwnerMap()),
      mTextChannel(0),
      mExistsChat(false),
      mModel(0),
      mPendingChannelRequest(0)
{
    qDebug() << "ChatAgent::ChatAgent: created for account " << mAccount->uniqueIdentifier()
             << "for a group chat named " << roomName;

    mPendingChannelRequest = mAccount->ensureTextChatroom(roomName, QDateTime::currentDateTime(), QLatin1String("org.freedesktop.Telepathy.Client.MeeGoIM"));
    if (!mPendingChannelRequest) {
        emit error(tr("Unable to create text channel room %1")
                   .arg(roomName));
        endChat();
        return;
    }

    connect(mPendingChannelRequest,
            SIGNAL(finished(Tp::PendingOperation*)),
            SLOT(onPendingChanelRequestFinished(Tp::PendingOperation*)));
    connect(mPendingChannelRequest,
            SIGNAL(channelRequestCreated(Tp::ChannelRequestPtr)),
            SLOT(onPendingChanelRequestCreated(Tp::ChannelRequestPtr)));
    connect(mAccount.data(), SIGNAL(connectionChanged(const Tp::ConnectionPtr&)),
            SLOT(onAccountConnectionChanged(Tp::ConnectionPtr)));
    onAccountConnectionChanged(mAccount->connection());
}

ChatAgent::ChatAgent(const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel, QObject *parent)
    : QObject(parent),
      mAccount(account),
      mHandleOwners(Tp::HandleOwnerMap()),
      mTextChannel(channel),
      mExistsChat(true),
      mModel(0),
      mPendingChannelRequest(0)
{
    qDebug() << "ChatAgent::ChatAgent: created for account " << mAccount->uniqueIdentifier()
             << "with an existing channel " << channel->objectPath();

    handleReadyChannel();
    emit isConferenceChanged();

    connect(mAccount.data(), SIGNAL(connectionChanged(const Tp::ConnectionPtr&)),
            SIGNAL(onAccountConnectionChanged(const Tp::ConnectionPtr&)));

    onAccountConnectionChanged(mAccount->connection());
}

ChatAgent::~ChatAgent()
{
    qDebug() << "ChatAgent::~ChatAgent: destroyed for contact " << mContact->id();

    // todo deallocate whatever is needed
    endChat();
}
{'fraction_non_alphanumeric': 0.1278725504018046, 'fraction_numerical': 0.007613139715212181, 'mean_word_length': 4.461123941493456, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3287608', 'n_tokens_mistral': 2056, 'n_tokens_neox': 2021, 'n_words': 381}