Link with C++ linker
[oweals/cde.git] / cde / programs / ttsnoop / sessionChooser_stubs.C.src
1 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
2 //%%  (c) Copyright 1993, 1994 Hewlett-Packard Company
3 //%%  (c) Copyright 1993, 1994 International Business Machines Corp.
4 //%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
5 //%%  (c) Copyright 1993, 1994 Novell, Inc.
6 //%%  $XConsortium: sessionChooser_stubs.C.src /main/3 1995/11/06 17:13:45 rswiston $
7 /*** DTB_USER_CODE_END   ^^^ Add file header above ^^^ ***/
8
9 /*
10  * File: sessionChooser_stubs.c
11  * Contains: Module callbacks and connection functions
12  *
13  * This file was generated by dtcodegen, from module sessionChooser
14  *
15  * Any text may be added between the DTB_USER_CODE_START and
16  * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
17  * are provided only as an aid.
18  *
19  *  ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS.  **
20  *  ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR  **
21  *  ** DELETE THE GENERATED COMMENTS!                                 **
22  */
23
24 #include <stdio.h>
25 #include <Xm/Xm.h>
26 #include "dtb_utils.h"
27 #include "sessionChooser_ui.h"
28
29 /*
30  * Header files for cross-module connections
31  */
32 #include "ttsnoop_ui.h"
33
34
35 /**************************************************************************
36  *** DTB_USER_CODE_START
37  ***
38  *** All necessary header files have been included.
39  ***
40  *** Add include files, types, macros, externs, and user functions here.
41  ***/
42
43 #include <Xm/TextF.h>
44 #include <fstream.h>
45 #include <strstream.h>
46 #include "DtTt.h"
47
48 extern ofstream snoopStream;
49
50 void
51 _DtSessionChooserSet(
52         _DtSessionChooserAction choice,
53         void *                  entity
54 )
55 {
56         char *okString;
57         char *title;
58         char *valueLabel;
59         switch (choice) {
60             case _DtSessionChoosePattern:
61                 okString = "Add";
62                 title = "tt_pattern_session_add";
63                 break;
64             case _DtSessionChooseMessage:
65                 okString = "Set";
66                 title = "tt_message_session_set";
67                 break;
68             case _DtSessionChooseJoin:
69                 okString = "Join";
70                 title = "tt_session_join";
71                 break;
72             case _DtSessionChooseDtJoin:
73                 okString = "Join";
74                 title = "ttdt_session_join";
75                 break;
76             case _DtSessionChooseQuit:
77                 okString = "Quit";
78                 title = "tt_session_quit";
79                 break;
80             case _DtSessionChooseDefault:
81                 okString = "Set";
82                 title = "tt_default_session_set";
83                 break;
84             default:
85                 return;
86         }
87         DtbSessionChooserSessionChooserInfo instance =
88                 &dtb_session_chooser_session_chooser;
89         if (! instance->initialized) {
90                 dtb_session_chooser_session_chooser_initialize(
91                         instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
92         }
93         DtTtSetLabel( instance->sessionOkButton, okString );
94         XtVaSetValues( instance->sessionChooser, XmNtitle, title, 0 );
95         // Remember dialog mode, entity
96         XtVaSetValues( instance->sessionOkButton, XmNuserData, choice, 0 );
97         XtVaSetValues( instance->sessionCancelButton, XmNuserData, entity, 0 );
98         XmTextPosition last =
99                 XmTextFieldGetLastPosition( instance->sessionText );
100         Time when =
101                 XtLastTimestampProcessed( XtDisplay( instance->sessionText ));
102         XmTextFieldSetSelection( instance->sessionText, 0, last, when );
103         XtManageChild( instance->sessionChooser_shellform );
104 }
105
106 static Tt_message
107 snoopSessionMsg(
108         Tt_message      msg,
109         void *          clientData,
110         Tt_message      contract
111 )
112 {
113         DtTtCreated( DTTT_MESSAGE, msg );
114         snoopIt( "Ttdt_contract_cb", snoopSessionMsg, msg );
115         if (   (tt_message_class( msg ) == TT_REQUEST)
116             && (tt_message_state( msg ) == TT_SENT))
117         {
118                 // Let user fill in the answer
119                 Widget newWidget = DtTtMessageWidgetCreate(
120                                     dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
121                                     msg, DtTtMessageWidgetUpdate );
122                 if (! tt_is_err( tt_ptr_error( newWidget ) )) {
123                         XRaiseWindow( XtDisplay( newWidget ),
124                                       XtWindow( newWidget ));
125                 }
126         }
127         return 0;
128 }
129
130 /*** DTB_USER_CODE_END
131  ***
132  *** End of user code section
133  ***
134  **************************************************************************/
135
136
137
138 void 
139 sessionChooser_sessionCancelButton_CB1(
140     Widget widget,
141     XtPointer clientData,
142     XtPointer callData
143 )
144 {
145     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
146     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
147     
148     DtbSessionChooserSessionChooserInfo instance = (DtbSessionChooserSessionChooserInfo)clientData;
149     
150     if (!(instance->initialized))
151     {
152         dtb_session_chooser_session_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
153     }
154     XtUnmanageChild(instance->sessionChooser_shellform);
155     
156     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
157     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
158 }
159
160
161 void 
162 defaultSession(
163     Widget widget,
164     XtPointer clientData,
165     XtPointer callData
166 )
167 {
168     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
169     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
170     
171     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
172     DtbSessionChooserSessionChooserInfo instance =
173             (DtbSessionChooserSessionChooserInfo)clientData;
174     char *sess = tt_default_session();
175     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
176                                      "tt_default_session()", sess );
177     if (tt_is_err( status )) {
178             return;
179     }
180     XmTextFieldSetString( instance->sessionText, sess );
181     tt_free( sess );
182     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
183 }
184
185
186 void 
187 sessionOK(
188     Widget widget,
189     XtPointer clientData,
190     XtPointer callData
191 )
192 {
193     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
194     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
195     
196     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
197     DtbSessionChooserSessionChooserInfo instance =
198             (DtbSessionChooserSessionChooserInfo)clientData;
199     char *session = XmTextFieldGetString( instance->sessionText );
200     if ((session != 0) && (session[0] == '\0')) {
201             XtFree( session );
202             session = 0;
203     }
204     XtPointer val;
205     XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, 0 );
206     _DtSessionChooserAction choice = (_DtSessionChooserAction)val;
207     XtVaGetValues( instance->sessionCancelButton, XmNuserData, &val, 0 );
208     Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
209     switch (choice) {
210             Tt_status status;
211             Tt_pattern *pats;
212         case _DtSessionChoosePattern:
213             _DtTtPatternUpdate( (Tt_pattern)val, choice, session );
214             break;
215         case _DtSessionChooseMessage:
216             _DtTtMessageUpdate( (Tt_message)val, choice, session );
217             break;
218         case _DtSessionChooseJoin:
219             status = tt_session_join( session );
220             DtTtSetLabel( label, "tt_session_join()", status );
221             break;
222         case _DtSessionChooseDtJoin:
223             pats = ttdt_session_join( session, snoopSessionMsg,
224                                 dtb_ttsnoop_ttsnoop_win.ttsnoopWin, 0, 1 );
225             status = DtTtSetLabel( label, "ttdt_session_join()", pats );
226             if ((status == TT_OK) && (pats != 0)) {
227                     DtTtCreated( DTTT_DTSESSION, pats, session );
228             }
229             break;
230         case _DtSessionChooseQuit:
231             status = tt_session_quit( session );
232             DtTtSetLabel( label, "tt_session_quit()", status );
233             break;
234         case _DtSessionChooseDefault:
235             status = tt_default_session_set( session );
236             DtTtSetLabel( label, "tt_default_session_set()", status );
237             break;
238         default:
239             break;
240     }
241     if (session != 0) {
242             XtFree( session );
243     }
244     XtUnmanageChild(instance->sessionChooser_shellform);
245     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
246 }
247
248
249 void 
250 sessionHelp(
251     Widget widget,
252     XtPointer clientData,
253     XtPointer callData
254 )
255 {
256     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
257     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
258     
259     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
260     DtbSessionChooserSessionChooserInfo instance =
261             (DtbSessionChooserSessionChooserInfo)clientData;
262     XtPointer val;
263     XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, 0 );
264     _DtSessionChooserAction choice = (_DtSessionChooserAction)val;
265     Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
266     switch (choice) {
267         case _DtSessionChoosePattern:
268             _DtMan( label, "tt_pattern_session_add" );
269             break;
270         case _DtSessionChooseMessage:
271             _DtMan( label, "tt_message_session_set" );
272             break;
273         case _DtSessionChooseJoin:
274             _DtMan( label, "tt_session_join" );
275             break;
276         case _DtSessionChooseDtJoin:
277             _DtMan( label, "ttdt_session_join" );
278             break;
279         case _DtSessionChooseQuit:
280             _DtMan( label, "tt_session_quit" );
281             break;
282         case _DtSessionChooseDefault:
283             _DtMan( label, "tt_default_session_set" );
284             break;
285         default:
286             break;
287     }
288     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
289 }
290
291
292 void 
293 xSession(
294     Widget widget,
295     XtPointer clientData,
296     XtPointer callData
297 )
298 {
299     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
300     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
301     
302     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
303     DtbSessionChooserSessionChooserInfo instance =
304             (DtbSessionChooserSessionChooserInfo)clientData;
305     char *sess = tt_X_session( getenv( "DISPLAY" ));
306     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
307                                 "tt_X_session( getenv( \"DISPLAY\" ))", sess );
308     if (tt_is_err( status )) {
309             return;
310     }
311     XmTextFieldSetString( instance->sessionText, sess );
312     tt_free( sess );
313     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
314 }
315
316
317 void 
318 initialSession(
319     Widget widget,
320     XtPointer clientData,
321     XtPointer callData
322 )
323 {
324     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
325     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
326     
327     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
328     DtbSessionChooserSessionChooserInfo instance =
329             (DtbSessionChooserSessionChooserInfo)clientData;
330     char *sess = tt_initial_session();
331     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
332                                      "tt_initial_session()", sess );
333     if (tt_is_err( status )) {
334             return;
335     }
336     XmTextFieldSetString( instance->sessionText, sess );
337     tt_free( sess );
338     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
339 }
340
341
342
343 /**************************************************************************
344  *** DTB_USER_CODE_START
345  ***
346  *** All automatically-generated data and functions have been defined.
347  ***
348  *** Add new functions here, or at the top of the file.
349  ***/
350
351 /*** DTB_USER_CODE_END
352  ***
353  *** End of user code section
354  ***
355  **************************************************************************/
356
357