1ae77b8caSAriel Constenla-Haile /**************************************************************
2ae77b8caSAriel Constenla-Haile *
3ae77b8caSAriel Constenla-Haile * Licensed to the Apache Software Foundation (ASF) under one
4ae77b8caSAriel Constenla-Haile * or more contributor license agreements. See the NOTICE file
5ae77b8caSAriel Constenla-Haile * distributed with this work for additional information
6ae77b8caSAriel Constenla-Haile * regarding copyright ownership. The ASF licenses this file
7ae77b8caSAriel Constenla-Haile * to you under the Apache License, Version 2.0 (the
8ae77b8caSAriel Constenla-Haile * "License"); you may not use this file except in compliance
9ae77b8caSAriel Constenla-Haile * with the License. You may obtain a copy of the License at
10ae77b8caSAriel Constenla-Haile *
11ae77b8caSAriel Constenla-Haile * http://www.apache.org/licenses/LICENSE-2.0
12ae77b8caSAriel Constenla-Haile *
13ae77b8caSAriel Constenla-Haile * Unless required by applicable law or agreed to in writing,
14ae77b8caSAriel Constenla-Haile * software distributed under the License is distributed on an
15ae77b8caSAriel Constenla-Haile * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ae77b8caSAriel Constenla-Haile * KIND, either express or implied. See the License for the
17ae77b8caSAriel Constenla-Haile * specific language governing permissions and limitations
18ae77b8caSAriel Constenla-Haile * under the License.
19ae77b8caSAriel Constenla-Haile *
20ae77b8caSAriel Constenla-Haile *************************************************************/
21ae77b8caSAriel Constenla-Haile
22ae77b8caSAriel Constenla-Haile // MARKER(update_precomp.py): autogen include statement, do not remove
23ae77b8caSAriel Constenla-Haile #include "precompiled_shell.hxx"
24ae77b8caSAriel Constenla-Haile
25ae77b8caSAriel Constenla-Haile #include "syscmdmail.hxx"
26ae77b8caSAriel Constenla-Haile #include "cmdmailmsg.hxx"
27ae77b8caSAriel Constenla-Haile
28ae77b8caSAriel Constenla-Haile #include <com/sun/star/system/MailClientFlags.hpp>
29ae77b8caSAriel Constenla-Haile #include <com/sun/star/container/XNameAccess.hpp>
30ae77b8caSAriel Constenla-Haile #include <com/sun/star/beans/PropertyValue.hpp>
31ae77b8caSAriel Constenla-Haile #include <com/sun/star/beans/XPropertySet.hpp>
32ae77b8caSAriel Constenla-Haile
33ae77b8caSAriel Constenla-Haile #include <osl/file.hxx>
34ae77b8caSAriel Constenla-Haile #include <osl/thread.hxx>
35ae77b8caSAriel Constenla-Haile #include <rtl/bootstrap.hxx>
36ae77b8caSAriel Constenla-Haile #include <rtl/strbuf.hxx>
37ae77b8caSAriel Constenla-Haile
38ae77b8caSAriel Constenla-Haile #include <unistd.h>
39ae77b8caSAriel Constenla-Haile
40ae77b8caSAriel Constenla-Haile using com::sun::star::beans::PropertyValue;
41ae77b8caSAriel Constenla-Haile using com::sun::star::container::XNameAccess;
42ae77b8caSAriel Constenla-Haile using com::sun::star::system::XMailClient;
43ae77b8caSAriel Constenla-Haile using com::sun::star::system::XMailMessage;
44ae77b8caSAriel Constenla-Haile using rtl::OString;
45ae77b8caSAriel Constenla-Haile using rtl::OStringBuffer;
46ae77b8caSAriel Constenla-Haile using rtl::OUString;
47ae77b8caSAriel Constenla-Haile using rtl::OUStringToOString;
48ae77b8caSAriel Constenla-Haile
49ae77b8caSAriel Constenla-Haile using namespace com::sun::star::lang;
50ae77b8caSAriel Constenla-Haile using namespace com::sun::star::system::MailClientFlags;
51ae77b8caSAriel Constenla-Haile using namespace com::sun::star::uno;
52ae77b8caSAriel Constenla-Haile
53ae77b8caSAriel Constenla-Haile #define COMP_SERVICE_NAME "com.sun.star.system.SystemMailProvider"
54ae77b8caSAriel Constenla-Haile #define COMP_IMPL_NAME "com.sun.star.comp.system.unx.SystemMailProvider"
55ae77b8caSAriel Constenla-Haile
56ae77b8caSAriel Constenla-Haile namespace shell
57ae77b8caSAriel Constenla-Haile {
58ae77b8caSAriel Constenla-Haile
59ae77b8caSAriel Constenla-Haile namespace
60ae77b8caSAriel Constenla-Haile {
escapeDoubleQuotes(OStringBuffer & rBuffer,const OUString & ustr,rtl_TextEncoding iEncoding)61ae77b8caSAriel Constenla-Haile static void escapeDoubleQuotes( OStringBuffer &rBuffer,
62ae77b8caSAriel Constenla-Haile const OUString &ustr,
63ae77b8caSAriel Constenla-Haile rtl_TextEncoding iEncoding )
64ae77b8caSAriel Constenla-Haile {
65ae77b8caSAriel Constenla-Haile const OString rStr( OUStringToOString( ustr, iEncoding ) );
66ae77b8caSAriel Constenla-Haile sal_Int32 nIndex = rStr.indexOf('"');
67ae77b8caSAriel Constenla-Haile if ( nIndex == -1 )
68ae77b8caSAriel Constenla-Haile rBuffer.append( rStr );
69ae77b8caSAriel Constenla-Haile else
70ae77b8caSAriel Constenla-Haile {
71ae77b8caSAriel Constenla-Haile const sal_Char *pStart = rStr.getStr();
72ae77b8caSAriel Constenla-Haile const sal_Char *pFrom = pStart;
73ae77b8caSAriel Constenla-Haile const sal_Int32 nLen = rStr.getLength();
74*41983ec9Smseidel sal_Int32 nPrev = 0;
75ae77b8caSAriel Constenla-Haile do
76ae77b8caSAriel Constenla-Haile {
77ae77b8caSAriel Constenla-Haile rBuffer.append( pFrom, nIndex - nPrev );
78ae77b8caSAriel Constenla-Haile rBuffer.append( RTL_CONSTASCII_STRINGPARAM( "\\\"" ) );
79ae77b8caSAriel Constenla-Haile nIndex++;
80ae77b8caSAriel Constenla-Haile pFrom = pStart + nIndex;
81ae77b8caSAriel Constenla-Haile nPrev = nIndex;
82ae77b8caSAriel Constenla-Haile }
83ae77b8caSAriel Constenla-Haile while ( ( nIndex = rStr.indexOf( '"' , nIndex ) ) != -1 );
84ae77b8caSAriel Constenla-Haile
85ae77b8caSAriel Constenla-Haile rBuffer.append( pFrom, nLen - nPrev );
86ae77b8caSAriel Constenla-Haile }
87ae77b8caSAriel Constenla-Haile }
88ae77b8caSAriel Constenla-Haile }
89ae77b8caSAriel Constenla-Haile
SystemCommandMail(const Reference<XComponentContext> & xContext)90ae77b8caSAriel Constenla-Haile SystemCommandMail::SystemCommandMail(
91ae77b8caSAriel Constenla-Haile const Reference< XComponentContext >& xContext )
92ae77b8caSAriel Constenla-Haile : SystemCommandMail_Base( m_aMutex )
93ae77b8caSAriel Constenla-Haile , m_xContext( xContext )
94ae77b8caSAriel Constenla-Haile {
95ae77b8caSAriel Constenla-Haile try
96ae77b8caSAriel Constenla-Haile {
97ae77b8caSAriel Constenla-Haile m_xConfigurationProvider.set(
98ae77b8caSAriel Constenla-Haile m_xContext->getServiceManager()->createInstanceWithContext(
99ae77b8caSAriel Constenla-Haile OUString( RTL_CONSTASCII_USTRINGPARAM(
100ae77b8caSAriel Constenla-Haile "com.sun.star.configuration.ConfigurationProvider") ),
101ae77b8caSAriel Constenla-Haile m_xContext ),
102ae77b8caSAriel Constenla-Haile UNO_QUERY );
103ae77b8caSAriel Constenla-Haile }
104ae77b8caSAriel Constenla-Haile catch(...){}
105ae77b8caSAriel Constenla-Haile }
106ae77b8caSAriel Constenla-Haile
~SystemCommandMail()107ae77b8caSAriel Constenla-Haile SystemCommandMail::~SystemCommandMail()
108ae77b8caSAriel Constenla-Haile {
109ae77b8caSAriel Constenla-Haile m_xConfigurationProvider.clear();
110ae77b8caSAriel Constenla-Haile m_xContext.clear();
111ae77b8caSAriel Constenla-Haile }
112ae77b8caSAriel Constenla-Haile
113ae77b8caSAriel Constenla-Haile Reference< XMailClient > SAL_CALL
queryMailClient()114ae77b8caSAriel Constenla-Haile SystemCommandMail::queryMailClient()
115ae77b8caSAriel Constenla-Haile throw ( RuntimeException )
116ae77b8caSAriel Constenla-Haile {
117ae77b8caSAriel Constenla-Haile return Reference< XMailClient >(
118ae77b8caSAriel Constenla-Haile static_cast < cppu::OWeakObject * >( this ), UNO_QUERY );
119ae77b8caSAriel Constenla-Haile }
120ae77b8caSAriel Constenla-Haile
121ae77b8caSAriel Constenla-Haile
122ae77b8caSAriel Constenla-Haile Reference< XMailMessage > SAL_CALL
createMailMessage()123ae77b8caSAriel Constenla-Haile SystemCommandMail::createMailMessage()
124ae77b8caSAriel Constenla-Haile throw ( RuntimeException )
125ae77b8caSAriel Constenla-Haile {
126ae77b8caSAriel Constenla-Haile return Reference< XMailMessage >(
127ae77b8caSAriel Constenla-Haile static_cast< cppu::OWeakObject *>(
128ae77b8caSAriel Constenla-Haile new CmdMailMsg() ),
129ae77b8caSAriel Constenla-Haile UNO_QUERY );
130ae77b8caSAriel Constenla-Haile }
131ae77b8caSAriel Constenla-Haile
132ae77b8caSAriel Constenla-Haile
133ae77b8caSAriel Constenla-Haile void SAL_CALL
sendMailMessage(const Reference<XMailMessage> & xMailMessage,sal_Int32)134ae77b8caSAriel Constenla-Haile SystemCommandMail::sendMailMessage(
135ae77b8caSAriel Constenla-Haile const Reference< XMailMessage >& xMailMessage,
136ae77b8caSAriel Constenla-Haile sal_Int32 /*aFlag*/ )
137ae77b8caSAriel Constenla-Haile throw (IllegalArgumentException, Exception, RuntimeException)
138ae77b8caSAriel Constenla-Haile {
139ae77b8caSAriel Constenla-Haile osl::ClearableMutexGuard aGuard( m_aMutex );
140ae77b8caSAriel Constenla-Haile Reference< XMultiServiceFactory > xConfigurationProvider = m_xConfigurationProvider;
141ae77b8caSAriel Constenla-Haile aGuard.clear();
142ae77b8caSAriel Constenla-Haile
143ae77b8caSAriel Constenla-Haile if ( ! xMailMessage.is() )
144ae77b8caSAriel Constenla-Haile {
145ae77b8caSAriel Constenla-Haile throw IllegalArgumentException(
146ae77b8caSAriel Constenla-Haile OUString(RTL_CONSTASCII_USTRINGPARAM( "No message specified" )),
147ae77b8caSAriel Constenla-Haile static_cast < XMailClient * > (this), 1 );
148ae77b8caSAriel Constenla-Haile }
149ae77b8caSAriel Constenla-Haile
150ae77b8caSAriel Constenla-Haile if( ! xConfigurationProvider.is() )
151ae77b8caSAriel Constenla-Haile {
152ae77b8caSAriel Constenla-Haile throw Exception(
153ae77b8caSAriel Constenla-Haile OUString(RTL_CONSTASCII_USTRINGPARAM( "Can not access configuration" )),
154ae77b8caSAriel Constenla-Haile static_cast < XMailClient * > (this) );
155ae77b8caSAriel Constenla-Haile }
156ae77b8caSAriel Constenla-Haile
157ae77b8caSAriel Constenla-Haile OStringBuffer aBuffer;
158ae77b8caSAriel Constenla-Haile aBuffer.append("\"");
159ae77b8caSAriel Constenla-Haile
160ae77b8caSAriel Constenla-Haile OUString aProgramURL(RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/senddoc"));
161ae77b8caSAriel Constenla-Haile rtl::Bootstrap::expandMacros(aProgramURL);
162ae77b8caSAriel Constenla-Haile OUString aProgram;
163ae77b8caSAriel Constenla-Haile if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(aProgramURL, aProgram))
164ae77b8caSAriel Constenla-Haile {
165ae77b8caSAriel Constenla-Haile throw Exception(
166ae77b8caSAriel Constenla-Haile OUString(RTL_CONSTASCII_USTRINGPARAM("Cound not convert executable path")),
167ae77b8caSAriel Constenla-Haile static_cast < XMailClient * > (this));
168ae77b8caSAriel Constenla-Haile }
169ae77b8caSAriel Constenla-Haile
170ae77b8caSAriel Constenla-Haile const rtl_TextEncoding iEncoding = osl_getThreadTextEncoding();
171ae77b8caSAriel Constenla-Haile aBuffer.append(OUStringToOString(aProgram, iEncoding));
172ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
173ae77b8caSAriel Constenla-Haile
174ae77b8caSAriel Constenla-Haile try
175ae77b8caSAriel Constenla-Haile {
176ae77b8caSAriel Constenla-Haile // Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer
177ae77b8caSAriel Constenla-Haile // configuration node to retriece the users preferred email application. This may
178ae77b8caSAriel Constenla-Haile // transparently by redirected to e.g. the corresponding GConf setting in GNOME.
179ae77b8caSAriel Constenla-Haile OUString aConfigRoot = OUString(
180ae77b8caSAriel Constenla-Haile RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer" ) );
181ae77b8caSAriel Constenla-Haile
182ae77b8caSAriel Constenla-Haile PropertyValue aProperty;
183ae77b8caSAriel Constenla-Haile aProperty.Name = OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath" ));
184ae77b8caSAriel Constenla-Haile aProperty.Value = makeAny( aConfigRoot );
185ae77b8caSAriel Constenla-Haile
186ae77b8caSAriel Constenla-Haile Sequence< Any > aArgumentList( 1 );
187ae77b8caSAriel Constenla-Haile aArgumentList[0] = makeAny( aProperty );
188ae77b8caSAriel Constenla-Haile
189ae77b8caSAriel Constenla-Haile Reference< XNameAccess > xNameAccess =
190ae77b8caSAriel Constenla-Haile Reference< XNameAccess > (
191ae77b8caSAriel Constenla-Haile xConfigurationProvider->createInstanceWithArguments(
192ae77b8caSAriel Constenla-Haile OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" )),
193ae77b8caSAriel Constenla-Haile aArgumentList ),
194ae77b8caSAriel Constenla-Haile UNO_QUERY );
195ae77b8caSAriel Constenla-Haile
196ae77b8caSAriel Constenla-Haile if( xNameAccess.is() )
197ae77b8caSAriel Constenla-Haile {
198ae77b8caSAriel Constenla-Haile OUString aMailer;
199ae77b8caSAriel Constenla-Haile
200ae77b8caSAriel Constenla-Haile // Retrieve the value for "Program" node and append it feed senddoc with it
201ae77b8caSAriel Constenla-Haile // using the (undocumented) --mailclient switch
202ae77b8caSAriel Constenla-Haile xNameAccess->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM("Program") ) ) >>= aMailer;
203ae77b8caSAriel Constenla-Haile
204ae77b8caSAriel Constenla-Haile if( aMailer.getLength() )
205ae77b8caSAriel Constenla-Haile {
206ae77b8caSAriel Constenla-Haile // make sure we have a system path
207ae77b8caSAriel Constenla-Haile osl::FileBase::getSystemPathFromFileURL( aMailer, aMailer );
208ae77b8caSAriel Constenla-Haile
209ae77b8caSAriel Constenla-Haile aBuffer.append("--mailclient ");
210ae77b8caSAriel Constenla-Haile aBuffer.append(OUStringToOString( aMailer, iEncoding ));
211ae77b8caSAriel Constenla-Haile aBuffer.append(" ");
212ae77b8caSAriel Constenla-Haile }
213ae77b8caSAriel Constenla-Haile #ifdef MACOSX
214ae77b8caSAriel Constenla-Haile else
215ae77b8caSAriel Constenla-Haile aBuffer.append("--mailclient Mail ");
216ae77b8caSAriel Constenla-Haile #endif
217ae77b8caSAriel Constenla-Haile }
218ae77b8caSAriel Constenla-Haile
219ae77b8caSAriel Constenla-Haile }
220ae77b8caSAriel Constenla-Haile catch( RuntimeException e )
221ae77b8caSAriel Constenla-Haile {
222ae77b8caSAriel Constenla-Haile OSL_TRACE( "RuntimeException caught accessing configuration provider." );
223ae77b8caSAriel Constenla-Haile OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
224ae77b8caSAriel Constenla-Haile throw e;
225ae77b8caSAriel Constenla-Haile }
226ae77b8caSAriel Constenla-Haile
227ae77b8caSAriel Constenla-Haile // Append body if set in the message
228ae77b8caSAriel Constenla-Haile OUString ustr = xMailMessage->getBody();
229ae77b8caSAriel Constenla-Haile if ( ustr.getLength() > 0 )
230ae77b8caSAriel Constenla-Haile {
231ae77b8caSAriel Constenla-Haile aBuffer.append("--body \"");
232ae77b8caSAriel Constenla-Haile escapeDoubleQuotes( aBuffer, ustr, iEncoding );
233ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
234ae77b8caSAriel Constenla-Haile }
235ae77b8caSAriel Constenla-Haile
236ae77b8caSAriel Constenla-Haile // Append subject if set in the message
237ae77b8caSAriel Constenla-Haile ustr = xMailMessage->getSubject();
238ae77b8caSAriel Constenla-Haile if ( ustr.getLength() > 0 )
239ae77b8caSAriel Constenla-Haile {
240ae77b8caSAriel Constenla-Haile aBuffer.append("--subject \"");
241ae77b8caSAriel Constenla-Haile escapeDoubleQuotes( aBuffer, ustr, iEncoding );
242ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
243ae77b8caSAriel Constenla-Haile }
244ae77b8caSAriel Constenla-Haile
245ae77b8caSAriel Constenla-Haile // Append originator if set in the message
246ae77b8caSAriel Constenla-Haile if ( xMailMessage->getOriginator().getLength() > 0 )
247ae77b8caSAriel Constenla-Haile {
248ae77b8caSAriel Constenla-Haile aBuffer.append("--from \"");
249ae77b8caSAriel Constenla-Haile aBuffer.append(OUStringToOString(xMailMessage->getOriginator(), iEncoding));
250ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
251ae77b8caSAriel Constenla-Haile }
252ae77b8caSAriel Constenla-Haile
253ae77b8caSAriel Constenla-Haile // Append receipient if set in the message
254ae77b8caSAriel Constenla-Haile if ( xMailMessage->getRecipient().getLength() > 0 )
255ae77b8caSAriel Constenla-Haile {
256ae77b8caSAriel Constenla-Haile aBuffer.append("--to \"");
257ae77b8caSAriel Constenla-Haile aBuffer.append(OUStringToOString(xMailMessage->getRecipient(), iEncoding));
258ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
259ae77b8caSAriel Constenla-Haile }
260ae77b8caSAriel Constenla-Haile
261ae77b8caSAriel Constenla-Haile // Append carbon copy receipients set in the message
262ae77b8caSAriel Constenla-Haile Sequence< OUString > aStringList = xMailMessage->getCcRecipient();
263ae77b8caSAriel Constenla-Haile sal_Int32 n, nmax = aStringList.getLength();
264ae77b8caSAriel Constenla-Haile for ( n = 0; n < nmax; n++ )
265ae77b8caSAriel Constenla-Haile {
266ae77b8caSAriel Constenla-Haile aBuffer.append("--cc \"");
267ae77b8caSAriel Constenla-Haile aBuffer.append(OUStringToOString(aStringList[n], iEncoding));
268ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
269ae77b8caSAriel Constenla-Haile }
270ae77b8caSAriel Constenla-Haile
271ae77b8caSAriel Constenla-Haile // Append blind carbon copy receipients set in the message
272ae77b8caSAriel Constenla-Haile aStringList = xMailMessage->getBccRecipient();
273ae77b8caSAriel Constenla-Haile nmax = aStringList.getLength();
274ae77b8caSAriel Constenla-Haile for ( n = 0; n < nmax; n++ )
275ae77b8caSAriel Constenla-Haile {
276ae77b8caSAriel Constenla-Haile aBuffer.append("--bcc \"");
277ae77b8caSAriel Constenla-Haile aBuffer.append(OUStringToOString(aStringList[n], iEncoding));
278ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
279ae77b8caSAriel Constenla-Haile }
280ae77b8caSAriel Constenla-Haile
281ae77b8caSAriel Constenla-Haile // Append attachments set in the message
282ae77b8caSAriel Constenla-Haile aStringList = xMailMessage->getAttachement();
283ae77b8caSAriel Constenla-Haile nmax = aStringList.getLength();
284ae77b8caSAriel Constenla-Haile for ( n = 0; n < nmax; n++ )
285ae77b8caSAriel Constenla-Haile {
286ae77b8caSAriel Constenla-Haile OUString aSystemPath;
287ae77b8caSAriel Constenla-Haile if ( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
288ae77b8caSAriel Constenla-Haile {
289ae77b8caSAriel Constenla-Haile aBuffer.append("--attach \"");
290ae77b8caSAriel Constenla-Haile aBuffer.append(OUStringToOString(aSystemPath, iEncoding));
291ae77b8caSAriel Constenla-Haile aBuffer.append("\" ");
292ae77b8caSAriel Constenla-Haile }
293ae77b8caSAriel Constenla-Haile }
294ae77b8caSAriel Constenla-Haile
295ae77b8caSAriel Constenla-Haile OString cmd = aBuffer.makeStringAndClear();
296ae77b8caSAriel Constenla-Haile if ( 0 != pclose(popen(cmd.getStr(), "w")) )
297ae77b8caSAriel Constenla-Haile {
298ae77b8caSAriel Constenla-Haile throw ::com::sun::star::uno::Exception(
299ae77b8caSAriel Constenla-Haile OUString(RTL_CONSTASCII_USTRINGPARAM( "No mail client configured" )),
300ae77b8caSAriel Constenla-Haile static_cast < XMailClient * > (this) );
301ae77b8caSAriel Constenla-Haile }
302ae77b8caSAriel Constenla-Haile }
303ae77b8caSAriel Constenla-Haile
304ae77b8caSAriel Constenla-Haile OUString SAL_CALL
getImplementationName()305ae77b8caSAriel Constenla-Haile SystemCommandMail::getImplementationName( )
306ae77b8caSAriel Constenla-Haile throw( RuntimeException )
307ae77b8caSAriel Constenla-Haile {
308ae77b8caSAriel Constenla-Haile return getImplementationName_static();
309ae77b8caSAriel Constenla-Haile }
310ae77b8caSAriel Constenla-Haile
311ae77b8caSAriel Constenla-Haile sal_Bool SAL_CALL
supportsService(const OUString & ServiceName)312ae77b8caSAriel Constenla-Haile SystemCommandMail::supportsService(
313ae77b8caSAriel Constenla-Haile const OUString& ServiceName )
314ae77b8caSAriel Constenla-Haile throw( RuntimeException )
315ae77b8caSAriel Constenla-Haile {
316ae77b8caSAriel Constenla-Haile Sequence < OUString > SupportedServicesNames = getSupportedServiceNames_static();
317ae77b8caSAriel Constenla-Haile
318ae77b8caSAriel Constenla-Haile for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
319ae77b8caSAriel Constenla-Haile if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
320ae77b8caSAriel Constenla-Haile return sal_True;
321ae77b8caSAriel Constenla-Haile
322ae77b8caSAriel Constenla-Haile return sal_False;
323ae77b8caSAriel Constenla-Haile }
324ae77b8caSAriel Constenla-Haile
325ae77b8caSAriel Constenla-Haile Sequence< OUString > SAL_CALL
getSupportedServiceNames()326ae77b8caSAriel Constenla-Haile SystemCommandMail::getSupportedServiceNames()
327ae77b8caSAriel Constenla-Haile throw( RuntimeException )
328ae77b8caSAriel Constenla-Haile {
329ae77b8caSAriel Constenla-Haile return getSupportedServiceNames_static();
330ae77b8caSAriel Constenla-Haile }
331ae77b8caSAriel Constenla-Haile
332ae77b8caSAriel Constenla-Haile Reference< XInterface >
Create(const Reference<XComponentContext> & xContext)333ae77b8caSAriel Constenla-Haile SystemCommandMail::Create(
334ae77b8caSAriel Constenla-Haile const Reference< XComponentContext > &xContext)
335ae77b8caSAriel Constenla-Haile {
336ae77b8caSAriel Constenla-Haile return Reference< XInterface >(
337ae77b8caSAriel Constenla-Haile static_cast< cppu::OWeakObject *>(
338ae77b8caSAriel Constenla-Haile new SystemCommandMail( xContext ) ) );
339ae77b8caSAriel Constenla-Haile }
340ae77b8caSAriel Constenla-Haile
341ae77b8caSAriel Constenla-Haile OUString
getImplementationName_static()342ae77b8caSAriel Constenla-Haile SystemCommandMail::getImplementationName_static()
343ae77b8caSAriel Constenla-Haile {
344ae77b8caSAriel Constenla-Haile return OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_IMPL_NAME ) );
345ae77b8caSAriel Constenla-Haile }
346ae77b8caSAriel Constenla-Haile
347ae77b8caSAriel Constenla-Haile Sequence< OUString >
getSupportedServiceNames_static()348ae77b8caSAriel Constenla-Haile SystemCommandMail::getSupportedServiceNames_static()
349ae77b8caSAriel Constenla-Haile {
350ae77b8caSAriel Constenla-Haile Sequence< OUString > aRet(1);
351ae77b8caSAriel Constenla-Haile aRet[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_SERVICE_NAME ) );
352ae77b8caSAriel Constenla-Haile return aRet;
353ae77b8caSAriel Constenla-Haile }
354ae77b8caSAriel Constenla-Haile
355ae77b8caSAriel Constenla-Haile }
356