xref: /aoo41x/main/framework/source/jobs/jobdata.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //________________________________
32*cdf0e10cSrcweir //	my own includes
33*cdf0e10cSrcweir #include <jobs/jobdata.hxx>
34*cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
35*cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
36*cdf0e10cSrcweir #include <classes/converter.hxx>
37*cdf0e10cSrcweir #include <general.h>
38*cdf0e10cSrcweir #include <services.h>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir //________________________________
41*cdf0e10cSrcweir //	interface includes
42*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir //________________________________
48*cdf0e10cSrcweir //	includes of other projects
49*cdf0e10cSrcweir #include <tools/wldcrd.hxx>
50*cdf0e10cSrcweir #include <unotools/configpathes.hxx>
51*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
52*cdf0e10cSrcweir #include <vcl/svapp.hxx>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //________________________________
55*cdf0e10cSrcweir //	namespace
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir namespace framework{
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir //________________________________
60*cdf0e10cSrcweir //  exported const
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir const sal_Char* JobData::JOBCFG_ROOT              = "/org.openoffice.Office.Jobs/Jobs/"   ;
63*cdf0e10cSrcweir const sal_Char* JobData::JOBCFG_PROP_SERVICE      = "Service"                             ;
64*cdf0e10cSrcweir const sal_Char* JobData::JOBCFG_PROP_CONTEXT      = "Context"                             ;
65*cdf0e10cSrcweir const sal_Char* JobData::JOBCFG_PROP_ARGUMENTS    = "Arguments"                           ;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir const sal_Char* JobData::EVENTCFG_ROOT            = "/org.openoffice.Office.Jobs/Events/" ;
68*cdf0e10cSrcweir const sal_Char* JobData::EVENTCFG_PATH_JOBLIST    = "/JobList"                            ;
69*cdf0e10cSrcweir const sal_Char* JobData::EVENTCFG_PROP_ADMINTIME  = "AdminTime"                           ;
70*cdf0e10cSrcweir const sal_Char* JobData::EVENTCFG_PROP_USERTIME   = "UserTime"                            ;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir const sal_Char* JobData::PROPSET_CONFIG           = "Config"                              ;
73*cdf0e10cSrcweir const sal_Char* JobData::PROPSET_OWNCONFIG        = "JobConfig"                           ;
74*cdf0e10cSrcweir const sal_Char* JobData::PROPSET_ENVIRONMENT      = "Environment"                         ;
75*cdf0e10cSrcweir const sal_Char* JobData::PROPSET_DYNAMICDATA      = "DynamicData"                         ;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir const sal_Char* JobData::PROP_ALIAS               = "Alias"                               ;
78*cdf0e10cSrcweir const sal_Char* JobData::PROP_EVENTNAME           = "EventName"                           ;
79*cdf0e10cSrcweir const sal_Char* JobData::PROP_ENVTYPE             = "EnvType"                             ;
80*cdf0e10cSrcweir const sal_Char* JobData::PROP_FRAME               = "Frame"                               ;
81*cdf0e10cSrcweir const sal_Char* JobData::PROP_MODEL               = "Model"                               ;
82*cdf0e10cSrcweir const sal_Char* JobData::PROP_SERVICE             = "Service"                             ;
83*cdf0e10cSrcweir const sal_Char* JobData::PROP_CONTEXT             = "Context"                             ;
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir //________________________________
86*cdf0e10cSrcweir //	non exported definitions
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir //________________________________
89*cdf0e10cSrcweir //	declarations
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir //________________________________
92*cdf0e10cSrcweir /**
93*cdf0e10cSrcweir     @short      standard ctor
94*cdf0e10cSrcweir     @descr      It initialize this new instance.
95*cdf0e10cSrcweir                 But for real working it's neccessary to call setAlias() or setService() later.
96*cdf0e10cSrcweir                 Because we need the job data ...
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     @param      xSMGR
99*cdf0e10cSrcweir                     reference to the uno service manager
100*cdf0e10cSrcweir */
101*cdf0e10cSrcweir JobData::JobData( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
102*cdf0e10cSrcweir     : ThreadHelpBase(&Application::GetSolarMutex())
103*cdf0e10cSrcweir     , m_xSMGR       (xSMGR                        )
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir     // share code for member initialization with defaults!
106*cdf0e10cSrcweir     impl_reset();
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir //________________________________
110*cdf0e10cSrcweir /**
111*cdf0e10cSrcweir     @short  copy ctor
112*cdf0e10cSrcweir     @descr  Sometimes such job data container must be moved from one using place
113*cdf0e10cSrcweir             to another one. Then a copy ctor and copy operator must be available.
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     @param  rCopy
116*cdf0e10cSrcweir                 the original instance, from which we must copy all data
117*cdf0e10cSrcweir */
118*cdf0e10cSrcweir JobData::JobData( const JobData& rCopy )
119*cdf0e10cSrcweir     : ThreadHelpBase(&Application::GetSolarMutex())
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     // use the copy operator to share the same code
122*cdf0e10cSrcweir     *this = rCopy;
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir //________________________________
126*cdf0e10cSrcweir /**
127*cdf0e10cSrcweir     @short  operator for coping JobData instances
128*cdf0e10cSrcweir     @descr  Sometimes such job data container must be moved from one using place
129*cdf0e10cSrcweir             to another one. Then a copy ctor and copy operator must be available.
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     @param  rCopy
132*cdf0e10cSrcweir                 the original instance, from which we must copy all data
133*cdf0e10cSrcweir */
134*cdf0e10cSrcweir void JobData::operator=( const JobData& rCopy )
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir     /* SAFE { */
137*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
138*cdf0e10cSrcweir     // Please don't copy the uno service manager reference.
139*cdf0e10cSrcweir     // That can change the uno context, which isn't a good idea!
140*cdf0e10cSrcweir     m_eMode                = rCopy.m_eMode               ;
141*cdf0e10cSrcweir     m_eEnvironment         = rCopy.m_eEnvironment        ;
142*cdf0e10cSrcweir     m_sAlias               = rCopy.m_sAlias              ;
143*cdf0e10cSrcweir     m_sService             = rCopy.m_sService            ;
144*cdf0e10cSrcweir     m_sContext             = rCopy.m_sContext            ;
145*cdf0e10cSrcweir     m_sEvent               = rCopy.m_sEvent              ;
146*cdf0e10cSrcweir     m_lArguments           = rCopy.m_lArguments          ;
147*cdf0e10cSrcweir     m_aLastExecutionResult = rCopy.m_aLastExecutionResult;
148*cdf0e10cSrcweir     aWriteLock.unlock();
149*cdf0e10cSrcweir     /* } SAFE */
150*cdf0e10cSrcweir }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir //________________________________
153*cdf0e10cSrcweir /**
154*cdf0e10cSrcweir     @short  let this instance die
155*cdf0e10cSrcweir     @descr  There is no chance any longer to work. We have to
156*cdf0e10cSrcweir             release all used ressources and free used memory.
157*cdf0e10cSrcweir */
158*cdf0e10cSrcweir JobData::~JobData()
159*cdf0e10cSrcweir {
160*cdf0e10cSrcweir     impl_reset();
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir //________________________________
164*cdf0e10cSrcweir /**
165*cdf0e10cSrcweir     @short      initalize this instance as a job with configuration
166*cdf0e10cSrcweir     @descr      They given alias can be used to adress some configuraton data.
167*cdf0e10cSrcweir                 We read it and fill our internal structures. Of course old informations
168*cdf0e10cSrcweir                 will be lost doing so.
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     @param      sAlias
171*cdf0e10cSrcweir                     the alias name of this job, used to locate job properties inside cfg
172*cdf0e10cSrcweir */
173*cdf0e10cSrcweir void JobData::setAlias( const ::rtl::OUString& sAlias )
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir     /* SAFE { */
176*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
177*cdf0e10cSrcweir     // delete all old informations! Otherwhise we mix it with the new one ...
178*cdf0e10cSrcweir     impl_reset();
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     // take over the new informations
181*cdf0e10cSrcweir     m_sAlias   = sAlias;
182*cdf0e10cSrcweir     m_eMode    = E_ALIAS;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     // try to open the configuration set of this job directly and get a property access to it
185*cdf0e10cSrcweir     // We open it readonly here
186*cdf0e10cSrcweir     ::rtl::OUString sKey;
187*cdf0e10cSrcweir     sKey  = ::rtl::OUString::createFromAscii(JOBCFG_ROOT);
188*cdf0e10cSrcweir     sKey += ::utl::wrapConfigurationElementName(m_sAlias);
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     ConfigAccess aConfig(m_xSMGR, sKey);
191*cdf0e10cSrcweir     aConfig.open(ConfigAccess::E_READONLY);
192*cdf0e10cSrcweir     if (aConfig.getMode()==ConfigAccess::E_CLOSED)
193*cdf0e10cSrcweir     {
194*cdf0e10cSrcweir         impl_reset();
195*cdf0e10cSrcweir         return;
196*cdf0e10cSrcweir     }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xJobProperties(aConfig.cfg(), css::uno::UNO_QUERY);
199*cdf0e10cSrcweir     if (xJobProperties.is())
200*cdf0e10cSrcweir     {
201*cdf0e10cSrcweir         css::uno::Any aValue;
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir         // read uno implementation name
204*cdf0e10cSrcweir         aValue   = xJobProperties->getPropertyValue(::rtl::OUString::createFromAscii(JOBCFG_PROP_SERVICE));
205*cdf0e10cSrcweir         aValue >>= m_sService;
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         // read module context list
208*cdf0e10cSrcweir         aValue   = xJobProperties->getPropertyValue(::rtl::OUString::createFromAscii(JOBCFG_PROP_CONTEXT));
209*cdf0e10cSrcweir         aValue >>= m_sContext;
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir         // read whole argument list
212*cdf0e10cSrcweir         aValue = xJobProperties->getPropertyValue(::rtl::OUString::createFromAscii(JOBCFG_PROP_ARGUMENTS));
213*cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xArgumentList;
214*cdf0e10cSrcweir         if (
215*cdf0e10cSrcweir             (aValue >>= xArgumentList)  &&
216*cdf0e10cSrcweir             (xArgumentList.is()      )
217*cdf0e10cSrcweir            )
218*cdf0e10cSrcweir         {
219*cdf0e10cSrcweir             css::uno::Sequence< ::rtl::OUString > lArgumentNames = xArgumentList->getElementNames();
220*cdf0e10cSrcweir             sal_Int32                             nCount         = lArgumentNames.getLength();
221*cdf0e10cSrcweir             m_lArguments.realloc(nCount);
222*cdf0e10cSrcweir             for (sal_Int32 i=0; i<nCount; ++i)
223*cdf0e10cSrcweir             {
224*cdf0e10cSrcweir                 m_lArguments[i].Name  = lArgumentNames[i];
225*cdf0e10cSrcweir                 m_lArguments[i].Value = xArgumentList->getByName(m_lArguments[i].Name);
226*cdf0e10cSrcweir             }
227*cdf0e10cSrcweir         }
228*cdf0e10cSrcweir     }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     aConfig.close();
231*cdf0e10cSrcweir     aWriteLock.unlock();
232*cdf0e10cSrcweir     /* } SAFE */
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir //________________________________
236*cdf0e10cSrcweir /**
237*cdf0e10cSrcweir     @short      initalize this instance as a job without configuration
238*cdf0e10cSrcweir     @descr      This job has no configuration data. We have to forget all old informations
239*cdf0e10cSrcweir                 and set only some of them new, so this instance can work.
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir     @param      sService
242*cdf0e10cSrcweir                     the uno service name of this "non configured" job
243*cdf0e10cSrcweir */
244*cdf0e10cSrcweir void JobData::setService( const ::rtl::OUString& sService )
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir     /* SAFE { */
247*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     // delete all old informations! Otherwhise we mix it with the new one ...
250*cdf0e10cSrcweir     impl_reset();
251*cdf0e10cSrcweir     // take over the new informations
252*cdf0e10cSrcweir     m_sService = sService;
253*cdf0e10cSrcweir     m_eMode    = E_SERVICE;
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     aWriteLock.unlock();
256*cdf0e10cSrcweir     /* } SAFE */
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir //________________________________
260*cdf0e10cSrcweir /**
261*cdf0e10cSrcweir     @short      initialize this instance with new job values.
262*cdf0e10cSrcweir     @descr      It reads automaticly all properties of the specified
263*cdf0e10cSrcweir                 job (using it's alias name) and "register it" for the
264*cdf0e10cSrcweir                 given event. This registration will not be validated against
265*cdf0e10cSrcweir                 the underlying configuration! (That must be done from outside.
266*cdf0e10cSrcweir                 Because the caller must have the configuration already open to
267*cdf0e10cSrcweir                 get the values for sEvent and sAlias! And doing so it can perform
268*cdf0e10cSrcweir                 only, if the time stanp values are readed outside too.
269*cdf0e10cSrcweir                 Further it make no sense to initialize and start a disabled job.
270*cdf0e10cSrcweir                 So this initialization method will be called for enabled jobs only.)
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir     @param      sEvent
273*cdf0e10cSrcweir                     the triggered event, for which this job should be started
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir     @param      sAlias
276*cdf0e10cSrcweir                     mark the required job inside event registration list
277*cdf0e10cSrcweir */
278*cdf0e10cSrcweir void JobData::setEvent( const ::rtl::OUString& sEvent ,
279*cdf0e10cSrcweir                         const ::rtl::OUString& sAlias )
280*cdf0e10cSrcweir {
281*cdf0e10cSrcweir     // share code to read all job properties!
282*cdf0e10cSrcweir     setAlias(sAlias);
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     /* SAFE { */
285*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     // take over the new informations - which differ against set on of method setAlias()!
288*cdf0e10cSrcweir     m_sEvent = sEvent;
289*cdf0e10cSrcweir     m_eMode  = E_EVENT;
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     aWriteLock.unlock();
292*cdf0e10cSrcweir     /* } SAFE */
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir //________________________________
296*cdf0e10cSrcweir /**
297*cdf0e10cSrcweir     @short      set the new job specific arguments
298*cdf0e10cSrcweir     @descr      If a job finish his work, it can give us a new list of arguments (which
299*cdf0e10cSrcweir                 will not interpreted by us). We write it back to the configuration only
300*cdf0e10cSrcweir                 (if this job has it's own configuration!).
301*cdf0e10cSrcweir                 So a job can have persistent data without implementing anything
302*cdf0e10cSrcweir                 or define own config areas for that.
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     @param      lArguments
305*cdf0e10cSrcweir                     list of arguments, which should be set for this job
306*cdf0e10cSrcweir  */
307*cdf0e10cSrcweir void JobData::setJobConfig( const css::uno::Sequence< css::beans::NamedValue >& lArguments )
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     /* SAFE { */
310*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir     // update member
313*cdf0e10cSrcweir     m_lArguments = lArguments;
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir     // update the configuration ... if possible!
316*cdf0e10cSrcweir     if (m_eMode==E_ALIAS)
317*cdf0e10cSrcweir     {
318*cdf0e10cSrcweir         // It doesn't matter if this config object was already opened before.
319*cdf0e10cSrcweir         // It doesn nothing here then ... or it change the mode automaticly, if
320*cdf0e10cSrcweir         // it was opened using another one before.
321*cdf0e10cSrcweir         ::rtl::OUString sKey;
322*cdf0e10cSrcweir         sKey  = ::rtl::OUString::createFromAscii(JOBCFG_ROOT);
323*cdf0e10cSrcweir         sKey += ::utl::wrapConfigurationElementName(m_sAlias);
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir         ConfigAccess aConfig(m_xSMGR, sKey);
326*cdf0e10cSrcweir         aConfig.open(ConfigAccess::E_READWRITE);
327*cdf0e10cSrcweir         if (aConfig.getMode()==ConfigAccess::E_CLOSED)
328*cdf0e10cSrcweir             return;
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir         css::uno::Reference< css::beans::XMultiHierarchicalPropertySet > xArgumentList(aConfig.cfg(), css::uno::UNO_QUERY);
331*cdf0e10cSrcweir         if (xArgumentList.is())
332*cdf0e10cSrcweir         {
333*cdf0e10cSrcweir             sal_Int32                             nCount = m_lArguments.getLength();
334*cdf0e10cSrcweir             css::uno::Sequence< ::rtl::OUString > lNames (nCount);
335*cdf0e10cSrcweir             css::uno::Sequence< css::uno::Any >   lValues(nCount);
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir             for (sal_Int32 i=0; i<nCount; ++i)
338*cdf0e10cSrcweir             {
339*cdf0e10cSrcweir                 lNames [i] = m_lArguments[i].Name ;
340*cdf0e10cSrcweir                 lValues[i] = m_lArguments[i].Value;
341*cdf0e10cSrcweir             }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir             xArgumentList->setHierarchicalPropertyValues(lNames, lValues);
344*cdf0e10cSrcweir         }
345*cdf0e10cSrcweir         aConfig.close();
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     aWriteLock.unlock();
349*cdf0e10cSrcweir     /* } SAFE */
350*cdf0e10cSrcweir }
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir //________________________________
353*cdf0e10cSrcweir /**
354*cdf0e10cSrcweir     @short      set a new excution result
355*cdf0e10cSrcweir     @descr      Every executed job can have returned a result.
356*cdf0e10cSrcweir                 We set it here, so our user can use it may be later.
357*cdf0e10cSrcweir                 But the outside code can use it too, to analyze it and
358*cdf0e10cSrcweir                 adopt the configuration of this job too. Because the
359*cdf0e10cSrcweir                 result uses a protocol, which allow that. And we provide
360*cdf0e10cSrcweir                 right functionality to save it.
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     @param      aResult
363*cdf0e10cSrcweir                     the result of last execution
364*cdf0e10cSrcweir  */
365*cdf0e10cSrcweir void JobData::setResult( const JobResult& aResult )
366*cdf0e10cSrcweir {
367*cdf0e10cSrcweir     /* SAFE { */
368*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir     // overwrite the last saved result
371*cdf0e10cSrcweir     m_aLastExecutionResult = aResult;
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir     // Don't use his informations to update
374*cdf0e10cSrcweir     // e.g. the arguments of this job. It must be done
375*cdf0e10cSrcweir     // from outside! Here we save this information only.
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir     aWriteLock.unlock();
378*cdf0e10cSrcweir     /* } SAFE */
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir //________________________________
382*cdf0e10cSrcweir /**
383*cdf0e10cSrcweir     @short  set a new environment descriptor for this job
384*cdf0e10cSrcweir     @descr  It must(!) be done everytime this container is initialized
385*cdf0e10cSrcweir             with new job datas e.g.: setAlias()/setEvent()/setService() ...
386*cdf0e10cSrcweir             Otherwhise the environment will be unknown!
387*cdf0e10cSrcweir  */
388*cdf0e10cSrcweir void JobData::setEnvironment( EEnvironment eEnvironment )
389*cdf0e10cSrcweir {
390*cdf0e10cSrcweir     /* SAFE { */
391*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
392*cdf0e10cSrcweir     m_eEnvironment = eEnvironment;
393*cdf0e10cSrcweir     aWriteLock.unlock();
394*cdf0e10cSrcweir     /* } SAFE */
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir //________________________________
398*cdf0e10cSrcweir /**
399*cdf0e10cSrcweir     @short      these functions provides access to our internal members
400*cdf0e10cSrcweir     @descr      These member represent any information about the job
401*cdf0e10cSrcweir                 and can be used from outside to e.g. start a job.
402*cdf0e10cSrcweir  */
403*cdf0e10cSrcweir JobData::EMode JobData::getMode() const
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir     /* SAFE { */
406*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
407*cdf0e10cSrcweir     return m_eMode;
408*cdf0e10cSrcweir     /* } SAFE */
409*cdf0e10cSrcweir }
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir //________________________________
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir JobData::EEnvironment JobData::getEnvironment() const
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir     /* SAFE { */
416*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
417*cdf0e10cSrcweir     return m_eEnvironment;
418*cdf0e10cSrcweir     /* } SAFE */
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir //________________________________
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir ::rtl::OUString JobData::getEnvironmentDescriptor() const
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir     ::rtl::OUString sDescriptor;
426*cdf0e10cSrcweir     /* SAFE { */
427*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
428*cdf0e10cSrcweir     switch(m_eEnvironment)
429*cdf0e10cSrcweir     {
430*cdf0e10cSrcweir         case E_EXECUTION :
431*cdf0e10cSrcweir             sDescriptor = ::rtl::OUString::createFromAscii("EXECUTOR");
432*cdf0e10cSrcweir             break;
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir         case E_DISPATCH :
435*cdf0e10cSrcweir             sDescriptor = ::rtl::OUString::createFromAscii("DISPATCH");
436*cdf0e10cSrcweir             break;
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir         case E_DOCUMENTEVENT :
439*cdf0e10cSrcweir             sDescriptor = ::rtl::OUString::createFromAscii("DOCUMENTEVENT");
440*cdf0e10cSrcweir             break;
441*cdf0e10cSrcweir         default:
442*cdf0e10cSrcweir             break;
443*cdf0e10cSrcweir     }
444*cdf0e10cSrcweir     /* } SAFE */
445*cdf0e10cSrcweir     return sDescriptor;
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir //________________________________
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir ::rtl::OUString JobData::getService() const
451*cdf0e10cSrcweir {
452*cdf0e10cSrcweir     /* SAFE { */
453*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
454*cdf0e10cSrcweir     return m_sService;
455*cdf0e10cSrcweir     /* } SAFE */
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir //________________________________
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir ::rtl::OUString JobData::getEvent() const
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir     /* SAFE { */
463*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
464*cdf0e10cSrcweir     return m_sEvent;
465*cdf0e10cSrcweir     /* } SAFE */
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir //________________________________
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir css::uno::Sequence< css::beans::NamedValue > JobData::getJobConfig() const
471*cdf0e10cSrcweir {
472*cdf0e10cSrcweir     /* SAFE { */
473*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
474*cdf0e10cSrcweir     return m_lArguments;
475*cdf0e10cSrcweir     /* } SAFE */
476*cdf0e10cSrcweir }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir //________________________________
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir     /* SAFE { */
483*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
484*cdf0e10cSrcweir     css::uno::Sequence< css::beans::NamedValue > lConfig;
485*cdf0e10cSrcweir     if (m_eMode==E_ALIAS)
486*cdf0e10cSrcweir     {
487*cdf0e10cSrcweir         lConfig.realloc(3);
488*cdf0e10cSrcweir         sal_Int32 i = 0;
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir         lConfig[i].Name = ::rtl::OUString::createFromAscii(PROP_ALIAS);
491*cdf0e10cSrcweir         lConfig[i].Value <<= m_sAlias;
492*cdf0e10cSrcweir         ++i;
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir         lConfig[i].Name = ::rtl::OUString::createFromAscii(PROP_SERVICE);
495*cdf0e10cSrcweir         lConfig[i].Value <<= m_sService;
496*cdf0e10cSrcweir         ++i;
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir         lConfig[i].Name = ::rtl::OUString::createFromAscii(PROP_CONTEXT);
499*cdf0e10cSrcweir         lConfig[i].Value <<= m_sContext;
500*cdf0e10cSrcweir         ++i;
501*cdf0e10cSrcweir     }
502*cdf0e10cSrcweir     aReadLock.unlock();
503*cdf0e10cSrcweir     /* } SAFE */
504*cdf0e10cSrcweir     return lConfig;
505*cdf0e10cSrcweir }
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir //________________________________
508*cdf0e10cSrcweir /**
509*cdf0e10cSrcweir     @short  return information, if this job is part of the global configuration package
510*cdf0e10cSrcweir             org.openoffice.Office.Jobs
511*cdf0e10cSrcweir     @descr  Because jobs can be executed by the dispatch framework using an uno service name
512*cdf0e10cSrcweir             directly - an executed job must not have any configuration realy. Such jobs
513*cdf0e10cSrcweir             must provide the right interfaces only! But after finishing jobs can return
514*cdf0e10cSrcweir             some informations (e.g. for updating her configuration ...). We must know
515*cdf0e10cSrcweir             if such request is valid or not then.
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir     @return sal_True if the represented job is part of the underlying configuration package.
518*cdf0e10cSrcweir  */
519*cdf0e10cSrcweir sal_Bool JobData::hasConfig() const
520*cdf0e10cSrcweir {
521*cdf0e10cSrcweir     /* SAFE { */
522*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
523*cdf0e10cSrcweir     return (m_eMode==E_ALIAS || m_eMode==E_EVENT);
524*cdf0e10cSrcweir     /* } SAFE */
525*cdf0e10cSrcweir }
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir //________________________________
528*cdf0e10cSrcweir /**
529*cdf0e10cSrcweir     @short      mark a job as non startable for further requests
530*cdf0e10cSrcweir     @descr      We don't remove the configuration entry! We set a timestamp value only.
531*cdf0e10cSrcweir                 And there exist two of them: one for an administrator ... and one for the
532*cdf0e10cSrcweir                 current user. We change it for the user layer only. So this JobDispatch can't be
533*cdf0e10cSrcweir                 started any more ... till the administrator change his timestamp.
534*cdf0e10cSrcweir                 That can be usefull for post setup scenarios, which must run one time only.
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir                 Note: This method don't do anything, if ths represented job doesn't have a configuration!
537*cdf0e10cSrcweir  */
538*cdf0e10cSrcweir void JobData::disableJob()
539*cdf0e10cSrcweir {
540*cdf0e10cSrcweir     /* SAFE { */
541*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir     // No configuration - not used from EXECUTOR and not triggered from an event => no chance!
544*cdf0e10cSrcweir     if (m_eMode!=E_EVENT)
545*cdf0e10cSrcweir         return;
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir     // update the configuration
548*cdf0e10cSrcweir     // It doesn't matter if this config object was already opened before.
549*cdf0e10cSrcweir     // It doesn nothing here then ... or it change the mode automaticly, if
550*cdf0e10cSrcweir     // it was opened using another one before.
551*cdf0e10cSrcweir     ::rtl::OUStringBuffer sKey(256);
552*cdf0e10cSrcweir     sKey.appendAscii(JobData::EVENTCFG_ROOT                       );
553*cdf0e10cSrcweir     sKey.append     (::utl::wrapConfigurationElementName(m_sEvent));
554*cdf0e10cSrcweir     sKey.appendAscii(JobData::EVENTCFG_PATH_JOBLIST               );
555*cdf0e10cSrcweir     sKey.appendAscii("/"                                          );
556*cdf0e10cSrcweir     sKey.append     (::utl::wrapConfigurationElementName(m_sAlias));
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir     ConfigAccess aConfig(m_xSMGR, sKey.makeStringAndClear());
559*cdf0e10cSrcweir     aConfig.open(ConfigAccess::E_READWRITE);
560*cdf0e10cSrcweir     if (aConfig.getMode()==ConfigAccess::E_CLOSED)
561*cdf0e10cSrcweir         return;
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xPropSet(aConfig.cfg(), css::uno::UNO_QUERY);
564*cdf0e10cSrcweir     if (xPropSet.is())
565*cdf0e10cSrcweir     {
566*cdf0e10cSrcweir         // Convert and write the user timestamp to the configuration.
567*cdf0e10cSrcweir         css::uno::Any aValue;
568*cdf0e10cSrcweir         aValue <<= Converter::convert_DateTime2ISO8601(DateTime());
569*cdf0e10cSrcweir         xPropSet->setPropertyValue(::rtl::OUString::createFromAscii(EVENTCFG_PROP_USERTIME), aValue);
570*cdf0e10cSrcweir     }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir     aConfig.close();
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir     aWriteLock.unlock();
575*cdf0e10cSrcweir     /* } SAFE */
576*cdf0e10cSrcweir }
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir //________________________________
579*cdf0e10cSrcweir /**
580*cdf0e10cSrcweir  */
581*cdf0e10cSrcweir sal_Bool isEnabled( const ::rtl::OUString& sAdminTime ,
582*cdf0e10cSrcweir                     const ::rtl::OUString& sUserTime  )
583*cdf0e10cSrcweir {
584*cdf0e10cSrcweir     /*Attention!
585*cdf0e10cSrcweir         To prevent interpreting of TriGraphs inside next const string value,
586*cdf0e10cSrcweir         we have to encode all '?' signs. Otherwhise e.g. "??-" will be translated
587*cdf0e10cSrcweir         to "~" ...
588*cdf0e10cSrcweir      */
589*cdf0e10cSrcweir     static ::rtl::OUString PATTERN_ISO8601 = ::rtl::OUString::createFromAscii("\?\?\?\?-\?\?-\?\?*\0");
590*cdf0e10cSrcweir     WildCard aISOPattern(PATTERN_ISO8601);
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir     sal_Bool bValidAdmin = aISOPattern.Matches(sAdminTime);
593*cdf0e10cSrcweir     sal_Bool bValidUser  = aISOPattern.Matches(sUserTime );
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir     // We check for "isEnabled()" here only.
596*cdf0e10cSrcweir     // Note further: ISO8601 formated strings can be compared as strings directly!
597*cdf0e10cSrcweir     return (
598*cdf0e10cSrcweir             (!bValidAdmin && !bValidUser                         ) ||
599*cdf0e10cSrcweir             ( bValidAdmin &&  bValidUser && sAdminTime>=sUserTime)
600*cdf0e10cSrcweir            );
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir //________________________________
604*cdf0e10cSrcweir /**
605*cdf0e10cSrcweir  */
606*cdf0e10cSrcweir void JobData::appendEnabledJobsForEvent( const css::uno::Reference< css::lang::XMultiServiceFactory >&          xSMGR  ,
607*cdf0e10cSrcweir                                          const ::rtl::OUString&                                                 sEvent ,
608*cdf0e10cSrcweir                                                ::comphelper::SequenceAsVector< JobData::TJob2DocEventBinding >& lJobs  )
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > lAdditionalJobs = JobData::getEnabledJobsForEvent(xSMGR, sEvent);
611*cdf0e10cSrcweir     sal_Int32                             c               = lAdditionalJobs.getLength();
612*cdf0e10cSrcweir     sal_Int32                             i               = 0;
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir     for (i=0; i<c; ++i)
615*cdf0e10cSrcweir     {
616*cdf0e10cSrcweir         JobData::TJob2DocEventBinding aBinding(lAdditionalJobs[i], sEvent);
617*cdf0e10cSrcweir         lJobs.push_back(aBinding);
618*cdf0e10cSrcweir     }
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir //________________________________
622*cdf0e10cSrcweir /**
623*cdf0e10cSrcweir  */
624*cdf0e10cSrcweir sal_Bool JobData::hasCorrectContext(const ::rtl::OUString& rModuleIdent) const
625*cdf0e10cSrcweir {
626*cdf0e10cSrcweir     sal_Int32 nContextLen  = m_sContext.getLength();
627*cdf0e10cSrcweir     sal_Int32 nModuleIdLen = rModuleIdent.getLength();
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir     if ( nContextLen == 0 )
630*cdf0e10cSrcweir         return sal_True;
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir     if ( nModuleIdLen > 0 )
633*cdf0e10cSrcweir     {
634*cdf0e10cSrcweir         sal_Int32 nIndex = m_sContext.indexOf( rModuleIdent );
635*cdf0e10cSrcweir         if ( nIndex >= 0 && ( nIndex+nModuleIdLen <= nContextLen ))
636*cdf0e10cSrcweir 	{
637*cdf0e10cSrcweir 	    ::rtl::OUString sContextModule = m_sContext.copy( nIndex, nModuleIdLen );
638*cdf0e10cSrcweir 	    return sContextModule.equals( rModuleIdent );
639*cdf0e10cSrcweir 	}
640*cdf0e10cSrcweir     }
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir     return sal_False;
643*cdf0e10cSrcweir }
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir //________________________________
646*cdf0e10cSrcweir /**
647*cdf0e10cSrcweir  */
648*cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > JobData::getEnabledJobsForEvent( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR  ,
649*cdf0e10cSrcweir                                                                        const ::rtl::OUString&                                        sEvent )
650*cdf0e10cSrcweir {
651*cdf0e10cSrcweir     // these static values may perform following loop for reading time stamp values ...
652*cdf0e10cSrcweir     static ::rtl::OUString ADMINTIME = ::rtl::OUString::createFromAscii(JobData::EVENTCFG_PROP_ADMINTIME);
653*cdf0e10cSrcweir     static ::rtl::OUString USERTIME  = ::rtl::OUString::createFromAscii(JobData::EVENTCFG_PROP_USERTIME );
654*cdf0e10cSrcweir     static ::rtl::OUString ROOT      = ::rtl::OUString::createFromAscii(JobData::EVENTCFG_ROOT          );
655*cdf0e10cSrcweir     static ::rtl::OUString JOBLIST   = ::rtl::OUString::createFromAscii(JobData::EVENTCFG_PATH_JOBLIST  );
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir     // create a config access to "/org.openoffice.Office.Jobs/Events"
658*cdf0e10cSrcweir     ConfigAccess aConfig(xSMGR,ROOT);
659*cdf0e10cSrcweir     aConfig.open(ConfigAccess::E_READONLY);
660*cdf0e10cSrcweir     if (aConfig.getMode()==ConfigAccess::E_CLOSED)
661*cdf0e10cSrcweir         return css::uno::Sequence< ::rtl::OUString >();
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir     css::uno::Reference< css::container::XHierarchicalNameAccess > xEventRegistry(aConfig.cfg(), css::uno::UNO_QUERY);
664*cdf0e10cSrcweir     if (!xEventRegistry.is())
665*cdf0e10cSrcweir         return css::uno::Sequence< ::rtl::OUString >();
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir     // check if the given event exist inside list of registered ones
668*cdf0e10cSrcweir     ::rtl::OUString sPath(sEvent);
669*cdf0e10cSrcweir     sPath += JOBLIST;
670*cdf0e10cSrcweir     if (!xEventRegistry->hasByHierarchicalName(sPath))
671*cdf0e10cSrcweir         return css::uno::Sequence< ::rtl::OUString >();
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir     // step to the job list, which is a child of the event node inside cfg
674*cdf0e10cSrcweir     // e.g. "/org.openoffice.Office.Jobs/Events/<event name>/JobList"
675*cdf0e10cSrcweir     css::uno::Any aJobList = xEventRegistry->getByHierarchicalName(sPath);
676*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xJobList;
677*cdf0e10cSrcweir     if (!(aJobList >>= xJobList) || !xJobList.is())
678*cdf0e10cSrcweir         return css::uno::Sequence< ::rtl::OUString >();
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir     // get all alias names of jobs, which are part of this job list
681*cdf0e10cSrcweir     // But Some of them can be disabled by it's time stamp values.
682*cdf0e10cSrcweir     // We create an additional job name list iwth the same size, then the original list ...
683*cdf0e10cSrcweir     // step over all job entries ... check her time stamps ... and put only job names to the
684*cdf0e10cSrcweir     // destination list, which represent an enabled job.
685*cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > lAllJobs = xJobList->getElementNames();
686*cdf0e10cSrcweir     ::rtl::OUString* pAllJobs = lAllJobs.getArray();
687*cdf0e10cSrcweir     sal_Int32 c = lAllJobs.getLength();
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > lEnabledJobs(c);
690*cdf0e10cSrcweir     ::rtl::OUString* pEnabledJobs = lEnabledJobs.getArray();
691*cdf0e10cSrcweir     sal_Int32 d = 0;
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir     for (sal_Int32 s=0; s<c; ++s)
694*cdf0e10cSrcweir     {
695*cdf0e10cSrcweir         css::uno::Reference< css::beans::XPropertySet > xJob;
696*cdf0e10cSrcweir         if (
697*cdf0e10cSrcweir             !(xJobList->getByName(pAllJobs[s]) >>= xJob) ||
698*cdf0e10cSrcweir             !(xJob.is()     )
699*cdf0e10cSrcweir            )
700*cdf0e10cSrcweir         {
701*cdf0e10cSrcweir            continue;
702*cdf0e10cSrcweir         }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir         ::rtl::OUString sAdminTime;
705*cdf0e10cSrcweir         xJob->getPropertyValue(ADMINTIME) >>= sAdminTime;
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir         ::rtl::OUString sUserTime;
708*cdf0e10cSrcweir         xJob->getPropertyValue(USERTIME) >>= sUserTime;
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir         if (!isEnabled(sAdminTime, sUserTime))
711*cdf0e10cSrcweir             continue;
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir         pEnabledJobs[d] = pAllJobs[s];
714*cdf0e10cSrcweir         ++d;
715*cdf0e10cSrcweir     }
716*cdf0e10cSrcweir     lEnabledJobs.realloc(d);
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir     aConfig.close();
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir     return lEnabledJobs;
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir //________________________________
724*cdf0e10cSrcweir /**
725*cdf0e10cSrcweir     @short      reset all internal structures
726*cdf0e10cSrcweir     @descr      If somehwere recycle this instance, he can switch from one
727*cdf0e10cSrcweir                 using mode to another one. But then we have to reset all currently
728*cdf0e10cSrcweir                 used informations. Otherwhise we mix it and they can make trouble.
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir                 But note: that does not set defaults for internal used members, which
731*cdf0e10cSrcweir                 does not relate to any job property! e.g. the reference to the global
732*cdf0e10cSrcweir                 uno service manager. Such informations are used for internal processes only
733*cdf0e10cSrcweir                 and are neccessary for our work.
734*cdf0e10cSrcweir  */
735*cdf0e10cSrcweir void JobData::impl_reset()
736*cdf0e10cSrcweir {
737*cdf0e10cSrcweir     /* SAFE { */
738*cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
739*cdf0e10cSrcweir     m_eMode        = E_UNKNOWN_MODE;
740*cdf0e10cSrcweir     m_eEnvironment = E_UNKNOWN_ENVIRONMENT;
741*cdf0e10cSrcweir     m_sAlias       = ::rtl::OUString();
742*cdf0e10cSrcweir     m_sService     = ::rtl::OUString();
743*cdf0e10cSrcweir     m_sContext     = ::rtl::OUString();
744*cdf0e10cSrcweir     m_sEvent       = ::rtl::OUString();
745*cdf0e10cSrcweir     m_lArguments   = css::uno::Sequence< css::beans::NamedValue >();
746*cdf0e10cSrcweir     aWriteLock.unlock();
747*cdf0e10cSrcweir     /* } SAFE */
748*cdf0e10cSrcweir }
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir } // namespace framework
751