home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Networking / SambaManager / NIProperty.h < prev    next >
Encoding:
Text File  |  1998-03-25  |  7.2 KB  |  198 lines

  1. /*
  2.     SambaManger. A graphical frontend to configure the NetInfo enhanced samba.
  3.     Copyright (C) 1998  Robert Frank
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.         
  19.         Robert Frank, frank@ifi.unibas.ch
  20. */
  21.  
  22. #import <appkit/appkit.h>
  23. #import <netinfo/ni.h>
  24.  
  25. #define NI_VALUE_NOT_FOUND    NI_INDEX_NULL
  26. #define NI_FIND_EXACT    YES
  27. #define NI_FIND_REGEX NO
  28.  
  29. @interface NIProperty:Object
  30. {
  31.     id                    delegate;                    // Where to send methods to
  32.     const char    *name;                        // The parameter's name
  33.     ni_proplist    *properties;            // Pointer to the property list
  34.                                                                 //    u_int        ni_proplist_len;
  35.                                                                 //    ni_property  *ni_proplist_val;
  36.                                                                 //           ni_name     nip_name;
  37.                                 //        ni_namelist nip_val;
  38.                                                                 //           u_int    ni_namelist_len
  39.                                                                 //           ni_name  *ni_namelist_val
  40.     int                    tag;                            // An arbitrary integer value
  41.     int                    setMode;                    // The panel to show for selecting existing values (NIPT_...)
  42.     const char    *path;                        // The path or directory for the panels
  43.     const char    *title;                        // The title for the panels
  44.     char                *temp;                        // Temporary storage.
  45. }
  46.  
  47. + init:strgs;
  48.  
  49. - init:sender properties:(ni_proplist *)props name:(const char *)label;
  50. - free;
  51. - display;
  52. - (const char *)name;
  53. - updateProperty;
  54. - updateProperty:(const char *)value default:(BOOL)remove;
  55.  
  56. - (int)values;
  57. - (const ni_namelist *)valueList;
  58. - (const char *)valueAt:(int)idx;
  59. - insertValue:(const char *)value;                                     // Creates the property if neccessary.
  60. - insertValue:(const char *)value at:(int)idx;            // Creates the property if neccessary.
  61. - updateValue:(const char *)value at:(int)idx;            // Creates the property if neccessary,
  62.                                                                                                         // removes it if value is NULL.
  63. - deleteValue:(int)vindex;
  64. - (int)findValue:(const char *)value how:(BOOL)mode;
  65. - removeValues;
  66.  
  67. - (int)index;
  68.  
  69. - delegate;
  70. - setDelegate:anObject;
  71.  
  72. - (int)tag;
  73. - setTag:(int)anInt;
  74.  
  75. // Methods to which the delegate may respond:
  76. //
  77. // For StringProperty and BrowserProperty:
  78. - (int)willSelect:sender what:(int)kind path:(char **)ni_path title:(char **)panel_title state:(int *)anInt;
  79. //    Called before displaying a selection panel (file, directory, NetInfo)
  80. //    If this returns NIPT_NONE, no panel is shown.
  81. //    When selecting from NetInfo, path and title may be changed. The strings
  82. //    pointed to by path and title are not freed. State is an arbitrary value passed back
  83. //        when calling didSelect.
  84. //
  85. - (int)didSelect:sender what:(int)kind value:(char **)selection domain:(const char *)niDomain state:(int)anInt;
  86. //    Called after a selection was made. Selection will hold a copy of the selection.
  87. //    The copy was allocated in [NXApp zone] and may be freed (must set *selection to NULL) 
  88. //        or reallocated.
  89. //    If the return value is greater than zero, the selection will be presented again.
  90. //    If the return value is zero, the returned value is used. If the return
  91. //    value is less than zero, the selection is discarded. State is the value passed back to
  92. //    willSelect.
  93. //
  94. - (BOOL)propertyWillChange:sender value:(char **)string default:(BOOL *)remove index:(int)anInt;
  95. //    Called before writing any changes to the value list. The value is a pointer to
  96. //    a copy of the string to be set or NULL for the default. The memory occupied by the 
  97. //    string will be freed. The string can be reallocated or freed from the [NXApp xone] zone.
  98. //    The index is the index into the property's value list. A value of
  99. //    NI_VALUE_NOT_FOUND indicates no original value. If remove is true, the value is to
  100. //    be removed from the value list. If the value list becomes empty, the entire property
  101. //    will be removed. A return value of YES will abort the operation and 
  102. //    will reset the value to its previous state.
  103. //
  104. - propertyDidChange:sender value:(const char *)string;
  105. //    Called after a change was accomplished. The string may not be changed. The value may be
  106. //    NULL indicating a default (i.e. the property was removed).
  107. //
  108. //
  109. // Methods which will be sent to the text field. These must be implemented if a GUI
  110. // component wishes to emulate a text field. Common methods for:
  111. //    NICharProperty, NIIntProperty, NIStringProperty, and NIBrowserProperty
  112. // - setTextDelegate:sender
  113. // - setStringValue:(const char *)aString;
  114. // - (const char *)stringValue;
  115. // for NIIntProperty only:
  116. // - setIntValue:(int);
  117. // for NIBrowserProperty only:
  118. // - selectText:sender;
  119. //
  120. // Methods which must be sent from the text field.
  121. // - textDidEnd:textObject endChar:(unsigned short)whyEnd
  122. // textDidChange:sender
  123.  
  124.  
  125. // Local to subclasses. Do not call directly!
  126. - (const char *)openNetInfo:(const char *)baseDir withTitle:(const char *)openTitle domain:(const char **)from;
  127. - (const char *)openFilePath:(BOOL)dirsOnly;
  128. - hasChanged:sender;
  129. - (const char *)usePanel:sender;
  130. @end
  131.  
  132.  
  133.  
  134. @interface NIBoolProperty:NIProperty
  135. {
  136.     id        outlet;                                        // The id of the GUI item
  137.     char    *yes, *no;
  138. }
  139. - init:sender properties:(ni_proplist *)props name:(const char *)label outlet:o;
  140. - setValues:(const char *)true :(const char *)false;
  141. @end
  142.  
  143. @interface NICharProperty:NIProperty
  144. {
  145.     id        outlet;                                        // The id of the GUI item
  146.     BOOL    needUpdate;
  147. }
  148. - init:sender properties:(ni_proplist *)props name:(const char *)label outlet:o;
  149. @end
  150.  
  151. @interface NIIntProperty:NICharProperty
  152. {
  153.     id                    slider;                // The id of any slider; may be nil
  154.     int                    intVal;                // The current value
  155.     const char    *defaultText;    // The default text (value: -1)
  156.     const char    *zero;                // The text for the zero value; may be NULL
  157. }
  158. - init:sender properties:(ni_proplist *)props name:(const char *)label
  159.         text:t slider:s default:(const char *)d zero:(const char *)z;
  160. @end
  161.  
  162. @interface NIStringProperty:NICharProperty
  163. {
  164.     id                    button;                        // The id of the set ... button
  165. }
  166. - init:sender properties:(ni_proplist *)props name:(const char *)label
  167.         text:t button:b mode:(int)m path:(const char *)p title:(const char *)tString;
  168. @end
  169.  
  170. @interface NIBrowserProperty:NIProperty
  171. {
  172.     id                    outlet;                        // The id of the browser
  173.     id                     textField;                // The id of any text field; may be nil
  174.     id                    addButton;
  175.     id                    deleteButton;
  176. }
  177. - init:sender properties:(ni_proplist *)props name:(const char *)label
  178.         text:t browser:b mode:(int)m path:(const char *)p
  179.         add:a remove:r title:(const char *)tString;
  180. @end
  181.  
  182. @interface NIPopupProperty:NIProperty
  183. {
  184.     id                    outlet;                                        // The id of the menu's target button
  185.     const char *defaultText;
  186. }
  187. - init:sender properties:(ni_proplist *)props name:(const char *)label
  188.         outlet:o default:(const char *)d;
  189. @end
  190.  
  191. @interface NICallProperty:NIProperty
  192. {
  193.     SEL                    display;
  194. }
  195. - init:sender properties:(ni_proplist *)props name:(const char *)label displayAction:(SEL)action;
  196. @end
  197.  
  198.