/*
    This file is part of Akonadi Contact.

    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>

    This library 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 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 Library General Public
    License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to the
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
*/

#include "recentcontactscollectionrequestjob.h"

#include "recentcontactscollections_p.h"

#include <KLocalizedString>
#include <QStandardPaths>

using namespace Akonadi;

static const QByteArray sRecentContactsType()
{
    static const QByteArray type = "recent-contacts";
    return type;
}

RecentContactsCollectionRequestJob::RecentContactsCollectionRequestJob(QObject *parent)
    : SpecialCollectionsRequestJob(RecentContactsCollections::self(), parent)
    , d(0)
{
    static QMap<QByteArray, QString> displayNameMap;
    displayNameMap.insert("recent-contacts", i18nc("recent contacts folder", "Recent Contacts"));

    static QMap<QByteArray, QString> iconNameMap;
    iconNameMap.insert("recent-contacts", QStringLiteral("folder"));

    QVariantMap options;
    options.insert(QStringLiteral("Name"), displayNameMap.value("recent-contacts"));
    options.insert(QStringLiteral("Path"), QString(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + QLatin1String("recent-contacts")));

    setDefaultResourceType(QStringLiteral("akonadi_contacts_resource"));
    setDefaultResourceOptions(options);

    setTypes(displayNameMap.keys());
    setNameForTypeMap(displayNameMap);
    setIconForTypeMap(iconNameMap);
}

RecentContactsCollectionRequestJob::~RecentContactsCollectionRequestJob()
{
}

void RecentContactsCollectionRequestJob::requestDefaultCollection()
{
    SpecialCollectionsRequestJob::requestDefaultCollection(sRecentContactsType());
}

void RecentContactsCollectionRequestJob::requestCollection(const AgentInstance &instance)
{
    SpecialCollectionsRequestJob::requestCollection(sRecentContactsType(), instance);
}
