File indexing completed on 2024-12-01 06:51:47

0001 /***************************************************************************
0002                           cunixsocket.h  -  UNIX domain socket
0003                              -------------------
0004     begin                : Pi okt 3 2003
0005     copyright            : (C) 2003-2009 by Tomas Mecir
0006     email                : kmuddy@kmuddy.com
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either version 2 of the License, or     *
0014  *   (at your option) any later version.                                   *
0015  *                                                                         *
0016  ***************************************************************************/
0017 
0018 #ifndef CUNIXSOCKET_H
0019 #define CUNIXSOCKET_H
0020 
0021 #include <qobject.h>
0022 
0023 #include <sys/un.h>
0024 
0025 class QSocketNotifier;
0026 
0027 class cRunningScript;
0028 class cVariableList;
0029 
0030 /**
0031 This class implements a UNIX domain socket, together with variable
0032 manipulation.
0033 
0034 Everything is done automatically, so the program can just create it
0035 and forget it (it just needs to delete it when no longer needed, of course).
0036 
0037   *@author Tomas Mecir
0038   */
0039 
0040 class cUnixSocket : public QObject  {
0041    Q_OBJECT
0042 public: 
0043   cUnixSocket (int _sess, cRunningScript *rs);
0044   ~cUnixSocket ();
0045   const QString &getName ();
0046 protected slots:
0047   void readData (int id);
0048   void writeData (int id);
0049 protected:
0050   void processRequest (const QString &type, const QString &data);
0051   void sendResult (const QString &result);
0052 
0053   struct sockaddr_un sa;
0054 
0055   int sess;
0056   cRunningScript *script;
0057 
0058   /** file name */
0059   QString name;
0060 
0061   /** things that are to be read/written */
0062   QString readCache, writeCache;
0063   
0064   /** socket descriptors */
0065   int id, id2;
0066   bool connected;
0067 
0068   /** necessary notifiers */
0069   QSocketNotifier *readnotifier, *writenotifier;
0070 
0071   /** variable list*/
0072   cVariableList *varlist;
0073 };
0074 
0075 #endif