Resolve many build warnings
[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
45 #if defined(linux) || defined(CSRG_BASED)
46 #include <fstream>
47 #include <strstream>
48 #else
49 #include <fstream.h>
50 #include <strstream.h>
51 #endif
52
53 #include "DtTt.h"
54
55 extern std::ofstream snoopStream;
56
57 void
58 _DtSessionChooserSet(
59         _DtSessionChooserAction choice,
60         void *                  entity
61 )
62 {
63         char *okString;
64         char *title;
65         char *valueLabel;
66         switch (choice) {
67             case _DtSessionChoosePattern:
68                 okString = "Add";
69                 title = "tt_pattern_session_add";
70                 break;
71             case _DtSessionChooseMessage:
72                 okString = "Set";
73                 title = "tt_message_session_set";
74                 break;
75             case _DtSessionChooseJoin:
76                 okString = "Join";
77                 title = "tt_session_join";
78                 break;
79             case _DtSessionChooseDtJoin:
80                 okString = "Join";
81                 title = "ttdt_session_join";
82                 break;
83             case _DtSessionChooseQuit:
84                 okString = "Quit";
85                 title = "tt_session_quit";
86                 break;
87             case _DtSessionChooseDefault:
88                 okString = "Set";
89                 title = "tt_default_session_set";
90                 break;
91             default:
92                 return;
93         }
94         DtbSessionChooserSessionChooserInfo instance =
95                 &dtb_session_chooser_session_chooser;
96         if (! instance->initialized) {
97                 dtb_session_chooser_session_chooser_initialize(
98                         instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
99         }
100         DtTtSetLabel( instance->sessionOkButton, okString );
101         XtVaSetValues( instance->sessionChooser, XmNtitle, title, NULL );
102         // Remember dialog mode, entity
103         XtVaSetValues( instance->sessionOkButton, XmNuserData, choice, NULL );
104         XtVaSetValues( instance->sessionCancelButton, XmNuserData, entity, NULL );
105         XmTextPosition last =
106                 XmTextFieldGetLastPosition( instance->sessionText );
107         Time when =
108                 XtLastTimestampProcessed( XtDisplay( instance->sessionText ));
109         XmTextFieldSetSelection( instance->sessionText, 0, last, when );
110         XtManageChild( instance->sessionChooser_shellform );
111 }
112
113 static Tt_message
114 snoopSessionMsg(
115         Tt_message      msg,
116         void *          clientData,
117         Tt_message      contract
118 )
119 {
120         DtTtCreated( DTTT_MESSAGE, msg );
121         snoopIt( "Ttdt_contract_cb", (void *) snoopSessionMsg, msg );
122         if (   (tt_message_class( msg ) == TT_REQUEST)
123             && (tt_message_state( msg ) == TT_SENT))
124         {
125                 // Let user fill in the answer
126                 Widget newWidget = DtTtMessageWidgetCreate(
127                                     dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
128                                     msg, DtTtMessageWidgetUpdate );
129                 if (! tt_is_err( tt_ptr_error( newWidget ) )) {
130                         XRaiseWindow( XtDisplay( newWidget ),
131                                       XtWindow( newWidget ));
132                 }
133         }
134         return 0;
135 }
136
137 /*** DTB_USER_CODE_END
138  ***
139  *** End of user code section
140  ***
141  **************************************************************************/
142
143
144
145 void 
146 sessionChooser_sessionCancelButton_CB1(
147     Widget widget,
148     XtPointer clientData,
149     XtPointer callData
150 )
151 {
152     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
153     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
154     
155     DtbSessionChooserSessionChooserInfo instance = (DtbSessionChooserSessionChooserInfo)clientData;
156     
157     if (!(instance->initialized))
158     {
159         dtb_session_chooser_session_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
160     }
161     XtUnmanageChild(instance->sessionChooser_shellform);
162     
163     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
164     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
165 }
166
167
168 void 
169 defaultSession(
170     Widget widget,
171     XtPointer clientData,
172     XtPointer callData
173 )
174 {
175     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
176     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
177     
178     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
179     DtbSessionChooserSessionChooserInfo instance =
180             (DtbSessionChooserSessionChooserInfo)clientData;
181     char *sess = tt_default_session();
182     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
183                                      "tt_default_session()", sess );
184     if (tt_is_err( status )) {
185             return;
186     }
187     XmTextFieldSetString( instance->sessionText, sess );
188     tt_free( sess );
189     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
190 }
191
192
193 void 
194 sessionOK(
195     Widget widget,
196     XtPointer clientData,
197     XtPointer callData
198 )
199 {
200     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
201     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
202     
203     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
204     DtbSessionChooserSessionChooserInfo instance =
205             (DtbSessionChooserSessionChooserInfo)clientData;
206     char *session = XmTextFieldGetString( instance->sessionText );
207     if ((session != 0) && (session[0] == '\0')) {
208             XtFree( session );
209             session = 0;
210     }
211     XtPointer val;
212     XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, NULL );
213     _DtSessionChooserAction choice = (_DtSessionChooserAction) (long) val;
214     XtVaGetValues( instance->sessionCancelButton, XmNuserData, &val, NULL );
215     Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
216     switch (choice) {
217             Tt_status status;
218             Tt_pattern *pats;
219         case _DtSessionChoosePattern:
220             _DtTtPatternUpdate( (Tt_pattern)val, choice, session );
221             break;
222         case _DtSessionChooseMessage:
223             _DtTtMessageUpdate( (Tt_message)val, choice, session );
224             break;
225         case _DtSessionChooseJoin:
226             status = tt_session_join( session );
227             DtTtSetLabel( label, "tt_session_join()", status );
228             break;
229         case _DtSessionChooseDtJoin:
230             pats = ttdt_session_join( session, snoopSessionMsg,
231                                 dtb_ttsnoop_ttsnoop_win.ttsnoopWin, 0, 1 );
232             status = DtTtSetLabel( label, "ttdt_session_join()", pats );
233             if ((status == TT_OK) && (pats != 0)) {
234                     DtTtCreated( DTTT_DTSESSION, pats, session );
235             }
236             break;
237         case _DtSessionChooseQuit:
238             status = tt_session_quit( session );
239             DtTtSetLabel( label, "tt_session_quit()", status );
240             break;
241         case _DtSessionChooseDefault:
242             status = tt_default_session_set( session );
243             DtTtSetLabel( label, "tt_default_session_set()", status );
244             break;
245         default:
246             break;
247     }
248     if (session != 0) {
249             XtFree( session );
250     }
251     XtUnmanageChild(instance->sessionChooser_shellform);
252     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
253 }
254
255
256 void 
257 sessionHelp(
258     Widget widget,
259     XtPointer clientData,
260     XtPointer callData
261 )
262 {
263     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
264     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
265     
266     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
267     DtbSessionChooserSessionChooserInfo instance =
268             (DtbSessionChooserSessionChooserInfo)clientData;
269     XtPointer val;
270     XtVaGetValues( instance->sessionOkButton, XmNuserData, &val, NULL );
271     _DtSessionChooserAction choice = (_DtSessionChooserAction) (long) val;
272     Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
273     switch (choice) {
274         case _DtSessionChoosePattern:
275             _DtMan( label, "tt_pattern_session_add" );
276             break;
277         case _DtSessionChooseMessage:
278             _DtMan( label, "tt_message_session_set" );
279             break;
280         case _DtSessionChooseJoin:
281             _DtMan( label, "tt_session_join" );
282             break;
283         case _DtSessionChooseDtJoin:
284             _DtMan( label, "ttdt_session_join" );
285             break;
286         case _DtSessionChooseQuit:
287             _DtMan( label, "tt_session_quit" );
288             break;
289         case _DtSessionChooseDefault:
290             _DtMan( label, "tt_default_session_set" );
291             break;
292         default:
293             break;
294     }
295     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
296 }
297
298
299 void 
300 xSession(
301     Widget widget,
302     XtPointer clientData,
303     XtPointer callData
304 )
305 {
306     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
307     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
308     
309     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
310     DtbSessionChooserSessionChooserInfo instance =
311             (DtbSessionChooserSessionChooserInfo)clientData;
312     char *sess = tt_X_session( getenv( "DISPLAY" ));
313     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
314                                 "tt_X_session( getenv( \"DISPLAY\" ))", sess );
315     if (tt_is_err( status )) {
316             return;
317     }
318     XmTextFieldSetString( instance->sessionText, sess );
319     tt_free( sess );
320     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
321 }
322
323
324 void 
325 initialSession(
326     Widget widget,
327     XtPointer clientData,
328     XtPointer callData
329 )
330 {
331     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
332     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
333     
334     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
335     DtbSessionChooserSessionChooserInfo instance =
336             (DtbSessionChooserSessionChooserInfo)clientData;
337     char *sess = tt_initial_session();
338     Tt_status status = DtTtSetLabel( instance->sessionChooser_label,
339                                      "tt_initial_session()", sess );
340     if (tt_is_err( status )) {
341             return;
342     }
343     XmTextFieldSetString( instance->sessionText, sess );
344     tt_free( sess );
345     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
346 }
347
348
349
350 /**************************************************************************
351  *** DTB_USER_CODE_START
352  ***
353  *** All automatically-generated data and functions have been defined.
354  ***
355  *** Add new functions here, or at the top of the file.
356  ***/
357
358 /*** DTB_USER_CODE_END
359  ***
360  *** End of user code section
361  ***
362  **************************************************************************/
363
364