00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SESSION_H
00022 #define SESSION_H
00023
00024 #include <kapplication.h>
00025 #include <kmainwindow.h>
00026 #include <tqstrlist.h>
00027
00028 #include "TEPty.h"
00029 #include "TEWidget.h"
00030 #include "TEmuVt102.h"
00031
00032 #include "sessioniface.h"
00033
00034 class KProcIO;
00035 class KProcess;
00036 class ZModemDialog;
00037
00038 class TESession : public TQObject, virtual public SessionIface
00039 { Q_OBJECT
00040
00041 public:
00042
00043 TESession(TEWidget* w,
00044 const TQString &term, ulong winId, const TQString &sessionId="session-1",
00045 const TQString &initial_cwd = TQString::null);
00046 void changeWidget(TEWidget* w);
00047 void setPty( TEPty *_sh );
00048 TEWidget* widget() { return te; }
00049 ~TESession();
00050
00051 void setConnect(bool r);
00052 void setListenToKeyPress(bool l);
00053 TEmulation* getEmulation();
00054 bool isSecure();
00055 bool isMonitorActivity();
00056 bool isMonitorSilence();
00057 bool isMasterMode();
00058 int schemaNo();
00059 int encodingNo();
00060 int fontNo();
00061 const TQString& Term();
00062 const TQString& SessionId();
00063 const TQString& Title();
00064 const TQString& IconName();
00065 const TQString& IconText();
00066 TQString fullTitle() const;
00067 int keymapNo();
00068 TQString keymap();
00069 TQStrList getArgs();
00070 TQString getPgm();
00071 TQString getCwd();
00072 TQString getInitial_cwd() { return initial_cwd; }
00073 void setInitial_cwd(const TQString& _cwd) { initial_cwd=_cwd; }
00074
00075 void setHistory(const HistoryType&);
00076 const HistoryType& history();
00077
00078 void setMonitorActivity(bool);
00079 void setMonitorSilence(bool);
00080 void setMonitorSilenceSeconds(int seconds);
00081 void setMasterMode(bool);
00082 void setSchemaNo(int sn);
00083 void setEncodingNo(int index);
00084 void setKeymapNo(int kn);
00085 void setKeymap(const TQString& _id);
00086 void setFontNo(int fn);
00087 void setTitle(const TQString& _title);
00088 void setIconName(const TQString& _iconName);
00089 void setIconText(const TQString& _iconText);
00090 void setAddToUtmp(bool);
00091 void setXonXoff(bool);
00092 bool testAndSetStateIconName (const TQString& newname);
00093 bool sendSignal(int signal);
00094
00095 void setAutoClose(bool b) { autoClose = b; }
00096
00097
00098 bool closeSession();
00099 void clearHistory();
00100 void feedSession(const TQString &text);
00101 void sendSession(const TQString &text);
00102 void renameSession(const TQString &name);
00103 TQString sessionName() { return title; }
00104 int sessionPID() { return sh->pid(); }
00105
00106 virtual bool processDynamic(const TQCString &fun, const TQByteArray &data, TQCString& replyType, TQByteArray &replyData);
00107 virtual QCStringList functionsDynamic();
00108 void enableFullScripting(bool b) { fullScripting = b; }
00109
00110 void startZModem(const TQString &rz, const TQString &dir, const TQStringList &list);
00111 void cancelZModem();
00112 bool zmodemIsBusy() { return zmodemBusy; }
00113
00114 void print(TQPainter &paint, bool friendly, bool exact);
00115
00116 TQString schema();
00117 void setSchema(const TQString &schema);
00118 TQString encoding();
00119 void setEncoding(const TQString &encoding);
00120 TQString keytab();
00121 void setKeytab(const TQString &keytab);
00122 TQSize size();
00123 void setSize(TQSize size);
00124 void setFont(const TQString &font);
00125 TQString font();
00126
00127 public slots:
00128
00129 void run();
00130 void setProgram( const TQString &_pgm, const TQStrList &_args );
00131 void done();
00132 void done(int);
00133 void terminate();
00134 void setUserTitle( int, const TQString &caption );
00135 void changeTabTextColor( int );
00136 void ptyError();
00137 void slotZModemDetected();
00138 void emitZModemDetected();
00139
00140 void zmodemStatus(KProcess *, char *data, int len);
00141 void zmodemSendBlock(KProcess *, char *data, int len);
00142 void zmodemRcvBlock(const char *data, int len);
00143 void zmodemDone();
00144 void zmodemContinue();
00145
00146 signals:
00147
00148 void processExited(KProcess *);
00149 void forkedChild();
00150 void receivedData( const TQString& text );
00151 void done(TESession*);
00152 void updateTitle(TESession*);
00153 void notifySessionState(TESession* session, int state);
00154 void changeTabTextColor( TESession*, int );
00155
00156 void disableMasterModeConnections();
00157 void enableMasterModeConnections();
00158 void renameSession(TESession* ses, const TQString &name);
00159
00160 void openURLRequest(const TQString &cwd);
00161
00162 void zmodemDetected(TESession *);
00163 void updateSessionConfig(TESession *);
00164 void resizeSession(TESession *session, TQSize size);
00165 void setSessionEncoding(TESession *session, const TQString &encoding);
00166 void getSessionSchema(TESession *session, TQString &schema);
00167 void setSessionSchema(TESession *session, const TQString &schema);
00168
00169 private slots:
00170 void onRcvBlock( const char* buf, int len );
00171 void monitorTimerDone();
00172 void notifySessionState(int state);
00173 void onContentSizeChange(int height, int width);
00174 void onFontMetricChange(int height, int width);
00175
00176 private:
00177
00178 TEPty* sh;
00179 TEWidget* te;
00180 TEmulation* em;
00181
00182 bool connected;
00183 bool monitorActivity;
00184 bool monitorSilence;
00185 bool notifiedActivity;
00186 bool masterMode;
00187 bool autoClose;
00188 bool wantedClose;
00189 TQTimer* monitorTimer;
00190
00191
00192
00193
00194 int schema_no;
00195 int font_no;
00196 int silence_seconds;
00197
00198 int font_h;
00199 int font_w;
00200
00201 TQString title;
00202 TQString userTitle;
00203 TQString iconName;
00204 TQString iconText;
00205 bool add_to_utmp;
00206 bool xon_xoff;
00207 bool fullScripting;
00208
00209 QString stateIconName;
00210
00211 TQString pgm;
00212 TQStrList args;
00213
00214 TQString term;
00215 ulong winId;
00216 TQString sessionId;
00217
00218 TQString cwd;
00219 TQString initial_cwd;
00220
00221
00222 bool zmodemBusy;
00223 KProcIO* zmodemProc;
00224 ZModemDialog* zmodemProgress;
00225
00226
00227
00228 TQColor modifiedBackground;
00229 int encoding_no;
00230 };
00231
00232 #endif