12a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 52a97ec55SAndrew Rist * distributed with this work for additional information 62a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 72a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 82a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 92a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 102a97ec55SAndrew Rist * 112a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 122a97ec55SAndrew Rist * 132a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 142a97ec55SAndrew Rist * software distributed under the License is distributed on an 152a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 172a97ec55SAndrew Rist * specific language governing permissions and limitations 182a97ec55SAndrew Rist * under the License. 192a97ec55SAndrew Rist * 202a97ec55SAndrew Rist *************************************************************/ 212a97ec55SAndrew Rist 222a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "invite_job.hxx" 29cdf0e10cSrcweir #include "config.hxx" 30cdf0e10cSrcweir #include "logstorage.hxx" 31cdf0e10cSrcweir #include <com/sun/star/oooimprovement/XCore.hpp> 32cdf0e10cSrcweir #include <rtl/process.h> 33cdf0e10cSrcweir 34cdf0e10cSrcweir 35cdf0e10cSrcweir using namespace ::com::sun::star::beans; 36cdf0e10cSrcweir using namespace ::com::sun::star::lang; 37cdf0e10cSrcweir using namespace ::com::sun::star::task; 38cdf0e10cSrcweir using namespace ::com::sun::star::uno; 39cdf0e10cSrcweir using ::com::sun::star::oooimprovement::XCore; 40cdf0e10cSrcweir using ::rtl::OUString; 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace 43cdf0e10cSrcweir { 44*30acf5e8Spfg // don't show Invitation, when: 45cdf0e10cSrcweir // -nofirststartwizard commandline switch is present 46cdf0e10cSrcweir // [add additional conditions here] lcl_IsInvitationAllowed()47cdf0e10cSrcweir static bool lcl_IsInvitationAllowed() 48cdf0e10cSrcweir { 49cdf0e10cSrcweir static OUString sNoFirstStartWizard = OUString::createFromAscii("-nofirststartwizard"); 50cdf0e10cSrcweir sal_Int32 nCount = rtl_getAppCommandArgCount(); 51cdf0e10cSrcweir for(sal_Int32 nCurrent=0; nCurrent<nCount; nCurrent++) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir OUString sArg; 54cdf0e10cSrcweir rtl_getAppCommandArg(nCurrent, &sArg.pData); 55cdf0e10cSrcweir if(sNoFirstStartWizard == sArg) 56cdf0e10cSrcweir return false; 57cdf0e10cSrcweir } 58cdf0e10cSrcweir return true; 59cdf0e10cSrcweir } 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir namespace oooimprovement 63cdf0e10cSrcweir { 64cdf0e10cSrcweir // InviteJob::InviteJob(const Reference<XComponentContext>& context) 65cdf0e10cSrcweir // : m_ServiceFactory(Reference<XMultiServiceFactory>( 66cdf0e10cSrcweir // context->getServiceManager()->createInstanceWithContext( 67cdf0e10cSrcweir // OUString::createFromAscii("com.sun.star.lang.XMultiServiceFactory"), context), 68cdf0e10cSrcweir // UNO_QUERY)) 69cdf0e10cSrcweir // { } 70cdf0e10cSrcweir InviteJob(const Reference<XMultiServiceFactory> & sf)71cdf0e10cSrcweir InviteJob::InviteJob(const Reference<XMultiServiceFactory>& sf) 72cdf0e10cSrcweir : m_ServiceFactory(sf) 73cdf0e10cSrcweir { } 74cdf0e10cSrcweir ~InviteJob()75cdf0e10cSrcweir InviteJob::~InviteJob() 76cdf0e10cSrcweir { } 77cdf0e10cSrcweir executeAsync(const Sequence<NamedValue> &,const Reference<XJobListener> & listener)78cdf0e10cSrcweir void SAL_CALL InviteJob::executeAsync(const Sequence<NamedValue>&, const Reference<XJobListener>& listener) throw(RuntimeException) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir Config config(m_ServiceFactory); 81cdf0e10cSrcweir { 82cdf0e10cSrcweir LogStorage log_storage(m_ServiceFactory); 83cdf0e10cSrcweir log_storage.assureExists(); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir if(config.getOfficeStartCounterdown() > 0) 86cdf0e10cSrcweir config.decrementOfficeStartCounterdown(1); 87cdf0e10cSrcweir else 88cdf0e10cSrcweir { 89cdf0e10cSrcweir if(lcl_IsInvitationAllowed() && !config.getShowedInvitation()) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir Reference<XCore> core( 92cdf0e10cSrcweir m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.Core")), 93cdf0e10cSrcweir UNO_QUERY); 94cdf0e10cSrcweir if(core.is()) core->inviteUser(); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir Any result; 98cdf0e10cSrcweir listener->jobFinished(Reference<XAsyncJob>(this), result); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir supportsService(const OUString & service_name)101cdf0e10cSrcweir sal_Bool SAL_CALL InviteJob::supportsService(const OUString& service_name) throw(RuntimeException) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir const Sequence<OUString> service_names(getSupportedServiceNames()); 104cdf0e10cSrcweir for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx) 105cdf0e10cSrcweir if(service_name == service_names[idx]) return sal_True; 106cdf0e10cSrcweir return sal_False; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir getImplementationName()109cdf0e10cSrcweir OUString SAL_CALL InviteJob::getImplementationName() throw(RuntimeException) 110cdf0e10cSrcweir { return getImplementationName_static(); } 111cdf0e10cSrcweir getSupportedServiceNames()112cdf0e10cSrcweir Sequence<OUString> SAL_CALL InviteJob::getSupportedServiceNames() throw(RuntimeException) 113cdf0e10cSrcweir { return getSupportedServiceNames_static(); } 114cdf0e10cSrcweir getImplementationName_static()115cdf0e10cSrcweir OUString SAL_CALL InviteJob::getImplementationName_static() 116cdf0e10cSrcweir { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.InviteJob"); } 117cdf0e10cSrcweir getSupportedServiceNames_static()118cdf0e10cSrcweir Sequence<OUString> SAL_CALL InviteJob::getSupportedServiceNames_static() 119cdf0e10cSrcweir { 120cdf0e10cSrcweir Sequence<OUString> aServiceNames(1); 121cdf0e10cSrcweir aServiceNames[0] = OUString::createFromAscii("com.sun.star.task.AsyncJob"); 122cdf0e10cSrcweir return aServiceNames; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir // Reference<XInterface> InviteJob::Create(const Reference<XComponentContext>& context) 126cdf0e10cSrcweir // { return *(new InviteJob(context)); } 127cdf0e10cSrcweir Create(const Reference<XMultiServiceFactory> & sm)128cdf0e10cSrcweir Reference<XInterface> InviteJob::Create(const Reference<XMultiServiceFactory>& sm) 129cdf0e10cSrcweir { return *(new InviteJob(sm)); } 130cdf0e10cSrcweir } 131