1 /*----------------------------------------------------------------------------
2 --
3 --  Module:           xtmAclAfs
4 --
5 --  Project:          XDiary
6 --  System:           xtm - X Desktop Calendar
7 --    Subsystem:      <>
8 --    Function block: <>
9 --
10 --  Description:
11 --    Manage access control lists for Andrew File System.
12 --
13 --  Filename:         xtmAclAfs.c
14 --
15 --  Authors:          Roger Larsson, Ulrika Bornetun
16 --  Creation date:    1991-10-15
17 --
18 --
19 --  (C) Copyright Ulrika Bornetun, Roger Larsson (1995)
20 --      All rights reserved
21 --
22 --  Permission to use, copy, modify, and distribute this software and its
23 --  documentation for any purpose and without fee is hereby granted,
24 --  provided that the above copyright notice appear in all copies. Ulrika
25 --  Bornetun and Roger Larsson make no representations about the usability
26 --  of this software for any purpose. It is provided "as is" without express
27 --  or implied warranty.
28 ----------------------------------------------------------------------------*/
29 
30 /* SCCS module identifier. */
31 static char SCCSID[] = "@(#) Module: xtmAclAfs.c, Version: 1.1, Date: 95/02/18 15:58:52";
32 
33 
34 /*----------------------------------------------------------------------------
35 --  Include files
36 ----------------------------------------------------------------------------*/
37 
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 
42 #include <X11/Intrinsic.h>
43 #include <X11/StringDefs.h>
44 #include <X11/Shell.h>
45 
46 #include <Xm/Protocols.h>
47 
48 #include <Xm/Xm.h>
49 #include <Xm/List.h>
50 #include <Xm/RowColumn.h>
51 
52 #include "System.h"
53 #include "LstLinked.h"
54 #include "Message.h"
55 
56 #include "msgTopic.h"
57 #include "msgXdiary.h"
58 #include "xtmGlobal.h"
59 #include "xtmAccBase.h"
60 #include "xtmAfsAclBs.h"
61 #include "xtmCalDb.h"
62 #include "xtmCustBase.h"
63 #include "xtmEdAclAfs.h"
64 #include "xtmHelp.h"
65 #include "xtmIcons.h"
66 #include "xtmResource.h"
67 #include "xitError.h"
68 #include "xitInfo.h"
69 #include "xitStickyMsg.h"
70 #include "xitTools.h"
71 
72 
73 /*----------------------------------------------------------------------------
74 --  Macro definitions
75 ----------------------------------------------------------------------------*/
76 
77 /* Name of program. */
78 #define PROGRAM_NAME   "xdaclafs"
79 
80 /* Program class (also the name of the application defaults file). */
81 #define PROGRAM_CLASS  "XDiary"
82 
83 /* Local widgets in the window. */
84 #define actionRc       dataLocalW[  0 ]
85 #define dbLocLa        dataLocalW[  1 ]
86 #define dbLocLi        dataLocalW[  2 ]
87 
88 
89 /*----------------------------------------------------------------------------
90 --  Type declarations
91 ----------------------------------------------------------------------------*/
92 
93 /* Basic data structure for the XDaclAfs appliaction. */
94 typedef struct {
95 
96   /* Command line flags. */
97   Boolean  startup_help;
98   Boolean  version_help;
99 
100   /* Any changes to the aACLs? */
101   Boolean  acl_changed;
102 
103   /* Default acl for the system administrators. */
104   char  *system_admin_acl;
105 
106   /* Calendar selction window. */
107   Widget  calSelectW;
108 
109   /* Toplevel widget. */
110   Widget  toplevel;
111 
112   /* The X application context. */
113   XtAppContext  context;
114 
115   /* Info reference. */
116   XIT_IN_HANDLE  info_handle;
117 
118   /* ACL window. */
119   XTM_AA_HANDLE  acl_handle;
120 
121   /* Customization data. */
122   XTM_GL_CUSTOM_DATA_REF  custom_data;
123 
124 } XTM_AL_BASE_DATA, *XTM_AL_BASE_DATA_REF;
125 
126 
127 
128 /*----------------------------------------------------------------------------
129 --  Global definitions
130 ----------------------------------------------------------------------------*/
131 
132 /* Name of program. */
133 static char  *program_name;
134 
135 /* Name of module. */
136 static char  *module_name = "xtmAclAfs";
137 
138 /* Name of text domain. */
139 static char  *text_domain      = "XDiary";
140 static char  *info_text_domain = "Topic";
141 
142 /* IDs for the help window. */
143 static char  *select_window_id   = "AclCalSelect";
144 
145 /* Keyboard translations for newline in multi-line editor. */
146 XtTranslations  xtm_di_newline_trans;
147 
148 /* Application data. */
149 static  XTM_AL_BASE_DATA  appl_data;
150 
151 
152 /* Key translations. */
153 static char newlineTrans[] =
154   "<Key>Return:    newline()";
155 
156 
157 /* Program options. */
158 static XrmOptionDescRec options[] = {
159   { "-geometry",     "*.AclTl.geometry",  XrmoptionSepArg, NULL },
160   { "-h",            "*.StartupHelp",     XrmoptionNoArg,  "True" },
161   { "-help",         "*.StartupHelp",     XrmoptionNoArg,  "True" },
162   { "-iconic",       "*.AclTl.iconic",    XrmoptionNoArg,  "True" },
163   { "-lan",          "*.msgLanguage",     XrmoptionSepArg, NULL },
164   { "-language",     "*.msgLanguage",     XrmoptionSepArg, NULL },
165   { "-noFileLock",   "*.useFileLock",     XrmoptionNoArg,  "False" },
166   { "-nofilelock",   "*.useFileLock",     XrmoptionNoArg,  "False" },
167   { "-usage",        "*.StartupHelp",     XrmoptionNoArg,  "True" },
168   { "-version",      "*.VersionHelp",     XrmoptionNoArg,  "True" },
169 };
170 
171 /* Application resources. */
172 static XtResource  base_resources[] = {
173 
174   { "startupHelp", "StartupHelp", XtRBoolean, sizeof( Boolean ),
175     XtOffset( XTM_AL_BASE_DATA_REF, startup_help ),
176     XtRString, "False" },
177 
178   { "systemAdminAcl", "SystemAdminAcl", XtRString, sizeof( String ),
179     XtOffset( XTM_AL_BASE_DATA_REF, system_admin_acl),
180     XtRString, "" },
181 
182   { "versionHelp", "VersionHelp", XtRBoolean, sizeof( Boolean ),
183     XtOffset( XTM_AL_BASE_DATA_REF, version_help ),
184     XtRString, "False" },
185 
186 };
187 
188 
189 
190 /*----------------------------------------------------------------------------
191 --  Function prototypes
192 ----------------------------------------------------------------------------*/
193 
194 static void
195   aclActionCB( XTM_AA_REASON  reason,
196                void           *user_data );
197 
198 static void
199   closeCB( Widget                widget,
200            XTM_AL_BASE_DATA_REF  appl_data_ref,
201            XtPointer             call_data );
202 
203 static Widget
204   createSelectWindow( Widget                parent,
205                       XTM_AL_BASE_DATA_REF  appl_data_ref );
206 
207 static void
208   defaultListCB( Widget                widget,
209                  XTM_AL_BASE_DATA_REF  appl_data_ref,
210                  XmListCallbackStruct  *call_data );
211 
212 static void
213   displayUsage();
214 
215 static void
216   doExitCB( Widget     widget,
217             XtPointer  client_data,
218             XtPointer  call_data );
219 
220 static void
221   editAclCB( Widget                widget,
222              XTM_AL_BASE_DATA_REF  appl_data_ref,
223              XtPointer             call_data );
224 
225 static void
226   helpCB( Widget                widget,
227           XTM_AL_BASE_DATA_REF  appl_data_ref,
228           XtPointer             call_data );
229 
230 
231 
232 /*----------------------------------------------------------------------------
233 --  Functions
234 ----------------------------------------------------------------------------*/
235 
236 void
main(unsigned int argc,char * argv[])237   main( unsigned int argc, char *argv[] )
238 {
239 
240   /* Variables. */
241   int                 index;
242   char                *char_ref;
243   Arg                 args[ 10 ];
244   Cardinal            n;
245   Display             *display;
246   TIM_STATUS_TYPE     time_status;
247   XTM_AF_STATUS       af_status;
248   XTM_CB_STATUS       custom_status;
249   XTM_GL_CUSTOM_DATA  custom_data;
250 
251 
252   /* Code. */
253 
254   /* Fetch the name of the program. */
255   program_name = PROGRAM_NAME;
256   xitErSetApplicationName( PROGRAM_CLASS );
257 
258 
259   /* Save the original command parameters. */
260   custom_data.orig_argc = argc;
261   custom_data.orig_argv = (char**) XtMalloc( argc * sizeof( char* ) );
262 
263   for( index = 0; index < argc; index++ )
264     custom_data.orig_argv[ index ] = XtNewString( argv[ index ] );
265 
266   /* NLS enabled. */
267   xtmToSetLocale( program_name );
268 
269 
270   /* Initialize connection to AFS server. */
271   af_status = xtmAfInitialize();
272   if( af_status != XTM_AF_OK )
273     xitErMessage( NULL, XIT_ER_FATAL,
274                   module_name, "main", "Cannot connect to AFS server.\n" );
275 
276 
277   /* Initialize toolkit and open display. */
278   SysInitializeEnvironment();
279 
280   XtToolkitInitialize();
281 
282   appl_data.context = XtCreateApplicationContext();
283   display = XtOpenDisplay( appl_data.context, NULL,
284                            NULL, PROGRAM_CLASS,
285                            options, XtNumber( options ),
286 #if XtSpecificationRelease < 5
287                            (Cardinal *) &argc,
288 #else
289                            (int *) &argc,
290 #endif
291                            argv );
292 
293   if( display == NULL )
294     xitErMessage( NULL, XIT_ER_FATAL,
295                   module_name, "main",
296                   "Cannot open display, check your DISPLAY variable." );
297 
298   /* Resource mapping.*/
299   xtmToInitializeResourceMapping( argc, argv, display );
300 
301   /* Default translations */
302   xtm_di_newline_trans   = XtParseTranslationTable( newlineTrans );
303 
304 
305   /* Create application shell. */
306   n = 0;
307   appl_data.toplevel = XtAppCreateShell( NULL, PROGRAM_CLASS,
308                                          applicationShellWidgetClass,
309                                          display,
310                                          args, n );
311 
312   /* Get base application resources. */
313   XtGetApplicationResources( appl_data.toplevel, &appl_data,
314                              base_resources,
315                              XtNumber( base_resources ),
316                              NULL, 0 );
317 
318   /* Get customize resources. */
319   xtmRsFetchCustomResources( &custom_data, appl_data.toplevel );
320 
321 
322   /* A valid resource file? */
323   if( ! custom_data.valid_resource_file )
324     xitErMessage( NULL, XIT_ER_FATAL,
325                   module_name, "main",
326                   "XDiary will only run with a correct X-Windows resource "
327                   "file.\nPlease check the XDiary installation." );
328 
329 
330   /* Initialize application data. */
331   custom_data.cal_db_handle   = NULL;
332   custom_data.group_db_handle = NULL;
333   custom_data.archive_files   = NULL;
334   custom_data.include_files   = NULL;
335 
336   appl_data.custom_data = &custom_data;
337   appl_data.acl_handle  = NULL;
338   appl_data.info_handle = NULL;
339   appl_data.acl_changed = False;
340 
341 
342   /* Display current version? */
343   if( appl_data.version_help ) {
344     printf( "%s: Version: %s\n", program_name, VERSION_ID );
345     exit( 0 );
346   }
347 
348   /* Help requested? */
349   if( appl_data.startup_help ) {
350     displayUsage();
351     exit( 0 );
352   }
353 
354 
355   /* Get customized data from file. */
356   custom_status = xtmCbGetDataFromFile( appl_data.custom_data );
357 
358   if( custom_status == XTM_CB_WRONG_VERSION ) {
359     char_ref = (char *)
360       SysMalloc( strlen( msgGetText( MXDI_CUST_WRONG_VERSION ) ) + 50 );
361 
362     sprintf( char_ref, msgGetText( MXDI_CUST_WRONG_VERSION ),
363              xtmCbWhatVersion() );
364 
365     xitStDisplaySticky( appl_data.toplevel,
366                         char_ref, XmUNSPECIFIED_PIXMAP,
367                         msgGetText( MXDI_OK_BUTTON ), NULL,
368                         NULL, NULL, NULL,
369                         NULL );
370     SysFree( char_ref );
371   }
372 
373 
374   /* Initialize necessary text domains. */
375   msgInitialize();
376   msgInitCatalogue( text_domain, NULL, custom_data.msg_language,
377                     msgXdiaryTexts );
378   msgInitCatalogue( info_text_domain, NULL, custom_data.msg_language,
379                     msgTopicTexts );
380 
381   /* Default catalogue Xdiary. */
382   msgTextDomain( text_domain );
383 
384 
385   /* Initialize the time formats. */
386   time_status = TimInitializeFormat( custom_data.date_format,
387                                      custom_data.time_format );
388   if( time_status != TIM_OK )
389     xitErMessage( appl_data.toplevel, XIT_ER_ERROR,
390                   module_name, "main",
391                   msgGetText( MXDI_ERRMSG_DATE_OR_TIME_FORMAT ) );
392 
393 
394   /* Set colors and fonts in the resource database. */
395   xtmRsFetchColors( &custom_data, appl_data.toplevel );
396 
397 
398   /* Create the calendar select window. */
399   appl_data.calSelectW = createSelectWindow( appl_data.toplevel, &appl_data );
400 
401 
402   /* Session management. */
403   xtmToSessionMgmt( appl_data.calSelectW,
404                     custom_data.orig_argc, custom_data.orig_argv );
405 
406 
407   /* Initialize the help system. */
408   appl_data.info_handle = xitInInitialize( appl_data.toplevel,
409                                            NULL, NULL );
410 
411 
412   /* Enter the event loop. */
413   XtAppMainLoop( appl_data.context );
414 
415 
416 } /* main */
417 
418 
419 /*----------------------------------------------------------------------*/
420 
421 static Widget
createSelectWindow(Widget parent,XTM_AL_BASE_DATA_REF appl_data_ref)422   createSelectWindow( Widget                parent,
423                       XTM_AL_BASE_DATA_REF  appl_data_ref )
424 {
425 
426   /* Variables. */
427   int                     index;
428   int                     index1;
429   char                    buffer[ 100 ];
430   char                    *char_ref;
431   char                    *db_names;
432   Arg                     args[ 10 ];
433   Cardinal                n;
434   Widget                  aclTl;
435   Widget                  actionBu[ 1 ];
436   Widget                  dataLocalW[ 3 ];
437   Widget                  toplevel;
438   Widget                  workFo;
439   XmString                list_items[ 500 ];
440   XTM_GL_CUSTOM_DATA_REF  custom_data;
441 
442   static XIT_PUSH_STRUCT action_def[] = {
443     { "EditAclPb", "", "", True, NULL },
444   };
445 
446   static XIT_ACTION_AREA_ITEM  action_buttons[] = {
447     { "",   closeCB, NULL },
448     { NULL, NULL,    NULL },
449     { NULL, NULL,    NULL },
450     { "",   helpCB,  NULL },
451   };
452 
453 
454   /* Code. */
455 
456   action_def[ 0 ].title = msgGetText( MXDI_ACL_EDIT );
457 
458   action_buttons[ 0 ].label = msgGetText( MXDI_CLOSE_BUTTON );
459   action_buttons[ 0 ].data  = appl_data_ref;
460   action_buttons[ 3 ].label = msgGetText( MXDI_HELP_BUTTON );
461   action_buttons[ 3 ].data  = appl_data_ref;
462 
463 
464   custom_data = appl_data_ref -> custom_data;
465 
466   /* Create a toplevel dialog with buttons. */
467   toplevel = xitGetToplevelWidget( parent );
468 
469   aclTl = xitCreateToplevelDialog( toplevel, "AclTl",
470                                    1, 0,
471                                    action_buttons,
472                                    XtNumber( action_buttons ) );
473 
474   char_ref = msgGetText( MXDI_AFS_ACCESS_TITLE );
475 
476   n = 0;
477   XtSetArg( args[ n ], XmNtitle, char_ref ); n++;
478   XtSetValues( aclTl, args, n );
479 
480   char_ref = msgGetText( MXDI_AFS_ACCESS_TITLE );
481 
482   n = 0;
483   XtSetArg( args[ n ], XmNiconName, char_ref ); n++;
484   XtSetValues( aclTl, args, n );
485 
486 
487   /* Exit the application if this window is deleted. */
488   {
489     Atom  wm_delete_window;
490 
491     wm_delete_window = XmInternAtom( XtDisplay( aclTl ),
492                                      "WM_DELETE_WINDOW", False );
493 
494     XmAddWMProtocols(        aclTl,    &wm_delete_window, 1 );
495     XmAddWMProtocolCallback( aclTl,    wm_delete_window,
496                              doExitCB, NULL );
497   } /* block */
498 
499 
500   /* Container for the contents of the window. */
501   workFo = XtNameToWidget( aclTl, "AclTlBase.AclTlFo" );
502 
503   dbLocLa = xitCreateLabel( workFo, "DbLocLa",
504                             msgGetText( MXDI_DB_LOCATION_LABEL ), -1 );
505 
506   /* List with database location. */
507   n = 0;
508   XtSetArg( args[ n ], XmNlistSizePolicy,         XmCONSTANT ); n++;
509   XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++;
510   XtSetArg( args[ n ], XmNselectionPolicy,        XmSINGLE_SELECT ); n++;
511   XtSetArg( args[ n ], XmNlistMarginHeight,       5 ); n++;
512   XtSetArg( args[ n ], XmNlistMarginWidth,        5 ); n++;
513   dbLocLi = XmCreateScrolledList( workFo, "DbLocLi", args, n );
514 
515   XtAddCallback( dbLocLi, XmNdefaultActionCallback,
516                  (XtCallbackProc) editAclCB, (XtPointer) appl_data_ref );
517   XtAddCallback( dbLocLi, XmNdefaultActionCallback,
518                  (XtCallbackProc) defaultListCB, (XtPointer) appl_data_ref );
519 
520 
521 
522   /* Actions. */
523   n = 0;
524   XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++;
525   XtSetArg( args[ n ], XmNspacing,      10 ); n++;
526   XtSetArg( args[ n ], XmNmarginHeight, 10 ); n++;
527   actionRc = XmCreateRowColumn( workFo, "ActionRc", args, n );
528 
529   for( index = 0; index < XtNumber( actionBu ); index++ )
530     actionBu[ index ] = xitCreatePushButton( actionRc, &action_def[ index ] );
531 
532   XtAddCallback( actionBu[ 0 ], XmNactivateCallback,
533                  (XtCallbackProc) editAclCB, (XtPointer) appl_data_ref );
534 
535 
536   /* Put the elements together. */
537   xitAttachWidget( dbLocLa,
538                    XmATTACH_FORM, NULL, XmATTACH_FORM, NULL,
539                    XmATTACH_NONE, NULL, XmATTACH_NONE, NULL );
540   xitAttachWidget( XtParent( dbLocLi ),
541                    XmATTACH_WIDGET, dbLocLa, XmATTACH_FORM, NULL,
542                    XmATTACH_NONE,   NULL,    XmATTACH_NONE, NULL );
543   xitAttachWidget( actionRc,
544                    XmATTACH_WIDGET, XtParent( dbLocLi ), XmATTACH_FORM, NULL,
545                    XmATTACH_NONE, NULL,                  XmATTACH_NONE, NULL );
546 
547 
548   /* Make sure there is enough space between the children. */
549   n = 0;
550   XtSetArg( args[ n ], XmNtopOffset,    5 ); n++;
551   XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++;
552   XtSetArg( args[ n ], XmNleftOffset,   5 ); n++;
553   XtSetArg( args[ n ], XmNrightOffset,  5 ); n++;
554   XtSetValues( dbLocLa,             args, n );
555   XtSetValues( XtParent( dbLocLi ), args, n );
556   XtSetValues( actionRc,            args, n );
557 
558 
559   /* Manage the widgets. */
560   XtManageChildren(  actionBu,   XtNumber( actionBu ) );
561 
562   xitManageChildren( dataLocalW, XtNumber( dataLocalW ) );
563 
564 
565   /* Set icon for this window. */
566   xtmIcSetSimpleIcon( aclTl, workFo, XTM_IC_ICON_ACL );
567 
568   /* Set the size of the window. */
569   xitSetSizeToplevelDialog( aclTl, True );
570 
571 
572   /* Make the final attachments. */
573   xitAttachWidget( actionRc,
574                    XmATTACH_NONE, NULL, XmATTACH_FORM, NULL,
575                    XmATTACH_NONE, NULL, XmATTACH_FORM, NULL );
576   xitAttachWidget( XtParent( dbLocLi ),
577                    XmATTACH_WIDGET, dbLocLa, XmATTACH_FORM,   NULL,
578                    XmATTACH_FORM,   NULL,    XmATTACH_WIDGET, actionRc );
579 
580 
581   /* Display the database select window. */
582   XtPopup( aclTl, XtGrabNone );
583 
584 
585   /* Set values for the database locations. */
586   (void) xtmCdFetchDbNames( custom_data -> cal_db_handle, &db_names );
587   char_ref = db_names;
588   index    = 0;
589 
590   do {
591 
592     int              char_read;
593     UINT32           afs_rights;
594     char             db_name[ XTM_GL_MAX_CAL_NAME + 1 ];
595     XTM_AF_STATUS    afs_status;
596     XTM_CD_CAL_INFO  db_info;
597 
598     while( isspace( *char_ref ) )
599       char_ref++;
600 
601     if( *char_ref == '\0' )
602       break;
603 
604     char_read = strlen( char_ref );
605     sscanf( char_ref, "%s%n", db_name, &char_read );
606     char_ref = char_ref + char_read;
607 
608 
609     /* Fetch information about the database. */
610     (void) xtmCdFetchNamedDb( custom_data -> cal_db_handle, db_name,
611                               &db_info, NULL );
612 
613     /* AFS rights. */
614     afs_rights = XTM_AF_FLAG_ADMINISTER;
615     afs_status = xtmAfAccess( db_info.directory, afs_rights );
616 
617     /* We cannot change included calendars. */
618     if( flagIsSet( db_info.flags, XTM_CD_FLAG_IS_INCLUDED ) )
619       continue;
620 
621     /* Administrators can change ACLs. */
622     if( afs_status != XTM_AF_OK )
623       continue;
624 
625     sprintf( buffer, "%-15.15s %s",
626              db_info.short_name, db_info.directory );
627 
628     list_items[ index ] = XmStringCreate( buffer, CS );
629     index++;
630 
631   } while( True && index < XtNumber( list_items ) );
632 
633   if( db_names != NULL )
634     SysFree( db_names );
635 
636 
637   /* The list is always sorted. */
638   xitSortStringList( list_items, index );
639 
640   /* Assign the database locations to the list. */
641   n = 0;
642   XtSetArg( args[ n ], XmNitems, list_items ); n++;
643   XtSetArg( args[ n ], XmNitemCount, index ); n++;
644   XtSetValues( dbLocLi, args, n );
645 
646   /* Free allocated memory. */
647   for( index1 = 0; index1 < index; index1++ )
648     XmStringFree( list_items[ index1 ] );
649 
650   XmListSelectPos( dbLocLi, 1, False );
651 
652 
653   return( aclTl );
654 
655 } /* createSelectWindow */
656 
657 
658 /*----------------------------------------------------------------------*/
659 
660 static void
displayUsage()661   displayUsage()
662 {
663 
664   printf(
665     "\n"
666     "%s (%s): XDiary access control for AFS.\n"
667     "\n"
668     "Allows you to define access control information to calendars where\n"
669     "you have admin privileges.\n"
670     "\n"
671     "Usage:\n"
672     "  %s [flags]\n"
673     "\n"
674     "Flags:\n"
675     "  -fmap large      : Use a large font.\n"
676     "  -fmap medium     : Use a medium font.\n"
677     "  -fmap small      : Use a small font.\n"
678     "  -help            : Display this help.\n"
679     "  -h               : See above.\n"
680     "  -language <lan>  : Use the language <lan>.\n"
681     "  -lan <lan>       : See above.\n"
682     "  -noFileLock      : Don't use any file locking.\n"
683     "  -palette gray    : Use color palette Gray.\n"
684     "  -palette lila    : Use color palette Lila.\n"
685     "  -palette motif   : Use color palette Motif.\n"
686     "  -palette neon    : Use color palette Neon.\n"
687     "  -palette nordic  : Use color palette Nordic.\n"
688     "  -palette red     : Use color palette Red.\n"
689     "  -palette sea     : Use color palette Sea.\n"
690     "  -palette sky     : Use color palette Sky.\n"
691     "  -palette wood    : Use color palette Wood.\n"
692     "  -usage           : Display this help.\n"
693     "  -version         : Display the current version.\n"
694     "\n",
695     program_name, VERSION_ID, program_name );
696 
697 
698   return;
699 
700 } /* displayUsage */
701 
702 
703 /*----------------------------------------------------------------------*/
704 
705 static void
aclActionCB(XTM_AA_REASON reason,void * user_data)706   aclActionCB( XTM_AA_REASON  reason,
707                void           *user_data )
708 {
709 
710   /* Variables. */
711   XTM_AL_BASE_DATA_REF  appl_data_ref;
712 
713 
714   /* Code. */
715 
716   appl_data_ref = (XTM_AL_BASE_DATA_REF) user_data;
717 
718 
719   /* ACL window destroyed? */
720   if( reason == XTM_AA_REASON_DESTROY )
721     appl_data_ref -> acl_handle = NULL;
722 
723 
724   /* ACLs saved? */
725   if( reason == XTM_AA_REASON_OK || reason == XTM_AA_REASON_APPLY )
726     appl_data_ref -> acl_changed = True;
727 
728 
729   return;
730 
731 } /* aclActionCB */
732 
733 
734 /*----------------------------------------------------------------------*/
735 
736 static void
closeCB(Widget widget,XTM_AL_BASE_DATA_REF appl_data_ref,XtPointer call_data)737   closeCB( Widget                widget,
738            XTM_AL_BASE_DATA_REF  appl_data_ref,
739            XtPointer             call_data )
740 {
741 
742   /* Variables. */
743   Widget  tempW;
744 
745 
746   /* Code. */
747 
748   /* Any ACL changed? */
749   if( appl_data_ref -> acl_changed ) {
750     tempW = xitCreateInformationDialog(
751               appl_data_ref -> calSelectW, "InformationDialog",
752 	      msgGetText( MXDI_INFORMATION_LABEL ),
753               msgGetText( MXDI_CUST_HOW_TO_ACTIVATE ),
754               doExitCB, NULL );
755     return;
756   }
757 
758   doExitCB( widget, NULL, NULL );
759 
760 
761 } /* closeCB */
762 
763 
764 /*----------------------------------------------------------------------*/
765 
766 static void
defaultListCB(Widget widget,XTM_AL_BASE_DATA_REF appl_data_ref,XmListCallbackStruct * call_data)767   defaultListCB( Widget                widget,
768                  XTM_AL_BASE_DATA_REF  appl_data_ref,
769                  XmListCallbackStruct  *call_data )
770 {
771 
772   /* Code. */
773 
774   /* This is called from a list default selection, select the object! */
775   XmListSelectPos( widget, call_data -> item_position, False );
776 
777   editAclCB( widget, appl_data_ref, NULL );
778 
779 
780   return;
781 
782 } /* addFromListCB */
783 
784 
785 /*----------------------------------------------------------------------*/
786 
787 static void
doExitCB(Widget widget,XtPointer client_data,XtPointer call_data)788   doExitCB( Widget     widget,
789             XtPointer  client_data,
790             XtPointer  call_data )
791 {
792 
793   /* Code. */
794 
795   exit( 0 );
796 
797 
798 } /* doExitCB */
799 
800 
801 /*----------------------------------------------------------------------*/
802 
803 static void
editAclCB(Widget widget,XTM_AL_BASE_DATA_REF appl_data_ref,XtPointer call_data)804   editAclCB( Widget                widget,
805              XTM_AL_BASE_DATA_REF  appl_data_ref,
806              XtPointer             call_data )
807 {
808 
809   /* Variables. */
810   int       selected_item_count;
811   char      cal_location[ XTM_GL_MAX_LOCATION + 1 ];
812   char      cal_name[ XTM_GL_MAX_CAL_NAME + 1 ];
813   char      *char_ref;
814   Arg       args[ 3 ];
815   Cardinal  n;
816   Widget    listW;
817   XmString  *selected_items;
818 
819 
820   /* Code. */
821 
822   listW = XtNameToWidget( appl_data_ref -> calSelectW,
823                           "AclTlBase.AclTlFo.DbLocLiSW.DbLocLi" );
824 
825   /* Fetch selected items from the list. */
826   n = 0;
827   XtSetArg( args[ n ], XmNselectedItemCount, &selected_item_count ); n++;
828   XtSetArg( args[ n ], XmNselectedItems, &selected_items ); n++;
829   XtGetValues( listW, args, n );
830 
831   if( selected_item_count != 1 )
832     return;
833 
834 
835   /* Extract the calendar and location. */
836   char_ref = xitStringGetString( *selected_items, CS );
837 
838   sscanf( char_ref, "%s %s", cal_name, cal_location );
839   SysFree( char_ref );
840 
841 
842   /* Create the ACL window? */
843   if( appl_data_ref -> acl_handle == NULL )
844     appl_data_ref -> acl_handle = xtmAaInitialize(
845                                     appl_data_ref -> custom_data,
846                                     appl_data_ref -> info_handle,
847                                     appl_data_ref -> calSelectW,
848                                     appl_data_ref -> system_admin_acl,
849                                     aclActionCB, (void *) appl_data_ref );
850 
851   /* Display the ACL window. */
852   xtmAaEditAcl( appl_data_ref -> acl_handle,
853                 cal_name, cal_location );
854 
855 
856   return;
857 
858 } /* editAclCB */
859 
860 
861 /*----------------------------------------------------------------------*/
862 
863 static void
helpCB(Widget widget,XTM_AL_BASE_DATA_REF appl_data_ref,XtPointer call_data)864   helpCB( Widget                widget,
865           XTM_AL_BASE_DATA_REF  appl_data_ref,
866           XtPointer             call_data )
867 {
868 
869   /* Code. */
870 
871   xtmHlDisplayHelp( appl_data_ref -> info_handle,
872                     XTM_HL_WINDOW_INDEX,
873                     select_window_id, "" );
874 
875   return;
876 
877 } /* selectHelpCB */
878