A
download gitkrinit.c
Language: C
LOC: 112
Project Info
GITK - Generalized Interface Toolkit(gitk)
Server: SourceForge
Type: cvs
...k\gitk\gitk‑renderer‑phone\
   autogen.sh
   config.h.in
   configure.in
   gitkr-phoneConf.sh.in
   gitkrdefines.h
   gitkrdone.c
   gitkrdone.h
   gitkreventloop.c
   gitkreventloop.h
   gitkrglobal.c
   gitkrglobal.h
   gitkrhideshow.c
   gitkrhideshow.h
   gitkrincludes.h
   gitkrinfo.c
   gitkrinfo.h
   gitkrinit.c
   gitkrinit.h
   gitkrlayout.c
   gitkrlayout.h
   gitkrrenderer.c
   gitkrrenderer.h
   gitkrtools.c
   gitkrtools.h
   Makefile.am

/** $Id: gitkrinit.c,v 1.11 2004/10/29 12:12:21 ensonic Exp $
 *
 * @file   gitk-renderer-phone/gitkrinit.c
 * @author Steffen Ast <sast@users.sf.net>
 * @date   Thu Oct 23 13:10:50 2003
 *
 * @brief  gitk renderer init routine
 * @ingroup gitkrendererphone
 * 
 */

/** @defgroup gitkrendererphone libgitk phone mode renderer
 * @ingroup gitkrenderer
 * A telephony based rendering module for gitk.
 */

#define GITK_RENDERER_C
#define GITKR_INIT_C

#include "gitkrincludes.h"
#include <unistd.h>
#include <fcntl.h>

/** @brief initialises the renderer
 */
 
gboolean gitkr_init(guint *argc, gchar ***argv) {
  unsigned char testbuf[256];
  unsigned char c = ' ';
  
  g_log_set_handler(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG|G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING|G_LOG_LEVEL_ERROR|G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION, gitk_log_handler, NULL);
  gitk_log("phone mode render plugin init beg");
  
  selected = strdup(_("is focussed"));
  TextOn = strdup(_("is on"));
  TextOff = strdup(_("is off"));
  IconApplication = strdup(_("application"));
  IconPagename = strdup(_("page name"));
  IconLabel = strdup(_("label"));
  IconEdit = strdup(_("edit"));
  IconOptionChoice = strdup(_("option choice"));
  IconControl = strdup(_("control"));
  IconAction = strdup(_("button"));
  IconProgress = strdup(_("progress bar"));
  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 # "));
  
  if(!gitkr_init_process_commandline(argc,argv)) {

    //-- init curses library and set io-params
    initscr();
    
    cbreak();               	/* take input chars one at a time, no wait for \n */
    noecho();               	/* disable echo mode */
    nonl();                 	/* tell curses not to do NL->CR/NL on output */
    scrollok(stdscr, FALSE);	/* do not scroll */
    intrflush(stdscr, FALSE);	/* intermediate display-queue flush, when using break */
    keypad(stdscr, TRUE);   	/* enable keyboard mapping */

    code_set=nl_langinfo(CODESET);	
    //-- init speech library and set params
    if(!(ftinfo=festival_initialize(gitkr_phone_festival_host,gitkr_phone_festival_port,gitkr_phone_speech_name))) {
      gitk_log("*no* speech output available!");
      return(FALSE);
    }
    else {
      gitk_log("speech output available!");
    }
    
#ifdef HAVE_CAPI20

    if(gitkr_phone_capi_datalength)
      gitkr_phone_capi_betweendigits = 24*256/gitkr_phone_capi_datalength;
    if (!(capiinfo = capi_initialize(gitkr_phone_capi_logicalconnections, gitkr_phone_capi_datablocks, gitkr_phone_capi_datalength))) {
      gitk_log("*no* capi20 available!");
      return(FALSE);
    }else{
      gitk_log("capi20 available!");
      if(capi_listen(capiinfo, CAPI_DEFAULT_CONTROLLER, CAPI_DEFAULT_INFOMASK, CAPI_DEFAULT_CIPMASK, CAPI_DEFAULT_CIPMASK2)>0){
      	gitk_log("capi20 listen incoming calls");
      }else{
        gitk_log("capi20 listen failed");
        capi_done(capiinfo);
      }
    }
    
#endif //HAVE_CAPI20

  }
  gitk_log("phone mode render plugin init end");
  return(TRUE);
}

/** @brief check if there have been passed some parameters for libgitkr_phone and process them
 * @internal
 * @return TRUE for success, otherwise FALSE
 */
gboolean gitkr_init_process_commandline(guint *argc, gchar ***argv) {
  guint i;
  gchar *arg;
  gboolean info_only=FALSE;	
  gboolean info_help=FALSE, info_version=FALSE;	

  gitk_log("gitkr_init_process_commandline() beg");

  //-- check if there have been passed some parameters for libgitk
  for (i=1;i<*argc;) {
		if (!strcmp("--help", (*argv)[i]) || !strcmp("-h", (*argv)[i])) {
	  		info_only=info_help=TRUE;
			//break;
		}
		else if((*argv)[i] && (!strcmp("--version", (*argv)[i]))) {
			info_only=info_version=TRUE;
			//puts(PACKAGE_NAME": version "PACKAGE_VERSION" by "PACKAGE_BUGREPORT);
			//info_only=TRUE;
		}
		else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-speech"))) {
			gitkr_phone_speech_name=strdup(arg);
			gitk_log1("selected speech (par) : \"%s\"",gitkr_phone_speech_name);
		} 
		else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-festival-host"))) {
			gitkr_phone_festival_host=strdup(arg);
			gitk_log1("selected festival_host (par) : \"%s\"",gitkr_phone_festival_host);
		} 
		else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-festival-port"))) {
			gitkr_phone_festival_port=(gint)(strdup(arg));
			gitk_log1("selected festival_port (par) : \"%d\"",gitkr_phone_festival_port);
		}
		else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-capi-logical-connections"))) {
			gitkr_phone_capi_logicalconnections=(gint)(strdup(arg));
			gitk_log1("selected capi_logicalconnections (par) : \"%d\"",gitkr_phone_capi_logicalconnections);
		} 
		else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-capi-datablocks"))) {
			gitkr_phone_capi_datablocks=(gint)(strdup(arg));
			gitk_log1("selected capi_datablocks (par) : \"%d\"",gitkr_phone_capi_datablocks);
		} 
		else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-phone-capi-datalength"))) {
			gitkr_phone_capi_datalength=(gint)(strdup(arg));
			gitk_log1("selected capi_datalength (par) : \"%d\"",gitkr_phone_capi_datalength);
		}
		i++;
  }
  if(info_help){
  	gitk_puts(_("GITK-Renderer-Phone options"));
	gitk_puts(_("      --gitkr-phone-speech\t\t\twhich speech module to use {festival}"));
	gitk_puts(_("      --gitkr-phone-festival-host\t\twhich host to use {festival}"));
	gitk_puts(_("      --gitkr-phone-festival-port\t\twhich port to use {festival}"));
	gitk_puts(_("      --gitkr-phone-capi-logical-connections\thow many logical connections to use {capi20}"));
	gitk_puts(_("      --gitkr-phone-capi-datablocks\t\thow many B-Channel Datablocks to use {capi20}"));
	gitk_puts(_("      --gitkr-phone-capi-datalength\t\twhich B-Channel Datalength to use {capi20}\n"));
  }
  if(info_version) puts(PACKAGE_NAME": version "PACKAGE_VERSION" by "PACKAGE_BUGREPORT);
  
  //-- remove found parameters
  cleanup_commandline_args(argc,argv);
  gitk_log1("gitk_init_process_commandline()=%1d end",info_only);
  return(info_only);
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us