00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef CCXX_LIBEXEC_H_
00039 #define CCXX_LIBEXEC_H_
00040
00041 #ifndef CCXX_BAYONNE_H_
00042 #include <cc++/bayonne.h>
00043 #endif
00044
00045 #ifndef CCXX_SLOG_H_
00046 #include <cc++/slog.h>
00047 #endif
00048
00049 #ifndef CCXX_PROCESS_H_
00050 #include <cc++/process.h>
00051 #endif
00052
00053 namespace ost {
00054
00063 class __EXPORT Libexec : public Bayonne
00064 {
00065 protected:
00066 Keydata head, args;
00067 const char *tsid;
00068 const char *voice;
00069 Audio::Level level;
00070
00071 public:
00072 result_t result;
00073 char digits[64];
00074 char query[512];
00075 char position[32];
00076 unsigned exitcode, reply;
00077
00081 Libexec();
00082
00089 const char *getEnv(const char *id);
00090
00097 const char *getArg(const char *id);
00098
00107 const char *getPath(const char *filename, char *buffer, unsigned size);
00108
00115 const char *getFile(const char *filename);
00116
00122 inline void setVoice(const char *v)
00123 {voice = v;};
00124
00130 inline void setLevel(Audio::Level l)
00131 {level = l;};
00132
00136 void hangupSession(void);
00137
00141 void detachSession(unsigned code);
00142
00151 result_t sendCommand(const char *text, char *buffer = NULL, unsigned size = 0);
00152
00159 result_t sendResult(const char *text);
00160
00167 result_t xferCall(const char *dest);
00168
00175 result_t replayFile(const char *file);
00176
00184 result_t replayOffset(const char *file, const char *offset);
00185
00194 result_t recordFile(const char *file, timeout_t duration, timeout_t silence = 0);
00195
00202 result_t speak(const char *format, ...);
00203
00212 result_t playTone(const char *name, timeout_t duration = 0, unsigned level = 0);
00213 result_t playSingleTone(short f1, timeout_t duration, unsigned level = 0);
00214 result_t playDualTone(short f1, short f2, timeout_t duration, unsigned level = 0);
00215
00225 result_t recordOffset(const char *file, const char *offset, timeout_t duration, timeout_t silence = 0);
00226
00233 result_t eraseFile(const char *file);
00234
00242 result_t moveFile(const char *file1, const char *file2);
00243
00247 result_t clearInput(void);
00248
00254 bool waitInput(timeout_t timeout);
00255
00264 result_t readInput(char *buffer, unsigned size, timeout_t timeout);
00265
00272 char readKey(timeout_t timeout);
00273
00274 result_t sizeSym(const char *id, unsigned size);
00275 result_t addSym(const char *id, const char *value);
00276 result_t setSym(const char *id, const char *value);
00277 result_t getSym(const char *id, char *buf, unsigned size);
00278
00286 void postSym(const char *id, const char *value);
00287 };
00288
00289 class __EXPORT BayonneTSession : public BayonneSession
00290 {
00291 protected:
00292 friend class __EXPORT BayonneSysexec;
00293
00294 void sysPost(const char *sid, char *id, const char *value);
00295 void sysVar(const char *tsid, char *id, const char *value, int size);
00296 void sysHeader(const char *tsid);
00297 void sysArgs(const char *tsid);
00298 void sysStatus(const char *tsid);
00299 void sysRecord(const char *tsid, char *token);
00300 void sysReplay(const char *tsid, char *token);
00301 void sysFlush(const char *tsid);
00302 void sysWait(const char *tsid, char *token);
00303 void sysTone(const char *tsid, char *token);
00304 void sysSTone(const char *tsid, char *token);
00305 void sysDTone(const char *tsid, char *token);
00306 void sysPrompt(const char *tsid, const char *voice, const char *text);
00307 void sysInput(const char *tsid, char *token);
00308 void sysHangup(const char *tsid);
00309 void sysExit(const char *tsid, char *token);
00310 void sysReturn(const char *tsid, const char *text);
00311 void sysXfer(const char *tsid, const char *dest);
00312 };
00313
00320 class __EXPORT BayonneSysexec : protected Thread, protected Bayonne
00321 {
00322 private:
00323 static bool exiting;
00324 #ifndef WIN32
00325 static int iopair[2];
00326 #endif
00327 static BayonneSysexec *libexec;
00328
00329 static void readline(char *buf, unsigned max);
00330
00331 void run(void);
00332
00333 BayonneSysexec();
00334 ~BayonneSysexec();
00335
00336 public:
00337 static bool create(BayonneSession *s);
00338 static void allocate(const char *path, size_t bs = 0, int pri = 0, const char *modpath = NULL);
00339 static void cleanup(void);
00340 static void startup(void);
00341 };
00342
00343 };
00344
00345 #endif