xref: /trunk/main/framework/inc/macros/debug/plugin.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_
29 #define __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_
30 
31 //*****************************************************************************************************************
32 //  special macros to debug asynchronous methods of plugin frame
33 //*****************************************************************************************************************
34 
35 #ifdef  ENABLE_PLUGINDEBUG
36 
37     //_____________________________________________________________________________________________________________
38     //  includes
39     //_____________________________________________________________________________________________________________
40 
41     #ifndef _RTL_STRBUF_HXX_
42     #include <rtl/strbuf.hxx>
43     #endif
44 
45     #ifndef _RTL_STRING_HXX_
46     #include <rtl/string.hxx>
47     #endif
48 
49     /*_____________________________________________________________________________________________________________
50         LOGFILE_PLUGIN
51 
52         For follow macros we need a special log file. If user forget to specify anyone, we must do it for him!
53     _____________________________________________________________________________________________________________*/
54 
55     #ifndef LOGFILE_PLUGIN
56         #define LOGFILE_PLUGIN  \
57                     "plugin.log"
58     #endif
59 
60     /*_____________________________________________________________________________________________________________
61         LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL )
62 
63         Our plugin forward special url's to plugin dll, browser and webserver.
64         We convert internal url's to an external notation.
65         With this macro you can log some parameter of this operation.
66     _____________________________________________________________________________________________________________*/
67 
68     #define LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL )                                \
69                 /* Use new scope to declare local private variables! */                                     \
70                 {                                                                                           \
71                     ::rtl::OStringBuffer sBuffer(1024);                                                     \
72                     sBuffer.append( "PlugInFrame [ \""  );                                                  \
73                     sBuffer.append( SFRAMENAME          );                                                  \
74                     sBuffer.append( "\" ] send "        );                                                  \
75                     sBuffer.append( SSENDMODE           );                                                  \
76                     sBuffer.append( "( internalURL=\""  );                                                  \
77                     sBuffer.append( U2B( SINTERNALURL ) );                                                  \
78                     sBuffer.append( "\", externalURL=\"");                                                  \
79                     sBuffer.append( U2B( SEXTERNALURL ) );                                                  \
80                     sBuffer.append( "\" ) to browser.\n");                                                  \
81                     WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )                           \
82                 }
83 
84     /*_____________________________________________________________________________________________________________
85         LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL )
86 
87         A plugin frame can get a url request in two different modes.
88         1) newURL()
89         2) newStream()
90         We convert external url's to an internal notation.
91         With this macro you can log some parameter of this operations.
92     _____________________________________________________________________________________________________________*/
93 
94     #define LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL )                          \
95                 /* Use new scope to declare local private variables! */                                     \
96                 {                                                                                           \
97                     ::rtl::OStringBuffer sBuffer(1024);                                                     \
98                     sBuffer.append( "PlugInFrame [ \""      );                                              \
99                     sBuffer.append( U2B( SFRAMENAME )       );                                              \
100                     sBuffer.append( "\" ] receive "         );                                              \
101                     sBuffer.append( SRECEIVEMODE            );                                              \
102                     sBuffer.append( "( externalURL=\""      );                                              \
103                     sBuffer.append( U2B( SEXTERNALURL )     );                                              \
104                     sBuffer.append( "\", internalURL=\""    );                                              \
105                     sBuffer.append( U2B( SINTERNALURL )     );                                              \
106                     sBuffer.append( "\" ) from browser.\n"  );                                              \
107                     WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )                           \
108                 }
109 
110     /*_____________________________________________________________________________________________________________
111         LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, AANY )
112 
113         Log information about parameter of a newURL() at a plugin frame.
114     _____________________________________________________________________________________________________________*/
115 
116     #define LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, sFILTER, AANY )                              \
117                 /* Use new scope to declare local private variables! */                                     \
118                 {                                                                                           \
119                     ::rtl::OStringBuffer sBuffer(1024);                                                     \
120                     sBuffer.append( "PlugInFrame [ \""              );                                      \
121                     sBuffer.append( U2B( SFRAMENAME )               );                                      \
122                     sBuffer.append( "\" ] called with newURL( \""   );                                      \
123                     sBuffer.append( U2B( SMIMETYPE )                );                                      \
124                     sBuffer.append( "\", \""                        );                                      \
125                     sBuffer.append( U2B( SURL )                     );                                      \
126                     sBuffer.append( "\", \""                        );                                      \
127                     sBuffer.append( U2B( SFILTER )                  );                                      \
128                     sBuffer.append( "\", "                          );                                      \
129                     if( AANY.hasValue() == sal_True )                                                       \
130                     {                                                                                       \
131                         sBuffer.append( "filled Any )"  );                                                  \
132                     }                                                                                       \
133                     else                                                                                    \
134                     {                                                                                       \
135                         sBuffer.append( "empty Any )"   );                                                  \
136                     }                                                                                       \
137                     sBuffer.append( "\n"    );                                                              \
138                     WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )                           \
139                 }
140 
141     /*_____________________________________________________________________________________________________________
142         LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, ASTREAM, AANY )
143 
144         Log information about parameter of a newStream() at a plugin frame.
145     _____________________________________________________________________________________________________________*/
146 
147     #define LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, SFILTER, XSTREAM, AANY )                  \
148                 /* Use new scope to declare local private variables! */                                     \
149                 {                                                                                           \
150                     ::rtl::OStringBuffer sBuffer(1024);                                                     \
151                     sBuffer.append( "PlugInFrame [ \""              );                                      \
152                     sBuffer.append( U2B( SFRAMENAME )               );                                      \
153                     sBuffer.append( "\" ] called with newStream( \"");                                      \
154                     sBuffer.append( U2B( SMIMETYPE )                );                                      \
155                     sBuffer.append( "\", \""                        );                                      \
156                     sBuffer.append( U2B( SURL )                     );                                      \
157                     sBuffer.append( "\", \""                        );                                      \
158                     sBuffer.append( U2B( SFILTER )                  );                                      \
159                     sBuffer.append( "\", "                          );                                      \
160                     if( XSTREAM.is() == sal_True )                                                          \
161                     {                                                                                       \
162                         sal_Int32 nBytes = XSTREAM->available();                                            \
163                         OString sInfo("Stream with ");                                                      \
164                         sInfo += OString::valueOf( (sal_Int32)nBytes );                                     \
165                         sInfo += " Bytes, ";                                                                \
166                         sBuffer.append( sInfo );                                                            \
167                     }                                                                                       \
168                     else                                                                                    \
169                     {                                                                                       \
170                         sBuffer.append( "empty Stream, "    );                                              \
171                     }                                                                                       \
172                     if( AANY.hasValue() == sal_True )                                                       \
173                     {                                                                                       \
174                         sBuffer.append( "filled Any )"  );                                                  \
175                     }                                                                                       \
176                     else                                                                                    \
177                     {                                                                                       \
178                         sBuffer.append( "empty Any )"   );                                                  \
179                     }                                                                                       \
180                     sBuffer.append( "\n"    );                                                              \
181                     WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() )                           \
182                 }
183 
184 #else   // #ifdef ENABLE_PLUGINDEBUG
185 
186     /*_____________________________________________________________________________________________________________
187         If right testmode is'nt set - implements these macro empty!
188     _____________________________________________________________________________________________________________*/
189 
190     #undef  LOGFILE_PLUGIN
191     #define LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL )
192     #define LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL )
193     #define LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, SFILTER, AANY )
194     #define LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, SFILTER, XSTREAM, AANY )
195 
196 #endif  // #ifdef ENABLE_PLUGINDEBUG
197 
198 //*****************************************************************************************************************
199 //  end of file
200 //*****************************************************************************************************************
201 
202 #endif  // #ifndef __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_
203