home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / dirprefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.6 KB  |  224 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef _DIRPREFS_H_
  20. #define _DIRPREFS_H_
  21.  
  22. #define kCurrentListVersion 1 
  23.  
  24. /* DIR_Server.dirType */
  25. typedef enum
  26. {
  27.     LDAPDirectory,
  28.     HTMLDirectory,
  29.     PABDirectory
  30. } DirectoryType;
  31.  
  32. typedef enum
  33. {
  34.     cn,
  35.     givenname,
  36.     sn,
  37.     mail,
  38.     telephonenumber,
  39.     o,
  40.     ou,
  41.     l,
  42.     street,
  43.     auth,
  44.     custom1,
  45.     custom2,
  46.     custom3,
  47.     custom4,
  48.     custom5
  49. } DIR_AttributeId;
  50.  
  51.  
  52. typedef struct _DIR_ReplicationInfo DIR_ReplicationInfo;
  53.  
  54.  
  55. typedef struct DIR_Server
  56. {
  57.     char *description;            /* human readable name                    */
  58.     char *serverName;            /* network host name                      */
  59.     char *searchBase;            /* DN suffix to search at                 */
  60.     char *fileName;                /* XP path name of local DB               */
  61.     char *prefId;               /* name of this server's tree in JS prefs */
  62.     int port;                    /* network port number                    */
  63.     int maxHits;                /* maximum number of hits to return       */
  64.     XP_Bool isSecure;           /* use SSL?                               */
  65.     XP_Bool saveResults;    
  66.     XP_Bool efficientWildcards; /* server can match substrings            */
  67.     char *lastSearchString;        /* required if saving results             */
  68.     DirectoryType dirType;    
  69.     uint32 flags;               
  70.  
  71.     /* site-configurable attributes and filters */
  72.     XP_List *customFilters;
  73.     XP_List *customAttributes;
  74.     char *tokenSeps;
  75.     XP_Bool stopFiltersOnHit;
  76.     XP_Bool isOffline;
  77.  
  78.     /* site-configurable list of attributes whose values are DNs */
  79.     char **dnAttributes;
  80.     int dnAttributesCount;
  81.  
  82.     /* site-configurable list of attributes we shouldn't display in HTML */
  83.     char **suppressedAttributes;
  84.     int suppressedAttributesCount;
  85.  
  86.     /* site-configurable list of attributes for the Basic Search dialog */
  87.     DIR_AttributeId *basicSearchAttributes;
  88.     int basicSearchAttributesCount;
  89.  
  90.     /* site-configurable URL to open LDAP results */
  91.     char *customDisplayUrl;
  92.  
  93.     /* authentication fields */
  94.     XP_Bool enableAuth;        /* Use DN and password when binding?        */
  95.     XP_Bool savePassword;    /* Remember the DN and password we gave?    */
  96.     char *authDn;            /* DN to give to authenticate as            */
  97.     char *password;            /* Password for the DN                        */
  98.  
  99.     /* replication fields */
  100.     DIR_ReplicationInfo *replInfo;
  101.  
  102. } DIR_Server;
  103.  
  104.  
  105. XP_BEGIN_PROTOS
  106.  
  107. /* Return the list of directory servers
  108.  * each front end hangs on to the list
  109.  */
  110. XP_List * FE_GetDirServers(void);
  111.  
  112. /* Since the strings in DIR_Server are allocated, we have bottleneck
  113.  * routines to help with memory mgmt
  114.  */
  115. int        DIR_CopyServer (DIR_Server *in, DIR_Server **out);
  116. int        DIR_DeleteServer (DIR_Server *);
  117. int        DIR_InitServer (DIR_Server *);
  118.  
  119. int        DIR_ValidateServer (DIR_Server *);
  120. XP_Bool    DIR_AreServersSame (DIR_Server *first, DIR_Server *second);
  121. int        DIR_DeleteServerList(XP_List *wholeList);
  122.  
  123. int        DIR_GetLdapServers (XP_List *wholeList, XP_List *subList);
  124. int        DIR_ReorderLdapServers (XP_List *wholeList);
  125.  
  126. /* These two routines should be called to initialize and save 
  127.  * directory preferences from the XP Java Script preferences
  128.  */
  129. int        DIR_GetServerPreferences (XP_List **list, const char* pabFile);
  130. int        DIR_SaveServerPreferences (XP_List *wholeList);
  131.  
  132. /* This routine will clean up files for deleted directories */
  133. int        DIR_CleanUpServerPreferences(XP_List *deletedList);
  134.  
  135.  
  136. #if 1 
  137.  
  138. /* Returns a pointer into the list (not allocated, so don't free) */
  139. int        DIR_GetPersonalAddressBook (XP_List *wholeList, DIR_Server **pab);
  140. int        DIR_GetComposeNameCompletionAddressBook (XP_List *wholeList, DIR_Server **cab);
  141.  
  142. #else
  143.  
  144. /* Returns an allocated list of all personal address books, excluding
  145.  * LDAP directories, replicated directories, and CABs
  146.  */
  147. XP_List *DIR_GetPersonalAddressBooks (XP_List *wholeList);
  148. XP_List *DIR_GetAddressBooksForCompletion (XP_List *wholeList);
  149.  
  150. #endif
  151.  
  152. void    DIR_GetServerFileName(char** filename, const char* leafName);
  153. void    DIR_SetServerFileName(DIR_Server* pServer, const char* leafName);
  154.  
  155. /* APIs for site-configurability of LDAP attribute names and 
  156.  * search filter behavior.
  157.  *
  158.  * Strings are NOT allocated, and arrays are NULL-terminated
  159.  */
  160. const char  *DIR_GetAttributeName (DIR_Server *server, DIR_AttributeId id);
  161. const char **DIR_GetAttributeStrings (DIR_Server *server, DIR_AttributeId id);
  162. const char  *DIR_GetFirstAttributeString (DIR_Server *server, DIR_AttributeId id);
  163. const char  *DIR_GetFilterString (DIR_Server *server);
  164. const char  *DIR_GetTokenSeparators (DIR_Server *server);
  165. XP_Bool         DIR_RepeatFilterForTokens (DIR_Server *server, const char *filter);
  166. XP_Bool         DIR_SubstStarsForSpaces (DIR_Server *server, const char *filter);
  167. XP_Bool      DIR_UseCustomAttribute (DIR_Server *server, DIR_AttributeId id);
  168.  
  169. XP_Bool      DIR_IsDnAttribute (DIR_Server *s, const char *attr);
  170. XP_Bool      DIR_IsAttributeExcludedFromHtml (DIR_Server *s, const char *attr);
  171.  
  172. int DIR_AttributeNameToId (const char *attrName, DIR_AttributeId *id);
  173.  
  174. /* APIs for authentication */
  175. void        DIR_SetAuthDN (DIR_Server *s, const char *dn);
  176. void        DIR_SetPassword (DIR_Server *s, const char *password);
  177.  
  178. /* APIs for unescaping LDAP special chars */
  179. char   *DIR_Unescape (const char *src, XP_Bool makeHtml);
  180. XP_Bool DIR_IsEscapedAttribute (DIR_Server *s, const char *attrib);
  181.  
  182. /* APIs for replication */
  183. int DIR_ValidateRootDSE (DIR_Server *s, int32 gen, int32 first, int32 last);
  184.  
  185. /* API for building a URL */
  186. char *DIR_BuildUrl (DIR_Server *s, const char *dn, XP_Bool forAddToAB);
  187.  
  188. /* Flags manipulation */
  189.  
  190. #define DIR_AUTO_COMPLETE_ENABLED          0x00000001
  191. #define DIR_ENABLE_AUTH                    0x00000002
  192. #define DIR_SAVE_PASSWORD                  0x00000004
  193. #define DIR_UTF8_DISABLED                  0x00000008  /* not used by the FEs */
  194. #define DIR_IS_SECURE                      0x00000010
  195. #define DIR_SAVE_RESULTS                   0x00000020  /* not used by the FEs */
  196. #define DIR_EFFICIENT_WILDCARDS            0x00000040  /* not used by the FEs */
  197. #define DIR_LDAPV3_SUPPORTED               0x00000080  /* not used by the FEs */
  198. #define DIR_LDAPV3_NOT_SUPPORTED           0x00000100  /* not used by the FEs */
  199. #define DIR_VIRTUAL_LISTBOX_SUPPORTED      0x00000200  /* not used by the FEs */
  200. #define DIR_VIRTUAL_LISTBOX_NOT_SUPPORTED  0x00000400  /* not used by the FEs */
  201.  
  202. void DIR_SetAutoCompleteEnabled (XP_List *list, DIR_Server *server, XP_Bool onOrOff);
  203.  
  204. XP_Bool DIR_TestFlag  (DIR_Server *server, uint32 flag);
  205. void    DIR_SetFlag   (DIR_Server *server, uint32 flag);
  206. void    DIR_ClearFlag (DIR_Server *server, uint32 flag);
  207. void    DIR_ForceFlag (DIR_Server *server, uint32 flag, XP_Bool forceOnOrOff);
  208.  
  209. char *DIR_ConvertToServerCharSet   (DIR_Server *s, char *src, int16 srcCsid);
  210. char *DIR_ConvertFromServerCharSet (DIR_Server *s, char *src, int16 dstCsid);
  211.  
  212. #ifdef MOZ_LDAP
  213.  
  214. /* Does the LDAP client lib work for SSL */
  215. #include "ldap.h"
  216. int DIR_SetupSecureConnection (LDAP *ld);
  217.  
  218. #endif /* MOZ_LDAP */
  219.  
  220. XP_END_PROTOS
  221.  
  222.  
  223. #endif /* dirprefs.h */
  224.