<commit_before>/*
 * Global Presence - wrap Tp::Presence with KDE functionality
 *
 * Copyright (C) 2011 <NAME> <<EMAIL>>
 * Copyright (C) 2012 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "presence.h"

#include <KLocalizedString>
#include <KIconLoader>

namespace KTp
{

Presence::Presence() :
    Tp::Presence()
{
}

Presence::Presence(const Tp::Presence &presence) :
    Tp::Presence(presence)
{
}

KIcon Presence::icon(bool useImIcons) const
{
    switch (type()) {
    case Tp::ConnectionPresenceTypeAvailable:
    case Tp::ConnectionPresenceTypeBusy:
    case Tp::ConnectionPresenceTypeAway:
    case Tp::ConnectionPresenceTypeExtendedAway:
    case Tp::ConnectionPresenceTypeHidden:
    case Tp::ConnectionPresenceTypeOffline:
        return KIcon(iconName(useImIcons));
    default:
        return KIcon();
    }
}
KIcon Presence::icon(QStringList overlays, bool useImIcons) const
{
    switch (type()) {
    case Tp::ConnectionPresenceTypeAvailable:
    case Tp::ConnectionPresenceTypeBusy:
    case Tp::ConnectionPresenceTypeAway:
    case Tp::ConnectionPresenceTypeExtendedAway:
    case Tp::ConnectionPresenceTypeHidden:
    case Tp::ConnectionPresenceTypeOffline:
        return KIcon(iconName(useImIcons),
                     KIconLoader::global(),
                     overlays);
    default:
        return KIcon();
    }
}

QString Presence::iconName(bool useImIcons) const
{
    switch (type()) {
    case Tp::ConnectionPresenceTypeAvailable:
        return useImIcons ? QLatin1String("im-user") : QLatin1String("user-online");<commit_msg>Replace switch with if check<commit_after>/*
 * Global Presence - wrap Tp::Presence with KDE functionality
 *
 * Copyright (C) 2011 <NAME> <<EMAIL>>
 * Copyright (C) 2012 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "presence.h"

#include <KLocalizedString>
#include <KIconLoader>

namespace KTp
{

Presence::Presence() :
    Tp::Presence()
{
}

Presence::Presence(const Tp::Presence &presence) :
    Tp::Presence(presence)
{
}

KIcon Presence::icon(bool useImIcons) const
{
    const QString &name(iconName(useImIcons));
    if (!name.isEmpty()) {
        return KIcon(name);
    }
    return KIcon();
}
KIcon Presence::icon(QStringList overlays, bool useImIcons) const
{
    const QString &name(iconName(useImIcons));
    if (!name.isEmpty()) {
        return KIcon(name,
                     KIconLoader::global(),
                     overlays);
    }
    return KIcon();
}

QString Presence::iconName(bool useImIcons) const
{
    switch (type()) {
    case Tp::ConnectionPresenceTypeAvailable:
        return useImIcons ? QLatin1String("im-user") : QLatin1String("user-online");
{'fraction_non_alphanumeric': 0.0972391888590276, 'fraction_numerical': 0.011238700219887612, 'mean_word_length': 3.810810810810811, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '756797', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1186, 'n_words': 403}