kservice.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __kservices_h__ 00021 #define __kservices_h__ 00022 00023 #include <tqstringlist.h> 00024 #include <tqmap.h> 00025 #include <tqvariant.h> 00026 #include <kicontheme.h> 00027 00028 #include "tdesycocaentry.h" 00029 00030 class TQDataStream; 00031 class KDesktopFile; 00032 class KService; 00033 class KBuildSycoca; 00034 class TQWidget; 00035 00048 class TDEIO_EXPORT KService : public KSycocaEntry 00049 { 00050 K_SYCOCATYPE( KST_KService, KSycocaEntry ) 00051 00052 friend class KBuildSycoca; 00053 00054 public: 00055 typedef TDESharedPtr<KService> Ptr; 00056 typedef TQValueList<Ptr> List; 00057 public: 00064 KService( const TQString & _name, const TQString &_exec, const TQString &_icon); 00065 00071 explicit KService( const TQString & _fullpath ); 00072 00077 KService( KDesktopFile *config ); // KDE-4.0: make explicit 00078 00084 KService( TQDataStream& _str, int offset ); 00085 00086 virtual ~KService(); 00087 00092 virtual TQString type() const { return m_strType; } 00098 virtual TQString name() const { return m_strName; } 00104 TQString exec() const { return m_strExec; } 00111 TQString library() const { return m_strLibrary; } 00118 TQString init() const { return m_strInit; } 00119 00125 TQString icon() const { return m_strIcon; } 00132 TQPixmap pixmap( TDEIcon::Group _group, int _force_size = 0, int _state = 0, 00133 TQString * _path = 0L ) const; 00138 bool terminal() const { return m_bTerminal; } 00147 TQString terminalOptions() const { return m_strTerminalOptions; } 00153 bool substituteUid() const; 00161 TQString username() const; 00162 00174 TQString desktopEntryPath() const { return entryPath(); } 00175 00182 TQString desktopEntryName() const { return m_strDesktopEntryName; } 00183 00190 TQString menuId() const; 00191 00199 TQString storageId() const; 00200 00213 enum DCOPServiceType_t { DCOP_None = 0, DCOP_Unique, DCOP_Multi, DCOP_Wait }; 00214 00219 DCOPServiceType_t DCOPServiceType() const { return m_DCOPServiceType; } 00220 00226 TQString path() const { return m_strPath; } 00227 00233 TQString comment() const { return m_strComment; } 00234 00241 TQString genericName() const { return m_strGenName; } 00242 00251 TQString untranslatedGenericName() const; 00252 00257 TQStringList keywords() const { return m_lstKeywords; } 00258 00264 TQStringList categories() const; 00265 00270 TQStringList serviceTypes() const { return m_lstServiceTypes; } 00271 00280 bool hasServiceType( const TQString& _service ) const; 00281 00292 bool allowAsDefault() const { return m_bAllowAsDefault; } 00293 00300 bool allowMultipleFiles() const; 00301 00308 int initialPreference() const { return m_initialPreference; } 00309 00318 int initialPreferenceForMimeType( const TQString& mimeType ) const; 00319 00323 void setInitialPreference( int i ) { m_initialPreference = i; } 00324 00329 bool noDisplay() const; 00333 bool SuSEunimportant() const; 00334 00341 TQString parentApp() const; 00342 00355 virtual TQVariant property( const TQString& _name ) const; 00356 00366 TQVariant property( const TQString& _name, TQVariant::Type t ) const; 00367 00373 virtual TQStringList propertyNames() const; 00374 00379 bool isValid() const { return m_bValid; } 00380 00387 TQString locateLocal(); 00388 00393 virtual void load( TQDataStream& ); 00398 virtual void save( TQDataStream& ); 00403 void setMenuId(const TQString &menuId); 00408 void setTerminal(bool b) { m_bTerminal = b; } 00413 void setTerminalOptions(const TQString &options) { m_strTerminalOptions = options; } 00414 00424 static Ptr serviceByName( const TQString& _name ); 00425 00435 static Ptr serviceByDesktopPath( const TQString& _path ); 00436 00451 static Ptr serviceByDesktopName( const TQString& _name ); 00452 00462 static Ptr serviceByMenuId( const TQString& _menuId ); 00463 00474 static Ptr serviceByStorageId( const TQString& _storageId ); 00475 00485 static List allServices(); 00486 00493 static List allInitServices(); 00494 00510 static TQString newServicePath(bool showInMenu, const TQString &suggestedName, 00511 TQString *menuId = 0, 00512 const TQStringList *reservedMenuIds = 0); 00513 00514 00520 static void rebuildKSycoca(TQWidget *parent); 00521 00522 protected: 00523 00524 void init(KDesktopFile *config); 00525 00526 TQStringList &accessServiceTypes() { return m_lstServiceTypes; } 00527 00528 00529 private: 00530 KService( const KService& ); // forbidden 00531 KService& operator=(const KService&); 00532 00533 TQString m_strType; 00534 TQString m_strName; 00535 TQString m_strExec; 00536 TQString m_strIcon; 00537 TQString m_strTerminalOptions; 00538 TQString m_strPath; 00539 TQString m_strComment; 00540 TQString m_strLibrary; 00541 TQStringList m_lstServiceTypes; 00542 bool m_bAllowAsDefault; 00543 int m_initialPreference; 00544 bool m_bTerminal; 00545 //bool m_bSuid; 00546 //TQString m_strUsername; 00547 TQString m_strDesktopEntryName; 00548 //TQString m_docPath; 00549 //bool m_bHideFromPanel; 00550 DCOPServiceType_t m_DCOPServiceType; 00551 TQMap<TQString,TQVariant> m_mapProps; 00552 bool m_bValid; 00553 TQStringList m_lstKeywords; 00554 TQString m_strInit; 00555 TQString m_strGenName; 00556 protected: 00557 virtual void virtual_hook( int id, void* data ); 00558 private: 00559 class KServicePrivate; 00560 KServicePrivate* d; 00561 }; 00562 #endif