kservicetype.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00003 1999 Waldo Bastian <bastian@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 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 #ifndef __kservicetype_h__ 00022 #define __kservicetype_h__ 00023 00024 #include "ksycocaentry.h" 00025 #include "kservice.h" 00026 00027 #include <tqstring.h> 00028 #include <tqstringlist.h> 00029 #include <tqptrlist.h> 00030 #include <tqmap.h> 00031 #include <tqshared.h> 00032 #include <tqdatastream.h> 00033 #include <tqvariant.h> 00034 00035 #include <ksimpleconfig.h> 00036 00045 class KIO_EXPORT KServiceType : public KSycocaEntry 00046 { 00047 K_SYCOCATYPE( KST_KServiceType, KSycocaEntry ) 00048 00049 public: 00050 typedef KSharedPtr<KServiceType> Ptr; 00051 typedef TQValueList<Ptr> List; 00052 public: 00053 00062 KServiceType( const TQString & _fullpath, const TQString& _name, 00063 const TQString& _icon, const TQString& _comment); 00064 00070 KServiceType( const TQString & _fullpath ); 00071 00076 KServiceType( KDesktopFile *config); 00077 00082 KServiceType( TQDataStream& _str, int offset ); 00083 00084 virtual ~KServiceType(); 00085 00094 TQString icon() const { return m_strIcon; } 00095 00100 TQString comment() const { return m_strComment; } 00101 00106 TQString name() const { return m_strName; } 00107 00114 TQString desktopEntryPath() const { return entryPath(); } 00115 00121 bool isDerived() const { return m_bDerived; } 00122 00129 TQString parentServiceType() const; 00130 00136 bool inherits( const TQString& servTypeName ) const; 00137 00146 virtual TQVariant property( const TQString& _name ) const; 00147 00152 virtual TQStringList propertyNames() const; 00153 00158 bool isValid() const { return m_bValid; } 00159 00166 virtual TQVariant::Type propertyDef( const TQString& _name ) const; 00167 00168 virtual TQStringList propertyDefNames() const; 00169 virtual const TQMap<TQString,TQVariant::Type>& propertyDefs() const { return m_mapPropDefs; } 00170 00175 virtual void save( TQDataStream& ); 00176 00181 virtual void load( TQDataStream& ); 00182 00187 // gcc 2.95.x doesn't understand KServiceType::Ptr here 00188 /* KServiceType:: */ Ptr parentType(); 00193 void addService(KService::Ptr service); 00198 KService::List services(); 00199 00207 static Ptr serviceType( const TQString& _name ); 00208 00217 static KService::List offers( const TQString& _servicetype ); 00218 00227 static List allServiceTypes(); 00228 00229 protected: 00230 void init( KDesktopFile *config ); 00231 00232 protected: 00233 TQString m_strName; 00234 TQString m_strIcon; 00235 TQString m_strComment; 00236 TQMap<TQString,TQVariant> m_mapProps; 00237 TQMap<TQString,TQVariant::Type> m_mapPropDefs; 00238 00239 bool m_bValid:1; 00240 bool m_bDerived:1; 00241 protected: 00242 virtual void virtual_hook( int id, void* data ); 00243 private: 00244 class KServiceTypePrivate; 00245 KServiceTypePrivate* d; 00246 }; 00247 00248 //TQDataStream& operator>>( TQDataStream& _str, KServiceType& s ); 00249 //TQDataStream& operator<<( TQDataStream& _str, KServiceType& s ); 00250 00251 #endif