1 /*
2  * $Id: handle.h 814 2007-11-14 18:39:28Z hubert@u.washington.edu $
3  *
4  * ========================================================================
5  * Copyright 2013-2021 Eduardo Chappa
6  * Copyright 2006-2007 University of Washington
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * ========================================================================
15  */
16 
17 #ifndef PITH_HANDLE_INCLUDED
18 #define PITH_HANDLE_INCLUDED
19 
20 
21 #include "../pith/context.h"
22 #include "../pith/msgno.h"
23 #include "../pith/atttype.h"
24 #include "../pith/util.h"
25 #include "../pith/icaltype.h"
26 
27 typedef struct screen_position_list {
28     Pos				  where;
29     struct screen_position_list  *next;
30 } POSLIST_S;
31 
32 
33 /*
34  * Struct to help manage embedded urls (and anythin' else we might embed)
35  */
36 typedef	struct handle_s {
37     int		     key;		/* tag number embedded in text */
38     enum	     {URL, iCal, Attach, Folder, Function, IMG} type;
39     unsigned	     force_display:1;	/* Don't ask before launching */
40     unsigned	     using_is_used:1;	/* bit below is being used     */
41     unsigned	     is_used:1;		/* if not, remove it from list */
42     unsigned	     color_unseen:1;	/* we're coloring folders with unseen */
43     unsigned	     color_folder:1;	/* and just folders for that matter... */
44     unsigned	     is_dual_do_open:1;	/* choosing this handle means open */
45     union {
46 	struct {			/* URL corresponding to this handle */
47 	    char *path,			/* Actual url string */
48 		 *tool,			/* displaying application */
49 		 *name;			/* URL's NAME attribute */
50 	} url;				/* stuff to describe URL handle */
51 	struct {
52 	    char *src,			/* src of image (CID: only?) */
53 		 *alt;			/* image alternate text */
54 	} img;				/* stuff to describe img */
55 	ATTACH_S    *attach;		/* Attachment struct for this handle */
56 	struct {
57 	    ATTACH_S *attach;		/* full Calendar entry */
58 	    int depth;			/* which event to display */
59 	} ical;
60 	struct {
61 	    int	       index;		/* folder's place in context's list */
62 	    CONTEXT_S *context;		/* description of folders */
63 	} f;				/* stuff to describe Folder handle */
64 	struct {
65 	    struct {			/* function and args to pass it */
66 		MAILSTREAM *stream;
67 		MSGNO_S	   *msgmap;
68 		long	    msgno;
69 	    } args;
70 	    void	(*f)(MAILSTREAM *, MSGNO_S *, long);
71 	} func;
72     } h;
73     POSLIST_S	    *loc;		/* list of places it exists in text */
74     struct handle_s *next, *prev;	/* next and previous in the list */
75 } HANDLE_S ;
76 
77 
78 
79 /*
80  * Function used to dispatch locally handled URL's
81  */
82 typedef	int	(*url_tool_t)(char *);
83 
84 
85 /* exported prototypes */
86 HANDLE_S   *get_handle(HANDLE_S *, int);
87 void	    init_handles(HANDLE_S **);
88 HANDLE_S   *new_handle(HANDLE_S **);
89 void        delete_unused_handles(HANDLE_S **);
90 void	    free_handle(HANDLE_S **);
91 void	    free_handles(HANDLE_S **);
92 void	    free_handle_locations(POSLIST_S **);
93 
94 
95 #endif /* PITH_HANDLE_INCLUDED */
96