home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / hotlist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.6 KB  |  251 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 HOTLIST_H
  20. #define HOTLIST_H
  21.  
  22. #include "xp_mcom.h"
  23. #include "ntypes.h"
  24.  
  25. XP_BEGIN_PROTOS
  26.  
  27. typedef enum HOT_Type {
  28.   HOT_URLType, HOT_HeaderType, HOT_SeparatorType } HOT_Type;
  29.  
  30. typedef struct HotlistStruct_ {
  31.     HOT_Type  type;
  32.     Bool      is_folded;        /* if it's a header is it folded? */
  33.     XP_List  *children;         /* a list of children, only headers have these */
  34.     char     *name;             /* a title */
  35.     char     *address;          /* the URL address */
  36.     char     *description;      /* random text */
  37.     time_t    last_visit;
  38.     time_t    addition_date;
  39.     char     *content_type;
  40.     struct HotlistStruct_  *parent; /* My hotlist parent */
  41.     XP_List  *lParent;          /* The XP_List object that points to my parent or NULL */
  42. } HotlistStruct;
  43.  
  44. /* tell the hotlist code that the hotlist has been modified
  45.  * so that it gets saved the next time SaveHotlist is called
  46.  */
  47. extern void HOT_SetModified(void);
  48.  
  49. /* changes a entry to a header type from a non header type
  50.  * and vice versa.  If the object was a header and
  51.  * has children, the children will be blown away. (very bad)
  52.  */
  53. extern void HOT_ChangeEntryType(HotlistStruct * entry, HOT_Type new_type);
  54.  
  55. /* Fold or unfold a hotlist header
  56.  * 
  57.  * set the Boolean to True to fold the list and
  58.  * False to unfold
  59.  */
  60. extern void HOT_FoldHeader(HotlistStruct * item, Bool fold);
  61.  
  62. /* checks the hotlist for a url and updates the last accessed
  63.  * time
  64.  */
  65. extern void HOT_UpdateHotlistTime(URL_Struct *URL_s, time_t cur_time);
  66.  
  67. /* Performs regular expression match on hotlist name and address
  68.  * fields.  Returns the found object, or NULL if not
  69.  * found.
  70.  *
  71.  * start_obj specifies the object to start searching
  72.  * on.  The start_num object WILL NOT be searched but all those
  73.  * after it will be.
  74.  * To search the whole list give NULL as start_obj.
  75.  *
  76.  * If headers became unfolded because of the search then redisplay_all
  77.  * will be set to TRUE
  78.  */
  79. extern HotlistStruct * HOT_SearchHotlist(char * search_string, 
  80.                                         HotlistStruct * start_obj, 
  81.                                         Bool * redisplay_all);
  82.  
  83. /* returns TRUE if the second argument is a direct
  84.  * descendent of the first argument.
  85.  *
  86.  * returns FALSE otherwise
  87.  */
  88. extern Bool HOT_IsDescendent(HotlistStruct *parent, HotlistStruct *possible_child);
  89.  
  90.  
  91. /* Reads the hostlist from disk, what else?
  92.  *
  93.  * pass in the hotlist filename and a relative URL which represents
  94.  * the original location of the html file.  If you are reading the
  95.  * default hotlist you should pass in a file URL of the form
  96.  * file://localhost/PATH
  97.  *
  98.  */
  99. extern void HOT_ReadHotlistFromDisk (char * filename, char * relative_url);
  100.  
  101. /* returns an integer index of the item in the list
  102.  */
  103. extern int HOT_GetIndex(HotlistStruct * item);
  104.  
  105. /* returns an integer index of the item in the list
  106.  * and does not pay attention to the is_folded value
  107.  */
  108. extern int HOT_GetUnfoldedIndex(HotlistStruct * item);
  109.  
  110. /* returns the object associated with the index returned by 
  111.  * HOT_GetIndex()
  112.  */
  113. extern HotlistStruct * HOT_IndexOf(int index);
  114.  
  115. /* returns the object associated with the index returned by 
  116.  * HOT_GetUnfoldedIndex()
  117.  */
  118. extern HotlistStruct * HOT_UnfoldedIndexOf(int index);
  119.  
  120. /* returns an integer depth of the item in the list starting at zero
  121.  */
  122. extern int HOT_GetDepth(HotlistStruct * item);
  123.  
  124. /* return a pointer to the main hotlist list
  125.  *
  126.  * returns NULL if nothing has ever been
  127.  * added to the hotlist
  128.  */
  129. extern XP_List * HOT_GetHotlistList(void);
  130.  
  131. /* saves the hotlist to a configuration file
  132.  */
  133. extern int HOT_SaveHotlist (char * filename);
  134.  
  135. /* Free's the entire hotlist
  136.  */
  137. extern void HOT_FreeHotlist (void);
  138.  
  139.  
  140. /* create a hotlist entry struct and fill it in with
  141.  * the passed in data
  142.  *
  143.  * returns NULL on out of memory error.
  144.  */
  145. extern HotlistStruct *
  146. HOT_CreateEntry(HOT_Type type,
  147.                 const char *name,
  148.                 const char *address,
  149.                 const char *content_type,
  150.                 time_t      last_visit);
  151.  
  152. /* free's a hotlist entry
  153.  */
  154. extern void HOT_FreeEntry(HotlistStruct * entry);
  155.  
  156. /* create a completely new copy of the entry passed in
  157.  */
  158. extern HotlistStruct * HOT_CopyEntry(HotlistStruct * entry);
  159.  
  160. /* insert an item before another item in the hotlist
  161.  *
  162.  * if the insert_before item is NULL or not found the item
  163.  * will be inserted at the begining of the list
  164.  */
  165. extern void HOT_InsertItemBefore(HotlistStruct * insert_before, HotlistStruct * insertee);
  166.  
  167. /* insert an item after another item in the hotlist
  168.  *
  169.  * if the insert_after item is NULL or not found the item
  170.  * will be inserted at the end of the list
  171.  */
  172. extern void HOT_InsertItemAfter(HotlistStruct * insert_after, HotlistStruct * insertee);
  173.  
  174. /* insert an item in a header if "insert_after" is a
  175.  * Header type, or after the item if "insert after" is
  176.  * not a header type.
  177.  *
  178.  * if the insert_after item is NULL or not found the item
  179.  * will be inserted at the end of the hotlist
  180.  */
  181. extern void
  182. HOT_InsertItemInHeaderOrAfterItem(HotlistStruct * insert_after,
  183.                                   HotlistStruct * insertee);
  184.  
  185. /* remove an item from the hotlist and free's it
  186.  *
  187.  * returns TRUE on success, FALSE if not found
  188.  */
  189. extern Bool HOT_RemoveItem(HotlistStruct * old_item);
  190.  
  191. /* remove an item from the hotlist and doesn't free it
  192.  *
  193.  * returns TRUE on success, FALSE if not found
  194.  */
  195. extern Bool HOT_RemoveItemFromList(HotlistStruct * old_item);
  196.  
  197. /* move an item up in the list
  198.  */
  199. extern void HOT_MoveObjectUp(HotlistStruct * item);
  200.  
  201. /* move an item down in the list
  202.  */
  203. extern void HOT_MoveObjectDown(HotlistStruct * item);
  204.  
  205. /* returns True if the object can be moved Up
  206.  * False if the object cannot be moved Up or if
  207.  * it cannot be found in the list
  208.  */
  209. extern Bool HOT_ObjectCanGoUp(HotlistStruct * item);
  210.  
  211. /* returns True if the object can be moved down
  212.  * False if the object cannot be moved down or if
  213.  * it cannot be found in the list
  214.  */
  215. extern Bool HOT_ObjectCanGoDown(HotlistStruct * item);
  216.  
  217. /* Whether the file will be written when Save is called. */
  218. extern Bool HOT_Modified(void);
  219.  
  220. /*
  221.  *    Gets the top node of the hotlist
  222. */
  223. extern HotlistStruct*
  224. HOT_GetHotlist (void);
  225.  
  226.  
  227. /*
  228.  * Convert a number of selections in a hotlist list into a block of
  229.  *   memory that the user can use for cut and paste operations
  230.  */
  231. extern char *
  232. HOT_ConvertSelectionsToBlock(HotlistStruct ** list, 
  233.                              int iCount, 
  234.                              int bLongFormat, 
  235.                              int32 * lTotalLen);
  236. /*
  237.  * Take a block of memory and insert the hotlist items it represents into
  238.  *   the current hotlist
  239.  */
  240. extern void
  241. HOT_InsertBlockAt(char * pOriginalBlock, 
  242.                   HotlistStruct * item, 
  243.                   int bLongFormat, 
  244.                   int32 lTotalLen);
  245.  
  246. XP_END_PROTOS
  247.  
  248. #endif /* HOTLIST_H */
  249.  
  250.  
  251.