summaryrefslogtreecommitdiffstats
path: root/src/kvilib/ext/kvi_sharedfiles.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-28 18:31:12 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-28 18:31:12 +0000
commit0a80cfd57d271dd44221467efb426675fa470356 (patch)
tree6f503a31aa078eaf8fa015cf1749808529d49fc9 /src/kvilib/ext/kvi_sharedfiles.cpp
parent3329e5a804e28ef3f5eb51d1e7affdd5a508e8f2 (diff)
downloadkvirc-0a80cfd57d271dd44221467efb426675fa470356.tar.gz
kvirc-0a80cfd57d271dd44221467efb426675fa470356.zip
TQt4 port kvirc
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1238719 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/kvilib/ext/kvi_sharedfiles.cpp')
-rw-r--r--src/kvilib/ext/kvi_sharedfiles.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/kvilib/ext/kvi_sharedfiles.cpp b/src/kvilib/ext/kvi_sharedfiles.cpp
index 65ce0d69..b3c96e11 100644
--- a/src/kvilib/ext/kvi_sharedfiles.cpp
+++ b/src/kvilib/ext/kvi_sharedfiles.cpp
@@ -30,7 +30,7 @@
#include "kvi_config.h"
#include "kvi_fileutils.h"
-#include <qfileinfo.h>
+#include <tqfileinfo.h>
// TODO: Match servers that the file requests come from
// TODO: Max number of downloads ?
@@ -60,7 +60,7 @@
with /usr/arch/mp3/SonataArctica_SingInSilence_Live.mp3 as real file path , something like
"SonataArctica_SingInSilence.mp3". A remote user will then request you a DCC GET SonataArctica_SingInSilence.mp3
and KVIrc will automatically send the file.[br]
- Each file offer has an "user mask" that the requesting remote users must match to
+ Each file offer has an "user tqmask" that the requesting remote users must match to
obtain the file: *!*@* matches any user, Pragma!*@* matches any user with nickname pragma,
*!*@*.omnikron.net matches any user coming from the omnikron.net domain.[br]
Each offer can have an expire time: the offer will be automatically removed after
@@ -69,8 +69,8 @@
use an additional "size" parameter in the DCC GET request.[br]
[big]Security issues[/big]
This is a nice but unsecure method of sharing files.[br]
- The user mask is a good protection but you have to use it properly!.[br]
- Setting the user mask to Nick!*@* can be easily exploited (just by making an user disconnect
+ The user tqmask is a good protection but you have to use it properly!.[br]
+ Setting the user tqmask to Nick!*@* can be easily exploited (just by making an user disconnect
in one of the well known ways and then by using his nickname).[br]
On the other side, the remote end must know exactly the visible name of the offer to request
and noone but you will tell him that name.[br]
@@ -79,7 +79,7 @@
Please don't send complains if someone stoles your /etc/passwd : it is because you have permitted that.[br]
*/
-KviSharedFile::KviSharedFile(const QString &szName,const QString &szAbsPath,const QString &szUserMask,time_t expireTime,unsigned int uFileSize)
+KviSharedFile::KviSharedFile(const TQString &szName,const TQString &szAbsPath,const TQString &szUserMask,time_t expireTime,unsigned int uFileSize)
{
m_szName = szName;
m_szAbsFilePath = szAbsPath;
@@ -87,10 +87,10 @@ KviSharedFile::KviSharedFile(const QString &szName,const QString &szAbsPath,cons
m_expireTime = expireTime;
m_uFileSize = uFileSize;
#ifdef COMPILE_USE_QT4
- // QT4ROX: Because they have finally moved the functionality of QString::contains() to QString::count(), and QString::contains() now does the right job
+ // QT4ROX: Because they have finally moved the functionality of TQString::tqcontains() to TQString::count(), and TQString::tqcontains() now does the right job
m_uWildCount = m_szUserMask.count('*');
#else
- m_uWildCount = m_szUserMask.contains('*');
+ m_uWildCount = m_szUserMask.tqcontains('*');
#endif
m_uNonWildCount = m_szUserMask.length() - m_uWildCount;
}
@@ -101,12 +101,12 @@ KviSharedFile::~KviSharedFile()
KviSharedFilesManager::KviSharedFilesManager()
-: QObject()
+: TQObject()
{
- m_pSharedListDict = new KviPointerHashTable<QString,KviSharedFileList>();
+ m_pSharedListDict = new KviPointerHashTable<TQString,KviSharedFileList>();
m_pSharedListDict->setAutoDelete(true);
- m_pCleanupTimer = new QTimer();
- connect(m_pCleanupTimer,SIGNAL(timeout()),this,SLOT(cleanup()));
+ m_pCleanupTimer = new TQTimer();
+ connect(m_pCleanupTimer,TQT_SIGNAL(timeout()),this,TQT_SLOT(cleanup()));
}
KviSharedFilesManager::~KviSharedFilesManager()
@@ -118,13 +118,13 @@ KviSharedFilesManager::~KviSharedFilesManager()
void KviSharedFilesManager::cleanup()
{
- KviPointerHashTableIterator<QString,KviSharedFileList> it(*m_pSharedListDict);
+ KviPointerHashTableIterator<TQString,KviSharedFileList> it(*m_pSharedListDict);
time_t curTime = time(0);
bool bOtherStuffToCleanup = false;
//bool bChanged = false;
- KviPointerList<QString> lDying;
+ KviPointerList<TQString> lDying;
lDying.setAutoDelete(true);
while(KviSharedFileList * l = it.current())
@@ -150,12 +150,12 @@ void KviSharedFilesManager::cleanup()
emit sharedFileRemoved(fo);
}
if(l->count() == 0)
- lDying.append(new QString(it.currentKey()));
+ lDying.append(new TQString(it.currentKey()));
++it;
}
- for(QString * pDyingKey = lDying.first();pDyingKey;pDyingKey = lDying.next())
+ for(TQString * pDyingKey = lDying.first();pDyingKey;pDyingKey = lDying.next())
m_pSharedListDict->remove(*pDyingKey);
if(!bOtherStuffToCleanup)m_pCleanupTimer->stop();
@@ -175,7 +175,7 @@ void KviSharedFilesManager::doInsert(KviSharedFileList * l, KviSharedFile * o)
{
if(o->wildcardCount() > 0)
{
- // the new mask has wildcards... if the current one has none, skip it
+ // the new tqmask has wildcards... if the current one has none, skip it
if(fo->wildcardCount() > 0)
{
// the one in the list has wildcards too...
@@ -200,7 +200,7 @@ void KviSharedFilesManager::doInsert(KviSharedFileList * l, KviSharedFile * o)
}
} // else the current has no wildcards...skip
} else {
- // the new mask has no wildcards....
+ // the new tqmask has no wildcards....
if(fo->wildcardCount() > 0)
{
// current one has wildcards...insert
@@ -208,8 +208,8 @@ void KviSharedFilesManager::doInsert(KviSharedFileList * l, KviSharedFile * o)
return;
}
// the current one has no wildcards...
- // the longer masks go first....
- if(fo->maskLength() < o->maskLength())
+ // the longer tqmasks go first....
+ if(fo->tqmaskLength() < o->tqmaskLength())
{
// the current one is shorter than the new one...insert
l->insert(index,o);
@@ -224,12 +224,12 @@ void KviSharedFilesManager::doInsert(KviSharedFileList * l, KviSharedFile * o)
void KviSharedFilesManager::addSharedFile(KviSharedFile * f)
{
// First find the list
- KviSharedFileList * l = m_pSharedListDict->find(f->name());
+ KviSharedFileList * l = m_pSharedListDict->tqfind(f->name());
if(!l)
{
l = new KviSharedFileList;
l->setAutoDelete(true);
- m_pSharedListDict->replace(f->name(),l);
+ m_pSharedListDict->tqreplace(f->name(),l);
}
doInsert(l,f);
@@ -242,18 +242,18 @@ void KviSharedFilesManager::addSharedFile(KviSharedFile * f)
emit sharedFileAdded(f);
}
-KviSharedFile * KviSharedFilesManager::addSharedFile(const QString &szName,const QString &szAbsPath,const QString &szMask,int timeoutInSecs)
+KviSharedFile * KviSharedFilesManager::addSharedFile(const TQString &szName,const TQString &szAbsPath,const TQString &szMask,int timeoutInSecs)
{
- QFileInfo inf(szAbsPath);
+ TQFileInfo inf(szAbsPath);
if(inf.exists() && inf.isFile() && inf.isReadable() && (inf.size() > 0))
{
// First find the list
- KviSharedFileList * l = m_pSharedListDict->find(szName);
+ KviSharedFileList * l = m_pSharedListDict->tqfind(szName);
if(!l)
{
l = new KviSharedFileList;
l->setAutoDelete(true);
- m_pSharedListDict->replace(szName,l);
+ m_pSharedListDict->tqreplace(szName,l);
}
// Now insert
@@ -270,24 +270,24 @@ KviSharedFile * KviSharedFilesManager::addSharedFile(const QString &szName,const
return o;
} else {
- debug("File %s unreadable: can't add offer",KviQString::toUtf8(szAbsPath).data());
+ debug("File %s unreadable: can't add offer",KviTQString::toUtf8(szAbsPath).data());
return 0;
}
}
-KviSharedFile * KviSharedFilesManager::lookupSharedFile(const QString &szName,KviIrcMask * mask,unsigned int uFileSize)
+KviSharedFile * KviSharedFilesManager::lookupSharedFile(const TQString &szName,KviIrcMask * tqmask,unsigned int uFileSize)
{
- KviSharedFileList * l = m_pSharedListDict->find(szName);
+ KviSharedFileList * l = m_pSharedListDict->tqfind(szName);
if(!l)return 0;
for(KviSharedFile * o = l->first();o;o = l->next())
{
bool bMatch;
- if(mask)
+ if(tqmask)
{
KviIrcMask umask(o->userMask());
- bMatch = mask->matchedBy(umask);
- } else bMatch = KviQString::equalCS(o->userMask(),"*!*@*");
+ bMatch = tqmask->matchedBy(umask);
+ } else bMatch = KviTQString::equalCS(o->userMask(),"*!*@*");
if(bMatch)
{
if(uFileSize > 0)
@@ -299,18 +299,18 @@ KviSharedFile * KviSharedFilesManager::lookupSharedFile(const QString &szName,Kv
return 0;
}
-bool KviSharedFilesManager::removeSharedFile(const QString &szName,const QString &szMask,unsigned int uFileSize)
+bool KviSharedFilesManager::removeSharedFile(const TQString &szName,const TQString &szMask,unsigned int uFileSize)
{
- KviSharedFileList * l = m_pSharedListDict->find(szName);
+ KviSharedFileList * l = m_pSharedListDict->tqfind(szName);
if(!l)return false;
for(KviSharedFile * o = l->first();o;o = l->next())
{
- if(KviQString::equalCI(szMask,o->userMask()))
+ if(KviTQString::equalCI(szMask,o->userMask()))
{
bool bMatch = uFileSize > 0 ? uFileSize == o->fileSize() : true;
if(bMatch)
{
- QString save = szName; // <-- szName MAY Be a pointer to o->name()
+ TQString save = szName; // <-- szName MAY Be a pointer to o->name()
l->removeRef(o);
if(l->count() == 0)m_pSharedListDict->remove(save);
emit sharedFileRemoved(o);
@@ -321,15 +321,15 @@ bool KviSharedFilesManager::removeSharedFile(const QString &szName,const QString
return false;
}
-bool KviSharedFilesManager::removeSharedFile(const QString &szName,KviSharedFile * off)
+bool KviSharedFilesManager::removeSharedFile(const TQString &szName,KviSharedFile * off)
{
- KviSharedFileList * l = m_pSharedListDict->find(szName);
+ KviSharedFileList * l = m_pSharedListDict->tqfind(szName);
if(!l)return false;
for(KviSharedFile * o = l->first();o;o = l->next())
{
if(off == o)
{
- QString save = szName; // <-- szName MAY Be a pointer to o->name()
+ TQString save = szName; // <-- szName MAY Be a pointer to o->name()
l->removeRef(o);
if(l->count() == 0)m_pSharedListDict->remove(save);
emit sharedFileRemoved(off);
@@ -340,7 +340,7 @@ bool KviSharedFilesManager::removeSharedFile(const QString &szName,KviSharedFile
}
-void KviSharedFilesManager::load(const QString &filename)
+void KviSharedFilesManager::load(const TQString &filename)
{
KviConfig cfg(filename,KviConfig::Read);
//cfg.clear();
@@ -348,25 +348,25 @@ void KviSharedFilesManager::load(const QString &filename)
int num = cfg.readIntEntry("NEntries",0);
for(int idx=0;idx<num;idx++)
{
- QString tmp;
- KviQString::sprintf(tmp,"%dFName",idx);
- QString szName = cfg.readQStringEntry(tmp,"");
- KviQString::sprintf(tmp,"%dFilePath",idx);
- QString szPath = cfg.readQStringEntry(tmp,"");
- KviQString::sprintf(tmp,"%dUserMask",idx);
- QString szMask = cfg.readQStringEntry(tmp,"");
+ TQString tmp;
+ KviTQString::sprintf(tmp,"%dFName",idx);
+ TQString szName = cfg.readTQStringEntry(tmp,"");
+ KviTQString::sprintf(tmp,"%dFilePath",idx);
+ TQString szPath = cfg.readTQStringEntry(tmp,"");
+ KviTQString::sprintf(tmp,"%dUserMask",idx);
+ TQString szMask = cfg.readTQStringEntry(tmp,"");
if(!szMask.isEmpty() && !szPath.isEmpty() && !szName.isEmpty())
addSharedFile(szName,szPath,szMask,0);
}
}
-void KviSharedFilesManager::save(const QString &filename)
+void KviSharedFilesManager::save(const TQString &filename)
{
KviConfig cfg(filename,KviConfig::Write);
cfg.clear();
cfg.setGroup("PermanentFileOffers");
- KviPointerHashTableIterator<QString,KviSharedFileList> it(*m_pSharedListDict);
+ KviPointerHashTableIterator<TQString,KviSharedFileList> it(*m_pSharedListDict);
int idx = 0;
while(KviSharedFileList * l = it.current())
{
@@ -374,12 +374,12 @@ void KviSharedFilesManager::save(const QString &filename)
{
if(((int)(o->expireTime())) == 0)
{
- QString tmp;
- KviQString::sprintf(tmp,"%dFName",idx);
+ TQString tmp;
+ KviTQString::sprintf(tmp,"%dFName",idx);
cfg.writeEntry(tmp,it.currentKey());
- KviQString::sprintf(tmp,"%dFilePath",idx);
+ KviTQString::sprintf(tmp,"%dFilePath",idx);
cfg.writeEntry(tmp,o->absFilePath());
- KviQString::sprintf(tmp,"%dUserMask",idx);
+ KviTQString::sprintf(tmp,"%dUserMask",idx);
cfg.writeEntry(tmp,o->userMask());
++idx;
}