2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: ModAttr.c /main/11 1999/12/09 13:07:05 mgreess $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 * COMPONENT_NAME: Desktop File Manager (dtfile)
31 * Description: Source file for the modify file attributes dialog.
42 * InvalidModAttrMessage
50 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
51 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
52 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
53 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
55 ****************************************************************************
56 ************************************<+>*************************************/
61 #include <sys/types.h>
69 #include <Xm/BulletinB.h>
70 #include <Xm/CascadeBG.h>
71 #include <Xm/DialogS.h>
74 #include <Xm/LabelG.h>
75 #include <Xm/MessageB.h>
76 #include <Xm/PushBG.h>
77 #include <Xm/RowColumn.h>
78 #include <Xm/ScrolledW.h>
80 #include <Xm/ToggleBG.h>
81 #include <Xm/SeparatoG.h>
82 #include <Xm/VendorSEP.h>
83 #include <Xm/MwmUtil.h>
84 #include <Xm/Protocols.h>
88 #include <Dt/IconFile.h>
89 #include <Dt/TitleBox.h>
91 #include <X11/ShellP.h>
92 #include <X11/Shell.h>
93 #include <X11/Xatom.h>
95 #include <Dt/Connect.h>
96 #include <Dt/DtNlUtils.h>
101 #include "SharedProcs.h"
109 #ifndef CDE_INSTALLATION_TOP
110 #define CDE_INSTALLATION_TOP "/usr/dt"
113 /* Error message defines */
115 #define UNKNOWN_USER 0
116 #define UNKNOWN_GROUP 1
123 #define FILETYPE 0x08
128 #define MODTIME 0x100
131 #define GMA_INVALID 1
132 #define GMA_NO_FILE 2
134 #define ALL_FIELDS HOST|DIR|NAME|FILETYPE|GROUP|OWNER|BITS|SIZE|MODTIME
135 #define ALL_BUT_ACCESS HOST|DIR|NAME|FILETYPE|GROUP|OWNER|SIZE|MODTIME
136 #define ALL_BUT_OWNER_GROUP_ACCESS HOST|DIR|NAME|FILETYPE|SIZE|MODTIME
138 #define FM_TYPE_LABEL "TYPE_LABEL"
140 static char * MODIFY_ATTR = "ModifyAttributes";
141 ModAttrApply *globalApplyData;
144 /* Resource definitions for the modify file attribute dialog */
146 static DialogResource resources[] =
148 { "host", XmRString, sizeof(String),
149 XtOffset(ModAttrDataPtr, host),
150 (XtPointer) NULL, _DtStringToString },
152 { "directory", XmRString, sizeof(String),
153 XtOffset(ModAttrDataPtr, directory),
154 (XtPointer) NULL, _DtStringToString },
156 { "name", XmRString, sizeof(String),
157 XtOffset(ModAttrDataPtr, name),
158 (XtPointer) NULL, _DtStringToString },
160 { "link_name", XmRString, sizeof(String),
161 XtOffset(ModAttrDataPtr, link_name),
162 (XtPointer) NULL, _DtStringToString },
164 { "access", XmRInt, sizeof(int),
165 XtOffset(ModAttrDataPtr, accessBits),
166 (XtPointer) 0, _DtIntToString },
170 /******** Static Function Declarations ********/
175 Widget *return_widget,
177 static void InstallChange(
178 ModAttrRec *modAttr_rec,
179 XtCallbackProc callback,
180 XtPointer client_data) ;
181 static void InstallClose(
182 ModAttrRec *modAttr_rec,
183 XtCallbackProc callback,
184 XtPointer client_data) ;
186 ModAttrRec *modAttr_rec) ;
187 static XtPointer GetValues(
188 ModAttrRec *modAttr_rec) ;
189 static XtPointer GetDefaultValues( void ) ;
190 static XtPointer GetResourceValues(
191 XrmDatabase data_base,
193 static void SetValues(
194 ModAttrRec *modAttr_rec,
195 ModAttrData *modAttr_data) ;
196 static void WriteResourceValues(
200 static void FreeValues(
201 ModAttrData *modAttr_data) ;
202 static XtCallbackProc OkCallback(
204 ModAttrApply *apply_data,
205 XtPointer call_data) ;
206 static short GetModAttrValues(
207 ModAttrRec *modAttr_rec,
208 ModAttrData *modAttr_data,
210 static void InvalidModAttrMessage(
213 static Boolean _LoadFileAttributes(
217 ModAttrData *modAttr_data,
218 unsigned long mask) ;
219 static void displayFSDialog(
221 dtFSData * fileSystem,
222 XmPushButtonCallbackStruct * cbs);
223 static void DontChangeCB(
225 XtPointer client_data,
226 XtPointer call_data );
227 static void ChangeCB(
229 XtPointer client_data,
230 XtPointer call_data );
232 /******** End Static Function Declarations ********/
236 * The Dialog Class structure.
238 static DialogClass modAttrClassRec =
243 (DialogInstallChangeProc) InstallChange,
244 (DialogInstallCloseProc) InstallClose,
245 (DialogDestroyProc) Destroy,
246 (DialogGetValuesProc) GetValues,
249 (DialogSetValuesProc) SetValues,
251 (DialogFreeValuesProc) FreeValues,
252 (DialogMapWindowProc) _DtGenericMapWindow,
256 DialogClass * modAttrClass = (DialogClass *) &modAttrClassRec;
258 /************************************************************************
262 ************************************************************************/
268 Widget *return_widget,
271 ModAttrRec * modAttr_rec;
272 Widget shell, form, nameLabel, name;
273 Widget link_label, link_name;
274 Widget fileType, ownerLabel, owner;
275 Widget groupLabel, group, permissionLabel, permissionForm;
276 Widget ownerPLabel, groupPLabel, otherPLabel;
277 Widget readLabel, writeLabel, executeLabel;
278 Widget ownerRead, ownerWrite, ownerExecute;
279 Widget groupRead, groupWrite, groupExecute;
280 Widget otherRead, otherWrite, otherExecute;
281 Widget fsPushButton, fsWarning;
282 Widget sizeLabel, size;
283 Widget modLabel, mod;
284 Widget groupL, ownerL;
285 Widget separator, ok, cancel, help;
286 XmString label_string;
287 XmString empty_label_string;
295 /* Allocate the modify file attributes dialog instance record. */
297 modAttr_rec = (ModAttrRec *) XtMalloc (sizeof (ModAttrRec));
299 /* Create the shell form used for the dialog. */
302 XtSetArg (args[n], XmNmwmFunctions, MWM_FUNC_MOVE |
303 MWM_FUNC_CLOSE); ++n;
304 XtSetArg (args[n], XmNmwmDecorations, MWM_DECOR_BORDER |
305 MWM_DECOR_TITLE); ++n;
306 XtSetArg (args[n], XmNallowShellResize, True); ++n;
307 shell = XmCreateDialogShell (parent, "file_properties", args, n);
309 /* Set the useAsyncGeo on the shell */
310 XtSetArg (args[0], XmNuseAsyncGeometry, True);
311 XtSetValues (XtParent(shell), args, 1);
314 XtSetArg (args[n], XmNshadowThickness, 1); n++;
315 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
316 XtSetArg (args[n], XmNautoUnmanage, False); n++;
317 form = XmCreateForm (shell, "form", args, n);
318 XtAddCallback(form, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
319 HELP_PROPERTIES_DIALOG_STR);
322 /* Create the field displaying the selected file name */
324 label_string = XmStringCreateLocalized (((char *) GETMESSAGE(21,30, "Name: ")));
326 XtSetArg (args[n], XmNlabelString, label_string); n++;
327 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
328 XtSetArg (args[n], XmNleftOffset, 5); n++;
329 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
330 XtSetArg (args[n], XmNtopOffset, 5); n++;
331 XtSetArg (args[n], XmNtraversalOn, False); n++;
332 nameLabel = XmCreateLabelGadget (form, "file_name_label", args, n);
333 XtManageChild (nameLabel);
334 XmStringFree (label_string);
335 XtAddCallback(nameLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
336 HELP_PROPERTIES_DIALOG_STR);
339 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
340 XtSetArg (args[n], XmNleftWidget, nameLabel); n++;
341 XtSetArg (args[n], XmNleftOffset, 0); n++;
342 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
343 XtSetArg (args[n], XmNtopOffset, 5); n++;
344 XtSetArg (args[n], XmNtraversalOn, False); n++;
345 name = XmCreateLabelGadget (form, "file_name", args, n);
346 XtManageChild (name);
347 XtAddCallback(name, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
348 HELP_PROPERTIES_DIALOG_STR);
350 /* Create the optional field displaying the symbolic link name */
352 label_string = XmStringCreateLocalized ((GETMESSAGE(21,18, "Is Linked To: ")));
354 XtSetArg (args[n], XmNlabelString, label_string); n++;
355 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
356 XtSetArg (args[n], XmNleftOffset, 5); n++;
357 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
358 XtSetArg (args[n], XmNtopWidget, name); n++;
359 XtSetArg (args[n], XmNtopOffset, 5); n++;
360 XtSetArg (args[n], XmNtraversalOn, False); n++;
361 link_label= XmCreateLabelGadget (form, "link_name_label", args, n);
362 XtManageChild (link_label);
363 XmStringFree (label_string);
364 XtAddCallback(link_label, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
365 HELP_PROPERTIES_DIALOG_STR);
368 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
369 XtSetArg (args[n], XmNleftWidget, link_label); n++;
370 XtSetArg (args[n], XmNleftOffset, 0); n++;
371 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
372 XtSetArg (args[n], XmNtopWidget, name); n++;
373 XtSetArg (args[n], XmNtopOffset, 5); n++;
374 XtSetArg (args[n], XmNtraversalOn, False); n++;
375 link_name = XmCreateLabelGadget (form, "link_name", args, n);
376 XtManageChild (link_name);
377 XtAddCallback(link_name, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
378 HELP_PROPERTIES_DIALOG_STR);
381 /* Create the field displaying the owner name and the group name*/
383 label_string = XmStringCreateLocalized (((char *)
384 GETMESSAGE(21, 3, "Owner Name: ")));
386 XtSetArg (args[n], XmNlabelString, label_string); n++;
387 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
388 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
389 XtSetArg (args[n], XmNtopWidget, link_name); n++;
390 XtSetArg (args[n], XmNtopOffset, 15); n++;
391 XtSetArg (args[n], XmNleftOffset, 5); n++;
392 XtSetArg (args[n], XmNtraversalOn, False); n++;
393 ownerLabel = XmCreateLabelGadget (form, "owner_name", args, n);
394 XtManageChild (ownerLabel);
395 XmStringFree (label_string);
396 XtAddCallback(ownerLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
397 HELP_PROPERTIES_DIALOG_STR);
399 label_string = XmStringCreateLocalized (((char *)
400 GETMESSAGE(21, 4, "Group Name: ")));
402 XtSetArg (args[n], XmNlabelString, label_string); n++;
403 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
404 XtSetArg (args[n], XmNleftOffset, 5); n++;
405 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
406 XtSetArg (args[n], XmNtopWidget, ownerLabel); n++;
407 XtSetArg (args[n], XmNtopOffset, 22); n++;
408 XtSetArg (args[n], XmNtraversalOn, False); n++;
409 groupLabel = XmCreateLabelGadget (form, "group_name", args, n);
410 XtManageChild (groupLabel);
411 XmStringFree (label_string);
412 XtAddCallback(groupLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
413 HELP_PROPERTIES_DIALOG_STR);
415 XtSetArg (args[0], XmNwidth, &len[0]);
416 XtGetValues(ownerLabel, args, 1);
417 XtSetArg (args[0], XmNwidth, &len[1]);
418 XtGetValues(groupLabel, args, 1);
421 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
422 if(len[0] > len[1]) {
423 XtSetArg (args[n], XmNleftWidget, ownerLabel); n++;
426 XtSetArg (args[n], XmNleftWidget, groupLabel); n++;
428 XtSetArg (args[n], XmNleftOffset, 0); n++;
429 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
430 XtSetArg (args[n], XmNtopWidget, link_name); n++;
431 XtSetArg (args[n], XmNtopOffset, 8); n++;
432 owner = XmCreateTextField (form, "owner_text", args, n);
433 XtManageChild (owner);
434 XtAddCallback(owner, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
435 HELP_PROPERTIES_DIALOG_STR);
438 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
439 if(len[0] > len[1]) {
440 XtSetArg (args[n], XmNleftWidget, ownerLabel); n++;
443 XtSetArg (args[n], XmNleftWidget, groupLabel); n++;
445 XtSetArg (args[n], XmNleftOffset, 5); n++;
446 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
447 XtSetArg (args[n], XmNtopWidget, ownerLabel); n++;
448 XtSetArg (args[n], XmNtopOffset, 0); n++;
449 XtSetArg (args[n], XmNtraversalOn, False); n++;
450 ownerL = XmCreateLabelGadget (form, "owner_textL", args, n);
451 XtAddCallback(ownerL, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
452 HELP_PROPERTIES_DIALOG_STR);
455 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
456 if(len[0] > len[1]) {
457 XtSetArg (args[n], XmNleftWidget, ownerLabel); n++;
460 XtSetArg (args[n], XmNleftWidget, groupLabel); n++;
462 XtSetArg (args[n], XmNleftOffset, 0); n++;
463 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
464 XtSetArg (args[n], XmNtopWidget, ownerLabel); n++;
465 XtSetArg (args[n], XmNtopOffset, 15); n++;
466 group = XmCreateTextField (form, "group_text", args, n);
467 XtManageChild (group);
468 XtAddCallback(group, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
469 HELP_PROPERTIES_DIALOG_STR);
472 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
473 if(len[0] > len[1]) {
474 XtSetArg (args[n], XmNleftWidget, ownerLabel); n++;
477 XtSetArg (args[n], XmNleftWidget, groupLabel); n++;
479 XtSetArg (args[n], XmNleftOffset, 5); n++;
480 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
481 XtSetArg (args[n], XmNtopWidget, groupLabel); n++;
482 XtSetArg (args[n], XmNtopOffset, 0); n++;
483 XtSetArg (args[n], XmNtraversalOn, False); n++;
484 groupL = XmCreateLabelGadget (form, "group_textL", args, n);
485 XtAddCallback(groupL, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
486 HELP_PROPERTIES_DIALOG_STR);
488 /* Create the field displaying the file type info */
491 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
492 XtSetArg (args[n], XmNtopWidget, link_name); n++;
493 XtSetArg (args[n], XmNtopOffset, 5); n++;
494 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
495 XtSetArg (args[n], XmNleftWidget, owner); n++;
496 XtSetArg (args[n], XmNleftOffset, 20); n++;
497 XtSetArg (args[n], XmNshadowThickness, 2); n++;
498 XtSetArg (args[n], XmNshadowType, XmSHADOW_ETCHED_IN); n++;
499 XtSetArg (args[n], XmNhighlightThickness, 5); n++;
500 XtSetArg (args[n], XmNmarginWidth, 4); n++;
501 XtSetArg (args[n], XmNmarginHeight, 4); n++;
502 XtSetArg (args[n], XmNtraversalOn, False); n++;
503 XtSetArg (args[n], XmNpixmapPosition, XmPIXMAP_TOP); n++;
504 XtSetArg (args[n], XmNbehavior, XmICON_LABEL); n++;
505 fileType = _DtCreateIcon (form, "file_type", args, n);
506 XtManageChild (fileType);
507 XtAddCallback(fileType, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
508 HELP_PROPERTIES_DIALOG_STR);
510 /* Create the label for the permissions */
512 label_string = XmStringCreateLocalized (((char *)
513 GETMESSAGE(21, 5, "Permissions:")));
515 XtSetArg (args[n], XmNlabelString, label_string); n++;
516 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
517 XtSetArg (args[n], XmNleftOffset, 5); n++;
518 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
519 XtSetArg (args[n], XmNtopWidget, groupLabel); n++;
520 XtSetArg (args[n], XmNtopOffset, 15); n++;
521 XtSetArg (args[n], XmNtraversalOn, False); n++;
522 permissionLabel = XmCreateLabelGadget (form, "permission_label", args, n);
523 XtManageChild (permissionLabel);
524 XmStringFree (label_string);
525 XtAddCallback(permissionLabel, XmNhelpCallback,
526 (XtCallbackProc)HelpRequestCB,
527 HELP_PROPERTIES_DIALOG_STR);
529 /* Create the box containing the permission settings */
532 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
533 XtSetArg (args[n], XmNleftOffset, 10); n++;
534 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
535 XtSetArg (args[n], XmNrightOffset, 5); n++;
536 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
537 XtSetArg (args[n], XmNtopWidget, permissionLabel); n++;
538 XtSetArg (args[n], XmNtopOffset, 3); n++;
539 XtSetArg (args[n], XmNshadowThickness, 2); n++;
540 XtSetArg (args[n], XmNshadowType, XmSHADOW_IN); n++;
541 permissionForm = XmCreateForm (form, "permission_form", args, n);
542 XtManageChild (permissionForm);
543 XtAddCallback(permissionForm, XmNhelpCallback,
544 (XtCallbackProc)HelpRequestCB,
545 HELP_PROPERTIES_DIALOG_STR);
547 /* Create the labels and toggles for the permissions */
549 label_string = XmStringCreateLocalized (((char *)
550 GETMESSAGE(21, 6, "Read")));
552 XtSetArg (args[n], XmNlabelString, label_string); n++;
553 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
554 XtSetArg (args[n], XmNleftPosition, 20); n++;
555 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
556 XtSetArg (args[n], XmNrightPosition, 45); n++;
557 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
558 XtSetArg (args[n], XmNtopOffset, 10); n++;
559 XtSetArg (args[n], XmNtraversalOn, False); n++;
560 readLabel = XmCreateLabelGadget (permissionForm, "read_label", args, n);
561 XtManageChild (readLabel);
562 XmStringFree (label_string);
563 XtAddCallback(readLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
564 HELP_PROPERTIES_DIALOG_STR);
566 label_string = XmStringCreateLocalized (((char *)
567 GETMESSAGE(21, 7, "Write")));
569 XtSetArg (args[n], XmNlabelString, label_string); n++;
570 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
571 XtSetArg (args[n], XmNleftPosition, 45); n++;
572 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
573 XtSetArg (args[n], XmNrightPosition, 70); n++;
574 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
575 XtSetArg (args[n], XmNtopOffset, 10); n++;
576 XtSetArg (args[n], XmNtraversalOn, False); n++;
577 writeLabel = XmCreateLabelGadget (permissionForm, "write_label", args, n);
578 XtManageChild (writeLabel);
579 XmStringFree (label_string);
580 XtAddCallback(writeLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
581 HELP_PROPERTIES_DIALOG_STR);
583 label_string = XmStringCreateLocalized (((char *)
584 GETMESSAGE(21, 8, "Execute")));
586 XtSetArg (args[n], XmNlabelString, label_string); n++;
587 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
588 XtSetArg (args[n], XmNleftPosition, 70); n++;
589 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
590 XtSetArg (args[n], XmNrightPosition, 95); n++;
591 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
592 XtSetArg (args[n], XmNtopOffset, 10); n++;
593 XtSetArg (args[n], XmNtraversalOn, False); n++;
594 executeLabel = XmCreateLabelGadget(permissionForm, "execute_label", args, n);
595 XtAddCallback(executeLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
596 HELP_PROPERTIES_DIALOG_STR);
597 XtManageChild (executeLabel);
598 XmStringFree (label_string);
600 label_string = XmStringCreateLocalized (((char *)
601 GETMESSAGE(21, 9, "Owner:")));
603 XtSetArg (args[n], XmNlabelString, label_string); n++;
604 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
605 XtSetArg (args[n], XmNleftPosition, 5); n++;
606 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
607 XtSetArg (args[n], XmNtopWidget, readLabel); n++;
608 XtSetArg (args[n], XmNtopOffset, 10); n++;
609 XtSetArg (args[n], XmNtraversalOn, False); n++;
610 ownerPLabel = XmCreateLabelGadget (permissionForm, "owner_label", args, n);
611 XtManageChild (ownerPLabel);
612 XmStringFree (label_string);
613 XtAddCallback(ownerPLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
614 HELP_PROPERTIES_DIALOG_STR);
616 empty_label_string = XmStringCreateLocalized ("");
618 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
619 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
620 XtSetArg (args[n], XmNleftPosition, 30); n++;
621 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
622 XtSetArg (args[n], XmNtopWidget, ownerPLabel); n++;
623 XtSetArg (args[n], XmNtopOffset, 0); n++;
624 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
625 XtSetArg (args[n], XmNbottomWidget, ownerPLabel); n++;
626 XtSetArg (args[n], XmNshadowThickness, 0); n++;
628 XmCreateToggleButtonGadget (permissionForm, "owner_read", args, n);
629 XtManageChild (ownerRead);
630 XtAddCallback(ownerRead, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
631 HELP_PROPERTIES_DIALOG_STR);
634 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
635 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
636 XtSetArg (args[n], XmNleftPosition, 54); n++;
637 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
638 XtSetArg (args[n], XmNtopWidget, ownerPLabel); n++;
639 XtSetArg (args[n], XmNtopOffset, 0); n++;
640 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
641 XtSetArg (args[n], XmNbottomWidget, ownerPLabel); n++;
642 XtSetArg (args[n], XmNshadowThickness, 0); n++;
644 XmCreateToggleButtonGadget (permissionForm, "owner_write", args, n);
645 XtManageChild (ownerWrite);
646 XtAddCallback(ownerWrite, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
647 HELP_PROPERTIES_DIALOG_STR);
650 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
651 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
652 XtSetArg (args[n], XmNleftPosition, 78); n++;
653 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
654 XtSetArg (args[n], XmNtopWidget, ownerPLabel); n++;
655 XtSetArg (args[n], XmNtopOffset, 0); n++;
656 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
657 XtSetArg (args[n], XmNbottomWidget, ownerPLabel); n++;
658 XtSetArg (args[n], XmNshadowThickness, 0); n++;
660 XmCreateToggleButtonGadget (permissionForm, "owner_execute", args, n);
661 XtManageChild (ownerExecute);
662 XtAddCallback(ownerExecute, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
663 HELP_PROPERTIES_DIALOG_STR);
665 label_string = XmStringCreateLocalized (((char *)
666 GETMESSAGE(21, 10, "Group:")));
668 XtSetArg (args[n], XmNlabelString, label_string); n++;
669 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
670 XtSetArg (args[n], XmNleftPosition, 5); n++;
671 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
672 XtSetArg (args[n], XmNtopWidget, ownerPLabel); n++;
673 XtSetArg (args[n], XmNtopOffset, 10); n++;
674 XtSetArg (args[n], XmNtraversalOn, False); n++;
675 groupPLabel = XmCreateLabelGadget (permissionForm, "group_label", args, n);
676 XtManageChild (groupPLabel);
677 XmStringFree (label_string);
678 XtAddCallback(groupPLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
679 HELP_PROPERTIES_DIALOG_STR);
682 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
683 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
684 XtSetArg (args[n], XmNleftPosition, 30); n++;
685 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
686 XtSetArg (args[n], XmNtopWidget, groupPLabel); n++;
687 XtSetArg (args[n], XmNtopOffset, 0); n++;
688 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
689 XtSetArg (args[n], XmNbottomWidget, groupPLabel); n++;
690 XtSetArg (args[n], XmNshadowThickness, 0); n++;
692 XmCreateToggleButtonGadget (permissionForm, "group_read", args, n);
693 XtManageChild (groupRead);
694 XtAddCallback(groupRead, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
695 HELP_PROPERTIES_DIALOG_STR);
698 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
699 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
700 XtSetArg (args[n], XmNleftPosition, 54); n++;
701 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
702 XtSetArg (args[n], XmNtopWidget, groupPLabel); n++;
703 XtSetArg (args[n], XmNtopOffset, 0); n++;
704 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
705 XtSetArg (args[n], XmNbottomWidget, groupPLabel); n++;
706 XtSetArg (args[n], XmNshadowThickness, 0); n++;
708 XmCreateToggleButtonGadget (permissionForm, "group_write", args, n);
709 XtManageChild (groupWrite);
710 XtAddCallback(groupWrite, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
711 HELP_PROPERTIES_DIALOG_STR);
714 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
715 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
716 XtSetArg (args[n], XmNleftPosition, 78); n++;
717 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
718 XtSetArg (args[n], XmNtopWidget, groupPLabel); n++;
719 XtSetArg (args[n], XmNtopOffset, 0); n++;
720 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
721 XtSetArg (args[n], XmNbottomWidget, groupPLabel); n++;
722 XtSetArg (args[n], XmNshadowThickness, 0); n++;
724 XmCreateToggleButtonGadget (permissionForm, "group_execute", args, n);
725 XtManageChild (groupExecute);
726 XtAddCallback(groupExecute, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
727 HELP_PROPERTIES_DIALOG_STR);
729 label_string = XmStringCreateLocalized (((char *)
730 GETMESSAGE(21, 11, "Other:")));
732 XtSetArg (args[n], XmNlabelString, label_string); n++;
733 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
734 XtSetArg (args[n], XmNleftPosition, 5); n++;
735 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
736 XtSetArg (args[n], XmNtopWidget, groupPLabel); n++;
737 XtSetArg (args[n], XmNtopOffset, 10); n++;
738 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
739 XtSetArg (args[n], XmNbottomOffset, 15); n++;
740 XtSetArg (args[n], XmNtraversalOn, False); n++;
741 otherPLabel = XmCreateLabelGadget (permissionForm, "other_label", args, n);
742 XtManageChild (otherPLabel);
743 XmStringFree (label_string);
744 XtAddCallback(otherPLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
745 HELP_PROPERTIES_DIALOG_STR);
748 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
749 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
750 XtSetArg (args[n], XmNleftPosition, 30); n++;
751 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
752 XtSetArg (args[n], XmNtopWidget, otherPLabel); n++;
753 XtSetArg (args[n], XmNtopOffset, 0); n++;
754 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
755 XtSetArg (args[n], XmNbottomWidget, otherPLabel); n++;
756 XtSetArg (args[n], XmNshadowThickness, 0); n++;
758 XmCreateToggleButtonGadget (permissionForm, "other_read", args, n);
759 XtManageChild (otherRead);
760 XtAddCallback(otherRead, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
761 HELP_PROPERTIES_DIALOG_STR);
764 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
765 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
766 XtSetArg (args[n], XmNleftPosition, 54); n++;
767 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
768 XtSetArg (args[n], XmNtopWidget, otherPLabel); n++;
769 XtSetArg (args[n], XmNtopOffset, 0); n++;
770 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
771 XtSetArg (args[n], XmNbottomWidget, otherPLabel); n++;
772 XtSetArg (args[n], XmNshadowThickness, 0); n++;
774 XmCreateToggleButtonGadget (permissionForm, "other_write", args, n);
775 XtManageChild (otherWrite);
776 XtAddCallback(otherWrite, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
777 HELP_PROPERTIES_DIALOG_STR);
780 XtSetArg (args[n], XmNlabelString, empty_label_string); n++;
781 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
782 XtSetArg (args[n], XmNleftPosition, 78); n++;
783 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
784 XtSetArg (args[n], XmNtopWidget, otherPLabel); n++;
785 XtSetArg (args[n], XmNtopOffset, 0); n++;
786 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
787 XtSetArg (args[n], XmNbottomWidget, otherPLabel); n++;
788 XtSetArg (args[n], XmNshadowThickness, 0); n++;
790 XmCreateToggleButtonGadget (permissionForm, "other_execute", args, n);
791 XtManageChild (otherExecute);
792 XmStringFree (empty_label_string);
793 XtAddCallback(otherExecute, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
794 HELP_PROPERTIES_DIALOG_STR);
797 /* Create the optional label and push button to invoke a file-system specific dialog */
798 /* Bottom and top attachments will be made when we know which of these widgets will be mannaged */
799 /* The callback will be registered in SetValues after the config file has been read */
802 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
803 XtSetArg (args[n], XmNleftPosition, 5); n++;
804 fsWarning = XmCreateLabelGadget (permissionForm, "fs_warning_label",
808 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
809 XtSetArg (args[n], XmNleftPosition, 5); n++;
810 fsPushButton = XmCreatePushButtonGadget (permissionForm, "fs_dialog_button",
815 /* Create the field displaying the size */
817 label_string = XmStringCreateLocalized (((char *)
818 GETMESSAGE(21, 12, "Size (in bytes): ")));
820 XtSetArg (args[n], XmNlabelString, label_string); n++;
821 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
822 XtSetArg (args[n], XmNtopWidget, permissionForm); n++;
823 XtSetArg (args[n], XmNtopOffset, 10); n++;
824 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
825 XtSetArg (args[n], XmNleftOffset, 5); n++;
826 XtSetArg (args[n], XmNtraversalOn, False); n++;
827 sizeLabel = XmCreateLabelGadget (form, "size_label", args, n);
828 XtManageChild (sizeLabel);
829 XmStringFree (label_string);
830 XtAddCallback(sizeLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
831 HELP_PROPERTIES_DIALOG_STR);
834 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
835 XtSetArg (args[n], XmNleftWidget, sizeLabel); n++;
836 XtSetArg (args[n], XmNleftOffset, 0); n++;
837 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
838 XtSetArg (args[n], XmNtopWidget, permissionForm); n++;
839 XtSetArg (args[n], XmNtopOffset, 10); n++;
840 XtSetArg (args[n], XmNtraversalOn, False); n++;
841 size = XmCreateLabelGadget (form, "size", args, n);
842 XtManageChild (size);
843 XtAddCallback(size, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
844 HELP_PROPERTIES_DIALOG_STR);
847 /* Create the field displaying the modification time */
849 label_string = XmStringCreateLocalized (((char *)
850 GETMESSAGE(21, 13, "Modified: ")));
852 XtSetArg (args[n], XmNlabelString, label_string); n++;
853 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
854 XtSetArg (args[n], XmNleftWidget, size); n++;
855 XtSetArg (args[n], XmNleftOffset, 20); n++;
856 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
857 XtSetArg (args[n], XmNtopWidget, permissionForm); n++;
858 XtSetArg (args[n], XmNtopOffset, 10); n++;
859 XtSetArg (args[n], XmNtraversalOn, False); n++;
860 modLabel = XmCreateLabelGadget (form, "modify_date_label", args, n);
861 XtManageChild (modLabel);
862 XmStringFree (label_string);
863 XtAddCallback(modLabel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
864 HELP_PROPERTIES_DIALOG_STR);
867 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
868 XtSetArg (args[n], XmNleftOffset, 0); n++;
869 XtSetArg (args[n], XmNleftWidget, modLabel); n++;
870 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
871 XtSetArg (args[n], XmNtopWidget, permissionForm); n++;
872 XtSetArg (args[n], XmNtopOffset, 10); n++;
873 XtSetArg (args[n], XmNtraversalOn, False); n++;
874 mod = XmCreateLabelGadget (form, "modify_date", args, n);
876 XtAddCallback(mod, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
877 HELP_PROPERTIES_DIALOG_STR);
880 /* Create a separator between the buttons */
883 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
884 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
885 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
886 XtSetArg (args[n], XmNtopWidget, sizeLabel); n++;
887 XtSetArg (args[n], XmNtopOffset, 5); n++;
888 XtSetArg (args[n], XmNtraversalOn, False); n++;
889 separator = XmCreateSeparatorGadget (form, "separator", args, n);
890 XtManageChild (separator);
892 /* Create the ok, cancel and help buttons */
895 XtSetArg (args[n], XmNlabelString, okXmString); n++;
896 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
897 XtSetArg (args[n], XmNleftPosition, 2); n++;
898 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
899 XtSetArg (args[n], XmNrightPosition, 32); n++;
900 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
901 XtSetArg (args[n], XmNtopWidget, separator); n++;
902 XtSetArg (args[n], XmNtopOffset, 5); n++;
903 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
904 XtSetArg (args[n], XmNbottomOffset, 5); n++;
905 XtSetArg (args[n], XmNmarginHeight, 4); n++;
906 XtSetArg (args[n], XmNuserData, flag); n++;
907 ok = XmCreatePushButtonGadget (form, "ok", args, n);
909 XtAddCallback(ok, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
910 HELP_PROPERTIES_DIALOG_STR);
913 /* Set the default action */
914 XtSetArg (args[0], XmNdefaultButton, ok);
915 XtSetValues (form, args, 1);
919 XtSetArg (args[n], XmNlabelString, cancelXmString); n++;
920 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
921 XtSetArg (args[n], XmNleftPosition, 35); n++;
922 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
923 XtSetArg (args[n], XmNrightPosition, 65); n++;
924 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
925 XtSetArg (args[n], XmNtopWidget, separator); n++;
926 XtSetArg (args[n], XmNtopOffset, 5); n++;
927 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
928 XtSetArg (args[n], XmNbottomOffset, 5); n++;
929 XtSetArg (args[n], XmNmarginHeight, 4); n++;
930 XtSetArg (args[n], XmNuserData, flag); n++;
931 cancel = XmCreatePushButtonGadget (form, "cancel", args, n);
932 XtManageChild (cancel);
933 XtAddCallback(cancel, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
934 HELP_PROPERTIES_DIALOG_STR);
938 XtSetArg (args[n], XmNlabelString, helpXmString); n++;
939 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
940 XtSetArg (args[n], XmNleftPosition, 68); n++;
941 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
942 XtSetArg (args[n], XmNrightPosition, 98); n++;
943 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
944 XtSetArg (args[n], XmNtopWidget, separator); n++;
945 XtSetArg (args[n], XmNtopOffset, 5); n++;
946 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
947 XtSetArg (args[n], XmNbottomOffset, 5); n++;
948 XtSetArg (args[n], XmNmarginHeight, 4); n++;
949 help = XmCreatePushButtonGadget (form, "help", args, n);
950 XtManageChild (help);
951 XtAddCallback(help, XmNactivateCallback, (XtCallbackProc)HelpRequestCB,
952 HELP_PROPERTIES_DIALOG_STR);
953 XtAddCallback(help, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
954 HELP_PROPERTIES_DIALOG_STR);
957 XtSetArg (args[0], XmNcancelButton, cancel);
958 XtSetValues (form, args, 1);
960 /* Fill in our instance structure */
962 modAttr_rec->shell = shell;
963 modAttr_rec->bboard = form;
964 modAttr_rec->name = name;
965 modAttr_rec->link_name = link_name;
966 modAttr_rec->link_label = link_label;
967 modAttr_rec->fileType = fileType;
968 modAttr_rec->owner_label = ownerLabel;
969 modAttr_rec->owner = owner;
970 modAttr_rec->group = group;
971 modAttr_rec->ownerL = ownerL;
972 modAttr_rec->groupL = groupL;
973 modAttr_rec->ownerRead = ownerRead;
974 modAttr_rec->ownerWrite = ownerWrite;
975 modAttr_rec->ownerExecute = ownerExecute;
976 modAttr_rec->groupRead = groupRead;
977 modAttr_rec->groupWrite = groupWrite;
978 modAttr_rec->groupExecute = groupExecute;
979 modAttr_rec->otherRead = otherRead;
980 modAttr_rec->otherWrite = otherWrite;
981 modAttr_rec->otherExecute = otherExecute;
982 modAttr_rec->otherPLabel = otherPLabel;
983 modAttr_rec->fsWarning = fsWarning;
984 modAttr_rec->fsPushButton = fsPushButton;
985 modAttr_rec->size = size;
986 modAttr_rec->modTime = mod;
987 modAttr_rec->ok = ok;
988 modAttr_rec->cancel = cancel;
989 modAttr_rec->help = help;
992 /* Set the return values for the dialog widget and dialog instance. */
994 *return_widget = form;
995 *dialog = (XtPointer) modAttr_rec;
1001 /************************************************************************
1005 ************************************************************************/
1009 ModAttrRec *modAttr_rec,
1010 XtCallbackProc callback,
1011 XtPointer client_data )
1013 ModAttrApply * apply_data;
1016 /* Setup the callback data to be sent to the Ok callback. */
1017 /* This contains the encapsulation callback to invoke upon */
1018 /* the data within the dialog being changed. */
1020 apply_data = (ModAttrApply *) XtMalloc (sizeof (ModAttrApply));
1021 apply_data->callback = callback;
1022 apply_data->client_data = client_data;
1023 apply_data->modAttr_rec = (XtPointer) modAttr_rec;
1024 modAttr_rec->apply_data = apply_data;
1027 XtAddCallback (modAttr_rec->ok, XmNactivateCallback,
1028 (XtCallbackProc)OkCallback, (XtPointer) apply_data);
1034 /************************************************************************
1038 ************************************************************************/
1042 ModAttrRec *modAttr_rec,
1043 XtCallbackProc callback,
1044 XtPointer client_data )
1046 Atom delete_window_atom;
1048 XtAddCallback (modAttr_rec->cancel,
1049 XmNactivateCallback, callback, client_data);
1051 /* This callback is removed in SetValues if the config file does */
1052 /* not include a dismiss=yes directive. Thus for some filesystems */
1053 /* you can Cancel the regular permissions dialog when the fs */
1054 /* dialog button is pressed (e.g. for DFS?) or you can let the */
1055 /* the regular permissions dialog stay on screen along with the */
1056 /* fs-specfic dialog. */
1057 if (modAttr_rec->fsPushButton != NULL)
1058 XtAddCallback (modAttr_rec->fsPushButton,
1059 XmNactivateCallback, callback, client_data);
1061 delete_window_atom = XmInternAtom (XtDisplay(modAttr_rec->shell),
1062 "WM_DELETE_WINDOW", True);
1063 XmRemoveWMProtocols( modAttr_rec->shell, &delete_window_atom, 1 );
1064 XmAddWMProtocolCallback( modAttr_rec->shell, delete_window_atom, callback,
1065 (XtPointer) client_data );
1071 /************************************************************************
1075 ************************************************************************/
1079 ModAttrRec *modAttr_rec )
1081 XtDestroyWidget (modAttr_rec->shell);
1082 XtFree ((char *) modAttr_rec->apply_data);
1083 XtFree ((char *) modAttr_rec);
1089 /************************************************************************
1093 ************************************************************************/
1097 ModAttrRec *modAttr_rec )
1099 ModAttrData * modAttr_data;
1102 /* Allocate and initialize the modify file attribute dialog data. */
1104 modAttr_data = (ModAttrData *) XtCalloc (1, sizeof (ModAttrData));
1106 modAttr_data->displayed = True;
1108 (void) GetModAttrValues(modAttr_rec, modAttr_data, False);
1110 return ((XtPointer) modAttr_data);
1116 /************************************************************************
1120 ************************************************************************/
1123 GetDefaultValues( void )
1125 ModAttrData * modAttr_data;
1128 /* Allocate and initialize the default file attribute dialog data. */
1130 modAttr_data = (ModAttrData *) XtCalloc (1, sizeof (ModAttrData));
1132 modAttr_data->displayed = False;
1133 modAttr_data->x = 0;
1134 modAttr_data->y = 0;
1135 modAttr_data->height = 0;
1136 modAttr_data->width = 0;
1138 modAttr_data->name = NULL;
1139 modAttr_data->link_name = NULL;
1140 modAttr_data->filetype = NULL;
1141 modAttr_data->pixmapData = NULL;
1142 modAttr_data->owner = NULL;
1143 modAttr_data->group = NULL;
1144 modAttr_data->accessBits = 0;
1145 modAttr_data->setuidBits = 0;
1146 modAttr_data->size = 0;
1147 modAttr_data->modTime = time(NULL);
1148 modAttr_data->host = NULL;
1149 modAttr_data->directory = NULL;
1151 return ((XtPointer) modAttr_data);
1157 /************************************************************************
1161 ************************************************************************/
1165 XrmDatabase data_base,
1169 /* We are not using this code so we commented it out for now */
1172 ModAttrData * modAttr_data;
1173 String host, directory, name;
1176 /* Allocate and get the resources for modify file attrs dialog data. */
1178 modAttr_data = (ModAttrData *) XtCalloc (1, sizeof (ModAttrData));
1180 _DtDialogGetResources (data_base, name_list, MODIFY_ATTR, (char *)modAttr_data,
1181 resources, modAttrClass->resource_count);
1184 modAttr_data->link_name = XtNewString(modAttr_data->link_name);
1187 * Since the other fields are dynamic, use the obtained name to
1188 * stat the file, and use the current values. If the file no
1189 * longer exists, then return the default values.
1191 (void) _LoadFileAttributes (modAttr_data->host, modAttr_data->directory,
1192 modAttr_data->name, modAttr_data,
1194 return ((XtPointer) modAttr_data);
1200 /************************************************************************
1204 ************************************************************************/
1208 ModAttrRec *modAttr_rec,
1209 ModAttrData *modAttr_data )
1214 char date_string[256];
1217 Boolean sensitivity;
1218 struct passwd * user_data;
1224 uid_t effective_user;
1230 Pixel bottom_shadow;
1233 XmString labelString;
1235 Tt_status tt_status;
1237 /* Get the select color */
1239 XtSetArg (args[0], XmNbackground, &background);
1240 XtSetArg (args[1], XmNcolormap, &colormap);
1241 XtGetValues (modAttr_rec->bboard, args, 2);
1243 XmGetColors (XtScreen (modAttr_rec->bboard), colormap, background,
1244 &foreground, &top_shadow, &bottom_shadow, &select);
1246 /* Adjust the colors of the icon */
1247 SetToNormalColors (modAttr_rec->fileType, modAttr_rec->bboard,
1248 modAttr_data->main_widget, 0);
1250 /* Verify that we are allowed to change the attributes */
1251 if (modAttr_data->owner)
1252 user_data = getpwnam(modAttr_data->owner);
1255 effective_user = geteuid();
1258 if (user_data && user_data->pw_uid == getuid()
1259 || effective_user == root_user)
1261 /* Check for root user */
1262 if (effective_user == root_user)
1264 fullPath = ResolveLocalPathName (modAttr_data->host,
1265 modAttr_data->directory,
1267 home_host_name, &tt_status);
1269 if( TT_OK == tt_status )
1271 /* Check for access rights (e.g. NFS mounted filesystem) */
1272 mode = chmod(fullPath, modAttr_data->accessBits +
1273 modAttr_data->setuidBits);
1279 sensitivity = False;
1282 sensitivity = False;
1288 sensitivity = False;
1290 if (modAttr_data->link_name)
1294 children[0] = modAttr_rec->link_name;
1295 children[1] = modAttr_rec->link_label;
1296 XtManageChildren(children, 2);
1297 XtSetArg(args[0], XmNtopWidget, modAttr_rec->link_name);
1298 XtSetValues(modAttr_rec->owner, args, 1);
1299 XtSetValues(modAttr_rec->owner_label, args, 1);
1300 XtSetValues(modAttr_rec->fileType, args, 1);
1306 children[0] = modAttr_rec->link_name;
1307 children[1] = modAttr_rec->link_label;
1308 XtUnmanageChildren(children, 2);
1309 XtSetArg(args[0], XmNtopWidget, modAttr_rec->name);
1310 XtSetValues(modAttr_rec->owner, args, 1);
1311 XtSetValues(modAttr_rec->owner_label, args, 1);
1312 XtSetValues(modAttr_rec->fileType, args, 1);
1316 if (sensitivity == True)
1318 /* Only allow root user to change the ownership.
1320 if (effective_user == root_user)
1322 XtManageChild(modAttr_rec->owner);
1323 XmTextFieldSetEditable(modAttr_rec->owner, True);
1324 XtSetArg (args[0], XmNcursorPositionVisible, True);
1325 XtSetArg (args[1], XmNshadowThickness, 2);
1326 XtSetValues(modAttr_rec->owner, args, 2);
1328 if (modAttr_data->owner)
1330 if (getpwnam(modAttr_data->owner) == NULL)
1332 char *newstring = XtMalloc(strlen(modAttr_data->owner) +
1333 strlen(GETMESSAGE(21,19, "Unknown")) + 10);
1334 sprintf( newstring,"%s (%s) ",modAttr_data->owner,
1335 GETMESSAGE(21,19, "Unknown") );
1336 XmTextFieldSetString(modAttr_rec->owner, newstring);
1337 XtFree( newstring );
1340 XmTextFieldSetString(modAttr_rec->owner, modAttr_data->owner);
1343 XmTextFieldSetString(modAttr_rec->owner,
1344 (GETMESSAGE(21,19, "Unknown")));
1346 XtUnmanageChild(modAttr_rec->ownerL);
1347 XtUnmanageChild(modAttr_rec->groupL);
1348 XtManageChild(modAttr_rec->group);
1349 XmTextFieldSetEditable(modAttr_rec->group, True);
1351 XtSetArg (args[0], XmNcursorPositionVisible, True);
1352 XtSetArg (args[1], XmNshadowThickness, 2);
1353 XtSetValues(modAttr_rec->group, args, 2);
1355 XtSetArg (args[0], XmNshadowType, XmSHADOW_IN);
1356 XtSetArg (args[1], XmNbackground, select);
1357 XtSetValues(XtParent (modAttr_rec->ownerRead), args, 2);
1362 XtUnmanageChild(modAttr_rec->owner);
1364 if (modAttr_data->owner)
1366 if (getpwnam(modAttr_data->owner) == NULL)
1368 char *newstring = XtMalloc(strlen(modAttr_data->owner) +
1369 strlen(GETMESSAGE(21,19, "Unknown")) + 10);
1370 sprintf( newstring,"%s ( %s ) ",modAttr_data->owner,
1371 GETMESSAGE(21,19, "Unknown") );
1372 labelString = XmStringCreateLocalized( newstring );
1373 XtFree( newstring );
1376 labelString = XmStringCreateLocalized(modAttr_data->owner);
1380 labelString = XmStringCreateLocalized((GETMESSAGE(21,19, "Unknown")));
1383 XtSetArg (args[0], XmNlabelString, labelString);
1384 XtSetValues(modAttr_rec->ownerL, args, 1);
1385 XmStringFree (labelString);
1386 XtManageChild(modAttr_rec->ownerL);
1388 XtUnmanageChild(modAttr_rec->group);
1389 if (modAttr_data->group)
1391 if (getgrnam(modAttr_data->group) == NULL)
1393 char *newstring = XtMalloc(strlen(modAttr_data->group) +
1394 strlen(GETMESSAGE(21,19, "Unknown")) + 10);
1395 sprintf(newstring,"%s ( %s ) ",modAttr_data->group,
1396 GETMESSAGE(21,19, "Unknown"));
1397 labelString = XmStringCreateLocalized(newstring);
1401 labelString = XmStringCreateLocalized(modAttr_data->group);
1405 labelString = XmStringCreateLocalized((GETMESSAGE(21,19, "Unknown")));
1407 XtSetArg (args[0], XmNlabelString, labelString);
1408 XtSetValues(modAttr_rec->groupL, args, 1);
1409 XmStringFree (labelString);
1410 XtManageChild(modAttr_rec->groupL);
1412 XtSetArg (args[0], XmNshadowType, XmSHADOW_ETCHED_IN);
1413 XtSetArg (args[1], XmNbackground, background);
1414 XtSetValues(XtParent (modAttr_rec->ownerRead), args, 2);
1418 if (modAttr_data->group)
1420 if(getgrnam(modAttr_data->group) == NULL)
1422 char *newstring = XtMalloc(strlen(modAttr_data->group) +
1423 strlen(GETMESSAGE(21,19, "Unknown")) + 10);
1424 sprintf(newstring,"%s (%s) ",modAttr_data->group,
1425 GETMESSAGE(21,19, "Unknown"));
1426 XmTextFieldSetString(modAttr_rec->group, newstring);
1430 XmTextFieldSetString(modAttr_rec->group, modAttr_data->group);
1434 XmTextFieldSetString(modAttr_rec->group,
1435 (GETMESSAGE(21,19, "Unknown")));
1440 XtUnmanageChild(modAttr_rec->owner);
1441 XtUnmanageChild(modAttr_rec->group);
1442 /* I'm not sure why we care to set all these up.
1443 Both widgets are being unmanaged by the above 2 statements
1445 XmTextFieldSetEditable(modAttr_rec->owner, False);
1446 XmTextFieldSetEditable(modAttr_rec->group, False);
1447 XtSetArg (args[0], XmNcursorPositionVisible, False);
1448 XtSetArg (args[1], XmNshadowThickness, 0);
1449 XtSetArg (args[2], XmNbackground, background);
1450 XtSetValues(modAttr_rec->owner, args, 3);
1451 XtSetValues(modAttr_rec->group, args, 3);
1454 if (modAttr_data->owner)
1456 if (getpwnam(modAttr_data->owner) == NULL)
1458 char *newstring = XtMalloc(strlen(modAttr_data->owner) +
1459 strlen(GETMESSAGE(21,19, "Unknown")) + 10);
1460 sprintf(newstring,"%s ( %s ) ",modAttr_data->owner,
1461 GETMESSAGE(21,19, "Unknown"));
1462 labelString = XmStringCreateLocalized(newstring);
1466 labelString = XmStringCreateLocalized(modAttr_data->owner);
1470 labelString = XmStringCreateLocalized((GETMESSAGE(21,19, "Unknown")));
1472 XtSetArg (args[0], XmNlabelString, labelString);
1473 XtSetValues(modAttr_rec->ownerL, args, 1);
1474 XmStringFree (labelString);
1476 if (modAttr_data->group)
1478 if (getgrnam(modAttr_data->group) == NULL)
1480 char *newstring = XtMalloc(strlen(modAttr_data->group) +
1481 strlen(GETMESSAGE(21,19, "Unknown")) + 10);
1482 sprintf(newstring,"%s ( %s ) ",modAttr_data->group,
1483 GETMESSAGE(21,19, "Unknown"));
1484 labelString = XmStringCreateLocalized(newstring);
1488 labelString = XmStringCreateLocalized(modAttr_data->group);
1492 labelString = XmStringCreateLocalized((GETMESSAGE(21,19, "Unknown")));
1494 XtSetArg (args[0], XmNlabelString, labelString);
1495 XtSetValues(modAttr_rec->groupL, args, 1);
1496 XmStringFree (labelString);
1497 XtManageChild(modAttr_rec->ownerL);
1498 XtManageChild(modAttr_rec->groupL);
1500 XtSetArg (args[0], XmNshadowType, XmSHADOW_ETCHED_IN);
1501 XtSetArg (args[1], XmNbackground, background);
1502 XtSetValues(XtParent (modAttr_rec->ownerRead), args, 2);
1506 if(modAttr_data->filetype && (
1507 strcmp(modAttr_data->filetype,LT_RECURSIVE_LINK) == 0 ||
1508 strcmp(modAttr_data->filetype,LT_BROKEN_LINK) == 0))
1509 sensitivity = False;
1511 /* User doesn't have modification privileges */
1512 XtSetSensitive(modAttr_rec->ok, sensitivity);
1513 XtSetSensitive(modAttr_rec->ownerRead, sensitivity);
1514 XtSetSensitive(modAttr_rec->ownerWrite, sensitivity);
1515 XtSetSensitive(modAttr_rec->ownerExecute, sensitivity);
1516 XtSetSensitive(modAttr_rec->groupRead, sensitivity);
1517 XtSetSensitive(modAttr_rec->groupWrite, sensitivity);
1518 XtSetSensitive(modAttr_rec->groupExecute, sensitivity);
1519 XtSetSensitive(modAttr_rec->otherRead, sensitivity);
1520 XtSetSensitive(modAttr_rec->otherWrite, sensitivity);
1521 XtSetSensitive(modAttr_rec->otherExecute, sensitivity);
1524 if (modAttr_data->name)
1526 /* Build host:dir/name string */
1527 temp = XtMalloc(strlen(modAttr_data->host) +
1528 strlen(modAttr_data->directory) +
1529 strlen(modAttr_data->name) + 3);
1531 if (modAttr_data->host)
1533 (void) strcat(temp, modAttr_data->host);
1534 (void) strcat(temp, ":");
1536 if (modAttr_data->directory)
1538 (void) strcat(temp, modAttr_data->directory);
1539 if (strcmp (modAttr_data->directory, "/") != 0)
1540 (void) strcat(temp, "/");
1542 (void) strcat(temp, modAttr_data->name);
1543 string = XmStringCreateLocalized(temp);
1544 XtFree ((char *) temp);
1547 string = XmStringCreateLocalized(" ");
1550 XtSetArg (args[0], XmNlabelString, string);
1551 XtSetValues(modAttr_rec->name, args, 1);
1552 XmStringFree(string);
1554 if (modAttr_data->link_name)
1556 string = XmStringCreateLocalized(modAttr_data->link_name);
1557 XtSetArg (args[0], XmNlabelString, string);
1558 XtSetValues(modAttr_rec->link_name, args, 1);
1559 XmStringFree(string);
1562 if (modAttr_data->filetype)
1566 if (ptr = (char *)DtDtsDataTypeToAttributeValue(modAttr_data->filetype,
1570 string = XmStringCreateLocalized(ptr);
1571 DtDtsFreeAttributeValue(ptr);
1575 string = XmStringCreateLocalized(modAttr_data->filetype);
1579 string = XmStringCreateLocalized(" ");
1581 XtSetArg (args[0], XmNstring, string);
1582 if (modAttr_data->pixmapData)
1583 XtSetArg (args[1], XmNimageName, modAttr_data->pixmapData->iconFileName);
1585 XtSetArg (args[1], XmNimageName, NULL);
1586 XtSetValues(modAttr_rec->fileType, args, 2);
1588 _DtCheckAndFreePixmapData(modAttr_data->filetype,
1590 (DtIconGadget) modAttr_rec->fileType,
1591 modAttr_data->pixmapData);
1592 modAttr_data->pixmapData = NULL;
1593 XmStringFree(string);
1594 fullPath = ResolveLocalPathName (modAttr_data->host,
1595 modAttr_data->directory,
1597 home_host_name, &tt_status);
1598 if (fsDialogAvailable(fullPath, &modAttr_rec->fileSystem))
1600 if (strlen(modAttr_rec->fileSystem.warningMessage) == 0) /* fs dialog is available and there is no warning message */
1602 string = XmStringCreateLocalized (modAttr_rec->fileSystem.buttonLabel);
1604 XtSetArg (args[n], XmNlabelString, string); n++;
1605 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1606 XtSetArg (args[n], XmNtopWidget, modAttr_rec->otherPLabel); n++;
1607 XtSetArg (args[n], XmNtopOffset, 15); n++;
1608 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1609 XtSetArg (args[n], XmNbottomOffset, 15); n++;
1610 XtSetValues(modAttr_rec->fsPushButton, args, n);
1611 XmStringFree(string);
1613 else /* fs dialog is available and there is a warning message */
1616 string = XmStringCreateLocalized (modAttr_rec->fileSystem.warningMessage);
1617 XtSetArg (args[n], XmNlabelString, string); n++;
1618 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1619 XtSetArg (args[n], XmNtopWidget, modAttr_rec->otherPLabel); n++;
1620 XtSetArg (args[n], XmNtopOffset, 15); n++;
1621 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1622 XtSetArg (args[n], XmNrightOffset, 15); n++;
1623 XtSetValues(modAttr_rec->fsWarning, args, n);
1624 XmStringFree(string);
1626 string = XmStringCreateLocalized (modAttr_rec->fileSystem.buttonLabel);
1627 XtSetArg (args[n], XmNlabelString, string); n++;
1628 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1629 XtSetArg (args[n], XmNtopWidget, modAttr_rec->fsWarning); n++;
1630 XtSetArg (args[n], XmNtopOffset, 15); n++;
1631 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1632 XtSetArg (args[n], XmNbottomOffset, 15); n++;
1633 XtSetValues(modAttr_rec->fsPushButton, args, n);
1634 XmStringFree(string);
1637 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
1638 XtSetValues(modAttr_rec->otherPLabel, args, n);
1639 if (strlen(modAttr_rec->fileSystem.warningMessage) != 0)
1640 XtManageChild (modAttr_rec->fsWarning);
1642 XtUnmanageChild (modAttr_rec->fsWarning);
1643 /* the fs dialog pushbutton is created with a callback to cancel the */
1644 /* permissions dialog ... here that callback is removed if that was */
1645 /* requested by a directive in the configuration file dtfile.config */
1646 if (!modAttr_rec->fileSystem.dismissStdPermissionDialog)
1648 XtRemoveAllCallbacks(modAttr_rec->fsPushButton, XmNactivateCallback);
1650 XtAddCallback(modAttr_rec->fsPushButton,
1651 XmNactivateCallback,
1652 (XtCallbackProc)displayFSDialog,
1653 &modAttr_rec->fileSystem);
1654 XtManageChild (modAttr_rec->fsPushButton);
1658 if (strlen(modAttr_rec->fileSystem.warningMessage) == 0) /* fs dialog not available and there is no warning message */
1660 XtUnmanageChild (modAttr_rec->fsPushButton);
1661 XtUnmanageChild (modAttr_rec->fsWarning);
1663 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1664 XtSetValues(modAttr_rec->otherPLabel, args, n);
1666 else /* fs dialog is not available and there is a warning message */
1669 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
1670 XtSetValues(modAttr_rec->otherPLabel, args, n);
1672 string = XmStringCreateLocalized (modAttr_rec->fileSystem.warningMessage);
1673 XtSetArg (args[n], XmNlabelString, string); n++;
1674 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1675 XtSetArg (args[n], XmNtopWidget, modAttr_rec->otherPLabel); n++;
1676 XtSetArg (args[n], XmNtopOffset, 15); n++;
1677 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1678 XtSetArg (args[n], XmNbottomOffset, 15); n++;
1679 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1680 XtSetArg (args[n], XmNrightOffset, 15); n++;
1681 XtSetValues(modAttr_rec->fsWarning, args, n);
1682 XmStringFree(string);
1683 XtUnmanageChild (modAttr_rec->fsPushButton);
1684 XtManageChild (modAttr_rec->fsWarning);
1685 XtUnmanageChild (modAttr_rec->fsPushButton);
1692 if(modAttr_data->filetype && (
1693 strcmp(modAttr_data->filetype,LT_RECURSIVE_LINK) == 0 ||
1694 strcmp(modAttr_data->filetype,LT_BROKEN_LINK) == 0 ))
1696 tmpStr = GETMESSAGE(21,19, "Unknown");
1697 sprintf(date_string, " %s",tmpStr);
1698 string = XmStringCreateLocalized(date_string);
1699 XtSetArg (args[0], XmNlabelString, string);
1700 XtSetValues(modAttr_rec->size, args, 1);
1701 XtSetArg (args[0], XmNlabelString, string);
1702 XtSetValues(modAttr_rec->modTime, args, 1);
1703 XmStringFree(string);
1707 (void) sprintf(buf, "%d", modAttr_data->size);
1708 string = XmStringCreateLocalized(buf);
1709 XtSetArg (args[0], XmNlabelString, string);
1710 XtSetValues(modAttr_rec->size, args, 1);
1711 XmStringFree(string);
1713 tms = localtime(&modAttr_data->modTime);
1714 tmpStr = GETMESSAGE(21, 14, "%x %X ");
1715 timeString = XtNewString(tmpStr);
1716 (void)strftime(date_string, 256, timeString, tms);
1718 string = XmStringCreateLocalized(date_string);
1719 XtSetArg (args[0], XmNlabelString, string);
1720 XtSetValues(modAttr_rec->modTime, args, 1);
1721 XmStringFree(string);
1724 XtSetArg (trueArg[0], XmNset, True);
1725 XtSetArg (falseArg[0], XmNset, False);
1727 /* Set the access bits */
1728 if (modAttr_data->accessBits & S_IRUSR)
1729 XtSetValues(modAttr_rec->ownerRead, trueArg, 1);
1731 XtSetValues(modAttr_rec->ownerRead, falseArg, 1);
1733 if (modAttr_data->accessBits & S_IWUSR)
1734 XtSetValues(modAttr_rec->ownerWrite, trueArg, 1);
1736 XtSetValues(modAttr_rec->ownerWrite, falseArg, 1);
1738 if (modAttr_data->accessBits & S_IXUSR)
1739 XtSetValues(modAttr_rec->ownerExecute, trueArg, 1);
1741 XtSetValues(modAttr_rec->ownerExecute, falseArg, 1);
1743 if (modAttr_data->accessBits & S_IRGRP)
1744 XtSetValues(modAttr_rec->groupRead, trueArg, 1);
1746 XtSetValues(modAttr_rec->groupRead, falseArg, 1);
1748 if (modAttr_data->accessBits & S_IWGRP)
1749 XtSetValues(modAttr_rec->groupWrite, trueArg, 1);
1751 XtSetValues(modAttr_rec->groupWrite, falseArg, 1);
1753 if (modAttr_data->accessBits & S_IXGRP)
1754 XtSetValues(modAttr_rec->groupExecute, trueArg, 1);
1756 XtSetValues(modAttr_rec->groupExecute, falseArg, 1);
1758 if (modAttr_data->accessBits & S_IROTH)
1759 XtSetValues(modAttr_rec->otherRead, trueArg, 1);
1761 XtSetValues(modAttr_rec->otherRead, falseArg, 1);
1763 if (modAttr_data->accessBits & S_IWOTH)
1764 XtSetValues(modAttr_rec->otherWrite, trueArg, 1);
1766 XtSetValues(modAttr_rec->otherWrite, falseArg, 1);
1768 if (modAttr_data->accessBits & S_IXOTH)
1769 XtSetValues(modAttr_rec->otherExecute, trueArg, 1);
1771 XtSetValues(modAttr_rec->otherExecute, falseArg, 1);
1777 /************************************************************************
1779 * WriteResourceValues
1781 ************************************************************************/
1784 WriteResourceValues(
1790 /* We are not using this code so we commented it out for now */
1793 ModAttrData * modAttr_data = (ModAttrData *) values->data;
1794 ModAttrRec * modAttr_rec;
1798 /* If the dialog is currently displayed, update the geometry */
1799 /* fields to their current values. */
1801 if (modAttr_data->displayed == True)
1803 _DtGenericUpdateWindowPosition(values);
1804 modAttr_rec = (ModAttrRec *) _DtGetDialogInstance(values);
1807 _DtDialogPutResources (fd, name_list, MODIFY_ATTR, values->data,
1808 resources, modAttrClass->resource_count);
1814 /************************************************************************
1818 ************************************************************************/
1822 ModAttrData *modAttr_data )
1824 XtFree ((char *) modAttr_data->host);
1825 XtFree ((char *) modAttr_data->directory);
1826 XtFree ((char *) modAttr_data->name);
1827 XtFree ((char *) modAttr_data->link_name);
1828 XtFree ((char *) modAttr_data->filetype);
1829 XtFree ((char *) modAttr_data->owner);
1830 XtFree ((char *) modAttr_data->group);
1832 if( modAttr_data->pixmapData )
1834 DtDtsFreeAttributeValue(modAttr_data->pixmapData->hostPrefix);
1835 DtDtsFreeAttributeValue(modAttr_data->pixmapData->instanceIconName);
1836 DtDtsFreeAttributeValue(modAttr_data->pixmapData->iconName);
1837 DtDtsFreeAttributeValue(modAttr_data->pixmapData->iconFileName);
1838 XtFree((char *) modAttr_data->pixmapData);
1840 XtFree ((char *) modAttr_data);
1846 /************************************************************************
1849 * This is a callback function called when the (Ok) button
1850 * is pressed. It makes any indicated modifications, and then
1851 * discards the data and brings down the dialog.
1853 ************************************************************************/
1855 static XtCallbackProc
1858 ModAttrApply *apply_data,
1859 XtPointer call_data )
1861 ModAttrRec * modAttr_rec = (ModAttrRec *) apply_data->modAttr_rec;
1862 ModAttrData * new_attr_data;
1863 FileMgrRec *file_mgr_rec;
1864 Widget close = modAttr_rec->cancel;
1865 DialogData * old_dialog;
1867 Boolean question = False;
1870 old_dialog = _DtGetInstanceData ((XtPointer)modAttr_rec);
1871 old = (ModAttrData *) old_dialog->data;
1873 if(RecheckFlag(NULL,w))
1875 else if(RecheckFlag(NULL,close))
1878 new_attr_data = (ModAttrData *) XtCalloc (1, sizeof (ModAttrData));
1879 new_attr_data->displayed = True;
1881 /* Verify the user and group names */
1882 result = GetModAttrValues(modAttr_rec, new_attr_data, True);
1883 if (result == GMA_VALID)
1885 /* Check to see if the file we are changing is the CURRENT directory.
1886 * If it is we need to see if after the changes, the user will have
1887 * permissions to read this folder. If he/she doesn't we want to warn
1888 * the user that this will be the case and allow them to back out of
1889 * the change. If they don't want to back out of the change, we need
1890 * to make the change, then move them up to the parent directory.
1892 if(strcmp(old->name, ".") == 0)
1894 /* It is the current directory, now we need to test the cases where
1895 * by changing permissions the user would no should be in this
1896 * directory because lack of priviledges.
1897 * Cases where this is true:
1898 * 1. If the execute bit for owner has been changed to off and the
1899 * user is the owner.
1900 * 2. The user changes the owner, and the execute bit is for owner
1901 * is the only execute bit set.
1902 * 3. The read access bit for owner has been turned off.
1906 if(strcmp(old->owner, new_attr_data->owner) == 0 &&
1907 (new_attr_data->accessBits & 64) == 0)
1909 /* Criteria 1 above has been meet */
1912 else if (strcmp(old->owner, new_attr_data->owner) != 0 &&
1913 ((new_attr_data->accessBits & 73) == 0 ||
1914 (new_attr_data->accessBits & 73) == 64))
1916 /* Criteria 2 above has been meet */
1919 else if((new_attr_data->accessBits & 256) == 0)
1921 /* Criteria 3 above has been meet */
1928 char *title, *message;
1930 globalApplyData = apply_data;
1931 parentDir = XtNewString(old->directory);
1932 title = XtNewString(GETMESSAGE(21, 36, "Change Permissions Warning"));
1933 message = XtNewString(GETMESSAGE(21, 37, "You are changing the permissions on the Current\nFolder in a way that won't allow you to view\nthis folder any longer. It will be automatically\nclosed and you will no longer be able to reopen\nthe folder.\n\nIs this what you want to do?"));
1934 _DtMessageDialog(modAttr_rec->shell, title, message, NULL, TRUE,
1935 DontChangeCB, ChangeCB, NULL, HelpRequestCB, False,
1941 /* Information was valid */
1942 (*(apply_data->callback)) (w, apply_data->client_data, NULL);
1944 else if (result == GMA_NO_FILE)
1946 DialogData * old_dialog;
1947 char *title,*tmpmsg,*msg;
1950 old_dialog = _DtGetInstanceData ((XtPointer)modAttr_rec);
1951 old = (ModAttrData *) old_dialog->data;
1953 file_mgr_rec = (FileMgrRec *) LocateRecordStructure(w);
1955 ResetFlag(NULL,close);
1956 title = XtNewString(GETMESSAGE(21,33, "Permissions Error"));
1957 tmpmsg = GETMESSAGE(21,35,"The Permissions dialog for the object\n\n%s/%s\n\nhas been closed because this object has been deleted\nfrom your system.");
1958 msg = XtMalloc(strlen(tmpmsg)+strlen(old->directory)+strlen(old->name)+3);
1959 sprintf(msg,tmpmsg,old->directory,old->name);
1961 ModAttrClose ((XtPointer)file_mgr_rec, old_dialog, NULL);
1962 _DtMessage(toplevel, title, msg, NULL, HelpRequestCB);
1967 FreeValues (new_attr_data);
1972 /************************************************************************
1975 * Update the current file attribute values within the data structure.
1977 ************************************************************************/
1981 ModAttrRec *modAttr_rec,
1982 ModAttrData *modAttr_data,
1986 DialogData * old_dialog;
1991 old_dialog = _DtGetInstanceData ((XtPointer)modAttr_rec);
1992 old = (ModAttrData *) old_dialog->data;
1993 retStatus = _LoadFileAttributes (old->host, old->directory, old->name,
1994 modAttr_data, ALL_BUT_OWNER_GROUP_ACCESS);
1997 return ((short)GMA_NO_FILE);
1999 /* Get the current geometry */
2000 XtSetArg (args[0], XmNx, &modAttr_data->x);
2001 XtSetArg (args[1], XmNy, &modAttr_data->y);
2002 XtSetArg (args[2], XmNwidth, &modAttr_data->width);
2003 XtSetArg (args[3], XmNheight, &modAttr_data->height);
2004 XtGetValues (modAttr_rec->shell, args, 4);
2006 /* Get the user, group and access bits */
2007 if( XtIsManaged( modAttr_rec->owner ) )
2008 modAttr_data->owner = XmTextFieldGetString(modAttr_rec->owner);
2010 modAttr_data->owner = XtNewString( old->owner );
2012 modAttr_data->group = XmTextFieldGetString(modAttr_rec->group);
2013 modAttr_data->accessBits = 0;
2015 if (XmToggleButtonGadgetGetState(modAttr_rec->ownerRead))
2016 modAttr_data->accessBits |= S_IRUSR;
2017 if (XmToggleButtonGadgetGetState(modAttr_rec->ownerWrite))
2018 modAttr_data->accessBits |= S_IWUSR;
2019 if (XmToggleButtonGadgetGetState(modAttr_rec->ownerExecute))
2020 modAttr_data->accessBits |= S_IXUSR;
2021 if (XmToggleButtonGadgetGetState(modAttr_rec->groupRead))
2022 modAttr_data->accessBits |= S_IRGRP;
2023 if (XmToggleButtonGadgetGetState(modAttr_rec->groupWrite))
2024 modAttr_data->accessBits |= S_IWGRP;
2025 if (XmToggleButtonGadgetGetState(modAttr_rec->groupExecute))
2026 modAttr_data->accessBits |= S_IXGRP;
2027 if (XmToggleButtonGadgetGetState(modAttr_rec->otherRead))
2028 modAttr_data->accessBits |= S_IROTH;
2029 if (XmToggleButtonGadgetGetState(modAttr_rec->otherWrite))
2030 modAttr_data->accessBits |= S_IWOTH;
2031 if (XmToggleButtonGadgetGetState(modAttr_rec->otherExecute))
2032 modAttr_data->accessBits |= S_IXOTH;
2035 modAttr_data->link_name = XtNewString(old->link_name);
2037 modAttr_data->link_name = NULL;
2040 /* Validate the entry */
2043 /* Valid user name */
2045 if (getpwnam(modAttr_data->owner) == NULL)
2046 error = UNKNOWN_USER;
2047 else if (getgrnam(modAttr_data->group) == NULL)
2048 error = UNKNOWN_GROUP;
2052 /* Bad entry; free up everything allocated so far */
2053 ResetFlag(NULL,modAttr_rec->ok);
2054 ResetFlag(NULL,modAttr_rec->cancel);
2055 InvalidModAttrMessage(modAttr_rec->shell, error);
2056 XtFree ((char *) modAttr_data->host);
2057 modAttr_data->host = NULL;
2058 XtFree ((char *) modAttr_data->directory);
2059 modAttr_data->directory = NULL;
2060 XtFree ((char *) modAttr_data->name);
2061 modAttr_data->name = NULL;
2062 XtFree ((char *) modAttr_data->filetype);
2063 modAttr_data->filetype = NULL;
2064 XtFree ((char *) modAttr_data->owner);
2065 modAttr_data->owner = NULL;
2066 XtFree ((char *) modAttr_data->group);
2067 modAttr_data->group = NULL;
2068 XtFree ((char *) modAttr_data->link_name);
2069 modAttr_data->link_name = NULL;
2070 XSync(XtDisplay(modAttr_rec->ok), False);
2071 return ((short)GMA_INVALID);
2075 return((short)GMA_VALID);
2081 /************************************************************************
2083 * InvalidModAttrMessage
2084 * Display an error message.
2086 ************************************************************************/
2089 InvalidModAttrMessage(
2096 static String unknownUser = NULL;
2097 static String unknownGroup = NULL;
2099 if (unknownUser == NULL)
2101 tmpStr = GETMESSAGE(21,31, "Owner Name is invalid.\nThe specified user does not exist.");
2102 unknownUser = XtNewString(tmpStr);
2103 tmpStr = GETMESSAGE(21,32, "Group Name is invalid.\n\nNo group of users with this name has been created on your system.\nUse your system administration software if you want to create\na user group with this name.");
2104 unknownGroup = XtNewString(tmpStr);
2107 switch (messageIndex)
2110 string = unknownUser;
2113 string = unknownGroup;
2117 tmpStr = GETMESSAGE(21,33, "Permissions Error");
2118 title = XtNewString(tmpStr);
2119 _DtMessage (w, title, string, NULL, HelpRequestCB);
2126 /************************************************************************
2128 * _LoadFileAttributes
2129 * Load the data structure with the data describing the indicated file.
2131 * THIS IS A Private FUNCTION
2133 ************************************************************************/
2136 _LoadFileAttributes(
2140 ModAttrData *modAttr_data,
2141 unsigned long mask )
2144 FileData *file_data=NULL;
2145 struct group * group_data;
2146 struct passwd * user_data;
2147 Boolean returnStatus=TRUE;
2150 file_data = (FileData *) ReadFileData(dir,file);
2152 if (file_data && (file_data->errnum == 0 || file_data->link))
2154 /* Extract the most uptodate attributes */
2158 modAttr_data->host = XtNewString(host);
2160 modAttr_data->host = NULL;
2163 modAttr_data->host = NULL;
2168 modAttr_data->directory = XtNewString(dir);
2170 modAttr_data->directory = NULL;
2173 modAttr_data->directory = NULL;
2176 modAttr_data->name = XtNewString(file);
2178 modAttr_data->name = NULL;
2180 if (mask & FILETYPE)
2182 modAttr_data->filetype = XtNewString(file_data->logical_type);
2184 if (modAttr_data->pixmapData)
2186 /* free old pixmap data */
2187 DtDtsFreeAttributeValue(modAttr_data->pixmapData->hostPrefix);
2188 DtDtsFreeAttributeValue(modAttr_data->pixmapData->instanceIconName);
2189 DtDtsFreeAttributeValue(modAttr_data->pixmapData->iconName);
2190 DtDtsFreeAttributeValue(modAttr_data->pixmapData->iconFileName);
2191 XtFree((char *) modAttr_data->pixmapData);
2192 modAttr_data->pixmapData = NULL;
2195 modAttr_data->pixmapData = _DtRetrievePixmapData(
2196 file_data->logical_type,
2204 modAttr_data->filetype = NULL;
2205 modAttr_data->pixmapData = NULL;
2208 if (file_data->errnum == 0 &&
2209 (file_data->stat.st_mode & S_IFMT) != S_IFLNK )
2213 group_data = getgrgid(file_data->stat.st_gid);
2214 if(group_data != NULL)
2215 modAttr_data->group = XtNewString(group_data->gr_name);
2218 sprintf(buf, "%ld", (long)file_data->stat.st_gid);
2219 modAttr_data->group = XtNewString(buf);
2223 modAttr_data->group = NULL;
2227 user_data = getpwuid(file_data->stat.st_uid);
2228 if(user_data != NULL)
2229 modAttr_data->owner = XtNewString(user_data->pw_name);
2232 sprintf(buf, "%ld", (long)file_data->stat.st_uid);
2233 modAttr_data->owner = XtNewString(buf);
2237 modAttr_data->owner = NULL;
2239 modAttr_data->setuidBits = file_data->stat.st_mode & 07000;
2241 modAttr_data->accessBits = file_data->stat.st_mode & 0777;
2243 modAttr_data->size = file_data->stat.st_size;
2245 modAttr_data->modTime = file_data->stat.st_mtime;
2249 modAttr_data->owner = NULL;
2250 modAttr_data->group = NULL;
2251 modAttr_data->accessBits = 0;
2252 modAttr_data->size = 0;
2253 modAttr_data->modTime = 0;
2258 /* File did not exist or can't be accessed; use defaults */
2259 modAttr_data->host = NULL;
2260 modAttr_data->link_name = NULL;
2261 modAttr_data->directory = NULL;
2262 modAttr_data->name = NULL;
2263 modAttr_data->filetype = NULL;
2264 modAttr_data->pixmapData = NULL;
2265 modAttr_data->owner = NULL;
2266 modAttr_data->group = NULL;
2267 modAttr_data->accessBits = 0;
2268 modAttr_data->size = 0;
2269 modAttr_data->modTime = 0;
2270 returnStatus = False;
2274 FreeFileData(file_data,True);
2276 return(returnStatus);
2281 /************************************************************************
2283 * LoadFileAttributes
2284 * Load the data structure with the data describing the indicated file.
2286 * THIS IS A Public FUNCTION
2288 ************************************************************************/
2295 ModAttrData *modAttr_data )
2297 FileData *file_data=NULL;
2299 file_data = (FileData *) ReadFileData( dir, file);
2301 /* Get the link attributes */
2302 if (file_data && file_data->link)
2303 modAttr_data->link_name = XtNewString(file_data->link);
2305 modAttr_data->link_name = NULL;
2308 FreeFileData(file_data,True);
2310 return _LoadFileAttributes (host, dir, file, modAttr_data, ALL_FIELDS);
2315 /************************************************************************
2318 * Display dialog to edit file-system-specific attributes,
2319 * e.g. AFS Access Control Lists. The dialog is displayed
2320 * be executing an independent program. There is no communication
2321 * between the two. While this is ok for filesystems like AFS
2322 * where file-system specific attributes are independent of
2323 * unix attributes, it might not be ok for file systems where
2324 * the two are dependent on each other (e.g. DFS?).
2326 ************************************************************************/
2330 displayFSDialog (Widget w,
2331 dtFSData *fileSystem,
2332 XmPushButtonCallbackStruct *cbs)
2335 static char *pname = "displayFSDialog";
2342 String errorScript = CDE_INSTALLATION_TOP "/bin/dtfile_error";
2344 switch ((pid = fork()))
2346 case -1: /* error forking */
2347 s = GETMESSAGE(21, 26, "Unable to create a process for file system dialog");
2348 xm_string = XmStringCreateLocalized(s);
2350 XtSetArg(args[n], XmNmessageString, xm_string); n++;
2351 dialog = XmCreateErrorDialog(XtParent(w),"fork_error",args,1);
2352 XmStringFree(xm_string);
2353 XtManageChild(dialog);
2358 DBGFORK(("%s: child forked\n", pname));
2360 execl(fileSystem->fsDialogProgram,
2361 fileSystem->fsDialogProgram, /* argv[0] */
2362 fileSystem->path, /* argv[1] */
2364 /* if the exec fails, build a string and execute a script */
2366 s = (char *)XtMalloc( 50
2367 + strlen( GETMESSAGE(21, 27, "Error executing file system dialog") )
2368 + strlen( GETMESSAGE(21, 28, "Attempting to execute: ") )
2369 + strlen( fileSystem->fsDialogProgram )
2370 + strlen( fileSystem->path )
2371 + strlen( strerror(errno) ) );
2373 strcpy (s, GETMESSAGE(21, 27, "Error executing file system dialog"));
2375 strcat (s, GETMESSAGE(21, 28, "Attempting to execute: "));
2376 strcat (s, fileSystem->fsDialogProgram);
2378 strcat (s, fileSystem->path);
2380 strcat (s, strerror(errno));
2384 errorScript, /* argv[0] */
2390 DBGFORK(("%s: child exiting\n", pname));
2392 exit(EXIT_FAILURE); /* just in case */
2395 default: /* parent */
2396 DPRINTF(("in parent after forking file system dialog\n"));
2401 DBGFORK(("%s: forked child<%d>\n", pname, pid));
2402 } /* end displayFSDialog */
2405 /************************************************************************
2409 ************************************************************************/
2413 XtPointer client_data,
2414 XtPointer call_data )
2416 ModAttrRec * modAttr_rec = (ModAttrRec *) globalApplyData->modAttr_rec;
2417 Widget close = modAttr_rec->cancel;
2418 Widget ok = modAttr_rec->ok;
2420 XtUnmanageChild((Widget)client_data);
2421 XmUpdateDisplay((Widget)client_data);
2422 XtDestroyWidget((Widget)client_data);
2424 ResetFlag(NULL, ok);
2425 ResetFlag(NULL, close);
2428 /************************************************************************
2433 ************************************************************************/
2437 XtPointer client_data,
2438 XtPointer call_data )
2442 XtUnmanageChild((Widget)client_data);
2443 XmUpdateDisplay((Widget)client_data);
2444 XtDestroyWidget((Widget)client_data);
2446 /* user says they want to go ahead with the change, so first let's
2449 (*(globalApplyData->callback)) (w, globalApplyData->client_data, NULL);
2451 /* Now let's change the directory to the Parent directory */
2452 ptr = DtStrrchr(parentDir, '/');
2453 if(ptr != NULL && strcmp(parentDir, "/") != 0)
2456 _DtChangeTo(globalApplyData->client_data, parentDir);
2463 ModAttrData *modAttr_data )
2465 FreeValues(modAttr_data);