Example #1
0
Tt_message
MediaCallback( Tt_message msg,
	       void * client_data,
	       Tttk_op op,
	       Tt_status diag,
	       unsigned char * contents,
	       int len,
	       char * file,
	       char * docname )
{
	char *ceiling;
	Boolean restricted = False;

	tt_free( docname );
	if (diag != TT_OK) {
		return msg;
	}
	if (file == 0) {
		if (contents == 0) {
			tttk_message_fail( msg, TT_DESKTOP_ENODATA, 0, 1 );
			return 0;
		} else {
			/* Buffers and files are the same to dtfile */
			/* ToolTalk buffers are always null-terminated */
			tt_free( file );
			file = (char *)contents;
		}
	}
	/* Old libtt SEGVs if you ask for a context that is not there */
	if (tt_message_contexts_count( msg ) > 0) {
		ceiling = tt_message_context_val( msg, "restricted" );
		if (! tt_is_err( tt_ptr_error( ceiling ))) {
			if ((ceiling == 0) || (strcmp( ceiling, "." ) != 0)) {
				tttk_message_fail( msg,
						   TT_DESKTOP_ENOTSUP, 0, 1 );
				return 0;
			}
			restricted = True;
		}
	}
	switch ( op ) {
	    default:
		break;
	    case TTME_DISPLAY:
	    case TTME_EDIT:
		/*
		 * Create a display of the given directory tree
		 */
		ViewDirectoryProc( file, restricted, msg );
		msg = 0;
		break;
	}
	tt_free( file );
	tt_free( (caddr_t)contents );
	return msg;
}
Example #2
0
/******************************************************************************
 *
 * Initiallize Tooltalk world.
 *
 *****************************************************************************/
static void
ToolTalkError(char *errfmt, Tt_status status)
{
    char	*statmsg;

    if (! tt_is_err(status)) return;

    statmsg = tt_status_message(status);
    DtMsgLogMessage( "Dtexec", DtMsgLogStderr, errfmt, statmsg );
}
Example #3
0
void
ToolTalkError( char * procName, Tt_status errId )
{
  if( tt_is_err( errId ) )
  {
    switch( errId )
    {
      case TT_ERR_NOMP:
         XtRemoveInput( ProcessToolTalkInputId );
         break;
      default:
         break;
    }
  }
}
Example #4
0
int
InitializeToolTalkSession( Widget topLevel, int ttFd )
{
  Tt_status ttstat;

  ttstat = ttmedia_ptype_declare( "DT_File_Manager",
                                  0,
                                  MediaCallback,
                                  (void *) 0,
                                  0);
  if (ttstat == TT_OK)
    ttstat = ttmedia_ptype_declare( "DT_File_Manager",
                                    1000,
                                    MediaCallback,
                                    (void *) 0,
                                    1);
  tt_ptype_opnum_callback_add( "DT_File_Manager", 0, HandleTtRequest );
  if (ttstat == TT_OK)
  {
    /*
     * If we were started by a message, the following call to
     * tttk_Xt_input_handler will process it.  Otherwise,
     * tttk_Xt_input_handler will just return.
     */
    tttk_Xt_input_handler( NULL, 0, 0 );

    FileManagerToolTalkPattern = ttdt_session_join( tt_default_session( ),
                                                    SessionCallback,
                                                    topLevel,
                                                    NULL,
                                                    1 );
    if( tt_is_err( tt_ptr_error( FileManagerToolTalkPattern )))
    {
      ttdt_close( NULL, NULL, sendStopped );
      return( 0 );
    }
  }
  else
  {
    ttdt_close( NULL, NULL, sendStopped );
    return( 0 );
  }
  return( TT_OK );
}
Example #5
0
Tt_message
FileCallback(
	Tt_message msg,
	Tttk_op op,
	char * file,
	void * clientdata,
	int trust,
	int self)
{
  View *view = clientdata;
  char local_host[MAXHOSTNAMELEN];
  extern char home_host_name[];

  switch (op) {
	  char *to_file;
	  DialogData *dialog_data;
	  int i;
      default:
	  break;
      case TTDT_MOVED:
	  if (view == 0) {
		  break;
	  }
	  to_file = tt_message_arg_val(msg, 1);
	  strcpy(local_host, home_host_name);
	  dialog_data = (DialogData *)view->dialog_data;
	  ShowNewDirectory( (FileMgrData *)dialog_data->data,
			    local_host, to_file);

	  /* Quit the old file, join the new */
	  ttdt_file_quit( view->pats, 0 );
	  view->pats = ttdt_file_join( to_file, TT_SESSION,
				       0, FileCallback, view );
	  if (tt_is_err( tt_ptr_error( view->pats ))) {
	      view->pats = 0;
          }
	  tt_free( to_file );
	  tttk_message_destroy( msg );
	  msg = 0;
  }
  tt_free( file );
  return msg;
}