root/Trunk/Adium.framework/Versions/A/Headers/AIHTMLDecoder.h @ 2

Revision 2, 6.9 KB (checked in by jon, 16 years ago)

Initial commit of skeletal project.

Line 
1/*-------------------------------------------------------------------------------------------------------*\
2| Adium, Copyright (C) 2001-2006, Adam Iser  (adamiser@mac.com | http://www.adiumx.com)                   |
3\---------------------------------------------------------------------------------------------------------/
4 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU
5 | General Public License as published by the Free Software Foundation; either version 2 of the License,
6 | or (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
10 | Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License along with this program; if not,
13 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
14 \------------------------------------------------------------------------------------------------------ */
15
16@class AIXMLElement;
17
18@interface AIHTMLDecoder : NSObject {
19        NSString *XMLNamespace;
20        NSString *baseURL;
21
22        struct AIHTMLDecoderOptionsBitField {
23                unsigned reserved: 18;
24
25                unsigned generateStrictXHTML: 1;
26               
27                unsigned allowJavascriptURLs: 1;
28
29                //these next ten members are derived from the arguments to
30                //  +encodeHTML:::::::::::: in the old AIHTMLDecoder.
31                unsigned headers: 1;
32                unsigned fontTags: 1;
33                unsigned closingFontTags: 1;
34                unsigned colorTags: 1;
35                unsigned styleTags: 1;
36
37                unsigned nonASCII: 1;
38                unsigned allSpaces: 1;
39                unsigned attachmentTextEquivalents: 1;
40                unsigned onlyIncludeOutgoingImages: 1;
41                unsigned bodyBackground: 1;
42
43                unsigned simpleTagsOnly: 1;
44               
45                unsigned allowAIMsubprofileLinks: 1;
46        } thingsToInclude;
47       
48        //For the horribly ghetto span and div tags used by the HTML logs
49        BOOL send;
50        BOOL receive;
51        BOOL inDiv;
52        BOOL inLogSpan; 
53}
54
55#pragma mark Creation
56
57//+decoder, +new, and -init all return an instance with all flags set to 0.
58
59+ (AIHTMLDecoder *)decoder;
60
61//convenience methods to get a decoder that's already been set up a certain way.
62
63- (id)initWithHeaders:(BOOL)includeHeaders
64                         fontTags:(BOOL)includeFontTags
65                closeFontTags:(BOOL)closeFontTags
66                        colorTags:(BOOL)includeColorTags
67                        styleTags:(BOOL)includeStyleTags
68           encodeNonASCII:(BOOL)encodeNonASCII
69                 encodeSpaces:(BOOL)encodeSpaces
70        attachmentsAsText:(BOOL)attachmentsAsText
71onlyIncludeOutgoingImages:(BOOL)onlyIncludeOutgoingImages
72           simpleTagsOnly:(BOOL)simpleOnly
73           bodyBackground:(BOOL)bodyBackground
74  allowJavascriptURLs:(BOOL)allowJS;
75
76+ (AIHTMLDecoder *)decoderWithHeaders:(BOOL)includeHeaders
77                                                         fontTags:(BOOL)includeFontTags
78                                                closeFontTags:(BOOL)closeFontTags
79                                                        colorTags:(BOOL)includeColorTags
80                                                        styleTags:(BOOL)includeStyleTags
81                                           encodeNonASCII:(BOOL)encodeNonASCII
82                                                 encodeSpaces:(BOOL)encodeSpaces
83                                        attachmentsAsText:(BOOL)attachmentsAsText
84                        onlyIncludeOutgoingImages:(BOOL)onlyIncludeOutgoingImages
85                                           simpleTagsOnly:(BOOL)simpleOnly
86                                           bodyBackground:(BOOL)bodyBackground
87                  allowJavascriptURLs:(BOOL)allowJS;
88
89#pragma mark Work methods
90
91//turn HTML source into an attributed string.
92//uses no options.
93- (NSAttributedString *)decodeHTML:(NSString *)inMessage;
94
95//turn HTML source into an attributed string, passing the default attributes to use when tags don't explicitly set them
96- (NSAttributedString *)decodeHTML:(NSString *)inMessage withDefaultAttributes:(NSDictionary *)inDefaultAttributes;
97
98//turn an attributed string into HTML source.
99//uses all options.
100- (NSString *)encodeHTML:(NSAttributedString *)inMessage imagesPath:(NSString *)imagesPath;
101
102//Turn an attributed string into the root element of a strict XHTML (1.0) document.
103//Uses options: XMLNamespace, includeHeaders, attachmentsAsText.
104- (AIXMLElement *)rootStrictXHTMLElementForAttributedString:(NSAttributedString *)inMessage imagesPath:(NSString *)imagesSavePath;
105
106//pass a string containing all the attributes of a tag (for example,
107//  @"src=\"window.jp2\" alt=\"Window on the World\""). you will get back a
108//  dictionary containing those attributes (for example, @{ @"src" =
109//  @"window.jp2", @"alt" = @"Window on the World" }).
110//uses no options.
111- (NSDictionary *)parseArguments:(NSString *)arguments;
112
113#pragma mark Accessors
114
115- (NSString *)XMLNamespace;
116- (void) setXMLNamespace:(NSString *)newXMLNamespace;
117
118- (BOOL)generatesStrictXHTML;
119- (void)setGeneratesStrictXHTML:(BOOL)newValue;
120
121//meaning <HTML> and </HTML>.
122- (BOOL)includesHeaders;
123- (void)setIncludesHeaders:(BOOL)newValue;
124
125- (BOOL)includesFontTags;
126- (void)setIncludesFontTags:(BOOL)newValue;
127
128- (BOOL)closesFontTags;
129- (void)setClosesFontTags:(BOOL)newValue;
130
131- (BOOL)includesColorTags;
132- (void)setIncludesColorTags:(BOOL)newValue;
133
134- (BOOL)includesStyleTags;
135- (void)setIncludesStyleTags:(BOOL)newValue;
136
137//turn non-printable characters into entities.
138- (BOOL)encodesNonASCII;
139- (void)setEncodesNonASCII:(BOOL)newValue;
140
141- (BOOL)preservesAllSpaces;
142- (void)setPreservesAllSpaces:(BOOL)newValue;
143
144- (BOOL)usesAttachmentTextEquivalents;
145- (void)setUsesAttachmentTextEquivalents:(BOOL)newValue;
146
147- (BOOL)onlyConvertImageAttachmentsToIMGTagsWhenSendingAMessage;
148- (void)setOnlyConvertImageAttachmentsToIMGTagsWhenSendingAMessage:(BOOL)newValue;
149
150- (BOOL)onlyUsesSimpleTags;
151- (void)setOnlyUsesSimpleTags:(BOOL)newValue;
152
153- (BOOL)includesBodyBackground;
154- (void)setIncludesBodyBackground:(BOOL)newValue;
155
156- (BOOL)allowAIMsubprofileLinks;
157- (void)setAllowAIMsubprofileLinks:(BOOL)newValue;
158
159- (BOOL)allowJavascriptURLs;
160- (void)setAllowJavascriptURLs:(BOOL)newValue;
161
162- (NSString *)baseURL;
163- (void)setBaseURL:(NSString *)inBaseURL;
164
165@end
166
167@interface AIHTMLDecoder (ClassMethodCompatibility)
168
169/*these bring back the class methods that I (boredzo) turned into instance
170 *  methods for the sake of clarity.
171 *when these methods are no longer used, this category should be deleted.
172 */
173
174+ (AIHTMLDecoder *)classMethodInstance;
175
176+ (NSString *)encodeHTML:(NSAttributedString *)inMessage encodeFullString:(BOOL)encodeFullString;
177+ (NSString *)encodeHTML:(NSAttributedString *)inMessage
178                                 headers:(BOOL)includeHeaders
179                                fontTags:(BOOL)includeFontTags
180          includingColorTags:(BOOL)includeColorTags
181                   closeFontTags:(BOOL)closeFontTags
182                           styleTags:(BOOL)includeStyleTags
183 closeStyleTagsOnFontChange:(BOOL)closeStyleTagsOnFontChange
184                  encodeNonASCII:(BOOL)encodeNonASCII
185                        encodeSpaces:(BOOL)encodeSpaces
186                          imagesPath:(NSString *)imagesPath
187           attachmentsAsText:(BOOL)attachmentsAsText
188onlyIncludeOutgoingImages:(BOOL)onlyIncludeOutgoingImages
189                  simpleTagsOnly:(BOOL)simpleOnly
190                  bodyBackground:(BOOL)bodyBackground
191     allowJavascriptURLs:(BOOL)allowJS;
192
193+ (NSAttributedString *)decodeHTML:(NSString *)inMessage;
194+ (NSAttributedString *)decodeHTML:(NSString *)inMessage withDefaultAttributes:(NSDictionary *)inDefaultAttributes;
195
196+ (NSDictionary *)parseArguments:(NSString *)arguments;
197
198@end
Note: See TracBrowser for help on using the browser.