home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / rdf / src / ht.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  10.7 KB  |  298 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    _RDF_HT_H_
  20. #define    _RDF_HT_H_
  21.  
  22.  
  23. #include "xpassert.h"
  24. #include "xp_qsort.h"
  25. #include "client.h"
  26. #include "net.h"
  27. #include "xpgetstr.h"
  28. #include "xp_str.h"
  29. #include "htmldlgs.h"
  30. #include "xp_ncent.h"
  31. #include "xpassert.h"
  32. #include "nspr.h"
  33. #include "prefapi.h"
  34.  
  35. #ifdef    XP_MAC
  36. #include "stdlib.h"
  37. #endif
  38.  
  39. #include "rdf.h"
  40. #include "rdf-int.h"
  41. #include "math.h"
  42. #include "htrdf.h"
  43.  
  44.  
  45.  
  46. /* HT data structures and defines */
  47.  
  48. #define ITEM_LIST_SIZE        500        /* XXX ITEM_LIST_SIZE should be dynamic */
  49. #define ITEM_LIST_ELEMENT_SIZE    20
  50. #define NUM_MENU_CMDS           38
  51.  
  52.  
  53.  
  54.     /* external string references in allxpstr */
  55. extern    int    RDF_HTML_STR, RDF_HTML_STR_1, RDF_HTML_STR_2, RDF_HTML_STR_3;
  56. extern    int    RDF_HTML_STR_4, RDF_HTML_STR_5;
  57. extern    int    RDF_HTML_WINDATE, RDF_HTML_MACDATE, RDF_CMD_0, RDF_DATA_1, RDF_DATA_2;
  58. extern    int    RDF_DELETEFILE, RDF_UNABLETODELETEFILE, RDF_DELETEFOLDER;
  59. extern    int    RDF_UNABLETODELETEFOLDER, RDF_SITEMAPNAME;
  60. extern    int    RDF_RELATEDLINKSNAME, RDF_DEFAULTCOLUMNNAME;
  61. extern    int    RDF_NEWWORKSPACEPROMPT, RDF_DELETEWORKSPACE;
  62. extern    int    RDF_ADDITIONS_ALLOWED, RDF_DELETION_ALLOWED;
  63. extern    int    RDF_ICON_URL_LOCKED, RDF_NAME_LOCKED, RDF_COPY_ALLOWED;
  64. extern    int    RDF_MOVE_ALLOWED, RDF_WORKSPACE_POS_LOCKED;
  65.  
  66. #ifdef    HT_PASSWORD_RTNS
  67. extern    int    RDF_NEWPASSWORD, RDF_CONFIRMPASSWORD;
  68. extern    int    RDF_MISMATCHPASSWORD, RDF_ENTERPASSWORD;
  69. #endif
  70.  
  71.  
  72. #define    MISSION_CONTROL_RDF_PREF    "browser.navcenter.admin"
  73. #define    NETSCAPE_RDF_FILENAME        "netscape.rdf"
  74.  
  75. typedef struct _SBProviderStruct {
  76.     struct _SBProviderStruct    *next;
  77.     char                *url;
  78.     char                *name;
  79.     PRBool                containerp;
  80.     PRBool                openp;
  81. } SBProviderStruct;
  82. typedef SBProviderStruct* SBProvider;
  83.  
  84. typedef struct _HT_PaneStruct {
  85.     struct _HT_PaneStruct        *next;
  86.     void                *pdata;
  87.     HT_Notification            ns;
  88.     PLHashTable            *hash;
  89.     HT_NotificationMask        mask;
  90.     RDF                db;
  91.     RDF_Notification        rns;
  92.     struct _HT_ViewStruct        *viewList;
  93.     struct _HT_ViewStruct        *selectedView;
  94.     struct _HT_URLSiteMapAssoc    *smp;
  95.     uint32                viewListCount;
  96.     PRBool                autoFlushFlag;
  97.     SBProvider            smartBrowsingProviders;
  98.     PRBool                dirty;
  99.     PRBool                personaltoolbar;
  100.     PRBool                bookmarkmenu;
  101.     PRBool                special;
  102. } HT_PaneStruct;
  103.  
  104. typedef    struct HT_ColumnStruct {
  105.     struct HT_ColumnStruct        *next;
  106.     char                *name;
  107.     uint32                width;
  108.     uint32                tokenType;
  109.     void                *token;
  110. } HT_ColumnStruct, *HT_Column;
  111.  
  112. typedef struct _HT_ViewStruct {
  113.     struct _HT_ViewStruct        *next;
  114.     HT_Pane                pane;
  115.     HT_Resource            top;
  116.     void                *pdata;
  117.     HT_Column            columns;
  118.     uint32                workspacePos;
  119.     struct _HT_ResourceStruct    ***itemList;
  120.     uint32                itemListSize;
  121.     uint32                itemListCount;
  122.     uint32                selectedNodeHint;
  123.     uint32                sortTokenType;
  124.     void                *sortToken;
  125.     PRBool                descendingFlag;
  126.     PRBool                refreshingItemListp;
  127.     PRBool                inited;
  128. } HT_ViewStruct;
  129.  
  130. typedef    struct _HT_ValueStruct {
  131.     struct _HT_ValueStruct        *next;
  132.     uint32                tokenType;
  133.     void                *token;
  134.     void                *data;
  135. } HT_ValueStruct, *HT_Value;
  136.  
  137. #define    HT_CONTAINER_FLAG    0x0001
  138. #define    HT_OPEN_FLAG        0x0002
  139. #define    HT_HIDDEN_FLAG        0x0004
  140. #define    HT_SELECTED_FLAG    0x0008
  141. #define    HT_VOLATILE_URL_FLAG    0x0010
  142. #define    HT_FREEICON_URL_FLAG    0x0020
  143. #define    HT_PASSWORDOK_FLAG    0x0040
  144.  
  145. typedef struct _HT_ResourceStruct {
  146.     struct _HT_ResourceStruct    *nextItem; 
  147.     HT_View                view;
  148.     HT_Resource            parent;
  149.     RDF_Resource            node;
  150.     void                *feData;
  151.     char                *dataSource;
  152.     char                *url[2];
  153.     HT_Value            values;
  154.     HT_Resource            child;
  155.     HT_Resource            *children;        /* used by sorting */
  156.     uint32                unsortedIndex;        /* used by sorting */
  157.     uint32                itemListIndex;
  158.     uint32                numChildren, numChildrenTotal;
  159.     uint16                flags;
  160.     uint16                depth;
  161.     HT_Resource            next;
  162.     /* a pane or view might have multiple occurances of a RDF_Resource.
  163.     The hash table just points to the first of them. This allows us to
  164.     make a linked list of it */
  165. } HT_ResourceStruct;
  166.  
  167. typedef    struct    _HT_MenuCommandStruct    {
  168.     struct    _HT_MenuCommandStruct    *next;
  169.     HT_MenuCmd            menuCmd;
  170.     char                *name;
  171.     RDF_Resource            graphCommand;
  172. } _HT_MenuCommandStruct, *HT_MenuCommand;
  173.  
  174. typedef struct _HT_CursorStruct {
  175.     HT_Resource            container;
  176.     HT_Resource            node;
  177.     RDF_Cursor            cursor;
  178.     uint32                numElements;
  179.     HT_Column            columns;
  180.     uint16                contextMenuIndex;
  181.     PRBool                foundValidMenuItem;
  182.     PRBool                isWorkspaceFlag;
  183.     PRBool                isBackgroundFlag;
  184.     PRBool                commandExtensions;
  185.     PRBool                commandListBuild;
  186.     HT_MenuCmd            menuCmd;
  187.     HT_MenuCommand            menuCommandList;
  188. } HT_CursorStruct;
  189.  
  190. typedef    struct _HT_Icon {
  191.     struct _HT_Icon            *next;
  192.     char                *name;
  193. } _HT_Icon, *HT_Icon;
  194.  
  195. typedef struct    _htmlElement    {
  196.     struct    _htmlElement        *next;
  197.     HT_Resource            node;
  198.     RDF_Resource            token;
  199.     uint32                tokenType;
  200. } _htmlElement, *_htmlElementPtr;
  201.  
  202. typedef struct _HT_URLSiteMapAssoc {
  203.     uint8                siteToolType;
  204.     char                *url;
  205.     RDF_Resource            sitemap;
  206.     struct _HT_URLSiteMapAssoc    *next;
  207. } HT_URLSiteMapAssoc;
  208.  
  209.  
  210.  
  211. /* HT function prototypes */
  212.  
  213. XP_BEGIN_PROTOS
  214.  
  215. void                HT_Startup();
  216. void                HT_Shutdown();
  217. HT_Resource            newHTEntry (HT_View view, RDF_Resource node);
  218. void                addWorkspace(HT_Pane pane, RDF_Resource r, void *feData);
  219. void                deleteWorkspace(HT_Pane pane, RDF_Resource r);
  220. void                htrdfNotifFunc (RDF_Event ns, void* pdata);
  221. void                bmkNotifFunc (RDF_Event ns, void* pdata);
  222. void                refreshItemListInt (HT_View view, HT_Resource node);
  223. PRBool                relatedLinksContainerp (HT_Resource node);
  224. int                compareStrings(char *s1, char *s2);
  225. int                nodeCompareRtn(HT_Resource *node1, HT_Resource *node2);
  226. void                sortNodes(HT_View view, HT_Resource parent, HT_Resource *children, uint32 numChildren);
  227. uint32                refreshItemList1(HT_View view, HT_Resource node);
  228. void                refreshItemList (HT_Resource node, HT_Event whatHappened);
  229. void                refreshPanes();
  230. HT_Pane                paneFromResource(RDF_Resource resource, HT_Notification notify, PRBool autoFlushFlag, PRBool autoOpenFlag);
  231. RDF                newHTPaneDB();
  232. PRBool                initViews (HT_Pane pane);
  233. HT_PaneStruct *            HT_GetHTPaneList ();
  234. HT_PaneStruct *            HT_GetNextHTPane (HT_PaneStruct* pane);
  235. void                htSetWorkspaceOrder(RDF_Resource src, RDF_Resource dest, PRBool afterDestFlag);
  236. HT_View                HT_NewView (RDF_Resource topNode, HT_Pane pane, PRBool useColumns, void *feData, PRBool autoOpen);
  237. void                sendNotification (HT_Resource node, HT_Event whatHappened);
  238. void                deleteHTNode(HT_Resource node);
  239. void                destroyViewInt (HT_Resource r, PRBool saveOpenState);
  240. void                htDeletePane(HT_Pane pane, PRBool saveWorkspaceOrder);
  241. void                saveWorkspaceOrder(HT_Pane pane);
  242. void                resynchItem (HT_Resource node, void *token, void *data, PRBool assertAction);
  243. void                resynchContainer (HT_Resource container);
  244. HT_Resource            addContainerItem (HT_Resource container, RDF_Resource item);
  245. void                refreshContainerIndexes(HT_Resource container);
  246. void                removeHTFromHash (HT_Pane pane, HT_Resource item);
  247. void                deleteHTSubtree (HT_Resource subtree);
  248. void                deleteContainerItem (HT_Resource container, RDF_Resource item);
  249. uint32                fillContainer (HT_Resource node);
  250. PRBool                htIsMenuCmdEnabled(HT_Pane pane, HT_MenuCmd menuCmd, PRBool isWorkspaceFlag, PRBool isBackgroundFlag);
  251. void                freeMenuCommandList();
  252. void                exportCallbackWrite(PRFileDesc *fp, char *str);
  253. void                exportCallback(MWContext *context, char *filename, RDF_Resource node);
  254. void                htEmptyClipboard(RDF_Resource parent);
  255. void                htCopyReference(RDF_Resource original, RDF_Resource newParent, PRBool empty);
  256. PRBool                ht_isURLReal(HT_Resource node);
  257. char *                buildInternalIconURL(HT_Resource node, PRBool *volatileURLFlag,    PRBool largeIconFlag, PRBool workspaceFlag);
  258. char *                getIconURL( HT_Resource node, PRBool largeIconFlag, PRBool workspaceFlag);
  259. void                addHtmlElement(HT_Resource node, RDF_Resource token, uint32 tokenType);
  260. void                freeHtmlElementList();
  261. _htmlElementPtr            findHtmlElement(void *token);
  262. char *                constructHTML(char *dynStr, HT_Resource node, void *token, uint32 tokenType);
  263. char *                constructHTMLPermission(char *dynStr, HT_Resource node, RDF_Resource token, char *permText);
  264. PRBool                htIsOpLocked(HT_Resource node, RDF_Resource token);
  265. void                setHiddenState (HT_Resource node);
  266. PRBool                mutableContainerp (RDF_Resource node);
  267. void                possiblyCleanUpTitle (char* title);
  268. PRBool                htRemoveChild(HT_Resource parent, HT_Resource child, PRBool moveToTrash);
  269. void                ht_SetPassword(HT_Resource node, char *password);
  270. PRBool                ht_hasPassword(HT_Resource node);
  271. PRBool                ht_checkPassword(HT_Resource node, PRBool alwaysCheck);
  272. HT_DropAction            dropOn (HT_Resource dropTarget, HT_Resource dropObject, PRBool justAction);
  273. void                Win32FileCopyMove(HT_Resource dropTarget, HT_Resource dropObject);
  274. HT_DropAction            copyMoveRDFLink (HT_Resource dropTarget, HT_Resource dropObject);
  275. HT_DropAction            copyMoveRDFLinkAtPos (HT_Resource dropx, HT_Resource dropObject, PRBool before);
  276. HT_DropAction            uploadLFS (HT_Resource dropTarget, HT_Resource dropObject);
  277. HT_DropAction            uploadRDFFile (HT_Resource dropTarget, HT_Resource dropObject);
  278. HT_DropAction            esfsCopyMoveContent (HT_Resource dropTarget, HT_Resource dropObject);
  279. RDF_BT                urlResourceType (char* url);
  280. HT_DropAction            dropURLOn (HT_Resource dropTarget, char* objURL, char *objTitle, PRBool justAction);
  281. void                replacePipeWithColon(char* url);
  282. HT_DropAction            copyRDFLinkURL (HT_Resource dropTarget, char* objURL, char *objTitle);
  283. HT_DropAction            copyRDFLinkURLAt (HT_Resource dropx, char* objURL, char *objTitle, PRBool before);
  284. HT_DropAction            uploadLFSURL (HT_Resource dropTarget, char* objURL);
  285. HT_DropAction            uploadRDFFileURL (HT_Resource dropTarget, char* objURL);
  286. HT_DropAction            esfsCopyMoveContentURL (HT_Resource dropTarget, char* objURL);
  287. HT_URLSiteMapAssoc *        makeNewSMP (char* pUrl, RDF_Resource u);
  288. void                populateSBProviders (HT_Pane htPane);
  289. SBProvider            SBProviderOfNode (HT_Resource node);
  290. PRBool                implicitDomainURL (char* url);
  291. PRBool                domainMatches (char *dom, char *url);
  292. void                nextDomain (char* dom, size_t *n);
  293. PRBool                relatedLinksEnabledURL (char* url);
  294.  
  295. XP_END_PROTOS
  296.  
  297. #endif
  298.