script.cpp
00001 /***************************************************************************
00002 script.cpp - parse XML configuration file
00003 -------------------
00004 begin : Fri Apr 13 2001
00005 copyright : (C) 2001,2002,2003 by Claudiu Costin
00006 email : claudiuc@kde.org
00007 ***************************************************************************/
00008
00009 /***************************************************************************
00010 * *
00011 * This program is free software; you can redistribute it and/or modify *
00012 * it under the terms of the GNU General Public License as published by *
00013 * the Free Software Foundation; either version 2 of the License, or *
00014 * (at your option) any later version. *
00015 * *
00016 ***************************************************************************/
00017
00018 #include <qfile.h>
00019 #include <qdom.h>
00020
00021 #include <kstddirs.h>
00022
00023 #include "script.h"
00024
00025 Script::Script() {
00026 QString id, title, description, path, mode, script, optsep, linesep;
00027 KStandardDirs *dirs = KGlobal::dirs();
00028 QStringList list = dirs->findAllResources("data","kcmpureftpd/*.purescr",false,true);
00029
00030 for (QStringList::Iterator it=list.begin(); it != list.end(); ++it) {
00031 QFile f(*it);
00032 QDomDocument doc(dirs->findResource("data","kcmpureftpd/kcmpureftpdscript.dtd"));
00033 if (f.open(IO_ReadOnly)) {
00034 if (doc.setContent(&f)) {
00035 id = title = description = path = QString::null;
00036 script = optsep = linesep = QString::null;
00037 QDomElement docElem = doc.documentElement();
00038 mode = docElem.attribute("mode","0755");
00039 QDomNode n = docElem.firstChild();
00040 while (!n.isNull()) {
00041 QDomElement e = n.toElement();
00042 if (!e.isNull()) {
00043 if (!e.tagName().compare("id")) {
00044 id = e.text().stripWhiteSpace();
00045 }
00046 if (!e.tagName().compare("title")) {
00047 title = e.text().stripWhiteSpace();
00048 }
00049 if (!e.tagName().compare("description")) {
00050 description = e.text().stripWhiteSpace();
00051 }
00052 if (!e.tagName().compare("path")) {
00053 path = e.text().stripWhiteSpace();
00054 }
00055 if (!e.tagName().compare("script")) {
00056 script = e.text().stripWhiteSpace();
00057 }
00058 if (!e.tagName().compare("optsep")) {
00059 optsep = e.text();
00060 }
00061 if (!e.tagName().compare("linesep")) {
00062 linesep = e.text();
00063 }
00064 }
00065 n = n.nextSibling();
00066 }
00067 _scriptList.append(ScriptItem(id,title,description,path,mode,script,optsep,linesep));
00068 }
00069 f.close();
00070 }
00071 }
00072 }
00073
00074
00075 Script::~Script() {}
00076
00077
00078 int Script::count() {
00079 return _scriptList.count();
00080 }
00081
00082 ScriptList::Iterator Script::at(int position) {
00083 return _scriptList.at(position);
00084 }
00085
00086
Generated on Thu Jul 24 01:57:14 2003 by doxygen 1.2.15.
