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