diff options
Diffstat (limited to 'kbiff/kbiffmonitor.cpp')
-rw-r--r-- | kbiff/kbiffmonitor.cpp | 194 |
1 files changed, 97 insertions, 97 deletions
diff --git a/kbiff/kbiffmonitor.cpp b/kbiff/kbiffmonitor.cpp index 37b51e9..3a7066e 100644 --- a/kbiff/kbiffmonitor.cpp +++ b/kbiff/kbiffmonitor.cpp @@ -35,11 +35,11 @@ #include <kbiffurl.h> #include <kdebug.h> -#include <qapplication.h> -#include <qstring.h> -#include <qregexp.h> -#include <qdir.h> -#include <qdatetime.h> +#include <ntqapplication.h> +#include <ntqstring.h> +#include <ntqregexp.h> +#include <ntqdir.h> +#include <ntqdatetime.h> #include <ksimpleconfig.h> // Needed for CRAM-MD5 and APOP @@ -54,11 +54,11 @@ extern int h_errno; #endif -static bool real_from(const QString& buffer); +static bool real_from(const TQString& buffer); static const char* compare_header(const char* header, const char* field); KBiffMonitor::KBiffMonitor() - : QObject(), + : TQObject(), poll(60), oldTimer(0), started(false), @@ -114,25 +114,25 @@ void KBiffMonitor::readConfig() KSimpleConfig *config = new KSimpleConfig(MAIL_STATE_FILE); config->setDollarExpansion(false); - QString group; + TQString group; group = mailbox + "(" + key + ")"; config->setGroup(group); - QStrList list; + TQStrList list; mailState = (KBiffMailState)config->readNumEntry("mailState", UnknownState); lastSize = config->readNumEntry("lastSize"); config->readListEntry("lastRead", list); if (list.count()==6) { - lastRead.setDate(QDate(atoi(list.at(0)),atoi(list.at(1)),atoi(list.at(2)))); - lastRead.setTime(QTime(atoi(list.at(3)),atoi(list.at(4)),atoi(list.at(5)))); + lastRead.setDate(TQDate(atoi(list.at(0)),atoi(list.at(1)),atoi(list.at(2)))); + lastRead.setTime(TQTime(atoi(list.at(3)),atoi(list.at(4)),atoi(list.at(5)))); } config->readListEntry("lastModified", list); if (list.count()==6) { - lastModified.setDate(QDate(atoi(list.at(0)),atoi(list.at(1)),atoi(list.at(2)))); - lastModified.setTime(QTime(atoi(list.at(3)),atoi(list.at(4)),atoi(list.at(5)))); + lastModified.setDate(TQDate(atoi(list.at(0)),atoi(list.at(1)),atoi(list.at(2)))); + lastModified.setTime(TQTime(atoi(list.at(3)),atoi(list.at(4)),atoi(list.at(5)))); } config->readListEntry("uidlList", list); @@ -140,7 +140,7 @@ void KBiffMonitor::readConfig() uidlList.clear(); for (UIDL = list.first(); UIDL != 0; UIDL = list.next()) { - uidlList.append( new QString(UIDL) ); + uidlList.append( new TQString(UIDL) ); } newCount = config->readNumEntry("newCount", 0); @@ -155,12 +155,12 @@ void KBiffMonitor::saveConfig() KSimpleConfig *config = new KSimpleConfig(MAIL_STATE_FILE); config->setDollarExpansion(false); - QString group; + TQString group; group = mailbox + "(" + key + ")"; config->setGroup(group); - QStringList uidlist; - QString *UIDL; + TQStringList uidlist; + TQString *UIDL; for (UIDL = uidlList.first(); UIDL != 0; UIDL = uidlList.next()) { uidlist.append(*UIDL); @@ -224,7 +224,7 @@ void KBiffMonitor::setPollInterval(const int interval) } } -void KBiffMonitor::setMailbox(const QString& url) +void KBiffMonitor::setMailbox(const TQString& url) { KBiffURL kurl(url); setMailbox(kurl); @@ -420,7 +420,7 @@ void KBiffMonitor::setMailbox(KBiffURL& url) void KBiffMonitor::setMailboxIsRead() { - lastRead = QDateTime::currentDateTime(); + lastRead = TQDateTime::currentDateTime(); if (mailState == NewMail) { if (b_new_lastSize) lastSize = new_lastSize; @@ -444,17 +444,17 @@ void KBiffMonitor::checkMailNow() emit(signal_checkMail()); } -void KBiffMonitor::setPassword(const QString& pass) +void KBiffMonitor::setPassword(const TQString& pass) { password = pass; } -void KBiffMonitor::setMailboxKey(const QString& k) +void KBiffMonitor::setMailboxKey(const TQString& k) { key = k; } -void KBiffMonitor::timerEvent(QTimerEvent *) +void KBiffMonitor::timerEvent(TQTimerEvent *) { emit(signal_checkMail()); } @@ -462,7 +462,7 @@ void KBiffMonitor::timerEvent(QTimerEvent *) void KBiffMonitor::checkLocal() { // get the information about this local mailbox - QFileInfo mbox(mailbox); + TQFileInfo mbox(mailbox); // run external fetch client if (!fetchCommand.isEmpty()) @@ -477,7 +477,7 @@ void KBiffMonitor::checkLocal() void KBiffMonitor::checkMbox() { // get the information about this local mailbox - QFileInfo mbox(mailbox); + TQFileInfo mbox(mailbox); // run external fetch client if (!fetchCommand.isEmpty()) @@ -501,7 +501,7 @@ void KBiffMonitor::checkMbox() utimbuf buf; buf.actime = mbox.lastRead().toTime_t(); buf.modtime = mbox.lastModified().toTime_t(); - utime(QFile::encodeName(mailbox), &buf); + utime(TQFile::encodeName(mailbox), &buf); } // if there are any new messages, consider the state New @@ -537,7 +537,7 @@ void KBiffMonitor::checkPop() { firstRun = false; - QString command; + TQString command; // connect to the server unless it is active already if (pop->active() == false) @@ -598,7 +598,7 @@ void KBiffMonitor::checkImap() { firstRun = false; - QString command; + TQString command; int seq = 1000; bool do_login = false; @@ -622,7 +622,7 @@ void KBiffMonitor::checkImap() do_login = true; // check the server's capabilities (see RFC 3050, 6.1.1) - command = QString().setNum(seq) + " CAPABILITY\r\n"; + command = TQString().setNum(seq) + " CAPABILITY\r\n"; if (imap->command(command, seq) == false) { invalidLogin(); @@ -646,7 +646,7 @@ void KBiffMonitor::checkImap() imap->resetNumbers(); // The STATUS COMMAND is documented in RFC2060, 6.3.10 - command = QString().setNum(seq) + " STATUS " + mailbox + " (UNSEEN MESSAGES)\r\n"; + command = TQString().setNum(seq) + " STATUS " + mailbox + " (UNSEEN MESSAGES)\r\n"; if ( ! imap->command(command, seq)) { return; } @@ -655,7 +655,7 @@ void KBiffMonitor::checkImap() // lets not logout if we want to keep the session alive if (keepalive == false) { - command = QString().setNum(seq) + " LOGOUT\r\n"; + command = TQString().setNum(seq) + " LOGOUT\r\n"; if (imap->command(command, seq) == false) return; imap->close(); @@ -683,7 +683,7 @@ void KBiffMonitor::checkMaildir() firstRun = false; // get the information about this local mailbox - QDir mbox(mailbox); + TQDir mbox(mailbox); // run external fetch client if (!fetchCommand.isEmpty()) @@ -693,15 +693,15 @@ void KBiffMonitor::checkMaildir() if (mbox.exists()) { // maildir stores its mail in MAILDIR/new and MAILDIR/cur - QDir new_mailbox(mailbox + "/new"); - QDir cur_mailbox(mailbox + "/cur"); + TQDir new_mailbox(mailbox + "/new"); + TQDir cur_mailbox(mailbox + "/cur"); // make sure both exist if (new_mailbox.exists() && cur_mailbox.exists()) { // check only files - new_mailbox.setFilter(QDir::Files); - cur_mailbox.setFilter(QDir::Files); + new_mailbox.setFilter(TQDir::Files); + cur_mailbox.setFilter(TQDir::Files); // determining "new" (or "unread") mail in maildir folders // is a *little* tricky. all mail in the 'new' folder are @@ -710,11 +710,11 @@ void KBiffMonitor::checkMaildir() newCount = new_mailbox.count(); curCount = cur_mailbox.count(); - const QFileInfoList *cur_list = cur_mailbox.entryInfoList(); - QFileInfoListIterator it(*cur_list); - QFileInfo *info; + const TQFileInfoList *cur_list = cur_mailbox.entryInfoList(); + TQFileInfoListIterator it(*cur_list); + TQFileInfo *info; - static QRegExp suffix(":2,?F?R?S?T?$"); + static TQRegExp suffix(":2,?F?R?S?T?$"); while ((info = it.current())) { if (info->fileName().findRev(suffix) == -1) @@ -746,7 +746,7 @@ void KBiffMonitor::checkNntp() { firstRun = false; - QString command; + TQString command; bool do_login = false; // connect to the server @@ -792,9 +792,9 @@ void KBiffMonitor::checkNntp() } // now, we process the .newsrc file - QString home(getenv("HOME")); - QString newsrc_path(home + "/.newsrc"); - QFile newsrc(newsrc_path); + TQString home(getenv("HOME")); + TQString newsrc_path(home + "/.newsrc"); + TQFile newsrc(newsrc_path); if (newsrc.open(IO_ReadOnly) == false) { return; @@ -804,7 +804,7 @@ void KBiffMonitor::checkNntp() while(newsrc.readLine(c_buffer, MAXSTR) > 0) { // search for our mailbox name - QString str_buffer(c_buffer); + TQString str_buffer(c_buffer); if (str_buffer.left(mailbox.length()) != mailbox) continue; @@ -886,7 +886,7 @@ void KBiffMonitor::checkMHdir() firstRun = false; // get the information about this local mailbox - QDir mbox(mailbox); + TQDir mbox(mailbox); char the_buffer[MAXSTR]; char *buffer = the_buffer; @@ -898,7 +898,7 @@ void KBiffMonitor::checkMHdir() // make sure the mailbox exists if (mbox.exists()) { - QFile mhseq(mailbox+"/.mh_sequences"); + TQFile mhseq(mailbox+"/.mh_sequences"); if (mhseq.open(IO_ReadOnly) == true) { // Check the .mh_sequences file for 'unseen:' @@ -980,9 +980,9 @@ void KBiffMonitor::checkMHdir() // OK. No new messages listed in .mh_sequences. Check if // there are any old ones. - //mbox.setFilter(QDir::Files); - QStringList mails = mbox.entryList(QDir::Files); - QStringList::Iterator str; + //mbox.setFilter(TQDir::Files); + TQStringList mails = mbox.entryList(TQDir::Files); + TQStringList::Iterator str; for (str = mails.begin(); str != mails.end(); str++) { @@ -1079,7 +1079,7 @@ void KBiffMonitor::determineState(unsigned int size) void KBiffMonitor::determineState(KBiffUidlList uidl_list) { - QString *UIDL; + TQString *UIDL; unsigned int messages = 0; // if the uidl_list is empty then the number of messages = 0 @@ -1186,7 +1186,7 @@ void KBiffMonitor::determineState(KBiffMailState state) emit(signal_currentStatus(newCount, key, mailState)); } -void KBiffMonitor::determineState(unsigned int size, const QDateTime& last_read, const QDateTime& last_modified) +void KBiffMonitor::determineState(unsigned int size, const TQDateTime& last_read, const TQDateTime& last_modified) { // Check for NoMail if (size == 0) @@ -1253,7 +1253,7 @@ void KBiffMonitor::determineState(unsigned int size, const QDateTime& last_read, */ int KBiffMonitor::mboxMessages() { - QFile mbox(mailbox); + TQFile mbox(mailbox); char buffer[MAXSTR]; int count = 0; int msg_count = 0; @@ -1357,7 +1357,7 @@ int KBiffMonitor::mboxMessages() if(++msg_count >= 100 ) { - qApp->processEvents(); + tqApp->processEvents(); msg_count = 0; } }//while @@ -1433,7 +1433,7 @@ void KBiffSocket::close() FD_ZERO(&socketFDS); } -bool KBiffSocket::connectSocket(const QString& host, unsigned short int port) +bool KBiffSocket::connectSocket(const TQString& host, unsigned short int port) { sockaddr_in sin; hostent *hent; @@ -1546,7 +1546,7 @@ bool KBiffSocket::connectSocket(const QString& host, unsigned short int port) #endif // USE_SSL // we're connected! see if the connection is good - QString line(readLine()); + TQString line(readLine()); if (line.isNull() || ((line.find("200") == -1 ) && (line.find("OK") == -1) && (line.find("PREAUTH") == -1))) { if (line.isNull()) @@ -1637,7 +1637,7 @@ void KBiffSocket::setSSL(bool on) } #endif // USE_SSL -int KBiffSocket::writeLine(const QString& line) +int KBiffSocket::writeLine(const TQString& line) { int bytes = 0; @@ -1659,9 +1659,9 @@ int KBiffSocket::writeLine(const QString& line) return bytes; } -QString KBiffSocket::readLine() +TQString KBiffSocket::readLine() { - QString fault, response; + TQString fault, response; char buffer; ssize_t bytes = -1; @@ -1719,10 +1719,10 @@ KBiffImap::~KBiffImap() close(); } -bool KBiffImap::command(const QString& line, unsigned int seq) +bool KBiffImap::command(const TQString& line, unsigned int seq) { - QString messagesListString; - QStringList messagesList; + TQString messagesListString; + TQStringList messagesList; bool tried_cram_md5; // are we trying CRAM-MD5 ? if (writeLine(line) <= 0) @@ -1731,19 +1731,19 @@ bool KBiffImap::command(const QString& line, unsigned int seq) return false; } - QString ok, bad, no, response; + TQString ok, bad, no, response; ok.sprintf("%d OK", seq); bad.sprintf("%d BAD", seq); no.sprintf("%d NO", seq); // must be case insensitive - QRegExp status("\\* STATUS", FALSE); - QRegExp capability("\\* CAPABILITY", FALSE); - QRegExp cram_md5("AUTHENTICATE CRAM-MD5", FALSE); + TQRegExp status("\\* STATUS", FALSE); + TQRegExp capability("\\* CAPABILITY", FALSE); + TQRegExp cram_md5("AUTHENTICATE CRAM-MD5", FALSE); // are we trying CRAM-MD5 ? tried_cram_md5 = cram_md5.search(line)>=0; - cram_md5 = QRegExp("\\+ ([A-Za-z0-9+/=]+)"); + cram_md5 = TQRegExp("\\+ ([A-Za-z0-9+/=]+)"); while (!(response = readLine()).isNull()) { @@ -1766,15 +1766,15 @@ bool KBiffImap::command(const QString& line, unsigned int seq) * S: . OK STATUS Completed */ if (status.search(response) >= 0) { - QRegExp unseen("UNSEEN ([0-9]*)", FALSE); + TQRegExp unseen("UNSEEN ([0-9]*)", FALSE); if (unseen.search(response) >= 0) { - QString num = unseen.cap(1); + TQString num = unseen.cap(1); newMessages = num.toInt(); } - QRegExp number("MESSAGES ([0-9]*)", FALSE); + TQRegExp number("MESSAGES ([0-9]*)", FALSE); if (number.search(response) >= 0) { - QString num = number.cap(1); + TQString num = number.cap(1); messages = num.toInt(); } } @@ -1787,7 +1787,7 @@ bool KBiffImap::command(const QString& line, unsigned int seq) * S: . OK CAPABILITY completed. */ if (capability.search(response) >= 0) { - QRegExp cram_md5_cap("AUTH=CRAM-MD5", FALSE); + TQRegExp cram_md5_cap("AUTH=CRAM-MD5", FALSE); if (cram_md5_cap.search(response) >= 0) { auth_cram_md5 = true; } @@ -1809,9 +1809,9 @@ bool KBiffImap::command(const QString& line, unsigned int seq) return false; } -QString KBiffImap::mungeUserPass(const QString& old_user) +TQString KBiffImap::mungeUserPass(const TQString& old_user) { - QString new_user(old_user); + TQString new_user(old_user); if (new_user.left(1) != "\"") new_user.prepend("\""); @@ -1827,23 +1827,23 @@ void KBiffImap::resetNumbers() newMessages = 0; } -bool KBiffImap::authenticate(int *pseq, const QString& user, const QString& pass) +bool KBiffImap::authenticate(int *pseq, const TQString& user, const TQString& pass) { - QString cmd, username, password; + TQString cmd, username, password; // If CRAM-MD5 is available, use it. It's the best we know. // RFC 2195 defines the CRAM-MD5 authentication method // also see RFC 3501 section 6.2.2 for the AUTHENTICATE command if( auth_cram_md5 ) { - cmd = QString("%1 AUTHENTICATE CRAM-MD5\r\n").arg(*pseq); + cmd = TQString("%1 AUTHENTICATE CRAM-MD5\r\n").arg(*pseq); if (command(cmd, *pseq) == false) { return false; } // calculate the real response to the challenge - QString response = user + " " + KBiffCrypt::hmac_md5(chall_cram_md5, pass); + TQString response = user + " " + KBiffCrypt::hmac_md5(chall_cram_md5, pass); response = KCodecs::base64Encode(response.latin1()); // send the response @@ -1863,7 +1863,7 @@ bool KBiffImap::authenticate(int *pseq, const QString& user, const QString& pass // to _always_ munge the user and the password. password = mungeUserPass(pass); - cmd = QString().setNum(*pseq) + " LOGIN " + cmd = TQString().setNum(*pseq) + " LOGIN " + username + " " + password + "\r\n"; if (command(cmd, *pseq) == false) @@ -1899,12 +1899,12 @@ void KBiffPop::setApop( bool enabled ) use_apop = enabled; } -bool KBiffPop::command(const QString& line) +bool KBiffPop::command(const TQString& line) { if (writeLine(line) <= 0) return false; - QString response; + TQString response; response = readLine(); // check if the response was bad. if so, return now @@ -1925,7 +1925,7 @@ bool KBiffPop::command(const QString& line) !response.isNull() && response.left(1) != "."; response = readLine()) { - uidlList.append(new QString(response.right(response.length() - + uidlList.append(new TQString(response.right(response.length() - response.find(" ") - 1))); } } @@ -1948,7 +1948,7 @@ bool KBiffPop::command(const QString& line) // find out what the server is capable of if (line == "CAPA\r\n") { - QRegExp rx("\\bCRAM-MD5\\b"); + TQRegExp rx("\\bCRAM-MD5\\b"); auth_cram_md5 = false; // assume no support @@ -1964,7 +1964,7 @@ bool KBiffPop::command(const QString& line) // look for the CRAM-MD5 challenge if (line == "AUTH CRAM-MD5\r\n") { - QRegExp challenge("\\+ ([A-Za-z0-9+/=]+)"); + TQRegExp challenge("\\+ ([A-Za-z0-9+/=]+)"); if (challenge.search(response) == -1 ) { return false; @@ -1996,7 +1996,7 @@ bool KBiffPop::parseBanner(void) } // Look for the banner part that indicates APOP support - QRegExp rx("(<[a-zA-Z0-9_+.-]+@[a-zA-Z0-9_+.-]+>)"); + TQRegExp rx("(<[a-zA-Z0-9_+.-]+@[a-zA-Z0-9_+.-]+>)"); if( rx.search(banner) == -1 || !use_apop ) { auth_apop = false; } else { @@ -2010,11 +2010,11 @@ bool KBiffPop::parseBanner(void) /*! This method authenticates using the most secure technique available. - \fn KBiffPop::authenticate(const QString& user, const QString& pass) + \fn KBiffPop::authenticate(const TQString& user, const TQString& pass) */ -bool KBiffPop::authenticate(const QString& user, const QString& pass) +bool KBiffPop::authenticate(const TQString& user, const TQString& pass) { - QString popcommand; + TQString popcommand; // CRAM-MD5 authentication is the most secure we can handle // the use of the AUTH command is documented in RFC 1734 @@ -2026,7 +2026,7 @@ bool KBiffPop::authenticate(const QString& user, const QString& pass) } // calculate the real response to the challenge - QString response = user + " " + KBiffCrypt::hmac_md5(chall_cram_md5, pass); + TQString response = user + " " + KBiffCrypt::hmac_md5(chall_cram_md5, pass); response = KCodecs::base64Encode(response.latin1()); // send the response @@ -2042,14 +2042,14 @@ bool KBiffPop::authenticate(const QString& user, const QString& pass) // than sending the password in the clear if( auth_apop ) { - QCString digest; + TQCString digest; KMD5 md5(chall_apop); md5.update(pass); digest = md5.hexDigest(); - popcommand = QString("APOP %1 %2\r\n").arg(user, digest.data()); + popcommand = TQString("APOP %1 %2\r\n").arg(user, digest.data()); if (this->command(popcommand) == false) { return false; @@ -2082,14 +2082,14 @@ KBiffNntp::~KBiffNntp() close(); } -bool KBiffNntp::command(const QString& line) +bool KBiffNntp::command(const TQString& line) { int bogus; if (writeLine(line) <= 0) return false; - QString response; + TQString response; while (!(response = readLine()).isNull()) { // return if the response is bad @@ -2100,7 +2100,7 @@ bool KBiffNntp::command(const QString& line) } // find return codes for tcp, user, pass - QString code(response.left(3)); + TQString code(response.left(3)); if ((code == "200") || (code == "281") || (code == "381")) return true; @@ -2148,7 +2148,7 @@ static const char *day_name[8] = { "sun", "mon", "tue", "wed", "thu", "fri", "sat", 0 }; -static bool real_from(const QString& orig_buffer) +static bool real_from(const TQString& orig_buffer) { /* A valid from line will be in the following format: @@ -2181,7 +2181,7 @@ static bool real_from(const QString& orig_buffer) /* <weekday> */ found = 0; for (i = 0; day_name[i] != NULL; i++) - found = found || (qstrnicmp(day_name[i], buffer, 3) == 0); + found = found || (tqstrnicmp(day_name[i], buffer, 3) == 0); if (!found) return false; @@ -2191,7 +2191,7 @@ static bool real_from(const QString& orig_buffer) /* <month> */ found = 0; for (i = 0; month_name[i] != NULL; i++) - found = found || (qstrnicmp(month_name[i], buffer, 3) == 0); + found = found || (tqstrnicmp(month_name[i], buffer, 3) == 0); if (!found) return false; @@ -2208,7 +2208,7 @@ static const char* compare_header(const char* header, const char* field) { int len = strlen(field); - if (qstrnicmp(header, field, len)) + if (tqstrnicmp(header, field, len)) return NULL; header += len; |