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 #include <svpm.h>
25 
26 #include <unotools/moduleoptions.hxx>
27 
28 #include <unotools/dynamicmenuoptions.hxx>
29 
30 #include "shutdownicon.hxx"
31 #include <comphelper/processfactory.hxx>
32 #include <com/sun/star/uno/Reference.h>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/task/XJob.hpp>
35 #include <com/sun/star/beans/NamedValue.hpp>
36 
37 
38 using namespace ::rtl;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::task;
41 using namespace ::com::sun::star::lang;
42 using namespace ::com::sun::star::beans;
43 using namespace ::osl;
44 
45 //
46 // This ObjectID must match the one created in WarpIN scripts!!
47 //
48 #define QUICKSTART_OBJID	"AOO_QUICKSTART"
49 
IsQuickstarterInstalled()50 bool ShutdownIcon::IsQuickstarterInstalled()
51 {
52     HOBJECT hObject;
53     // Check quickstart icon presence
54     hObject = WinQueryObject( "<" QUICKSTART_OBJID ">");
55     if (hObject)
56         return true;
57     // object not found, quickstart not available
58     return false;
59 }
60 
SetAutostartOs2(bool bActivate)61 void ShutdownIcon::SetAutostartOs2( bool bActivate )
62 {
63     HOBJECT hObject;
64 
65     if( bActivate && IsQuickstarterInstalled() )
66     {
67         // place quickstart shadow in the startup folder
68         hObject = WinCreateObject( "WPShadow", "dummy",
69                               "OBJECTID=<" QUICKSTART_OBJID "_SHW>;SHADOWID=<" QUICKSTART_OBJID ">;",
70                               "<WP_START>",
71                               CO_UPDATEIFEXISTS);
72     }
73     else
74     {
75         // remove quickstart shadow from the startup folder
76         hObject = WinQueryObject( "<" QUICKSTART_OBJID "_SHW>");
77         if (hObject)
78             WinDestroyObject( hObject);
79     }
80 }
81 
GetAutostartOs2()82 bool ShutdownIcon::GetAutostartOs2( )
83 {
84     // check for quickstart shadow in the startup folder
85     if (WinQueryObject( "<" QUICKSTART_OBJID "_SHW>"))
86         return true;
87     else
88         return false;
89 }
90 
91 
92