summaryrefslogtreecommitdiffstats
path: root/kio/misc/ksendbugmail
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:04:16 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:04:16 -0600
commit5159cd2beb2e87806a5b54e9991b7895285c9d3e (patch)
tree9b70e8be47a390f8f4d56ead812ab0c9dad88709 /kio/misc/ksendbugmail
parentc17cb900dcf52b8bd6dc300d4f103392900ec2b4 (diff)
downloadtdelibs-5159cd2beb2e87806a5b54e9991b7895285c9d3e.tar.gz
tdelibs-5159cd2beb2e87806a5b54e9991b7895285c9d3e.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'kio/misc/ksendbugmail')
-rw-r--r--kio/misc/ksendbugmail/CMakeLists.txt37
-rw-r--r--kio/misc/ksendbugmail/Makefile.am26
-rw-r--r--kio/misc/ksendbugmail/main.cpp142
-rw-r--r--kio/misc/ksendbugmail/main.h20
-rw-r--r--kio/misc/ksendbugmail/smtp.cpp336
-rw-r--r--kio/misc/ksendbugmail/smtp.h144
6 files changed, 0 insertions, 705 deletions
diff --git a/kio/misc/ksendbugmail/CMakeLists.txt b/kio/misc/ksendbugmail/CMakeLists.txt
deleted file mode 100644
index f0e1b99b0..000000000
--- a/kio/misc/ksendbugmail/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-#################################################
-#
-# (C) 2010 Serghei Amelian
-# serghei (DOT) amelian (AT) gmail.com
-#
-# Improvements and feedback are welcome
-#
-# This file is released under GPL >= 2
-#
-#################################################
-
-include_directories(
- ${TQT_INCLUDE_DIRS}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_BINARY_DIR}/tdecore
- ${CMAKE_SOURCE_DIR}/tdecore
- ${CMAKE_SOURCE_DIR}/kio/kio
-)
-
-link_directories(
- ${TQT_LIBRARY_DIRS}
-)
-
-
-##### ksendbugmail ##############################
-
-set( target ksendbugmail )
-
-set( ${target}_SRCS
- main.cpp smtp.cpp
-)
-
-tde_add_executable( ${target} AUTOMOC
- SOURCES ${${target}_SRCS}
- LINK kio-shared
- DESTINATION ${BIN_INSTALL_DIR}
-)
diff --git a/kio/misc/ksendbugmail/Makefile.am b/kio/misc/ksendbugmail/Makefile.am
deleted file mode 100644
index b24e36a26..000000000
--- a/kio/misc/ksendbugmail/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-# This file is part of the KDE libraries
-# Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-
-# You should have received a copy of the GNU Library General Public License
-# along with this library; see the file COPYING.LIB. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-# Boston, MA 02110-1301, USA.
-
-bin_PROGRAMS = ksendbugmail
-INCLUDES= -I$(srcdir)/.. $(all_includes)
-
-ksendbugmail_SOURCES = main.cpp smtp.cpp
-ksendbugmail_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
-ksendbugmail_LDADD = ../../libkio.la
-
-METASOURCES = AUTO
diff --git a/kio/misc/ksendbugmail/main.cpp b/kio/misc/ksendbugmail/main.cpp
deleted file mode 100644
index be1eb8b96..000000000
--- a/kio/misc/ksendbugmail/main.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// $Id$
-
-#include <sys/types.h>
-#include "main.h"
-#include <pwd.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <tqtextstream.h>
-
-#include <kapplication.h>
-#include <kemailsettings.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-#include <kaboutdata.h>
-#include <kdebug.h>
-#include <kconfig.h>
-
-#include "smtp.h"
-
-static KCmdLineOptions options[] = {
- { "subject <argument>", I18N_NOOP("Subject line"), 0 },
- { "recipient <argument>", I18N_NOOP("Recipient"), "submit@bugs.kde.org" },
- KCmdLineLastOption
-};
-
-void BugMailer::slotError(int errornum) {
- kdDebug() << "slotError\n";
- TQString str, lstr;
-
- switch(errornum) {
- case SMTP::CONNECTERROR:
- lstr = i18n("Error connecting to server.");
- break;
- case SMTP::NOTCONNECTED:
- lstr = i18n("Not connected.");
- break;
- case SMTP::CONNECTTIMEOUT:
- lstr = i18n("Connection timed out.");
- break;
- case SMTP::INTERACTTIMEOUT:
- lstr = i18n("Time out waiting for server interaction.");
- break;
- default:
- lstr = sm->getLastLine().stripWhiteSpace();
- lstr = i18n("Server said: \"%1\"").arg(lstr);
- }
- fputs(lstr.utf8().data(), stdout);
- fflush(stdout);
-
- ::exit(1);
-}
-
-void BugMailer::slotSend() {
- kdDebug() << "slotSend\n";
- ::exit(0);
-}
-
-int main(int argc, char **argv) {
-
- KLocale::setMainCatalogue("tdelibs");
- TDEAboutData d("ksendbugmail", I18N_NOOP("KSendBugMail"), "1.0",
- I18N_NOOP("Sends a short bug report to submit@bugs.kde.org"),
- TDEAboutData::License_GPL, "(c) 2000 Stephan Kulow");
- d.addAuthor("Stephan Kulow", I18N_NOOP("Author"), "coolo@kde.org");
-
- TDECmdLineArgs::init(argc, argv, &d);
- TDECmdLineArgs::addCmdLineOptions(options);
- TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
-
- TDEApplication a(false, false);
-
- TQCString recipient = args->getOption("recipient");
- if (recipient.isEmpty())
- recipient = "submit@bugs.kde.org";
- else {
- if (recipient.at(0) == '\'') {
- recipient = recipient.mid(1).left(recipient.length() - 2);
- }
- }
- kdDebug() << "recp \"" << recipient << "\"\n";
-
- TQCString subject = args->getOption("subject");
- if (subject.isEmpty())
- subject = "(no subject)";
- else {
- if (subject.at(0) == '\'')
- subject = subject.mid(1).left(subject.length() - 2);
- }
- TQTextIStream input(stdin);
- TQString text, line;
- while (!input.eof()) {
- line = input.readLine();
- text += line + "\r\n";
- }
- kdDebug() << text << endl;
-
- KEMailSettings emailConfig;
- emailConfig.setProfile(emailConfig.defaultProfileName());
- TQString fromaddr = emailConfig.getSetting(KEMailSettings::EmailAddress);
- if (!fromaddr.isEmpty()) {
- TQString name = emailConfig.getSetting(KEMailSettings::RealName);
- if (!name.isEmpty())
- fromaddr = name + TQString::fromLatin1(" <") + fromaddr + TQString::fromLatin1(">");
- } else {
- struct passwd *p;
- p = getpwuid(getuid());
- fromaddr = TQString::fromLatin1(p->pw_name);
- fromaddr += "@";
- char buffer[256];
- buffer[0] = '\0';
- if(!gethostname(buffer, sizeof(buffer)))
- buffer[sizeof(buffer)-1] = '\0';
- fromaddr += buffer;
- }
- kdDebug() << "fromaddr \"" << fromaddr << "\"" << endl;
-
- TQString server = emailConfig.getSetting(KEMailSettings::OutServer);
- if (server.isEmpty())
- server=TQString::fromLatin1("bugs.kde.org");
-
- SMTP *sm = new SMTP;
- BugMailer bm(sm);
-
- TQObject::connect(sm, TQT_SIGNAL(messageSent()), &bm, TQT_SLOT(slotSend()));
- TQObject::connect(sm, TQT_SIGNAL(error(int)), &bm, TQT_SLOT(slotError(int)));
- sm->setServerHost(server);
- sm->setPort(25);
- sm->setSenderAddress(fromaddr);
- sm->setRecipientAddress(recipient);
- sm->setMessageSubject(subject);
- sm->setMessageHeader(TQString::fromLatin1("From: %1\r\nTo: %2\r\n").arg(fromaddr).arg(recipient.data()));
- sm->setMessageBody(text);
- sm->sendMessage();
-
- int r = a.exec();
- kdDebug() << "execing " << r << endl;
- delete sm;
- return r;
-}
-
-#include "main.moc"
diff --git a/kio/misc/ksendbugmail/main.h b/kio/misc/ksendbugmail/main.h
deleted file mode 100644
index 39d424bef..000000000
--- a/kio/misc/ksendbugmail/main.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef BUG_MAILER_H
-#define BUG_MAILER_H "$Id$"
-
-#include <tqobject.h>
-
-class SMTP;
-
-class BugMailer : public TQObject {
- Q_OBJECT
-public:
- BugMailer(SMTP* s) : TQObject(0, "mailer"), sm(s) {}
-
-public slots:
- void slotError(int);
- void slotSend();
-private:
- SMTP *sm;
-};
-
-#endif
diff --git a/kio/misc/ksendbugmail/smtp.cpp b/kio/misc/ksendbugmail/smtp.cpp
deleted file mode 100644
index d282782fc..000000000
--- a/kio/misc/ksendbugmail/smtp.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-/* $Id$ */
-
-#include <sys/utsname.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include <kdebug.h>
-
-#include "smtp.h"
-
-SMTP::SMTP(char *serverhost, unsigned short int port, int timeout)
-{
- struct utsname uts;
-
- serverHost = serverhost;
- hostPort = port;
- timeOut = timeout * 1000;
-
- senderAddress = "user@example.net";
- recipientAddress = "user@example.net";
- messageSubject = "(no subject)";
- messageBody = "empty";
- messageHeader = "";
-
- connected = false;
- finished = false;
-
- sock = 0L;
- state = INIT;
- serverState = NONE;
-
- uname(&uts);
- domainName = uts.nodename;
-
-
- if(domainName.isEmpty())
- domainName = "somemachine.example.net";
-
- kdDebug() << "SMTP object created" << endl;
-
- connect(&connectTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(connectTimerTick()));
- connect(&timeOutTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(connectTimedOut()));
- connect(&interactTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(interactTimedOut()));
-
- // some sendmail will give 'duplicate helo' error, quick fix for now
- connect(this, TQT_SIGNAL(messageSent()), TQT_SLOT(closeConnection()));
-}
-
-SMTP::~SMTP()
-{
- if(sock){
- delete sock;
- sock = 0L;
- }
- connectTimer.stop();
- timeOutTimer.stop();
-}
-
-void SMTP::setServerHost(const TQString& serverhost)
-{
- serverHost = serverhost;
-}
-
-void SMTP::setPort(unsigned short int port)
-{
- hostPort = port;
-}
-
-void SMTP::setTimeOut(int timeout)
-{
- timeOut = timeout;
-}
-
-void SMTP::setSenderAddress(const TQString& sender)
-{
- senderAddress = sender;
- int index = senderAddress.find('<');
- if (index == -1)
- return;
- senderAddress = senderAddress.mid(index + 1);
- index = senderAddress.find('>');
- if (index != -1)
- senderAddress = senderAddress.left(index);
- senderAddress = senderAddress.simplifyWhiteSpace();
- while (1) {
- index = senderAddress.find(' ');
- if (index != -1)
- senderAddress = senderAddress.mid(index + 1); // take one side
- else
- break;
- }
- index = senderAddress.find('@');
- if (index == -1)
- senderAddress.append("@localhost"); // won't go through without a local mail system
-
-}
-
-void SMTP::setRecipientAddress(const TQString& recipient)
-{
- recipientAddress = recipient;
-}
-
-void SMTP::setMessageSubject(const TQString& subject)
-{
- messageSubject = subject;
-}
-
-void SMTP::setMessageBody(const TQString& message)
-{
- messageBody = message;
-}
-
-void SMTP::setMessageHeader(const TQString &header)
-{
- messageHeader = header;
-}
-
-void SMTP::openConnection(void)
-{
- kdDebug() << "started connect timer" << endl;
- connectTimer.start(100, true);
-}
-
-void SMTP::closeConnection(void)
-{
- socketClose(sock);
-}
-
-void SMTP::sendMessage(void)
-{
- if(!connected)
- connectTimerTick();
- if(state == FINISHED && connected){
- kdDebug() << "state was == FINISHED\n" << endl;
- finished = false;
- state = IN;
- writeString = TQString::fromLatin1("helo %1\r\n").arg(domainName);
- write(sock->socket(), writeString.ascii(), writeString.length());
- }
- if(connected){
- kdDebug() << "enabling read on sock...\n" << endl;
- interactTimer.start(timeOut, true);
- sock->enableRead(true);
- }
-}
-#include <stdio.h>
-
-void SMTP::connectTimerTick(void)
-{
- connectTimer.stop();
-// timeOutTimer.start(timeOut, true);
-
- kdDebug() << "connectTimerTick called..." << endl;
-
- if(sock){
- delete sock;
- sock = 0L;
- }
-
- kdDebug() << "connecting to " << serverHost << ":" << hostPort << " ..... " << endl;
- sock = new TDESocket(serverHost.ascii(), hostPort);
-
- if(sock == 0L || sock->socket() < 0) {
- timeOutTimer.stop();
- kdDebug() << "connection failed!" << endl;
- socketClose(sock);
- emit error(CONNECTERROR);
- connected = false;
- return;
- }
- connected = true;
- finished = false;
- state = INIT;
- serverState = NONE;
-
- connect(sock, TQT_SIGNAL(readEvent(TDESocket *)), this, TQT_SLOT(socketRead(TDESocket *)));
- connect(sock, TQT_SIGNAL(closeEvent(TDESocket *)), this, TQT_SLOT(socketClose(TDESocket *)));
- // sock->enableRead(true);
- timeOutTimer.stop();
- kdDebug() << "connected" << endl;
-}
-
-void SMTP::connectTimedOut(void)
-{
- timeOutTimer.stop();
-
- if(sock)
- sock->enableRead(false);
- kdDebug() << "socket connection timed out" << endl;
- socketClose(sock);
- emit error(CONNECTTIMEOUT);
-}
-
-void SMTP::interactTimedOut(void)
-{
- interactTimer.stop();
-
- if(sock)
- sock->enableRead(false);
- kdDebug() << "time out waiting for server interaction" << endl;
- socketClose(sock);
- emit error(INTERACTTIMEOUT);
-}
-
-void SMTP::socketRead(TDESocket *socket)
-{
- int n, nl;
-
- kdDebug() << "socketRead() called..." << endl;
- interactTimer.stop();
-
- if(socket == 0L || socket->socket() < 0)
- return;
- n = read(socket->socket(), readBuffer, SMTP_READ_BUFFER_SIZE-1 );
-
- if(n < 0)
- return;
-
- readBuffer[n] = '\0';
- lineBuffer += readBuffer;
- nl = lineBuffer.find('\n');
- if(nl == -1)
- return;
- lastLine = lineBuffer.left(nl);
- lineBuffer = lineBuffer.right(lineBuffer.length() - nl - 1);
- processLine(&lastLine);
- if(connected)
- interactTimer.start(timeOut, true);
-}
-
-void SMTP::socketClose(TDESocket *socket)
-{
- timeOutTimer.stop();
- disconnect(sock, TQT_SIGNAL(readEvent(TDESocket *)), this, TQT_SLOT(socketRead(TDESocket *)));
- disconnect(sock, TQT_SIGNAL(closeEvent(TDESocket *)), this, TQT_SLOT(socketClose(TDESocket *)));
- socket->enableRead(false);
- kdDebug() << "connection terminated" << endl;
- connected = false;
- if(socket){
- delete socket;
- socket = 0L;
- sock = 0L;
- }
- emit connectionClosed();
-}
-
-void SMTP::processLine(TQString *line)
-{
- int i, stat;
- TQString tmpstr;
-
- i = line->find(' ');
- tmpstr = line->left(i);
- if(i > 3)
- kdDebug() << "warning: SMTP status code longer then 3 digits: " << tmpstr << endl;
- stat = tmpstr.toInt();
- serverState = (SMTPServerStatus)stat;
- lastState = state;
-
- kdDebug() << "smtp state: [" << stat << "][" << *line << "]" << endl;
-
- switch(stat){
- case GREET: //220
- state = IN;
- writeString = TQString::fromLatin1("helo %1\r\n").arg(domainName);
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case GOODBYE: //221
- state = QUIT;
- break;
- case SUCCESSFUL://250
- switch(state){
- case IN:
- state = READY;
- writeString = TQString::fromLatin1("mail from: %1\r\n").arg(senderAddress);
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case READY:
- state = SENTFROM;
- writeString = TQString::fromLatin1("rcpt to: %1\r\n").arg(recipientAddress);
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case SENTFROM:
- state = SENTTO;
- writeString = TQString::fromLatin1("data\r\n");
- kdDebug() << "out: " << writeString << endl;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case DATA:
- state = FINISHED;
- finished = true;
- sock->enableRead(false);
- emit messageSent();
- break;
- default:
- state = CERROR;
- kdDebug() << "smtp error (state error): [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
- socketClose(sock);
- emit error(COMMAND);
- break;
- }
- break;
- case READYDATA: //354
- state = DATA;
- writeString = TQString::fromLatin1("Subject: %1\r\n").arg(messageSubject);
- writeString += messageHeader;
- writeString += "\r\n";
- writeString += messageBody;
- writeString += TQString::fromLatin1(".\r\n");
- kdDebug() << "out: " << writeString;
- write(sock->socket(), writeString.ascii(), writeString.length());
- break;
- case ERROR: //501
- state = CERROR;
- kdDebug() << "smtp error (command error): [" << lastState << "]:[" << stat << "][" << *line << "]\n" << endl;
- socketClose(sock);
- emit error(COMMAND);
- break;
- case UNKNOWN: //550
- state = CERROR;
- kdDebug() << "smtp error (unknown user): [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
- socketClose(sock);
- emit error(UNKNOWNUSER);
- break;
- default:
- state = CERROR;
- kdDebug() << "unknown response: [" << lastState << "]:[" << stat << "][" << *line << "]" << endl;
- socketClose(sock);
- emit error(UNKNOWNRESPONSE);
- }
-}
-
-#include "smtp.moc"
diff --git a/kio/misc/ksendbugmail/smtp.h b/kio/misc/ksendbugmail/smtp.h
deleted file mode 100644
index acdb4a3c3..000000000
--- a/kio/misc/ksendbugmail/smtp.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* $Id$ */
-
-#ifndef SMTP_H
-#define SMTP_H
-
-#include <tqobject.h>
-#include <tqtimer.h>
-#include <ksock.h>
-
-/*int SMTPServerStatus[] = {
- 220, // greeting from server
- 221, // server acknolages goodbye
- 250, // command successful
- 354, // ready to receive data
- 501, // error
- 550, // user unknown
- 0 // null
-};
-
-int SMTPClientStatus[] = {
- 50, // not logged in yet.
- 100, // logged in, got 220
- 150, // sent helo, got 250
- 200, // sent mail from, got 250
- 250, // sent rctp to, got 250
- 300, // data sent, got 354
- 350, // sent data/., got 250
- 400, // send quit, got 221
- 450, // finished, logged out
- 0 // null
-};
-*/
-
-#define DEFAULT_SMTP_PORT 25
-#define DEFAULT_SMTP_SERVER localhost
-#define DEFAULT_SMTP_TIMEOUT 60
-
-#define SMTP_READ_BUFFER_SIZE 256
-
-class SMTP:public QObject
-{
- Q_OBJECT
-public:
- SMTP(char *serverhost = 0, unsigned short int port = 0, int timeout = DEFAULT_SMTP_TIMEOUT);
- ~SMTP();
-
- void setServerHost(const TQString& serverhost);
- void setPort(unsigned short int port);
- void setTimeOut(int timeout);
-
- bool isConnected(){return connected;};
- bool isFinished(){return finished;};
- TQString getLastLine(){return lastLine;};
-
- void setSenderAddress(const TQString& sender);
- void setRecipientAddress(const TQString& recipient);
- void setMessageSubject(const TQString& subject);
- void setMessageBody(const TQString& message);
- void setMessageHeader(const TQString &header);
-
- typedef enum {
- NONE = 0, // null
- GREET = 220, // greeting from server
- GOODBYE = 221, // server acknolages quit
- SUCCESSFUL = 250, // command successful
- READYDATA = 354, // server ready to receive data
- ERROR = 501, // error
- UNKNOWN = 550 // user unknown
- }SMTPServerStatus;
-
- typedef enum {
- INIT = 50, // not logged in yet
- IN = 100, // logged in, got 220
- READY = 150, // sent HELO, got 250
- SENTFROM = 200, // sent MAIL FROM:, got 250
- SENTTO = 250, // sent RCTP TO:, got 250
- DATA = 300, // DATA sent, got 354
- FINISHED = 350, // finished sending data, got 250
- QUIT = 400, // sent QUIT, got 221
- OUT = 450, // finished, logged out
- CERROR = 500 // didn't finish, had error or connection drop
- }SMTPClientStatus;
-
- typedef enum {
- NOERROR = 0,
- CONNECTERROR = 10,
- NOTCONNECTED = 11,
- CONNECTTIMEOUT = 15,
- INTERACTTIMEOUT = 16,
- UNKNOWNRESPONSE = 20,
- UNKNOWNUSER = 30,
- COMMAND = 40
- }SMTPError;
-
-protected:
- void processLine(TQString *line);
-
-public slots:
- void openConnection();
- void sendMessage();
- void closeConnection();
-
- void connectTimerTick();
- void connectTimedOut();
- void interactTimedOut();
-
- void socketRead(TDESocket *);
- void socketClose(TDESocket *);
-
-signals:
- void connectionClosed();
- void messageSent();
- void error(int);
-
-private:
- TQString serverHost;
- unsigned short int hostPort;
- int timeOut;
-
- bool connected;
- bool finished;
-
- TQString senderAddress;
- TQString recipientAddress;
- TQString messageSubject;
- TQString messageBody, messageHeader;
-
- SMTPClientStatus state;
- SMTPClientStatus lastState;
- SMTPServerStatus serverState;
-
- TQString domainName;
-
- TDESocket *sock;
- TQTimer connectTimer;
- TQTimer timeOutTimer;
- TQTimer interactTimer;
-
- char readBuffer[SMTP_READ_BUFFER_SIZE];
- TQString lineBuffer;
- TQString lastLine;
- TQString writeString;
-};
-#endif