1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 import java
.io
.IOException
;
31 import com
.sun
.star
.beans
.PropertyValue
;
32 import com
.sun
.star
.beans
.PropertyState
;
34 import com
.sun
.star
.bridge
.XBridge
;
36 // import com.sun.star.comp.bootstrap.Bootstrap;
38 import com
.sun
.star
.connection
.XConnector
;
39 import com
.sun
.star
.connection
.XConnection
;
41 import com
.sun
.star
.io
.BufferSizeExceededException
;
42 import com
.sun
.star
.io
.NotConnectedException
;
43 import com
.sun
.star
.io
.XInputStream
;
44 import com
.sun
.star
.io
.XOutputStream
;
46 import com
.sun
.star
.frame
.XComponentLoader
;
48 import com
.sun
.star
.lang
.XComponent
;
49 import com
.sun
.star
.lang
.XMultiServiceFactory
;
50 import com
.sun
.star
.lang
.XServiceInfo
;
52 import com
.sun
.star
.text
.XSimpleText
;
53 import com
.sun
.star
.text
.XText
;
54 import com
.sun
.star
.text
.XTextCursor
;
55 import com
.sun
.star
.text
.XTextDocument
;
56 import com
.sun
.star
.text
.XTextRange
;
58 import com
.sun
.star
.uno
.IBridge
;
59 import com
.sun
.star
.uno
.UnoRuntime
;
60 import com
.sun
.star
.uno
.XInterface
;
61 import com
.sun
.star
.uno
.XNamingService
;
62 import com
.sun
.star
.container
.*;
63 import com
.sun
.star
.lang
.*;
65 import com
.sun
.star
.pgp
.*;
69 public class TestPGP
{
72 static void doSomething(Object r
) throws com
.sun
.star
.uno
.Exception
, IOException
, Exception
{
73 XNamingService rName
= (XNamingService
)UnoRuntime
.queryInterface(XNamingService
.class, r
);
76 System
.err
.println("got the remote naming service !");
77 Object rXsmgr
= rName
.getRegisteredObject("StarOffice.ServiceManager");
79 XMultiServiceFactory rSmgr
= (XMultiServiceFactory
)UnoRuntime
.queryInterface(XMultiServiceFactory
.class, rXsmgr
);
81 System
.err
.println("got the remote service manager !");
84 XSet set
= (XSet
)UnoRuntime
.queryInterface(XSet
.class, rSmgr
);
86 System
.err
.println(" couldn't get XSet from ServiceFactory");
90 SimplePGPMailerFactoryReg mailerReg
= new SimplePGPMailerFactoryReg();
91 XSingleServiceFactory factory
= mailerReg
.getServiceFactory(
92 "com.sun.star.pgp.SimplePGPMailerImpl", rSmgr
, null, null);
94 if( factory
== null) {
95 System
.err
.println("couldn't create PGP factory !");
99 System
.err
.println("PGP factory inserted into service manager");
101 // }catch(Exception e ){
102 // System.err.println( "exception caught in TestPGP");
110 static String neededServices
[] = new String
[] {
111 "com.sun.star.comp.servicemanager.ServiceManager",
112 "com.sun.star.comp.loader.JavaLoader",
113 "com.sun.star.comp.connections.Connector",
114 "com.sun.star.comp.connections.Acceptor"
117 public static void main(String argv
[]) throws Exception
{
118 if(argv
.length
!= 1) {
119 System
.err
.println("usage : testoffice protocol:host:port");
124 com
.sun
.star
.comp
.servicemanager
.ServiceManager smgr
= new com
.sun
.star
.comp
.servicemanager
.ServiceManager();
125 smgr
.addFactories(neededServices
, null);
127 XConnector xConnector
= (XConnector
)smgr
.createInstance("com.sun.star.connection.Connector");
128 XConnection xConnection
= xConnector
.connect(argv
[0]);
130 String rootOid
= "classic_uno";
131 IBridge iBridge
= UnoRuntime
.getBridgeByName("java", null, "remote", null, new Object
[]{"iiop", xConnection
, null});
133 Object rInitialObject
= iBridge
.mapInterfaceFrom(rootOid
, XInterface
.class);
134 // Object rInitialObject = xBridge.getInstance("NamingService");
136 if(rInitialObject
!= null) {
137 System
.err
.println("got the remote object");
138 doSomething(rInitialObject
);
141 // catch (Exception exception) {
142 // System.err.println("Exception thrown:" + exception);