summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/io_layer.h
blob: 4f9bbe4e1794e05453f9ea1408806c947fe795d0 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef OPIE_IO_LAYER_H
#define OPIE_IO_LAYER_H

#include <qbitarray.h>
#include <qobject.h>


#include <qpe/config.h>

#include "profile.h"

/**
 * This is the base class for IO Layers
 * It will used to sent and recv data( QByteArray )
 * it
 */
class IOLayer : public QObject {
    Q_OBJECT
public:
    enum Error {
        NoError = -1,
        Refuse = 0,
        CouldNotOpen =1,
        ClosedUnexpected =2,
        ClosedError =3,
        Terminate = 4
        /* add more errors here */
    };
    enum Feature {
        AutoConnect = 0,
        TransferFile = 1,
        Close = 2
    };
    /**
     * a small c'tor
     */
    IOLayer();

    /**
     * create an IOLayer instance from a config file
     * the currently set group stores the profile/session
     * information
     */
    IOLayer( const Profile& );

    /**
     * destructor
     */
    virtual ~IOLayer();

    /**
     * a small internal identifier
     */
    virtual QString identifier() const = 0;

    /**
     * a short name
     */
    virtual QString name() const = 0;

    /**
     * a file descriptor which opens
     * the device for io but does not
     * do any ioctling on it...
     * and it'll stop listening to the before opened
     * device
     */
    virtual int rawIO() const;

    /**
     * will close the rawIO stuff
     * and will listen to it's data again...
     */
    virtual void closeRawIO(int);

    /**
     * What does the IOLayer support?
     * Bits are related to features
     */
    virtual QBitArray supports() const = 0;

    virtual bool isConnected() = 0;

signals:
    /**
     * received input as QCString
     */
    virtual void received( const QByteArray& );

    /**
     * an error occured
     * int for the error number
     * and QString for a text
     */
    virtual void error( int, const QString& );


    virtual void closed();

    /* signal emitted for closure of the IOLayer
     * for some reasons
     */
    virtual void closed(IOLayer*);
public slots:
    /**
     * send a QCString to the device
     */
    virtual void send( const QByteArray& ) = 0;

    /**
     * bool open
     */
    virtual bool open() = 0;

    /**
     * close the io
     */
    virtual void close() = 0;

    /**
     * closes and reloads the settings
     */
    virtual void reload( const Profile& ) = 0;

    /**
     * set the size
     * needed for pty
     */
    virtual void setSize(int lines, int cols );
};

#endif