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

tdeio/tdeio

  • tdeio
  • tdeio
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 TDEIO_SLAVE_H
23 #define TDEIO_SLAVE_H
24 
25 #include <time.h>
26 #include <unistd.h>
27 
28 #include <tqobject.h>
29 
30 #include <kurl.h>
31 
32 #include "tdeio/slaveinterface.h"
33 #include "tdeio/connection.h"
34 
35 class TDEServerSocket;
36 class TDESocket;
37 
38 namespace TDEIO {
39 
44  class TDEIO_EXPORT Slave : public TDEIO::SlaveInterface
45  {
46  Q_OBJECT
47 
48 
49  protected:
56  Slave(bool derived, TDEServerSocket *unixdomain, const TQString &protocol,
57  const TQString &socketname); // TODO(BIC): Remove in KDE 4
58 
59  public:
60  Slave(TDEServerSocket *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 tdeioslave ==
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 tdeioslave ==
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(TDESocket *socket);
215  void gotInput();
216  void timeout();
217  signals:
218  void slaveDied(TDEIO::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  TDEServerSocket *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  TDEIO::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
TDEIO::Slave::connection
KDE_DEPRECATED Connection * connection()
Definition: slave.h:208
TDEIO::Slave::isAlive
bool isAlive()
Definition: slave.h:77
TDEIO::Slave::slaveProtocol
TQString slaveProtocol()
The actual protocol used to handle the request.
Definition: slave.h:119
TDEIO
A namespace for TDEIO globals.
Definition: authinfo.h:29
TDEIO::Slave::user
TQString user()
Definition: slave.h:134
TDEIO::Slave::protocol
TQString protocol()
The protocol this slave handles.
Definition: slave.h:104
TDEIO::Slave::port
int port()
Definition: slave.h:129
TDEIO::Connection
This class provides a simple means for IPC between two applications via a pipe.
Definition: connection.h:49
TDEIO::Slave
Attention developers: If you change the implementation of TDEIO::Slave, do not use connection() or sl...
Definition: slave.h:44
TDEIO::SlaveInterface
There are two classes that specifies the protocol between application (TDEIO::Job) and tdeioslave...
Definition: slaveinterface.h:93
TDEIO::Slave::passwd
TQString passwd()
Definition: slave.h:139
TDEIO::Slave::host
TQString host()
Definition: slave.h:124
TDEIO::MetaData
MetaData is a simple map of key/value strings.
Definition: global.h:515

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.8.11
This website is maintained by Timothy Pearson.