• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kcomponentdata.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 1999 Torben Weis <weis@kde.org>
00003    Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
00004    Copyright (C) 2007 Bernhard Loos <nhuh.put@web.de>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "kcomponentdata.h"
00022 #include "kcomponentdata_p.h"
00023 
00024 #include <QtCore/QCoreApplication>
00025 
00026 #include "kaboutdata.h"
00027 #include "kcmdlineargs.h"
00028 #include "kconfig.h"
00029 #include "kglobal.h"
00030 #include "kglobal_p.h"
00031 #include "klocale.h"
00032 #include "kconfiggroup.h"
00033 #include "kstandarddirs.h"
00034 #include <QtDebug>
00035 
00036 KComponentData::KComponentData()
00037     : d(0)
00038 {
00039 }
00040 
00041 KComponentData::KComponentData(const KComponentData &rhs)
00042     : d(rhs.d)
00043 {
00044     if (d) {
00045         d->ref();
00046     }
00047 }
00048 
00049 KComponentData &KComponentData::operator=(const KComponentData &rhs)
00050 {
00051     if (rhs.d != d) {
00052         if (rhs.d) {
00053             rhs.d->ref();
00054         }
00055         if (d) {
00056             d->deref();
00057         }
00058         d = rhs.d;
00059     }
00060     return *this;
00061 }
00062 
00063 bool KComponentData::operator==(const KComponentData &rhs) const
00064 {
00065     return d == rhs.d;
00066 }
00067 
00068 KComponentData::KComponentData(const QByteArray &name, const QByteArray &catalog, MainComponentRegistration registerAsMain)
00069     : d(new KComponentDataPrivate(KAboutData(name, catalog, KLocalizedString(), "", KLocalizedString())))
00070 {
00071     Q_ASSERT(!name.isEmpty());
00072 
00073     if (registerAsMain == RegisterAsMainComponent) {
00074         KGlobal::newComponentData(*this);
00075     }
00076 }
00077 
00078 KComponentData::KComponentData(const KAboutData *aboutData, MainComponentRegistration registerAsMain)
00079     : d(new KComponentDataPrivate(*aboutData))
00080 {
00081     Q_ASSERT(!aboutData->appName().isEmpty());
00082 
00083     if (registerAsMain == RegisterAsMainComponent) {
00084         KGlobal::newComponentData(*this);
00085     }
00086 }
00087 
00088 KComponentData::KComponentData(const KAboutData &aboutData, MainComponentRegistration registerAsMain)
00089     : d(new KComponentDataPrivate(aboutData))
00090 {
00091     Q_ASSERT(!aboutData.appName().isEmpty());
00092 
00093     if (registerAsMain == RegisterAsMainComponent) {
00094         KGlobal::newComponentData(*this);
00095     }
00096 }
00097 
00098 KComponentData::~KComponentData()
00099 {
00100     if (d) {
00101         d->deref();
00102         d = 0;
00103     }
00104 }
00105 
00106 bool KComponentData::isValid() const
00107 {
00108     return (d != 0);
00109 }
00110 
00111 void KComponentDataPrivate::lazyInit(const KComponentData &component)
00112 {
00113     if (dirs == 0) {
00114         dirs = new KStandardDirs();
00115         // install appdata resource type
00116         dirs->addResourceType("appdata", "data", aboutData.appName() + QLatin1Char('/'), true);
00117         
00118         configInit(component);
00119 
00120         if (dirs->addCustomized(sharedConfig.data()))
00121             sharedConfig->reparseConfiguration();
00122     }
00123 }
00124 
00125 bool kde_kiosk_exception = false; // flag to disable kiosk restrictions
00126 bool kde_kiosk_admin = false;
00127 
00128 void KComponentDataPrivate::configInit(const KComponentData &component)
00129 {
00130     Q_ASSERT(!sharedConfig);
00131 
00132     if (!configName.isEmpty()) {
00133         sharedConfig = KSharedConfig::openConfig(component, configName);
00134 
00135         //FIXME: this is broken and I don't know how to repair it
00136         // Check whether custom config files are allowed.
00137         KConfigGroup cg(sharedConfig, "KDE Action Restrictions");
00138         QString kioskException = cg.readEntry("kiosk_exception");
00139         if (!cg.readEntry("custom_config", true)) {
00140            sharedConfig = 0;
00141         }
00142     }
00143     
00144     if (!sharedConfig) {
00145         sharedConfig = KSharedConfig::openConfig(component);
00146     }
00147 
00148     // Check if we are excempt from kiosk restrictions
00149     if (kde_kiosk_admin && !kde_kiosk_exception && !qgetenv("KDE_KIOSK_NO_RESTRICTIONS").isEmpty()) {
00150         kde_kiosk_exception = true;
00151         sharedConfig = 0;
00152         configInit(component); // Reread...
00153     }
00154 }
00155 
00156 KStandardDirs *KComponentData::dirs() const
00157 {
00158     Q_ASSERT(d);
00159     d->lazyInit(*this);
00160 
00161     return d->dirs;
00162 }
00163 
00164 const KSharedConfig::Ptr &KComponentData::config() const
00165 {
00166     Q_ASSERT(d);
00167     d->lazyInit(*this);
00168 
00169     return d->sharedConfig;
00170 }
00171 
00172 void KComponentData::setConfigName(const QString &configName)
00173 {
00174     Q_ASSERT(d);
00175     d->configName = configName;
00176 }
00177 
00178 const KAboutData *KComponentData::aboutData() const
00179 {
00180     Q_ASSERT(d);
00181     return &d->aboutData;
00182 }
00183 
00184 QString KComponentData::componentName() const
00185 {
00186     Q_ASSERT(d);
00187     return d->aboutData.appName();
00188 }
00189 
00190 QString KComponentData::catalogName() const
00191 {
00192     Q_ASSERT(d);
00193     return d->aboutData.catalogName();
00194 }
00195 
00196 void KComponentData::virtual_hook(int, void*)
00197 { /*BASE::virtual_hook(id, data);*/ }

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal