home *** CD-ROM | disk | FTP | other *** search
- /*
- SambaManger. A graphical frontend to configure the NetInfo enhanced samba.
- Copyright (C) 1998 Robert Frank
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Robert Frank, frank@ifi.unibas.ch
- */
-
- #import <appkit/appkit.h>
- #import <netinfo/ni.h>
-
- #define NI_VALUE_NOT_FOUND NI_INDEX_NULL
- #define NI_FIND_EXACT YES
- #define NI_FIND_REGEX NO
-
- @interface NIProperty:Object
- {
- id delegate; // Where to send methods to
- const char *name; // The parameter's name
- ni_proplist *properties; // Pointer to the property list
- // u_int ni_proplist_len;
- // ni_property *ni_proplist_val;
- // ni_name nip_name;
- // ni_namelist nip_val;
- // u_int ni_namelist_len
- // ni_name *ni_namelist_val
- int tag; // An arbitrary integer value
- int setMode; // The panel to show for selecting existing values (NIPT_...)
- const char *path; // The path or directory for the panels
- const char *title; // The title for the panels
- char *temp; // Temporary storage.
- }
-
- + init:strgs;
-
- - init:sender properties:(ni_proplist *)props name:(const char *)label;
- - free;
- - display;
- - (const char *)name;
- - updateProperty;
- - updateProperty:(const char *)value default:(BOOL)remove;
-
- - (int)values;
- - (const ni_namelist *)valueList;
- - (const char *)valueAt:(int)idx;
- - insertValue:(const char *)value; // Creates the property if neccessary.
- - insertValue:(const char *)value at:(int)idx; // Creates the property if neccessary.
- - updateValue:(const char *)value at:(int)idx; // Creates the property if neccessary,
- // removes it if value is NULL.
- - deleteValue:(int)vindex;
- - (int)findValue:(const char *)value how:(BOOL)mode;
- - removeValues;
-
- - (int)index;
-
- - delegate;
- - setDelegate:anObject;
-
- - (int)tag;
- - setTag:(int)anInt;
-
- // Methods to which the delegate may respond:
- //
- // For StringProperty and BrowserProperty:
- - (int)willSelect:sender what:(int)kind path:(char **)ni_path title:(char **)panel_title state:(int *)anInt;
- // Called before displaying a selection panel (file, directory, NetInfo)
- // If this returns NIPT_NONE, no panel is shown.
- // When selecting from NetInfo, path and title may be changed. The strings
- // pointed to by path and title are not freed. State is an arbitrary value passed back
- // when calling didSelect.
- //
- - (int)didSelect:sender what:(int)kind value:(char **)selection domain:(const char *)niDomain state:(int)anInt;
- // Called after a selection was made. Selection will hold a copy of the selection.
- // The copy was allocated in [NXApp zone] and may be freed (must set *selection to NULL)
- // or reallocated.
- // If the return value is greater than zero, the selection will be presented again.
- // If the return value is zero, the returned value is used. If the return
- // value is less than zero, the selection is discarded. State is the value passed back to
- // willSelect.
- //
- - (BOOL)propertyWillChange:sender value:(char **)string default:(BOOL *)remove index:(int)anInt;
- // Called before writing any changes to the value list. The value is a pointer to
- // a copy of the string to be set or NULL for the default. The memory occupied by the
- // string will be freed. The string can be reallocated or freed from the [NXApp xone] zone.
- // The index is the index into the property's value list. A value of
- // NI_VALUE_NOT_FOUND indicates no original value. If remove is true, the value is to
- // be removed from the value list. If the value list becomes empty, the entire property
- // will be removed. A return value of YES will abort the operation and
- // will reset the value to its previous state.
- //
- - propertyDidChange:sender value:(const char *)string;
- // Called after a change was accomplished. The string may not be changed. The value may be
- // NULL indicating a default (i.e. the property was removed).
- //
- //
- // Methods which will be sent to the text field. These must be implemented if a GUI
- // component wishes to emulate a text field. Common methods for:
- // NICharProperty, NIIntProperty, NIStringProperty, and NIBrowserProperty
- // - setTextDelegate:sender
- // - setStringValue:(const char *)aString;
- // - (const char *)stringValue;
- // for NIIntProperty only:
- // - setIntValue:(int);
- // for NIBrowserProperty only:
- // - selectText:sender;
- //
- // Methods which must be sent from the text field.
- // - textDidEnd:textObject endChar:(unsigned short)whyEnd
- // textDidChange:sender
-
-
- // Local to subclasses. Do not call directly!
- - (const char *)openNetInfo:(const char *)baseDir withTitle:(const char *)openTitle domain:(const char **)from;
- - (const char *)openFilePath:(BOOL)dirsOnly;
- - hasChanged:sender;
- - (const char *)usePanel:sender;
- @end
-
-
-
- @interface NIBoolProperty:NIProperty
- {
- id outlet; // The id of the GUI item
- char *yes, *no;
- }
- - init:sender properties:(ni_proplist *)props name:(const char *)label outlet:o;
- - setValues:(const char *)true :(const char *)false;
- @end
-
- @interface NICharProperty:NIProperty
- {
- id outlet; // The id of the GUI item
- BOOL needUpdate;
- }
- - init:sender properties:(ni_proplist *)props name:(const char *)label outlet:o;
- @end
-
- @interface NIIntProperty:NICharProperty
- {
- id slider; // The id of any slider; may be nil
- int intVal; // The current value
- const char *defaultText; // The default text (value: -1)
- const char *zero; // The text for the zero value; may be NULL
- }
- - init:sender properties:(ni_proplist *)props name:(const char *)label
- text:t slider:s default:(const char *)d zero:(const char *)z;
- @end
-
- @interface NIStringProperty:NICharProperty
- {
- id button; // The id of the set ... button
- }
- - init:sender properties:(ni_proplist *)props name:(const char *)label
- text:t button:b mode:(int)m path:(const char *)p title:(const char *)tString;
- @end
-
- @interface NIBrowserProperty:NIProperty
- {
- id outlet; // The id of the browser
- id textField; // The id of any text field; may be nil
- id addButton;
- id deleteButton;
- }
- - init:sender properties:(ni_proplist *)props name:(const char *)label
- text:t browser:b mode:(int)m path:(const char *)p
- add:a remove:r title:(const char *)tString;
- @end
-
- @interface NIPopupProperty:NIProperty
- {
- id outlet; // The id of the menu's target button
- const char *defaultText;
- }
- - init:sender properties:(ni_proplist *)props name:(const char *)label
- outlet:o default:(const char *)d;
- @end
-
- @interface NICallProperty:NIProperty
- {
- SEL display;
- }
- - init:sender properties:(ni_proplist *)props name:(const char *)label displayAction:(SEL)action;
- @end
-
-