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

tdecore

  • tdecore
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 <tdestandarddirs.h>
21#include <tdeglobal.h>
22#include <tdeapplication.h>
23#include <kdebug.h>
24#include <tdesycoca.h>
25#include <tdesycocadict.h>
26
27#include "kprotocolinfofactory.h"
28
29
30KProtocolInfoFactory* KProtocolInfoFactory::_self = 0;
31
32KProtocolInfoFactory::KProtocolInfoFactory() : KSycocaFactory( KST_KProtocolInfoFactory )
33{
34 _self = this;
35}
36
37KProtocolInfoFactory::~KProtocolInfoFactory()
38{
39 _self = 0;
40}
41
42
43KProtocolInfo*
44KProtocolInfoFactory::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
66TQStringList 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
84KProtocolInfo *
85KProtocolInfoFactory::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
111void KProtocolInfoFactory::virtual_hook( int id, void* data )
112{ KSycocaFactory::virtual_hook( id, data ); }
113
KProtocolInfoFactory
KProtocolInfoFactory is a factory for getting KProtocolInfo.
Definition: kprotocolinfofactory.h:41
KProtocolInfoFactory::protocols
TQStringList protocols()
Returns list of all known protocols.
Definition: kprotocolinfofactory.cpp:66
KSycocaEntry
Base class for all Sycoca entries.
Definition: tdesycocaentry.h:38

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.