1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * Copyright 2008 by Sun Microsystems, Inc.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * $RCSfile: invite_job.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
28 ************************************************************************/
30 // MARKER(update_precomp.py): autogen include statement, do not remove
31 #include "precompiled_extensions.hxx"
34 #include "invite_job.hxx"
36 #include "logstorage.hxx"
37 #include <com/sun/star/oooimprovement/XCore.hpp>
38 #include <rtl/process.h>
41 using namespace ::com::sun::star::beans
;
42 using namespace ::com::sun::star::lang
;
43 using namespace ::com::sun::star::task
;
44 using namespace ::com::sun::star::uno
;
45 using ::com::sun::star::oooimprovement::XCore
;
46 using ::rtl::OUString
;
50 // dont show Invitation, when:
51 // -nofirststartwizard commandline switch is present
52 // [add additional conditions here]
53 static bool lcl_IsInvitationAllowed()
55 static OUString sNoFirstStartWizard
= OUString::createFromAscii("-nofirststartwizard");
56 sal_Int32 nCount
= rtl_getAppCommandArgCount();
57 for(sal_Int32 nCurrent
=0; nCurrent
<nCount
; nCurrent
++)
60 rtl_getAppCommandArg(nCurrent
, &sArg
.pData
);
61 if(sNoFirstStartWizard
== sArg
)
68 namespace oooimprovement
70 // InviteJob::InviteJob(const Reference<XComponentContext>& context)
71 // : m_ServiceFactory(Reference<XMultiServiceFactory>(
72 // context->getServiceManager()->createInstanceWithContext(
73 // OUString::createFromAscii("com.sun.star.lang.XMultiServiceFactory"), context),
77 InviteJob::InviteJob(const Reference
<XMultiServiceFactory
>& sf
)
78 : m_ServiceFactory(sf
)
81 InviteJob::~InviteJob()
84 void SAL_CALL
InviteJob::executeAsync(const Sequence
<NamedValue
>&, const Reference
<XJobListener
>& listener
) throw(RuntimeException
)
86 Config
config(m_ServiceFactory
);
88 LogStorage
log_storage(m_ServiceFactory
);
89 log_storage
.assureExists();
91 if(config
.getOfficeStartCounterdown() > 0)
92 config
.decrementOfficeStartCounterdown(1);
95 if(lcl_IsInvitationAllowed() && !config
.getShowedInvitation())
97 Reference
<XCore
> core(
98 m_ServiceFactory
->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.Core")),
100 if(core
.is()) core
->inviteUser();
104 listener
->jobFinished(Reference
<XAsyncJob
>(this), result
);
107 sal_Bool SAL_CALL
InviteJob::supportsService(const OUString
& service_name
) throw(RuntimeException
)
109 const Sequence
<OUString
> service_names(getSupportedServiceNames());
110 for (sal_Int32 idx
= service_names
.getLength()-1; idx
>=0; --idx
)
111 if(service_name
== service_names
[idx
]) return sal_True
;
115 OUString SAL_CALL
InviteJob::getImplementationName() throw(RuntimeException
)
116 { return getImplementationName_static(); }
118 Sequence
<OUString
> SAL_CALL
InviteJob::getSupportedServiceNames() throw(RuntimeException
)
119 { return getSupportedServiceNames_static(); }
121 OUString SAL_CALL
InviteJob::getImplementationName_static()
122 { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.InviteJob"); }
124 Sequence
<OUString
> SAL_CALL
InviteJob::getSupportedServiceNames_static()
126 Sequence
<OUString
> aServiceNames(1);
127 aServiceNames
[0] = OUString::createFromAscii("com.sun.star.task.XAsyncJob");
128 return aServiceNames
;
131 // Reference<XInterface> InviteJob::Create(const Reference<XComponentContext>& context)
132 // { return *(new InviteJob(context)); }
134 Reference
<XInterface
> InviteJob::Create(const Reference
<XMultiServiceFactory
>& sm
)
135 { return *(new InviteJob(sm
)); }