summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/MyPty.h
blob: b292ce49078cecedd819c92a1a8e2c2f2b3c1574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* -------------------------------------------------------------------------- */
/*                                                                            */
/* [MyPty.h]                 Pseudo Terminal Device                           */
/*                                                                            */
/* -------------------------------------------------------------------------- */
/*                                                                            */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>            */
/*                                                                            */
/* This file is part of Konsole - an X terminal for KDE                       */
/*                                                                            */
/* -------------------------------------------------------------------------- */
/*									      */
/* Ported Konsole to Qt/Embedded                                              */
/*									      */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com>                  */
/*									      */
/* -------------------------------------------------------------------------- */

/*! \file
*/

#ifndef MY_PTY_H
#define MY_PTY_H

#include <qobject.h>
#include <qlist.h>
#include <qstrlist.h>

#include "io_layer.h"

typedef QMap<QString, QString> EnvironmentMap;

class Profile;
class QSocketNotifier;
class MyPty : public IOLayer
{
    Q_OBJECT
public:

    MyPty(const Profile&);
    ~MyPty();



    QString identifier()const;
    QString name()const;
    QBitArray supports()const;

  public slots:
 /*!
      having a `run' separate from the constructor allows to make
      the necessary connections to the signals and slots of the
      instance before starting the execution of the client.
    */
    void start();
    int run(const char* pgm, QStrList & args , const char* term, int addutmp);
    bool open();
    void close();
    void reload( const Profile& );
    void setSize(int lines, int columns);
    void error();
    bool isConnected() { return true; };
  signals:

    /*!
        emitted when the client program terminates.
        \param status the wait(2) status code of the terminated client program.
    */
    void done(int status);

    /*!
        emitted when a new block of data comes in.
        \param s - the data
        \param len - the length of the block
    */
    void received(const QByteArray&);

  public slots:

    void send(const QByteArray& );

private:
    const char* deviceName();

protected slots:
      void readPty();
      void donePty();

private:
    int  openPty();

private:

    char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx"
    char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..."
    int m_fd;
    int m_cpid;
    QSocketNotifier* m_sn_e;
    QSocketNotifier* m_sn_r;
    char* m_term;

    QString m_cmd;
    EnvironmentMap m_env;
};

#endif