KoDeviceRegistry.cpp 1.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/* This file is part of the KDE project
 * Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net>
 *
 * 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 "KoDeviceRegistry.h"
21
#include <KGlobal>
22 23 24

#include <KoPluginLoader.h>

25 26
KoDeviceRegistry::KoDeviceRegistry()
{
27 28
}

29 30
void KoDeviceRegistry::init()
{
31 32 33 34
    KoPluginLoader::PluginsConfig config;
    config.whiteList = "DevicePlugins";
    config.blacklist = "DevicePluginsDisabled";
    config.group = "koffice";
35 36
    KoPluginLoader::instance()->load(QString::fromLatin1("KOffice/Device"),
                                     QString::fromLatin1("[X-Flake-MinVersion] <= 0"));
37

Jan Hambrecht's avatar
Jan Hambrecht committed
38
    foreach(const QString & id, keys()) {
39
        KoDevice * d = value(id);
40
        if (d)
41 42 43 44 45 46
            d->start();
    }
}

KoDeviceRegistry::~KoDeviceRegistry()
{
Jan Hambrecht's avatar
Jan Hambrecht committed
47
    foreach(const QString & id, keys()) {
48
        KoDevice * d = value(id);
49
        if (d)
50 51 52 53 54 55
            d->stop();
    }
}

KoDeviceRegistry* KoDeviceRegistry::instance()
{
56 57 58
    K_GLOBAL_STATIC(KoDeviceRegistry, s_instance)
    if (!s_instance.exists()) {
        s_instance->init();
59
    }
60
    return s_instance;
61 62 63
}

#include "KoDeviceRegistry.moc"