00001
00017 #define GITK_RENDERER_C
00018 #define GITKR_INIT_C
00019
00020 #include "gitkrincludes.h"
00021 #include <unistd.h>
00022 #include <fcntl.h>
00023
00027 gboolean gitkr_init(guint *argc, gchar ***argv) {
00028 unsigned char testbuf[256];
00029 unsigned char c = ' ';
00030
00031 g_log_set_handler(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG|G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING|G_LOG_LEVEL_ERROR, gitk_log_handler, NULL);
00032 gitk_log("phone mode render plugin init beg");
00033
00034 selected = strdup(_("is focussed"));
00035 TextOn = strdup(_("is on"));
00036 TextOff = strdup(_("is off"));
00037 IconApplication = strdup(_("application"));
00038 IconPagename = strdup(_("page name"));
00039 IconLabel = strdup(_("label"));
00040 IconEdit = strdup(_("edit"));
00041 IconOptionChoice = strdup(_("option choice"));
00042 IconControl = strdup(_("control"));
00043 IconAction = strdup(_("button"));
00044 IconProgress = strdup(_("progress bar"));
00045 welcome = strdup(_("Hello, you are connected to a phone controlled application! If you work the first time with a G I T K phone interface, press number one, on your phone keyboard, else, press # "));
00046
00047 if(!gitkr_init_process_commandline(argc,argv)) {
00048
00049
00050 initscr();
00051
00052 cbreak();
00053 noecho();
00054 nonl();
00055 scrollok(stdscr, FALSE);
00056 intrflush(stdscr, FALSE);
00057 keypad(stdscr, TRUE);
00058
00059 code_set=nl_langinfo(CODESET);
00060
00061 if(!(ftinfo=festival_initialize(gitkr_phone_festival_host,gitkr_phone_festival_port,gitkr_phone_speech_name))) {
00062 gitk_log("*no* speech output available!");
00063 return(FALSE);
00064 }
00065 else {
00066 gitk_log("speech output available!");
00067 }
00068
00069 #ifdef HAVE_CAPI20
00070
00071 if(gitkr_phone_capi_datalength)
00072 gitkr_phone_capi_betweendigits = 24*256/gitkr_phone_capi_datalength;
00073 if (!(capiinfo = capi_initialize(gitkr_phone_capi_logicalconnections, gitkr_phone_capi_datablocks, gitkr_phone_capi_datalength))) {
00074 gitk_log("*no* capi20 available!");
00075 return(FALSE);
00076 }else{
00077 gitk_log("capi20 available!");
00078 if(capi_listen(capiinfo, CAPI_DEFAULT_CONTROLLER, CAPI_DEFAULT_INFOMASK, CAPI_DEFAULT_CIPMASK, CAPI_DEFAULT_CIPMASK2)>0){
00079 gitk_log("capi20 listen incoming calls");
00080 }else{
00081 gitk_log("capi20 listen failed");
00082 capi_done(capiinfo);
00083 }
00084 }
00085
00086 #endif //HAVE_CAPI20
00087
00088 }
00089 gitk_log("phone mode render plugin init end");
00090 return(TRUE);
00091 }
00092
00097 gboolean gitkr_init_process_commandline(guint *argc, gchar ***argv) {
00098 guint i;
00099 gchar *arg;
00100 gboolean info_only=FALSE;
00101 gboolean info_help=FALSE, info_version=FALSE;
00102
00103 gitk_log("gitkr_init_process_commandline() beg");
00104
00105
00106 for (i=1;i<*argc;) {
00107 if (!strcmp("--help", (*argv)[i]) || !strcmp("-h", (*argv)[i])) {
00108 info_only=info_help=TRUE;
00109
00110 }
00111 else if((*argv)[i] && (!strcmp("--version", (*argv)[i]))) {
00112 info_only=info_version=TRUE;
00113
00114
00115 }
00116 else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-speech"))) {
00117 gitkr_phone_speech_name=strdup(arg);
00118 gitk_log1("selected speech (par) : \"%s\"",gitkr_phone_speech_name);
00119 }
00120 else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-festival-host"))) {
00121 gitkr_phone_festival_host=strdup(arg);
00122 gitk_log1("selected festival_host (par) : \"%s\"",gitkr_phone_festival_host);
00123 }
00124 else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-festival-port"))) {
00125 gitkr_phone_festival_port=(gint)(strdup(arg));
00126 gitk_log1("selected festival_port (par) : \"%d\"",gitkr_phone_festival_port);
00127 }
00128 else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-capi-logical-connections"))) {
00129 gitkr_phone_capi_logicalconnections=(gint)(strdup(arg));
00130 gitk_log1("selected capi_logicalconnections (par) : \"%d\"",gitkr_phone_capi_logicalconnections);
00131 }
00132 else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-capi-datablocks"))) {
00133 gitkr_phone_capi_datablocks=(gint)(strdup(arg));
00134 gitk_log1("selected capi_datablocks (par) : \"%d\"",gitkr_phone_capi_datablocks);
00135 }
00136 else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-capi-datalength"))) {
00137 gitkr_phone_capi_datalength=(gint)(strdup(arg));
00138 gitk_log1("selected capi_datalength (par) : \"%d\"",gitkr_phone_capi_datalength);
00139 }
00140 i++;
00141 }
00142 if(info_help){
00143 gitk_puts(_("GITK-Renderer-Phone options"));
00144 gitk_puts(_(" --gitkr-phone-speech\t\t\twhich speech module to use {festival}"));
00145 gitk_puts(_(" --gitkr-phone-festival-host\t\twhich host to use {festival}"));
00146 gitk_puts(_(" --gitkr-phone-festival-port\t\twhich port to use {festival}"));
00147 gitk_puts(_(" --gitkr-phone-capi-logical-connections\thow many logical connections to use {capi20}"));
00148 gitk_puts(_(" --gitkr-phone-capi-datablocks\t\thow many B-Channel Datablocks to use {capi20}"));
00149 gitk_puts(_(" --gitkr-phone-capi-datalength\t\twhich B-Channel Datalength to use {capi20}\n"));
00150 }
00151 if(info_version) puts(PACKAGE_NAME": version "PACKAGE_VERSION" by "PACKAGE_BUGREPORT);
00152
00153
00154 cleanup_commandline_args(argc,argv);
00155 gitk_log1("gitk_init_process_commandline()=%1d end",info_only);
00156 return(info_only);
00157 }
00158