summaryrefslogtreecommitdiffstats
path: root/knode/knprotocolclient.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /knode/knprotocolclient.h
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knode/knprotocolclient.h')
-rw-r--r--knode/knprotocolclient.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/knode/knprotocolclient.h b/knode/knprotocolclient.h
new file mode 100644
index 000000000..e531a278b
--- /dev/null
+++ b/knode/knprotocolclient.h
@@ -0,0 +1,122 @@
+/*
+ knprotocolclient.h
+
+ KNode, the KDE newsreader
+ Copyright (c) 1999-2001 the KNode authors.
+ See file AUTHORS for details
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
+*/
+
+#ifndef KNPROTOCOLCLIENT_H
+#define KNPROTOCOLCLIENT_H
+
+#include <qdatetime.h>
+#include <qthread.h>
+#include <qcstring.h>
+
+#include <knserverinfo.h>
+
+class QStrList;
+class KNJobData;
+struct in_addr;
+
+
+class KNProtocolClient : public QThread {
+
+ public:
+ enum threadSignal { TSworkDone=0, TSjobStarted=1, TSconnect=2, TSloadGrouplist=3,
+ TSwriteGrouplist=4, TSdownloadGrouplist=5, TSdownloadNew=6,
+ TSsortNew=7, TSdownloadArticle=8, TSsendArticle=9, TSsendMail=10,
+ TSprogressUpdate=11, TSdownloadDesc=12, TSdownloadNewGroups=13 };
+
+ KNProtocolClient(int NfdPipeIn, int NfdPipeOut);
+ ~KNProtocolClient();
+
+ virtual void run();
+
+ void insertJob(KNJobData *newJob);
+ void removeJob();
+
+ void updatePercentage(int percent);
+
+ int getProgressValue() const { return progressValue; };
+ /** bytes in&out for the current connection */
+ int getByteCount() const { return byteCount; };
+ bool isInByteCountMode() const { return byteCountMode; };
+
+ void terminateClient() { mTerminate = true; }
+ protected:
+
+ /** main loop, maintains connection and waits for next job */
+ void waitForWork();
+ /** examines the job and calls the suitable handling method */
+ virtual void processJob();
+
+ /** connect, handshake and authorization */
+ virtual bool openConnection();
+ bool isConnected() { return (tcpSocket!=-1); };
+ /** sends QUIT-command and closes the socket */
+ virtual void closeConnection();
+
+ /** sends a command (one line), return code is written to rep */
+ virtual bool sendCommand(const QCString &cmd, int &rep);
+ /** checks return code and calls handleErrors() if necessary */
+ bool sendCommandWCheck(const QCString &cmd, int rep);
+ /** sends a message (multiple lines) */
+ bool sendMsg(const QCString &msg);
+
+ /** reads next complete line of input */
+ bool getNextLine();
+ /** returns pointer to current line of input */
+ char* getCurrentLine() { return thisLine; };
+ /** receives a message (multiple lines) */
+ bool getMsg(QStrList &msg);
+ /** reads next line and returns the response code */
+ bool getNextResponse(int &rep);
+ /** checks return code and calls handleErrors() if necessary */
+ bool checkNextResponse(int rep);
+
+ /** interprets error code, generates error message and closes the connection */
+ virtual void handleErrors();
+
+ void sendSignal(threadSignal s);
+
+ KNJobData *job;
+ KNServerInfo account;
+ /** handleErrors() adds this string to the error message */
+ QString errorPrefix;
+ int progressValue, predictedLines, doneLines;
+ bool byteCountMode;
+
+ private:
+ /** waits until socket is readable */
+ bool waitForRead();
+ /** waits until socket is writeable */
+ bool waitForWrite();
+ void closeSocket();
+ /** sends str to the server */
+ bool sendStr(const QCString &str);
+ /** removes start/stop signal */
+ void clearPipe();
+
+ char *input;
+ char *thisLine, *nextLine, *inputEnd;
+ unsigned int inputSize;
+ /** IPC-Pipes to/from async thread */
+ int fdPipeIn,fdPipeOut;
+ int tcpSocket;
+ /** bytes in&out for the current connection */
+ int byteCount;
+ QTime timer;
+ bool mTerminate;
+
+};
+
+#endif