360 lines
10 KiB
Plaintext
360 lines
10 KiB
Plaintext
/*** DTB_USER_CODE_START vvv Add file header below vvv ***/
|
|
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
|
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
|
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
|
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
|
//%% $XConsortium: sessionChooser_stubs.C.src /main/3 1995/11/06 17:13:45 rswiston $
|
|
/*** DTB_USER_CODE_END ^^^ Add file header above ^^^ ***/
|
|
|
|
/*
|
|
* File: sessionChooser_stubs.c
|
|
* Contains: Module callbacks and connection functions
|
|
*
|
|
* This file was generated by dtcodegen, from module sessionChooser
|
|
*
|
|
* Any text may be added between the DTB_USER_CODE_START and
|
|
* DTB_USER_CODE_END comments (even non-C code). Descriptive comments
|
|
* are provided only as an aid.
|
|
*
|
|
* ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS. **
|
|
* ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR **
|
|
* ** DELETE THE GENERATED COMMENTS! **
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <Xm/Xm.h>
|
|
#include "dtb_utils.h"
|
|
#include "sessionChooser_ui.h"
|
|
|
|
/*
|
|
* Header files for cross-module connections
|
|
*/
|
|
#include "ttsnoop_ui.h"
|
|
|
|
|
|
/**************************************************************************
|
|
*** DTB_USER_CODE_START
|
|
***
|
|
*** All necessary header files have been included.
|
|
***
|
|
*** Add include files, types, macros, externs, and user functions here.
|
|
***/
|
|
|
|
#include <Xm/TextF.h>
|
|
|
|
#include <fstream>
|
|
#include <sstream>
|
|
|
|
#include "DtTt.h"
|
|
|
|
extern std::ofstream snoopStream;
|
|
|
|
void
|
|
_DtSessionChooserSet(
|
|
_DtSessionChooserAction choice,
|
|
void * entity
|
|
)
|
|
{
|
|
char *okString;
|
|
char *title;
|
|
char *valueLabel;
|
|
switch (choice) {
|
|
case _DtSessionChoosePattern:
|
|
okString = "Add";
|
|
title = "tt_pattern_session_add";
|
|
break;
|
|
case _DtSessionChooseMessage:
|
|
okString = "Set";
|
|
title = "tt_message_session_set";
|
|
break;
|
|
case _DtSessionChooseJoin:
|
|
okString = "Join";
|
|
title = "tt_session_join";
|
|
break;
|
|
case _DtSessionChooseDtJoin:
|
|
okString = "Join";
|
|
title = "ttdt_session_join";
|
|
break;
|
|
case _DtSessionChooseQuit:
|
|
okString = "Quit";
|
|
title = "tt_session_quit";
|
|
break;
|
|
case _DtSessionChooseDefault:
|
|
okString = "Set";
|
|
title = "tt_default_session_set";
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
DtbSessionChooserSessionChooserInfo instance =
|
|
&dtb_session_chooser_session_chooser;
|
|
if (! instance->initialized) {
|
|
dtb_session_chooser_session_chooser_initialize(
|
|
instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
|
|
}
|
|
DtTtSetLabel( instance->sessionOkButton, okString );
|
|
XtVaSetValues( instance->sessionChooser, XmNtitle, title, NULL );
|
|
// Remember dialog mode, entity
|
|
XtVaSetValues( instance->sessionOkButton, XmNuserData, choice, NULL );
|
|
XtVaSetValues( instance->sessionCancelButton, XmNuserData, entity, NULL );
|
|
XmTextPosition last =
|
|
XmTextFieldGetLastPosition( instance->sessionText );
|
|
Time when =
|
|
XtLastTimestampProcessed( XtDisplay( instance->sessionText ));
|
|
XmTextFieldSetSelection( instance->sessionText, 0, last, when );
|
|
XtManageChild( instance->sessionChooser_shellform );
|
|
}
|
|
|
|
static Tt_message
|
|
snoopSessionMsg(
|
|
Tt_message msg,
|
|
void * clientData,
|
|
Tt_message contract
|
|
)
|
|
{
|
|
DtTtCreated( DTTT_MESSAGE, msg );
|
|
snoopIt( "Ttdt_contract_cb", (void *) snoopSessionMsg, msg );
|
|
if ( (tt_message_class( msg ) == TT_REQUEST)
|
|
&& (tt_message_state( msg ) == TT_SENT))
|
|
{
|
|
// Let user fill in the answer
|
|
Widget newWidget = DtTtMessageWidgetCreate(
|
|
dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
|
|
msg, DtTtMessageWidgetUpdate );
|
|
if (! tt_is_err( tt_ptr_error( newWidget ) )) {
|
|
XRaiseWindow( XtDisplay( newWidget ),
|
|
XtWindow( newWidget ));
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*** DTB_USER_CODE_END
|
|
***
|
|
*** End of user code section
|
|
***
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
sessionChooser_sessionCancelButton_CB1(
|
|
Widget widget,
|
|
XtPointer clientData,
|
|
XtPointer callData
|
|
)
|
|
{
|
|
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
|
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
|
|
|
DtbSessionChooserSessionChooserInfo instance = (DtbSessionChooserSessionChooserInfo)clientData;
|
|
|
|
if (!(instance->initialized))
|
|
{
|
|
dtb_session_chooser_session_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
|
|
}
|
|
XtUnmanageChild(instance->sessionChooser_shellform);
|
|
|
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
|
}
|
|
|
|
|
|
void
|
|
defaultSession(
|
|
Widget widget,
|
|
XtPointer clientData,
|
|
XtPointer callData
|
|
)
|
|
{
|
|
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
|
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
|
|
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
|
DtbSessionChooserSessionChooserInfo instance =
|
|
(DtbSessionChooserSessionChooserInfo)clientData;
|
|
char *sess = tt_default_session();
|
|
Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
|
|
"tt_default_session()", sess );
|
|
if (tt_is_err( status )) {
|
|
return;
|
|
}
|
|
XmTextFieldSetString( instance->sessionText, sess );
|
|
tt_free( sess );
|
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
|
}
|
|
|
|
|
|
void
|
|
sessionOK(
|
|
Widget widget,
|
|
XtPointer clientData,
|
|
XtPointer callData
|
|
)
|
|
{
|
|
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
|
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
|
|
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
|
DtbSessionChooserSessionChooserInfo instance =
|
|
(DtbSessionChooserSessionChooserInfo)clientData;
|
|
char *session = XmTextFieldGetString( instance->sessionText );
|
|
if ((session != 0) && (session[0] == '\0')) {
|
|
XtFree( session );
|
|
session = 0;
|
|
}
|
|
XtPointer val;
|
|
XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, NULL );
|
|
_DtSessionChooserAction choice = (_DtSessionChooserAction) (long) val;
|
|
XtVaGetValues( instance->sessionCancelButton, XmNuserData, &val, NULL );
|
|
Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
|
|
switch (choice) {
|
|
Tt_status status;
|
|
Tt_pattern *pats;
|
|
case _DtSessionChoosePattern:
|
|
_DtTtPatternUpdate( (Tt_pattern)val, choice, session );
|
|
break;
|
|
case _DtSessionChooseMessage:
|
|
_DtTtMessageUpdate( (Tt_message)val, choice, session );
|
|
break;
|
|
case _DtSessionChooseJoin:
|
|
status = tt_session_join( session );
|
|
DtTtSetLabel( label, "tt_session_join()", status );
|
|
break;
|
|
case _DtSessionChooseDtJoin:
|
|
pats = ttdt_session_join( session, snoopSessionMsg,
|
|
dtb_ttsnoop_ttsnoop_win.ttsnoopWin, 0, 1 );
|
|
status = DtTtSetLabel( label, "ttdt_session_join()", pats );
|
|
if ((status == TT_OK) && (pats != 0)) {
|
|
DtTtCreated( DTTT_DTSESSION, pats, session );
|
|
}
|
|
break;
|
|
case _DtSessionChooseQuit:
|
|
status = tt_session_quit( session );
|
|
DtTtSetLabel( label, "tt_session_quit()", status );
|
|
break;
|
|
case _DtSessionChooseDefault:
|
|
status = tt_default_session_set( session );
|
|
DtTtSetLabel( label, "tt_default_session_set()", status );
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if (session != 0) {
|
|
XtFree( session );
|
|
}
|
|
XtUnmanageChild(instance->sessionChooser_shellform);
|
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
|
}
|
|
|
|
|
|
void
|
|
sessionHelp(
|
|
Widget widget,
|
|
XtPointer clientData,
|
|
XtPointer callData
|
|
)
|
|
{
|
|
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
|
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
|
|
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
|
DtbSessionChooserSessionChooserInfo instance =
|
|
(DtbSessionChooserSessionChooserInfo)clientData;
|
|
XtPointer val;
|
|
XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, NULL );
|
|
_DtSessionChooserAction choice = (_DtSessionChooserAction) (long) val;
|
|
Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
|
|
switch (choice) {
|
|
case _DtSessionChoosePattern:
|
|
_DtMan( label, "tt_pattern_session_add" );
|
|
break;
|
|
case _DtSessionChooseMessage:
|
|
_DtMan( label, "tt_message_session_set" );
|
|
break;
|
|
case _DtSessionChooseJoin:
|
|
_DtMan( label, "tt_session_join" );
|
|
break;
|
|
case _DtSessionChooseDtJoin:
|
|
_DtMan( label, "ttdt_session_join" );
|
|
break;
|
|
case _DtSessionChooseQuit:
|
|
_DtMan( label, "tt_session_quit" );
|
|
break;
|
|
case _DtSessionChooseDefault:
|
|
_DtMan( label, "tt_default_session_set" );
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
|
}
|
|
|
|
|
|
void
|
|
xSession(
|
|
Widget widget,
|
|
XtPointer clientData,
|
|
XtPointer callData
|
|
)
|
|
{
|
|
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
|
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
|
|
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
|
DtbSessionChooserSessionChooserInfo instance =
|
|
(DtbSessionChooserSessionChooserInfo)clientData;
|
|
char *sess = tt_X_session( getenv( "DISPLAY" ));
|
|
Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
|
|
"tt_X_session( getenv( \"DISPLAY\" ))", sess );
|
|
if (tt_is_err( status )) {
|
|
return;
|
|
}
|
|
XmTextFieldSetString( instance->sessionText, sess );
|
|
tt_free( sess );
|
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
|
}
|
|
|
|
|
|
void
|
|
initialSession(
|
|
Widget widget,
|
|
XtPointer clientData,
|
|
XtPointer callData
|
|
)
|
|
{
|
|
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
|
|
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
|
|
|
|
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
|
|
DtbSessionChooserSessionChooserInfo instance =
|
|
(DtbSessionChooserSessionChooserInfo)clientData;
|
|
char *sess = tt_initial_session();
|
|
Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
|
|
"tt_initial_session()", sess );
|
|
if (tt_is_err( status )) {
|
|
return;
|
|
}
|
|
XmTextFieldSetString( instance->sessionText, sess );
|
|
tt_free( sess );
|
|
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*** DTB_USER_CODE_START
|
|
***
|
|
*** All automatically-generated data and functions have been defined.
|
|
***
|
|
*** Add new functions here, or at the top of the file.
|
|
***/
|
|
|
|
/*** DTB_USER_CODE_END
|
|
***
|
|
*** End of user code section
|
|
***
|
|
**************************************************************************/
|
|
|
|
|