1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <unotools/dynamicmenuoptions.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "shutdownicon.hxx"
30cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
31cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
32cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33cdf0e10cSrcweir #include <com/sun/star/task/XJob.hpp>
34cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace ::rtl;
38cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir using namespace ::com::sun::star::task;
40cdf0e10cSrcweir using namespace ::com::sun::star::lang;
41cdf0e10cSrcweir using namespace ::com::sun::star::beans;
42cdf0e10cSrcweir using namespace ::osl;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir //
45cdf0e10cSrcweir // This ObjectID must match the one created in WarpIN scripts!!
46cdf0e10cSrcweir //
47cdf0e10cSrcweir #define QUICKSTART_OBJID	"OO2_QUICKSTART"
48cdf0e10cSrcweir 
49cdf0e10cSrcweir bool ShutdownIcon::IsQuickstarterInstalled()
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     HOBJECT hObject;
52cdf0e10cSrcweir     // Check quickstart icon presence
53cdf0e10cSrcweir     hObject = WinQueryObject( "<" QUICKSTART_OBJID ">");
54cdf0e10cSrcweir     if (hObject)
55cdf0e10cSrcweir         return true;
56cdf0e10cSrcweir     // object not found, quickstart not available
57cdf0e10cSrcweir     return false;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir void ShutdownIcon::SetAutostartOs2( bool bActivate )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     HOBJECT hObject;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     if( bActivate && IsQuickstarterInstalled() )
65cdf0e10cSrcweir     {
66cdf0e10cSrcweir         // place quickstart shadow in the startup folder
67cdf0e10cSrcweir         hObject = WinCreateObject( "WPShadow", "dummy",
68cdf0e10cSrcweir                               "OBJECTID=<" QUICKSTART_OBJID "_SHW>;SHADOWID=<" QUICKSTART_OBJID ">;",
69cdf0e10cSrcweir                               "<WP_START>",
70cdf0e10cSrcweir                               CO_UPDATEIFEXISTS);
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir     else
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         // remove quickstart shadow from the startup folder
75cdf0e10cSrcweir         hObject = WinQueryObject( "<" QUICKSTART_OBJID "_SHW>");
76cdf0e10cSrcweir         if (hObject)
77cdf0e10cSrcweir             WinDestroyObject( hObject);
78cdf0e10cSrcweir     }
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir bool ShutdownIcon::GetAutostartOs2( )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     // check for quickstart shadow in the startup folder
84cdf0e10cSrcweir     if (WinQueryObject( "<" QUICKSTART_OBJID "_SHW>"))
85cdf0e10cSrcweir         return true;
86cdf0e10cSrcweir     else
87cdf0e10cSrcweir         return false;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
91