• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

  • sources
  • kde-4.14
  • kdelibs
  • kio
  • kio
connection_p.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2007 Thiago Macieira <thiago@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KIO_CONNECTION_P_H
21 #define KIO_CONNECTION_P_H
22 
23 #include <QObject>
24 #include <klocalsocket.h>
25 
26 class KUrl;
27 
28 namespace KIO {
29  struct Task {
30  int cmd;
31  QByteArray data;
32  };
33 
34  class AbstractConnectionBackend: public QObject
35  {
36  Q_OBJECT
37  public:
38  QString address;
39  QString errorString;
40  enum { Idle, Listening, Connected } state;
41 
42  explicit AbstractConnectionBackend(QObject *parent = 0);
43  ~AbstractConnectionBackend();
44 
45  virtual void setSuspended(bool enable) = 0;
46  virtual bool connectToRemote(const KUrl &url) = 0;
47  virtual bool listenForRemote() = 0;
48  virtual bool waitForIncomingTask(int ms) = 0;
49  virtual bool sendCommand(const Task &task) = 0;
50  virtual AbstractConnectionBackend *nextPendingConnection() = 0;
51 
52  Q_SIGNALS:
53  void disconnected();
54  void commandReceived(const Task &task);
55  void newConnection();
56  };
57 
58  class SocketConnectionBackend: public AbstractConnectionBackend
59  {
60  Q_OBJECT
61  public:
62  enum Mode { LocalSocketMode, TcpSocketMode };
63 
64  private:
65  enum { HeaderSize = 10, StandardBufferSize = 32*1024 };
66 
67  QTcpSocket *socket;
68  union {
69  KLocalSocketServer *localServer;
70  QTcpServer *tcpServer;
71  };
72  long len;
73  int cmd;
74  int port;
75  bool signalEmitted;
76  quint8 mode;
77 
78  public:
79  explicit SocketConnectionBackend(Mode m, QObject *parent = 0);
80  ~SocketConnectionBackend();
81 
82  void setSuspended(bool enable);
83  bool connectToRemote(const KUrl &url);
84  bool listenForRemote();
85  bool waitForIncomingTask(int ms);
86  bool sendCommand(const Task &task);
87  AbstractConnectionBackend *nextPendingConnection();
88  public slots:
89  void socketReadyRead();
90  void socketDisconnected();
91  };
92 }
93 
94 #endif
KIO::SocketConnectionBackend::LocalSocketMode
Definition: connection_p.h:62
KIO::AbstractConnectionBackend::~AbstractConnectionBackend
~AbstractConnectionBackend()
Definition: connection.cpp:114
KIO::AbstractConnectionBackend::sendCommand
virtual bool sendCommand(const Task &task)=0
KIO::Task
Definition: connection_p.h:29
KIO::AbstractConnectionBackend::commandReceived
void commandReceived(const Task &task)
KIO::SocketConnectionBackend::TcpSocketMode
Definition: connection_p.h:62
KIO::Task::data
QByteArray data
Definition: connection_p.h:31
QByteArray
KIO::AbstractConnectionBackend::newConnection
void newConnection()
KUrl
KIO::AbstractConnectionBackend::connectToRemote
virtual bool connectToRemote(const KUrl &url)=0
KIO::AbstractConnectionBackend::setSuspended
virtual void setSuspended(bool enable)=0
KIO::SocketConnectionBackend::waitForIncomingTask
bool waitForIncomingTask(int ms)
Definition: connection.cpp:251
KIO::AbstractConnectionBackend::Connected
Definition: connection_p.h:40
KIO::SocketConnectionBackend::tcpServer
QTcpServer * tcpServer
Definition: connection_p.h:70
KIO::AbstractConnectionBackend
Definition: connection_p.h:34
QObject
KIO::AbstractConnectionBackend::address
QString address
Definition: connection_p.h:38
KIO::SocketConnectionBackend::~SocketConnectionBackend
~SocketConnectionBackend()
Definition: connection.cpp:126
KIO::AbstractConnectionBackend::nextPendingConnection
virtual AbstractConnectionBackend * nextPendingConnection()=0
KIO::SocketConnectionBackend::Mode
Mode
Definition: connection_p.h:62
KIO::SocketConnectionBackend::setSuspended
void setSuspended(bool enable)
Definition: connection.cpp:133
KIO::AbstractConnectionBackend::state
enum KIO::AbstractConnectionBackend::@0 state
KIO::SocketConnectionBackend::socketReadyRead
void socketReadyRead()
Definition: connection.cpp:329
QString
KIO::AbstractConnectionBackend::Listening
Definition: connection_p.h:40
QTcpServer
KLocalSocketServer
KIO::SocketConnectionBackend::localServer
KLocalSocketServer * localServer
Definition: connection_p.h:69
KIO::SocketConnectionBackend
Definition: connection_p.h:58
KIO::SocketConnectionBackend::SocketConnectionBackend
SocketConnectionBackend(Mode m, QObject *parent=0)
Definition: connection.cpp:118
KIO::AbstractConnectionBackend::errorString
QString errorString
Definition: connection_p.h:39
KIO::SocketConnectionBackend::sendCommand
bool sendCommand(const Task &task)
Definition: connection.cpp:282
KIO::AbstractConnectionBackend::AbstractConnectionBackend
AbstractConnectionBackend(QObject *parent=0)
Definition: connection.cpp:109
KIO::SocketConnectionBackend::connectToRemote
bool connectToRemote(const KUrl &url)
Definition: connection.cpp:160
KIO::AbstractConnectionBackend::waitForIncomingTask
virtual bool waitForIncomingTask(int ms)=0
KIO::SocketConnectionBackend::socketDisconnected
void socketDisconnected()
Definition: connection.cpp:194
QTcpSocket
KIO::SocketConnectionBackend::nextPendingConnection
AbstractConnectionBackend * nextPendingConnection()
Definition: connection.cpp:303
QObject::parent
QObject * parent() const
KIO::Task::cmd
int cmd
Definition: connection_p.h:30
KIO::AbstractConnectionBackend::disconnected
void disconnected()
KIO::AbstractConnectionBackend::listenForRemote
virtual bool listenForRemote()=0
klocalsocket.h
KIO::SocketConnectionBackend::listenForRemote
bool listenForRemote()
Definition: connection.cpp:200
KIO::AbstractConnectionBackend::Idle
Definition: connection_p.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal