summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole/session.cpp
blob: a94712a0c5f2c01700e9765ed5330452ade4f428 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* -------------------------------------------------------------------------- */
/*									      */
/* Ported Konsole to Qt/Embedded                                              */
/*									      */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com>                  */
/*									      */
/* -------------------------------------------------------------------------- */
#include "session.h"
// #include <kdebug.h>

#include <stdlib.h>

#define HERE fprintf(stderr,"%s(%d): here\n",__FILE__,__LINE__)

/*! \class TESession

    Sessions are combinations of TEPTy and Emulations.

    The stuff in here does not belong to the terminal emulation framework,
    but to main.C. It serves it's duty by providing a single reference
    to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one
    of the abilities of the framework - multible sessions.
*/

TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args)
{
  te = _te;
  term = _term;

  // sh = new TEPty();
  sh = new MyPty();
  em = new TEmuVt102(te);

  sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary
  QObject::connect( sh,SIGNAL(block_in(const char*,int)),
                    em,SLOT(onRcvBlock(const char*,int)) );
  QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)),
                    sh,SLOT(setSize(int,int)));

  // 'main' should do those connects itself, somehow.
  // These aren't KTMW's slots, but konsole's.(David)

/*
  QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)),
                    main,SLOT(notifySize(int,int)));
*/
  QObject::connect( em,SIGNAL(sndBlock(const char*,int)),
                    sh,SLOT(send_bytes(const char*,int)) );
  QObject::connect( em,SIGNAL(changeColumns(int)),
                    main,SLOT(changeColumns(int)) );

  

  QObject::connect( em,SIGNAL(changeTitle(int,const QString&)),
                    this,SLOT(changeTitle(int,const QString&)) );

  QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) );
}



void TESession::run()
{
  //kdDebug() << "Running the session!" << pgm << "\n";
  sh->run(pgm,args,term.data(),FALSE);
}

void TESession::kill(int ) // signal)
{
//  sh->kill(signal);
}

TESession::~TESession()
{
 QObject::disconnect( sh, SIGNAL( done(int) ),
		      this, SLOT( done(int) ) );
  delete em;
  delete sh;
}

void TESession::setConnect(bool c)
{
  em->setConnect(c);
}

void TESession::done(int status)
{
  emit done(te,status);
}

void TESession::terminate()
{
  delete this;
}

TEmulation* TESession::getEmulation()
{
  return em;
}

// following interfaces might be misplaced ///

int TESession::schemaNo()
{
  return schema_no;
}

int TESession::keymap()
{
  return keymap_no;
}

int TESession::fontNo()
{
  return font_no;
}

const char* TESession::emuName()
{
  return term.data();
}

void TESession::setSchemaNo(int sn)
{
  schema_no = sn;
}

void TESession::setKeymapNo(int kn)
{
  keymap_no = kn;
  em->setKeytrans(kn);
}

void TESession::setFontNo(int fn)
{
  font_no = fn;
}

void TESession::changeTitle(int, const QString& title)
{
  this->title = title;
  emit changeTitle(te, title);
}

const QString& TESession::Title()
{
  return title;
}

void TESession::setHistory(bool on)
{
  em->setHistory( on );
}

bool TESession::history()
{
  return em->history();
}

// #include "session.moc"