• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kio
 

kio/kio

  • kio
  • kio
slave.h
1 // -*- c++ -*-
2 /*
3  * This file is part of the KDE libraries
4  * Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
5  * 2000 Stephan Kulow <coolo@kde.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License version 2 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  **/
21 
22 #ifndef KIO_SLAVE_H
23 #define KIO_SLAVE_H
24 
25 #include <time.h>
26 #include <unistd.h>
27 
28 #include <tqobject.h>
29 
30 #include <kurl.h>
31 
32 #include "kio/slaveinterface.h"
33 #include "kio/connection.h"
34 
35 class KServerSocket;
36 class KSocket;
37 
38 namespace KIO {
39 
44  class KIO_EXPORT Slave : public KIO::SlaveInterface
45  {
46  Q_OBJECT
47  TQ_OBJECT
48 
49  protected:
56  Slave(bool derived, KServerSocket *unixdomain, const TQString &protocol,
57  const TQString &socketname); // TODO(BIC): Remove in KDE 4
58 
59  public:
60  Slave(KServerSocket *unixdomain,
61  const TQString &protocol, const TQString &socketname);
62 
63  virtual ~Slave();
64 
65  void setPID(pid_t);
66 
67  int slave_pid() { return m_pid; }
68 
72  void kill();
73 
77  bool isAlive() { return !dead; }
78 
86  void setHost( const TQString &host, int port,
87  const TQString &user, const TQString &passwd); // TODO(BIC): make virtual
88 
92  void resetHost();
93 
97  void setConfig(const MetaData &config); // TODO(BIC): make virtual
98 
104  TQString protocol() { return m_protocol; }
105 
106  void setProtocol(const TQString & protocol);
119  TQString slaveProtocol() { return m_slaveProtocol; }
120 
124  TQString host() { return m_host; }
125 
129  int port() { return m_port; }
130 
134  TQString user() { return m_user; }
135 
139  TQString passwd() { return m_passwd; }
140 
152  static Slave* createSlave( const TQString &protocol, const KURL& url, int& error, TQString& error_text );
153 
154  static Slave* holdSlave( const TQString &protocol, const KURL& url );
155 
156  // == communication with connected kioslave ==
157  // whenever possible prefer these methods over the respective
158  // methods in connection()
162  void suspend(); // TODO(BIC): make virtual
166  void resume(); // TODO(BIC): make virtual
172  bool suspended(); // TODO(BIC): make virtual
179  void send(int cmd, const TQByteArray &data = TQByteArray());// TODO(BIC): make virtual
180  // == end communication with connected kioslave ==
181 
185  void hold(const KURL &url); // TODO(BIC): make virtual
186 
190  time_t idleTime();
191 
195  void setIdle();
196 
197  /*
198  * @returns Whether the slave is connected
199  * (Connection oriented slaves only)
200  */
201  bool isConnected() { return contacted; }
202  void setConnected(bool c) { contacted = c; }
203 
208  KDE_DEPRECATED Connection *connection() { return &slaveconn; } // TODO(BIC): remove before KDE 4
209 
210  void ref() { m_refCount++; }
211  void deref() { m_refCount--; if (!m_refCount) delete this; }
212 
213  public slots:
214  void accept(KSocket *socket);
215  void gotInput();
216  void timeout();
217  signals:
218  void slaveDied(KIO::Slave *slave);
219 
220  protected:
221  void unlinkSocket();
222 
223  private:
224  TQString m_protocol;
225  TQString m_slaveProtocol;
226  TQString m_host;
227  int m_port;
228  TQString m_user;
229  TQString m_passwd;
230  KServerSocket *serv;
231  TQString m_socket;
232  pid_t m_pid;
233  bool contacted;
234  bool dead;
235  time_t contact_started;
236  time_t idle_since;
237  KIO::Connection slaveconn;
238  int m_refCount;
239  protected:
240  virtual void virtual_hook( int id, void* data );
241  // grant SlaveInterface all IDs < 0x200
242  enum { VIRTUAL_SUSPEND = 0x200, VIRTUAL_RESUME, VIRTUAL_SEND,
243  VIRTUAL_HOLD, VIRTUAL_SUSPENDED,
244  VIRTUAL_SET_HOST, VIRTUAL_SET_CONFIG };
245  struct SendParams {
246  int cmd;
247  const TQByteArray *arr;
248  };
249  struct HoldParams {
250  const KURL *url;
251  };
252  struct SuspendedParams {
253  bool retval;
254  };
255  struct SetHostParams {
256  const TQString *host;
257  int port;
258  const TQString *user;
259  const TQString *passwd;
260  };
261  struct SetConfigParams {
262  const MetaData *config;
263  };
264  private:
265  class SlavePrivate* d;
266  };
267 
268 }
269 
270 #endif

kio/kio

Skip menu "kio/kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kio/kio

Skip menu "kio/kio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kio by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |