kio Library API Documentation

connection.h

00001 // -*- c++ -*-
00002 /* This file is part of the KDE libraries
00003     Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
00004                        David Faure <faure@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef __connection_h__
00023 #define __connection_h__ "$Id: connection.h,v 1.32 2003/08/16 16:38:56 coolo Exp $"
00024 
00025 #include <sys/types.h>
00026 
00027 #include <stdio.h>
00028 #include <qptrlist.h>
00029 #include <qobject.h>
00030 
00031 class KSocket;
00032 class QSocketNotifier;
00033 
00034 namespace KIO {
00035 
00036     struct Task {
00037     int cmd;
00038     QByteArray data;
00039     };
00040 
00047     class Connection : public QObject
00048     {
00049     Q_OBJECT
00050     public:
00055     Connection();
00056     virtual ~Connection();
00057 
00063     void init(KSocket *sock);
00071     void init(int fd_in, int fd_out); // Used by KDENOX
00072     void connect(QObject *receiver = 0, const char *member = 0);
00074     void close();
00075     
00080     int fd_from() const { return fd_in; }
00085         int fd_to() const { return fileno( f_out ); }
00086 
00092     bool inited() const { return (fd_in != -1) && (f_out != 0); }
00093     
00099     void send(int cmd, const QByteArray &arr = QByteArray());
00100 
00107     bool sendnow( int _cmd, const QByteArray &data );
00108 
00117     int read( int* _cmd, QByteArray &data );
00118 
00122         void suspend();
00123 
00127         void resume();
00128 
00133         bool suspended() const { return m_suspended; }
00134 
00135     protected slots:
00136         void dequeue();
00137     
00138     protected:
00139     
00140     
00141     private:
00142     int fd_in;
00143     FILE *f_out;
00144     KSocket *socket;
00145     QSocketNotifier *notifier;
00146     QObject *receiver;
00147     const char *member;
00148     QPtrList<Task> tasks;
00149         bool m_suspended;
00150     private:
00151     class ConnectionPrivate* d;
00152     };
00153 
00154 }
00155 
00156 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 30 05:18:20 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003