23 #include <ksimpleconfig.h>
24 #include <kstandarddirs.h>
25 #include <kstaticdeleter.h>
29 #include "vcardformatplugin.h"
31 #include "formatfactory.h"
48 FormatFactory::FormatFactory()
50 mFormatList.setAutoDelete(
true );
53 FormatInfo *
info =
new FormatInfo;
54 info->library =
"<NoLibrary>";
55 info->nameLabel = i18n(
"vCard" );
56 info->descriptionLabel = i18n(
"vCard Format" );
57 mFormatList.insert(
"vcard",
info );
60 for ( TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it )
64 if ( !config.hasGroup(
"Misc" ) || !config.hasGroup(
"Plugin" ) )
67 info =
new FormatInfo;
69 config.setGroup(
"Plugin" );
70 TQString type = config.readEntry(
"Type" );
71 info->library = config.readEntry(
"X-TDE-Library" );
73 config.setGroup(
"Misc" );
74 info->nameLabel = config.readEntry(
"Name" );
75 info->descriptionLabel = config.readEntry(
"Comment", i18n(
"No description available." ) );
77 mFormatList.insert( type,
info );
93 TQDictIterator<FormatInfo> it( mFormatList );
94 for ( ; it.current(); ++it )
95 if ( it.currentKey() !=
"vcard" )
96 retval << it.currentKey();
103 if ( type.isEmpty() )
106 return mFormatList[ type ];
113 if ( type.isEmpty() )
116 if ( type ==
"vcard" ) {
119 format->setNameLabel( i18n(
"vCard" ) );
120 format->setDescriptionLabel( i18n(
"vCard Format" ) );
124 FormatInfo *fi = mFormatList[ type ];
127 TQString libName = fi->library;
129 KLibrary *library = openLibrary( libName );
133 void *format_func = library->
symbol(
"format" );
138 format->setNameLabel( fi->nameLabel );
139 format->setDescriptionLabel( fi->descriptionLabel );
141 kdDebug( 5700 ) <<
"'" << libName <<
"' is not a format plugin." <<
endl;
149 KLibrary *FormatFactory::openLibrary(
const TQString& libName )
155 if ( path.isEmpty() ) {
156 kdDebug( 5700 ) <<
"No format plugin library was found!" <<
endl;
163 kdDebug( 5700 ) <<
"Could not load library '" << libName <<
"'" <<
endl;
static KLibLoader * self()
static TQString findLibrary(const char *name, const TDEInstance *instance=TDEGlobal::instance())
virtual KLibrary * library(const char *libname)
void * symbol(const char *name) const
static TDEStandardDirs * dirs()
TQStringList findAllResources(const char *type, const TQString &filter=TQString::null, bool recursive=false, bool unique=false) const
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
static data, shared by ALL addressee objects