diff options
Diffstat (limited to 'filesharing/advanced/kcm_sambaconf/sambafile.cpp')
-rw-r--r-- | filesharing/advanced/kcm_sambaconf/sambafile.cpp | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/filesharing/advanced/kcm_sambaconf/sambafile.cpp b/filesharing/advanced/kcm_sambaconf/sambafile.cpp index e8dbc5f8..25392514 100644 --- a/filesharing/advanced/kcm_sambaconf/sambafile.cpp +++ b/filesharing/advanced/kcm_sambaconf/sambafile.cpp @@ -17,13 +17,13 @@ */ -#include <qfile.h> -#include <qprocess.h> -#include <qfileinfo.h> +#include <tqfile.h> +#include <tqprocess.h> +#include <tqfileinfo.h> #include <ksimpleconfig.h> #include <kdebug.h> -#include <qfileinfo.h> +#include <tqfileinfo.h> #include <kio/job.h> #include <kprocess.h> #include <kmessagebox.h> @@ -41,20 +41,20 @@ SambaConfigFile::SambaConfigFile(SambaFile* sambaFile) { - QDict<QString>(10,false); + TQDict<TQString>(10,false); setAutoDelete(true); _sambaFile = sambaFile; } -QString SambaConfigFile::getDefaultValue(const QString & name) +TQString SambaConfigFile::getDefaultValue(const TQString & name) { SambaShare* defaults = _sambaFile->getTestParmValues(); - QString s = defaults->getValue(name,false,false); + TQString s = defaults->getValue(name,false,false); return s; } -SambaShare* SambaConfigFile::addShare(const QString & name) +SambaShare* SambaConfigFile::addShare(const TQString & name) { SambaShare* newShare = new SambaShare(name,this); addShare(name,newShare); @@ -62,25 +62,25 @@ SambaShare* SambaConfigFile::addShare(const QString & name) } -void SambaConfigFile::addShare(const QString & name, SambaShare* share) +void SambaConfigFile::addShare(const TQString & name, SambaShare* share) { insert(name,share), _shareList.append(name); } -void SambaConfigFile::removeShare(const QString & name) +void SambaConfigFile::removeShare(const TQString & name) { remove(name); _shareList.remove(name); } -QStringList SambaConfigFile::getShareList() +TQStringList SambaConfigFile::getShareList() { return _shareList; } -SambaFile::SambaFile(const QString & _path, bool _readonly) +SambaFile::SambaFile(const TQString & _path, bool _readonly) : readonly(_readonly), changed(false), path(_path), @@ -105,9 +105,9 @@ bool SambaFile::isRemoteFile() { } /** No descriptions */ -QString SambaFile::findShareByPath(const QString & path) const +TQString SambaFile::findShareByPath(const TQString & path) const { - QDictIterator<SambaShare> it(*_sambaConfig); + TQDictIterator<SambaShare> it(*_sambaConfig); KURL url(path); url.adjustPath(-1); @@ -115,7 +115,7 @@ QString SambaFile::findShareByPath(const QString & path) const { SambaShare* share = it.current(); - QString *s = share->find("path"); + TQString *s = share->find("path"); if (s) { KURL curUrl(*s); curUrl.adjustPath(-1); @@ -127,7 +127,7 @@ QString SambaFile::findShareByPath(const QString & path) const } } - return QString::null; + return TQString::null; } bool SambaFile::save() { @@ -147,7 +147,7 @@ bool SambaFile::slotApply() // if not we have to save the results in // a temporary file and copy it afterwards // over the smb.conf file with kdesu. - if (QFileInfo(path).isWritable()) + if (TQFileInfo(path).isWritable()) { saveTo(path); changed = false; @@ -166,14 +166,14 @@ bool SambaFile::slotApply() return false; } - QFileInfo fi(path); + TQFileInfo fi(path); KURL url(path); if (KURL(path).isLocalFile()) { KProcess proc; kdDebug(5009) << "SambaFile::slotApply: is local file!" << endl; - QString suCommand=QString("cp %1 %2; rm %3") + TQString suCommand=TQString("cp %1 %2; rm %3") .arg(_tempFile->name()) .arg(path) .arg(_tempFile->name()); @@ -200,8 +200,8 @@ bool SambaFile::slotApply() srcURL.setPath( _tempFile->name() ); KIO::FileCopyJob * job = KIO::file_copy( srcURL, url, -1, true ); - connect( job, SIGNAL( result( KIO::Job * ) ), - this, SLOT( slotSaveJobFinished ( KIO::Job * ) ) ); + connect( job, TQT_SIGNAL( result( KIO::Job * ) ), + this, TQT_SLOT( slotSaveJobFinished ( KIO::Job * ) ) ); return (job->error()==0); } @@ -211,20 +211,20 @@ bool SambaFile::slotApply() /** * Returns a name which isn't already used for a share **/ -QString SambaFile::getUnusedName(const QString alreadyUsedName) const +TQString SambaFile::getUnusedName(const TQString alreadyUsedName) const { - QString init = i18n("Unnamed"); - if (alreadyUsedName != QString::null) + TQString init = i18n("Unnamed"); + if (alreadyUsedName != TQString::null) init = alreadyUsedName; - QString s = init; + TQString s = init; int i = 2; while (_sambaConfig->find(s)) { - s = init+QString::number(i); + s = init+TQString::number(i); i++; } @@ -233,7 +233,7 @@ QString SambaFile::getUnusedName(const QString alreadyUsedName) const -SambaShare* SambaFile::newShare(const QString & name) +SambaShare* SambaFile::newShare(const TQString & name) { if (_sambaConfig->find(name)) return 0L; @@ -247,7 +247,7 @@ SambaShare* SambaFile::newShare(const QString & name) } -SambaShare* SambaFile::newShare(const QString & name, const QString & path) +SambaShare* SambaFile::newShare(const TQString & name, const TQString & path) { SambaShare* share = newShare(name); if (share) @@ -258,7 +258,7 @@ SambaShare* SambaFile::newShare(const QString & name, const QString & path) return share; } -SambaShare* SambaFile::newPrinter(const QString & name, const QString & printer) +SambaShare* SambaFile::newPrinter(const TQString & name, const TQString & printer) { SambaShare* share = newShare(name); @@ -273,7 +273,7 @@ SambaShare* SambaFile::newPrinter(const QString & name, const QString & printer) /** No descriptions */ -void SambaFile::removeShare(const QString & share) +void SambaFile::removeShare(const TQString & share) { changed = true; @@ -285,13 +285,13 @@ void SambaFile::removeShare(SambaShare* share) removeShare(share->getName()); } -void SambaFile::removeShareByPath(const QString & path) { - QString share = findShareByPath(path); +void SambaFile::removeShareByPath(const TQString & path) { + TQString share = findShareByPath(path); removeShare(share); } /** No descriptions */ -SambaShare* SambaFile::getShare(const QString & share) const +SambaShare* SambaFile::getShare(const TQString & share) const { SambaShare *s = _sambaConfig->find(share); @@ -305,7 +305,7 @@ SambaShareList* SambaFile::getSharedDirs() const { SambaShareList* list = new SambaShareList(); - QDictIterator<SambaShare> it(*_sambaConfig); + TQDictIterator<SambaShare> it(*_sambaConfig); for( ; it.current(); ++it ) { @@ -326,7 +326,7 @@ SambaShareList* SambaFile::getSharedPrinters() const { SambaShareList* list = new SambaShareList(); - QDictIterator<SambaShare> it(*_sambaConfig); + TQDictIterator<SambaShare> it(*_sambaConfig); for( ; it.current(); ++it ) { @@ -344,11 +344,11 @@ int SambaFile::getSambaVersion() { KProcess testParam; testParam << "testparm"; testParam << "-V"; - _parmOutput = QString(""); + _parmOutput = TQString(""); _sambaVersion = 2; - connect( &testParam, SIGNAL(receivedStdout(KProcess*,char*,int)), - this, SLOT(testParmStdOutReceived(KProcess*,char*,int))); + connect( &testParam, TQT_SIGNAL(receivedStdout(KProcess*,char*,int)), + this, TQT_SLOT(testParmStdOutReceived(KProcess*,char*,int))); @@ -378,10 +378,10 @@ SambaShare* SambaFile::getTestParmValues(bool reload) testParam << "/dev/null"; - _parmOutput = QString(""); + _parmOutput = TQString(""); - connect( &testParam, SIGNAL(receivedStdout(KProcess*,char*,int)), - this, SLOT(testParmStdOutReceived(KProcess*,char*,int))); + connect( &testParam, TQT_SIGNAL(receivedStdout(KProcess*,char*,int)), + this, TQT_SLOT(testParmStdOutReceived(KProcess*,char*,int))); if (testParam.start(KProcess::Block,KProcess::Stdout)) { @@ -394,23 +394,23 @@ SambaShare* SambaFile::getTestParmValues(bool reload) void SambaFile::testParmStdOutReceived(KProcess *, char *buffer, int buflen) { - _parmOutput+=QString::fromLatin1(buffer,buflen); + _parmOutput+=TQString::fromLatin1(buffer,buflen); } void SambaFile::parseParmStdOutput() { - QTextIStream s(&_parmOutput); + TQTextIStream s(&_parmOutput); if (_testParmValues) delete _testParmValues; _testParmValues = new SambaShare(_sambaConfig); - QString section=""; + TQString section=""; while (!s.atEnd()) { - QString line = s.readLine().stripWhiteSpace(); + TQString line = s.readLine().stripWhiteSpace(); // empty lines if (line.isEmpty()) @@ -437,8 +437,8 @@ void SambaFile::parseParmStdOutput() int i = line.find('='); if (i>-1) { - QString name = line.left(i).stripWhiteSpace(); - QString value = line.mid(i+1).stripWhiteSpace(); + TQString name = line.left(i).stripWhiteSpace(); + TQString value = line.mid(i+1).stripWhiteSpace(); _testParmValues->setValue(name,value,false,false); } @@ -452,9 +452,9 @@ void SambaFile::parseParmStdOutput() * Try to find the samba config file position * First tries the config file, then checks * several common positions -* If nothing is found returns QString::null +* If nothing is found returns TQString::null **/ -QString SambaFile::findSambaConf() +TQString SambaFile::findSambaConf() { return KSambaShare::instance()->smbConfPath(); } @@ -490,7 +490,7 @@ bool SambaFile::load() destURL.setPath( localPath ); KIO::FileCopyJob * job = KIO::file_copy( url, destURL, 0600, true, false, true ); // emit started( d->m_job ); - connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotJobFinished ( KIO::Job * ) ) ); + connect( job, TQT_SIGNAL( result( KIO::Job * ) ), this, TQT_SLOT( slotJobFinished ( KIO::Job * ) ) ); return true; } else { localPath = path; @@ -503,14 +503,14 @@ bool SambaFile::load() bool SambaFile::openFile() { - QFile f(localPath); + TQFile f(localPath); if (!f.open(IO_ReadOnly)) { - //throw SambaFileLoadException(QString("<qt>Could not open file <em>%1</em> for reading.</qt>").arg(path)); + //throw SambaFileLoadException(TQString("<qt>Could not open file <em>%1</em> for reading.</qt>").arg(path)); return false; } - QTextStream s(&f); + TQTextStream s(&f); delete _sambaConfig; @@ -518,12 +518,12 @@ bool SambaFile::openFile() { SambaShare *currentShare = 0L; bool continuedLine = false; // is true if the line before ended with a backslash - QString completeLine; - QStringList comments; + TQString completeLine; + TQStringList comments; while (!s.eof()) { - QString currentLine = s.readLine().stripWhiteSpace(); + TQString currentLine = s.readLine().stripWhiteSpace(); if (continuedLine) { @@ -555,7 +555,7 @@ bool SambaFile::openFile() { if ('[' == completeLine[0]) { // get the name of the section - QString section = completeLine.mid(1,completeLine.length()-2); + TQString section = completeLine.mid(1,completeLine.length()-2); currentShare = _sambaConfig->addShare(section); currentShare->setComments(comments); comments.clear(); @@ -568,8 +568,8 @@ bool SambaFile::openFile() { if (i>-1) { - QString name = completeLine.left(i).stripWhiteSpace(); - QString value = completeLine.mid(i+1).stripWhiteSpace(); + TQString name = completeLine.left(i).stripWhiteSpace(); + TQString value = completeLine.mid(i+1).stripWhiteSpace(); if (currentShare) { @@ -591,24 +591,24 @@ bool SambaFile::openFile() { return true; } -bool SambaFile::saveTo(const QString & path) +bool SambaFile::saveTo(const TQString & path) { - QFile f(path); + TQFile f(path); if (!f.open(IO_WriteOnly)) return false; - QTextStream s(&f); + TQTextStream s(&f); - QStringList shareList = _sambaConfig->getShareList(); + TQStringList shareList = _sambaConfig->getShareList(); - for ( QStringList::Iterator it = shareList.begin(); it != shareList.end(); ++it ) + for ( TQStringList::Iterator it = shareList.begin(); it != shareList.end(); ++it ) { SambaShare* share = _sambaConfig->find(*it); // First add all comments of the share to the file - QStringList comments = share->getComments(); - for ( QStringList::Iterator cmtIt = comments.begin(); cmtIt != comments.end(); ++cmtIt ) + TQStringList comments = share->getComments(); + for ( TQStringList::Iterator cmtIt = comments.begin(); cmtIt != comments.end(); ++cmtIt ) { s << *cmtIt << endl; @@ -624,14 +624,14 @@ bool SambaFile::saveTo(const QString & path) s << "[" << share->getName() << "]" << endl; // Add all options of the share - QStringList optionList = share->getOptionList(); + TQStringList optionList = share->getOptionList(); - for ( QStringList::Iterator optionIt = optionList.begin(); optionIt != optionList.end(); ++optionIt ) + for ( TQStringList::Iterator optionIt = optionList.begin(); optionIt != optionList.end(); ++optionIt ) { // Add the comments of the option comments = share->getComments(*optionIt); - for ( QStringList::Iterator cmtIt = comments.begin(); cmtIt != comments.end(); ++cmtIt ) + for ( TQStringList::Iterator cmtIt = comments.begin(); cmtIt != comments.end(); ++cmtIt ) { s << *cmtIt << endl; } @@ -651,21 +651,21 @@ bool SambaFile::saveTo(const QString & path) SambaConfigFile* SambaFile::getSambaConfigFile(KSimpleConfig* config) { - QStringList groups = config->groupList(); + TQStringList groups = config->groupList(); SambaConfigFile* samba = new SambaConfigFile(this); - for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) + for ( TQStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { - QMap<QString,QString> entries = config->entryMap(*it); + TQMap<TQString,TQString> entries = config->entryMap(*it); SambaShare *share = new SambaShare(*it,samba); samba->insert(*it,share); - for (QMap<QString,QString>::Iterator it2 = entries.begin(); it2 != entries.end(); ++it2 ) + for (TQMap<TQString,TQString>::Iterator it2 = entries.begin(); it2 != entries.end(); ++it2 ) { if (!it2.data().isEmpty()) - share->setValue(it2.key(),QString(it2.data()),false,false); + share->setValue(it2.key(),TQString(it2.data()),false,false); } } @@ -674,11 +674,11 @@ SambaConfigFile* SambaFile::getSambaConfigFile(KSimpleConfig* config) } -KSimpleConfig* SambaFile::getSimpleConfig(SambaConfigFile* sambaConfig, const QString & path) +KSimpleConfig* SambaFile::getSimpleConfig(SambaConfigFile* sambaConfig, const TQString & path) { KSimpleConfig *config = new KSimpleConfig(path,false); - QDictIterator<SambaShare> it(*sambaConfig); + TQDictIterator<SambaShare> it(*sambaConfig); for ( ; it.current(); ++it ) { @@ -686,7 +686,7 @@ KSimpleConfig* SambaFile::getSimpleConfig(SambaConfigFile* sambaConfig, const QS config->setGroup(it.currentKey()); - QDictIterator<QString> it2(*share); + TQDictIterator<TQString> it2(*share); for (; it2.current(); ++it2 ) { |