@paramrCopy theoriginalinstance,fromwhichwemustcopyalldata
*/
JobData::JobData( const JobData& rCopy )
{ // use the copy operator to share the same code
*this = rCopy;
}
@paramrCopy theoriginalinstance,fromwhichwemustcopyalldata
*/
JobData& JobData::operator=( const JobData& rCopy )
{ // Please don't copy the uno service manager reference. // That can change the uno context, which isn't a good idea!
m_eMode = rCopy.m_eMode;
m_eEnvironment = rCopy.m_eEnvironment;
m_sAlias = rCopy.m_sAlias;
m_sService = rCopy.m_sService;
m_sContext = rCopy.m_sContext;
m_sEvent = rCopy.m_sEvent;
m_lArguments = rCopy.m_lArguments; return *this;
}
@paramsAlias thealiasnameofthisjob,usedtolocatejobpropertiesinsidecfg
*/ void JobData::setAlias( const OUString& sAlias )
{ // delete all old information! Otherwise we mix it with the new one ...
impl_reset();
// take over the new information
m_sAlias = sAlias;
m_eMode = E_ALIAS;
// try to open the configuration set of this job directly and get a property access to it // We open it readonly here
ConfigAccess aConfig(
m_xContext,
("/org.openoffice.Office.Jobs/Jobs/"
+ utl::wrapConfigurationElementName(m_sAlias)));
aConfig.open(ConfigAccess::E_READONLY); if (aConfig.getMode()==ConfigAccess::E_CLOSED)
{
impl_reset(); return;
}
css::uno::Reference< css::beans::XPropertySet > xJobProperties(aConfig.cfg(), css::uno::UNO_QUERY); if (xJobProperties.is())
{
css::uno::Any aValue;
// read uno implementation name
aValue = xJobProperties->getPropertyValue(u"Service"_ustr);
aValue >>= m_sService;
@paramsService theunoservicenameofthis"nonconfigured"job
*/ void JobData::setService( const OUString& sService )
{ // delete all old information! Otherwise we mix it with the new one ...
impl_reset(); // take over the new information
m_sService = sService;
m_eMode = E_SERVICE;
}
// update the configuration ... if possible! if (m_eMode!=E_ALIAS) return;
// It doesn't matter if this config object was already opened before. // It doesn nothing here then ... or it change the mode automatically, if // it was opened using another one before.
ConfigAccess aConfig(
m_xContext,
("/org.openoffice.Office.Jobs/Jobs/"
+ utl::wrapConfigurationElementName(m_sAlias)));
aConfig.open(ConfigAccess::E_READWRITE); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return;
css::uno::Reference< css::beans::XMultiHierarchicalPropertySet > xArgumentList(aConfig.cfg(), css::uno::UNO_QUERY); if (xArgumentList.is())
{
sal_Int32 nCount = m_lArguments.size();
css::uno::Sequence< OUString > lNames (nCount); auto lNamesRange = asNonConstRange(lNames);
css::uno::Sequence< css::uno::Any > lValues(nCount); auto lValuesRange = asNonConstRange(lValues);
Note:Thismethoddon'tdoanything,ifthisrepresentedjobdoesn'thaveaconfiguration!
*/ void JobData::disableJob()
{ // No configuration - not used from EXECUTOR and not triggered from an event => no chance! if (m_eMode!=E_EVENT) return;
// update the configuration // It doesn't matter if this config object was already opened before. // It doesn nothing here then ... or it change the mode automatically, if // it was opened using another one before.
ConfigAccess aConfig(
m_xContext,
("/org.openoffice.Office.Jobs/Events/"
+ utl::wrapConfigurationElementName(m_sEvent) + "/JobList/"
+ utl::wrapConfigurationElementName(m_sAlias)));
aConfig.open(ConfigAccess::E_READWRITE); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return;
css::uno::Reference< css::beans::XPropertySet > xPropSet(aConfig.cfg(), css::uno::UNO_QUERY); if (xPropSet.is())
{ // Convert and write the user timestamp to the configuration.
css::uno::Any aValue;
aValue <<= Converter::convert_DateTime2ISO8601(DateTime( DateTime::SYSTEM));
xPropSet->setPropertyValue(u"UserTime"_ustr, aValue);
}
// We check for "isEnabled()" here only. // Note further: ISO8601 formatted strings can be compared as strings directly! // FIXME: this is not true! "T1215" is the same time as "T12:15" or "T121500" return (
(!bValidAdmin && !bValidUser ) ||
( bValidAdmin && bValidUser && sAdminTime>=sUserTime)
);
}
// check if the given event exist inside list of registered ones
OUString sPath(OUString::Concat(sEvent) + "/JobList"); if (!xEventRegistry->hasByHierarchicalName(sPath)) return std::vector< OUString >();
// step to the job list, which is a child of the event node inside cfg // e.g. "/org.openoffice.Office.Jobs/Events/<event name>/JobList"
css::uno::Any aJobList = xEventRegistry->getByHierarchicalName(sPath);
css::uno::Reference< css::container::XNameAccess > xJobList; if (!(aJobList >>= xJobList) || !xJobList.is()) return std::vector< OUString >();
// get all alias names of jobs, which are part of this job list // But Some of them can be disabled by its timestamp values. // We create an additional job name list with the same size, then the original list... // step over all job entries... check her timestamps... and put only job names to the // destination list, which represent an enabled job. const css::uno::Sequence< OUString > lAllJobs = xJobList->getElementNames();
sal_Int32 c = lAllJobs.getLength();
std::vector< OUString > lEnabledJobs(c);
sal_Int32 d = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.