1a0428e9eSAndrew Rist#**************************************************************
2a0428e9eSAndrew Rist#
3a0428e9eSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4a0428e9eSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5a0428e9eSAndrew Rist#  distributed with this work for additional information
6a0428e9eSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7a0428e9eSAndrew Rist#  to you under the Apache License, Version 2.0 (the
8a0428e9eSAndrew Rist#  "License"); you may not use this file except in compliance
9a0428e9eSAndrew Rist#  with the License.  You may obtain a copy of the License at
10a0428e9eSAndrew Rist#
11a0428e9eSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12a0428e9eSAndrew Rist#
13a0428e9eSAndrew Rist#  Unless required by applicable law or agreed to in writing,
14a0428e9eSAndrew Rist#  software distributed under the License is distributed on an
15a0428e9eSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16a0428e9eSAndrew Rist#  KIND, either express or implied.  See the License for the
17a0428e9eSAndrew Rist#  specific language governing permissions and limitations
18a0428e9eSAndrew Rist#  under the License.
19a0428e9eSAndrew Rist#
20a0428e9eSAndrew Rist#**************************************************************
21cdf0e10cSrcweir
22cdf0e10cSrcweirimport uno
23cdf0e10cSrcweirimport unohelper
24cdf0e10cSrcweir
25cdf0e10cSrcweirfrom com.sun.star.awt import Rectangle
26cdf0e10cSrcweirfrom com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
27*61161268SAriel Constenla-Hailefrom com.sun.star.awt.MessageBoxType import INFOBOX
28cdf0e10cSrcweirfrom com.sun.star.frame import XDispatch, XDispatchProvider
29cdf0e10cSrcweirfrom com.sun.star.lang import XServiceInfo
30cdf0e10cSrcweir
31cdf0e10cSrcweirclass Provider(unohelper.Base, XServiceInfo, XDispatchProvider):
32cdf0e10cSrcweir    implementationName = "com.sun.star.comp.test.deployment.passive_python"
33cdf0e10cSrcweir
34cdf0e10cSrcweir    serviceNames = ("com.sun.star.test.deployment.passive_python",)
35cdf0e10cSrcweir
36cdf0e10cSrcweir    def __init__(self, context):
37cdf0e10cSrcweir        self.context = context
38cdf0e10cSrcweir
39cdf0e10cSrcweir    def getImplementationName(self):
40cdf0e10cSrcweir        return self.implementationName
41cdf0e10cSrcweir
42cdf0e10cSrcweir    def supportsService(self, ServiceName):
43cdf0e10cSrcweir        return ServiceName in self.serviceNames
44cdf0e10cSrcweir
45cdf0e10cSrcweir    def getSupportedServiceNames(self):
46cdf0e10cSrcweir        return self.serviceNames
47cdf0e10cSrcweir
48cdf0e10cSrcweir    def queryDispatch(self, URL, TargetFrame, SearchFlags):
49cdf0e10cSrcweir        return self.context.getValueByName( \
50cdf0e10cSrcweir            "/singletons/com.sun.star.test.deployment.passive_python_singleton")
51cdf0e10cSrcweir
52cdf0e10cSrcweir    def queryDispatches(self, Requests):
53cdf0e10cSrcweir        tuple( \
54cdf0e10cSrcweir            self.queryDispatch(i.FeatureURL, i.FrameName, i.SearchFlags) \
55cdf0e10cSrcweir                for i in Requests)
56cdf0e10cSrcweir
57cdf0e10cSrcweirclass Dispatch(unohelper.Base, XServiceInfo, XDispatch):
58cdf0e10cSrcweir    implementationName = \
59cdf0e10cSrcweir        "com.sun.star.comp.test.deployment.passive_python_singleton"
60cdf0e10cSrcweir
61cdf0e10cSrcweir    serviceNames = ()
62cdf0e10cSrcweir
63cdf0e10cSrcweir    def __init__(self, context):
64cdf0e10cSrcweir        self.context = context
65cdf0e10cSrcweir
66cdf0e10cSrcweir    def getImplementationName(self):
67cdf0e10cSrcweir        return self.implementationName
68cdf0e10cSrcweir
69cdf0e10cSrcweir    def supportsService(self, ServiceName):
70cdf0e10cSrcweir        return ServiceName in self.serviceNames
71cdf0e10cSrcweir
72cdf0e10cSrcweir    def getSupportedServiceNames(self):
73cdf0e10cSrcweir        return self.serviceNames
74cdf0e10cSrcweir
75cdf0e10cSrcweir    def dispatch(self, URL, Arguments):
76cdf0e10cSrcweir        smgr = self.context.getServiceManager()
77cdf0e10cSrcweir        box = smgr.createInstanceWithContext( \
78cdf0e10cSrcweir            "com.sun.star.awt.Toolkit", self.context).createMessageBox( \
79cdf0e10cSrcweir                smgr.createInstanceWithContext( \
80cdf0e10cSrcweir                    "com.sun.star.frame.Desktop", self.context). \
81cdf0e10cSrcweir                    getCurrentFrame().getComponentWindow(), \
82*61161268SAriel Constenla-Haile                INFOBOX, BUTTONS_OK, "passive", "python")
83cdf0e10cSrcweir        box.execute();
84cdf0e10cSrcweir        box.dispose();
85cdf0e10cSrcweir
86cdf0e10cSrcweir    def addStatusListener(self, Control, URL):
87cdf0e10cSrcweir        pass
88cdf0e10cSrcweir
89cdf0e10cSrcweir    def removeStatusListener(self, Control, URL):
90cdf0e10cSrcweir        pass
91cdf0e10cSrcweir
92cdf0e10cSrcweirg_ImplementationHelper = unohelper.ImplementationHelper()
93cdf0e10cSrcweirg_ImplementationHelper.addImplementation( \
94cdf0e10cSrcweir    Provider, Provider.implementationName, Provider.serviceNames)
95cdf0e10cSrcweirg_ImplementationHelper.addImplementation( \
96cdf0e10cSrcweir    Dispatch, Dispatch.implementationName, Dispatch.serviceNames)
97