xref: /trunk/main/framework/inc/macros/debug/plugin.hxx (revision f8e07b45)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_
25 #define __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_
26 
27 //*****************************************************************************************************************
28 //	special macros to debug asynchronous methods of plugin frame
29 //*****************************************************************************************************************
30 
31 #ifdef	ENABLE_PLUGINDEBUG
32 
33 	//_____________________________________________________________________________________________________________
34 	//	includes
35 	//_____________________________________________________________________________________________________________
36 
37 	#ifndef _RTL_STRBUF_HXX_
38 	#include <rtl/strbuf.hxx>
39 	#endif
40 
41 	#ifndef _RTL_STRING_HXX_
42 	#include <rtl/string.hxx>
43 	#endif
44 
45 	/*_____________________________________________________________________________________________________________
46 		LOGFILE_PLUGIN
47 
48 		For follow macros we need a special log file. If user forget to specify anyone, we must do it for him!
49 	_____________________________________________________________________________________________________________*/
50 
51 	#ifndef	LOGFILE_PLUGIN
52 		#define	LOGFILE_PLUGIN	\
53 					"plugin.log"
54 	#endif
55 
56 	/*_____________________________________________________________________________________________________________
57 		LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL )
58 
59 		Our plugin forward special url's to plugin dll, browser and webserver.
60 		We convert internal url's to an external notation.
61 		With this macro you can log some parameter of this operation.
62 	_____________________________________________________________________________________________________________*/
63 
64 	#define	LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL )								\
65 				/* Use new scope to declare local private variables! */										\
66 				{																							\
67 					::rtl::OStringBuffer sBuffer(1024);														\
68 					sBuffer.append( "PlugInFrame [ \""	);													\
69 					sBuffer.append( SFRAMENAME			);													\
70 					sBuffer.append( "\" ] send "		);													\
71 					sBuffer.append( SSENDMODE			);													\
72 					sBuffer.append( "( internalURL=\""	);													\
73 					sBuffer.append( U2B( SINTERNALURL )	);													\
74 					sBuffer.append( "\", externalURL=\"");													\
75 					sBuffer.append( U2B( SEXTERNALURL )	);													\
76 					sBuffer.append( "\" ) to browser.\n");													\
77 					WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )							\
78 				}
79 
80 	/*_____________________________________________________________________________________________________________
81 		LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL )
82 
83 		A plugin frame can get a url request in two different modes.
84 		1) newURL()
85 		2) newStream()
86 		We convert external url's to an internal notation.
87 		With this macro you can log some parameter of this operations.
88 	_____________________________________________________________________________________________________________*/
89 
90 	#define	LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL )							\
91 				/* Use new scope to declare local private variables! */										\
92 				{																							\
93 					::rtl::OStringBuffer sBuffer(1024);														\
94 					sBuffer.append( "PlugInFrame [ \""		);												\
95 					sBuffer.append( U2B( SFRAMENAME )		);												\
96 					sBuffer.append( "\" ] receive "			);												\
97 					sBuffer.append( SRECEIVEMODE			);												\
98 					sBuffer.append( "( externalURL=\""		);												\
99 					sBuffer.append( U2B( SEXTERNALURL )		);												\
100 					sBuffer.append( "\", internalURL=\""	);												\
101 					sBuffer.append( U2B( SINTERNALURL )		);												\
102 					sBuffer.append( "\" ) from browser.\n"	);												\
103 					WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )							\
104 				}
105 
106 	/*_____________________________________________________________________________________________________________
107 		LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, AANY )
108 
109 		Log information about parameter of a newURL() at a plugin frame.
110 	_____________________________________________________________________________________________________________*/
111 
112 	#define	LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, sFILTER, AANY )								\
113 				/* Use new scope to declare local private variables! */										\
114 				{																							\
115 					::rtl::OStringBuffer sBuffer(1024);														\
116 					sBuffer.append( "PlugInFrame [ \""				);										\
117 					sBuffer.append( U2B( SFRAMENAME )				);										\
118 					sBuffer.append( "\" ] called with newURL( \""	);										\
119 					sBuffer.append( U2B( SMIMETYPE )				);										\
120 					sBuffer.append( "\", \""						);										\
121 					sBuffer.append( U2B( SURL )						);										\
122 					sBuffer.append( "\", \""						);										\
123 					sBuffer.append( U2B( SFILTER )					);										\
124 					sBuffer.append( "\", "							);										\
125 					if( AANY.hasValue() == sal_True )														\
126 					{																						\
127 						sBuffer.append( "filled Any )"	);													\
128 					}																						\
129 					else																					\
130 					{																						\
131 						sBuffer.append( "empty Any )"	);													\
132 					}																						\
133 					sBuffer.append( "\n"	);																\
134 					WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )							\
135 				}
136 
137 	/*_____________________________________________________________________________________________________________
138 		LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, ASTREAM, AANY )
139 
140 		Log information about parameter of a newStream() at a plugin frame.
141 	_____________________________________________________________________________________________________________*/
142 
143 	#define	LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, SFILTER, XSTREAM, AANY )					\
144 				/* Use new scope to declare local private variables! */										\
145 				{																							\
146 					::rtl::OStringBuffer sBuffer(1024);														\
147 					sBuffer.append( "PlugInFrame [ \""				);										\
148 					sBuffer.append( U2B( SFRAMENAME )				);										\
149 					sBuffer.append( "\" ] called with newStream( \"");										\
150 					sBuffer.append( U2B( SMIMETYPE )				);										\
151 					sBuffer.append( "\", \""						);										\
152 					sBuffer.append( U2B( SURL )						);										\
153 					sBuffer.append( "\", \""						);										\
154 					sBuffer.append( U2B( SFILTER )					);										\
155 					sBuffer.append( "\", "							);										\
156 					if( XSTREAM.is() == sal_True )															\
157 					{																						\
158 						sal_Int32 nBytes = XSTREAM->available();											\
159 						OString sInfo("Stream with ");														\
160 						sInfo += OString::valueOf( (sal_Int32)nBytes );										\
161 						sInfo += " Bytes, ";																\
162 						sBuffer.append( sInfo );															\
163 					}																						\
164 					else																					\
165 					{																						\
166 						sBuffer.append( "empty Stream, "	);												\
167 					}																						\
168 					if( AANY.hasValue() == sal_True )														\
169 					{																						\
170 						sBuffer.append( "filled Any )"	);													\
171 					}																						\
172 					else																					\
173 					{																						\
174 						sBuffer.append( "empty Any )"	);													\
175 					}																						\
176 					sBuffer.append( "\n"	);																\
177 					WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )							\
178 				}
179 
180 #else	// #ifdef ENABLE_PLUGINDEBUG
181 
182 	/*_____________________________________________________________________________________________________________
183 		If right testmode is'nt set - implements these macro empty!
184 	_____________________________________________________________________________________________________________*/
185 
186 	#undef	LOGFILE_PLUGIN
187 	#define	LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL )
188 	#define	LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL )
189 	#define	LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, SFILTER, AANY )
190 	#define	LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, SFILTER, XSTREAM, AANY )
191 
192 #endif	// #ifdef ENABLE_PLUGINDEBUG
193 
194 //*****************************************************************************************************************
195 //	end of file
196 //*****************************************************************************************************************
197 
198 #endif	// #ifndef __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_
199