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