• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

  • kdecore
kprotocolinfofactory.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 1999 Torben Weis <weis@kde.org>
3  Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include <kstandarddirs.h>
21 #include <kglobal.h>
22 #include <kapplication.h>
23 #include <kdebug.h>
24 #include <ksycoca.h>
25 #include <ksycocadict.h>
26 
27 #include "kprotocolinfofactory.h"
28 
29 
30 KProtocolInfoFactory* KProtocolInfoFactory::_self = 0;
31 
32 KProtocolInfoFactory::KProtocolInfoFactory() : KSycocaFactory( KST_KProtocolInfoFactory )
33 {
34  _self = this;
35 }
36 
37 KProtocolInfoFactory::~KProtocolInfoFactory()
38 {
39  _self = 0;
40 }
41 
42 
43 KProtocolInfo*
44 KProtocolInfoFactory::createEntry(int offset)
45 {
46  KProtocolInfo *info = 0;
47  KSycocaType type;
48  TQDataStream *str = KSycoca::self()->findEntry(offset, type);
49  switch (type)
50  {
51  case KST_KProtocolInfo:
52  info = new KProtocolInfo(*str, offset);
53  break;
54  default:
55  return 0;
56  }
57  if (!info->isValid())
58  {
59  delete info;
60  info = 0;
61  }
62  return info;
63 }
64 
65 
66 TQStringList KProtocolInfoFactory::protocols()
67 {
68  TQStringList res;
69 
70  KSycocaEntry::List list = allEntries();
71  for( KSycocaEntry::List::Iterator it = list.begin();
72  it != list.end();
73  ++it)
74  {
75  KSycocaEntry *entry = (*it).data();
76  KProtocolInfo *info = static_cast<KProtocolInfo *>(entry);
77 
78  res.append( info->name() );
79  }
80 
81  return res;
82 }
83 
84 KProtocolInfo *
85 KProtocolInfoFactory::findProtocol(const TQString &protocol)
86 {
87  if (!m_sycocaDict) return 0; // Error!
88 
89  TQMap<TQString,KProtocolInfo::Ptr>::iterator it = m_cache.find(protocol);
90  if (it != m_cache.end())
91  return (*it);
92 
93  int offset;
94 
95  offset = m_sycocaDict->find_string( protocol );
96 
97  if (!offset) return 0; // Not found;
98 
99  KProtocolInfo *info = createEntry(offset);
100 
101  if (info && (info->name() != protocol))
102  {
103  // No it wasn't...
104  delete info;
105  info = 0; // Not found
106  }
107  m_cache.insert(protocol,info);
108  return info;
109 }
110 
111 void KProtocolInfoFactory::virtual_hook( int id, void* data )
112 { KSycocaFactory::virtual_hook( id, data ); }
113 

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |