1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_shell.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski
28*b1cdbd2cSJim Jagielski //-----------------------------------------------------------
29*b1cdbd2cSJim Jagielski // interface includes
30*b1cdbd2cSJim Jagielski //-----------------------------------------------------------
31*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XComponent.hpp>
32*b1cdbd2cSJim Jagielski #include <com/sun/star/registry/XSimpleRegistry.hpp>
33*b1cdbd2cSJim Jagielski #include <com/sun/star/system/XSystemMailProvider.hpp>
34*b1cdbd2cSJim Jagielski #include <cppuhelper/servicefactory.hxx>
35*b1cdbd2cSJim Jagielski #include <cppuhelper/servicefactory.hxx>
36*b1cdbd2cSJim Jagielski #include <rtl/ustring.hxx>
37*b1cdbd2cSJim Jagielski #include <sal/types.h>
38*b1cdbd2cSJim Jagielski #include <osl/diagnose.h>
39*b1cdbd2cSJim Jagielski
40*b1cdbd2cSJim Jagielski #include <stdio.h>
41*b1cdbd2cSJim Jagielski #if defined _MSC_VER
42*b1cdbd2cSJim Jagielski #pragma warning(push, 1)
43*b1cdbd2cSJim Jagielski #endif
44*b1cdbd2cSJim Jagielski #include <windows.h>
45*b1cdbd2cSJim Jagielski #if defined _MSC_VER
46*b1cdbd2cSJim Jagielski #pragma warning(pop)
47*b1cdbd2cSJim Jagielski #endif
48*b1cdbd2cSJim Jagielski
49*b1cdbd2cSJim Jagielski #include <osl/file.hxx>
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
52*b1cdbd2cSJim Jagielski // namesapces
53*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
54*b1cdbd2cSJim Jagielski
55*b1cdbd2cSJim Jagielski using namespace ::rtl ;
56*b1cdbd2cSJim Jagielski using namespace ::cppu ;
57*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::uno ;
58*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::lang ;
59*b1cdbd2cSJim Jagielski using namespace std ;
60*b1cdbd2cSJim Jagielski using namespace com::sun::star::system;
61*b1cdbd2cSJim Jagielski
62*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
63*b1cdbd2cSJim Jagielski // defines
64*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
65*b1cdbd2cSJim Jagielski
66*b1cdbd2cSJim Jagielski #define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
67*b1cdbd2cSJim Jagielski
68*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
69*b1cdbd2cSJim Jagielski // global variables
70*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
71*b1cdbd2cSJim Jagielski
72*b1cdbd2cSJim Jagielski Reference< XMultiServiceFactory > g_xFactory;
73*b1cdbd2cSJim Jagielski
74*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
75*b1cdbd2cSJim Jagielski // main
76*b1cdbd2cSJim Jagielski //--------------------------------------------------------------
77*b1cdbd2cSJim Jagielski
78*b1cdbd2cSJim Jagielski
79*b1cdbd2cSJim Jagielski // int SAL_CALL main(int nArgc, char* Argv[], char* pEnv[] )
80*b1cdbd2cSJim Jagielski // make Warning free, leave out typename
main(int,char *,char *)81*b1cdbd2cSJim Jagielski int SAL_CALL main(int , char*, char* )
82*b1cdbd2cSJim Jagielski {
83*b1cdbd2cSJim Jagielski //-------------------------------------------------
84*b1cdbd2cSJim Jagielski // get the global service-manager
85*b1cdbd2cSJim Jagielski //-------------------------------------------------
86*b1cdbd2cSJim Jagielski
87*b1cdbd2cSJim Jagielski // Get global factory for uno services.
88*b1cdbd2cSJim Jagielski OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) );
89*b1cdbd2cSJim Jagielski Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) );
90*b1cdbd2cSJim Jagielski
91*b1cdbd2cSJim Jagielski // Print a message if an error occured.
92*b1cdbd2cSJim Jagielski if ( g_xFactory.is() == sal_False )
93*b1cdbd2cSJim Jagielski {
94*b1cdbd2cSJim Jagielski OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory");
95*b1cdbd2cSJim Jagielski return(-1);
96*b1cdbd2cSJim Jagielski }
97*b1cdbd2cSJim Jagielski
98*b1cdbd2cSJim Jagielski printf("Creating RegistryServiceFactory successful\n");
99*b1cdbd2cSJim Jagielski
100*b1cdbd2cSJim Jagielski //-------------------------------------------------
101*b1cdbd2cSJim Jagielski // try to get an Interface to a XFilePicker Service
102*b1cdbd2cSJim Jagielski //-------------------------------------------------
103*b1cdbd2cSJim Jagielski
104*b1cdbd2cSJim Jagielski try
105*b1cdbd2cSJim Jagielski {
106*b1cdbd2cSJim Jagielski Reference< XSystemMailProvider > xSmplMailClientSuppl(
107*b1cdbd2cSJim Jagielski g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SimpleSystemMail" ) ), UNO_QUERY );
108*b1cdbd2cSJim Jagielski
109*b1cdbd2cSJim Jagielski if ( !xSmplMailClientSuppl.is() )
110*b1cdbd2cSJim Jagielski {
111*b1cdbd2cSJim Jagielski OSL_ENSURE( sal_False, "Error creating SimpleSystemMail Service" );
112*b1cdbd2cSJim Jagielski return(-1);
113*b1cdbd2cSJim Jagielski }
114*b1cdbd2cSJim Jagielski
115*b1cdbd2cSJim Jagielski Reference< XMailClient > xSmplMailClient(
116*b1cdbd2cSJim Jagielski xSmplMailClientSuppl->queryMailClient( ) );
117*b1cdbd2cSJim Jagielski
118*b1cdbd2cSJim Jagielski if ( xSmplMailClient.is( ) )
119*b1cdbd2cSJim Jagielski {
120*b1cdbd2cSJim Jagielski Reference< XMailMessage > xSmplMailMsg(
121*b1cdbd2cSJim Jagielski xSmplMailClient->createMailMessage( ) );
122*b1cdbd2cSJim Jagielski
123*b1cdbd2cSJim Jagielski if ( xSmplMailMsg.is( ) )
124*b1cdbd2cSJim Jagielski {
125*b1cdbd2cSJim Jagielski xSmplMailMsg->setRecipient( OUString::createFromAscii("tino.rachui@germany.sun.com") );
126*b1cdbd2cSJim Jagielski xSmplMailMsg->setOriginator( OUString::createFromAscii( "tino.rachui@germany.sun.com" ) );
127*b1cdbd2cSJim Jagielski
128*b1cdbd2cSJim Jagielski Sequence< OUString > ccRecips( 1 );
129*b1cdbd2cSJim Jagielski ccRecips[0] = OUString::createFromAscii( "tino.rachui@germany.sun.com" );
130*b1cdbd2cSJim Jagielski
131*b1cdbd2cSJim Jagielski xSmplMailMsg->setCcRecipient( ccRecips );
132*b1cdbd2cSJim Jagielski
133*b1cdbd2cSJim Jagielski Sequence< OUString > bccRecips( 1 );
134*b1cdbd2cSJim Jagielski bccRecips[0] = OUString::createFromAscii( "tino.rachui@germany.sun.com" );
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim Jagielski xSmplMailMsg->setBccRecipient( bccRecips );
137*b1cdbd2cSJim Jagielski
138*b1cdbd2cSJim Jagielski xSmplMailMsg->setSubject( OUString::createFromAscii( "Mapi Test" ) );
139*b1cdbd2cSJim Jagielski
140*b1cdbd2cSJim Jagielski Sequence< OUString > attachements( 2 );
141*b1cdbd2cSJim Jagielski
142*b1cdbd2cSJim Jagielski OUString aFile = OUString::createFromAscii( "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testprx.exe" );
143*b1cdbd2cSJim Jagielski OUString aFileURL;
144*b1cdbd2cSJim Jagielski
145*b1cdbd2cSJim Jagielski osl::FileBase::getFileURLFromSystemPath( aFile, aFileURL );
146*b1cdbd2cSJim Jagielski attachements[0] = aFileURL;
147*b1cdbd2cSJim Jagielski
148*b1cdbd2cSJim Jagielski aFile = OUString::createFromAscii( "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testsyssh.exe" );
149*b1cdbd2cSJim Jagielski osl::FileBase::getFileURLFromSystemPath( aFile, aFileURL );
150*b1cdbd2cSJim Jagielski
151*b1cdbd2cSJim Jagielski attachements[1] = aFile;
152*b1cdbd2cSJim Jagielski
153*b1cdbd2cSJim Jagielski xSmplMailMsg->setAttachement( attachements );
154*b1cdbd2cSJim Jagielski
155*b1cdbd2cSJim Jagielski xSmplMailClient->sendMailMessage( xSmplMailMsg, 0 );
156*b1cdbd2cSJim Jagielski }
157*b1cdbd2cSJim Jagielski }
158*b1cdbd2cSJim Jagielski }
159*b1cdbd2cSJim Jagielski catch( Exception& )
160*b1cdbd2cSJim Jagielski {
161*b1cdbd2cSJim Jagielski }
162*b1cdbd2cSJim Jagielski
163*b1cdbd2cSJim Jagielski //--------------------------------------------------
164*b1cdbd2cSJim Jagielski // shutdown
165*b1cdbd2cSJim Jagielski //--------------------------------------------------
166*b1cdbd2cSJim Jagielski
167*b1cdbd2cSJim Jagielski // Cast factory to XComponent
168*b1cdbd2cSJim Jagielski Reference< XComponent > xComponent( g_xFactory, UNO_QUERY );
169*b1cdbd2cSJim Jagielski
170*b1cdbd2cSJim Jagielski // Print a message if an error occured.
171*b1cdbd2cSJim Jagielski if ( xComponent.is() == sal_False )
172*b1cdbd2cSJim Jagielski {
173*b1cdbd2cSJim Jagielski OSL_ENSURE(sal_False, "Error shuting down");
174*b1cdbd2cSJim Jagielski }
175*b1cdbd2cSJim Jagielski
176*b1cdbd2cSJim Jagielski // Dispose and clear factory
177*b1cdbd2cSJim Jagielski xComponent->dispose();
178*b1cdbd2cSJim Jagielski g_xFactory.clear();
179*b1cdbd2cSJim Jagielski g_xFactory = Reference< XMultiServiceFactory >();
180*b1cdbd2cSJim Jagielski
181*b1cdbd2cSJim Jagielski printf("Test successful\n");
182*b1cdbd2cSJim Jagielski
183*b1cdbd2cSJim Jagielski return 0;
184*b1cdbd2cSJim Jagielski }
185