2011-06-02 16:49:28 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 17:51:46 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2011-01-26 09:26:59 +01:00
|
|
|
|
|
|
|
#include "sal/config.h"
|
|
|
|
|
2011-11-28 21:11:28 +01:00
|
|
|
#include <cassert>
|
2011-01-26 09:26:59 +01:00
|
|
|
#include <exception>
|
2014-09-24 12:44:55 +02:00
|
|
|
#include <memory>
|
2011-01-26 09:26:59 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "com/sun/star/connection/XConnection.hpp"
|
|
|
|
#include "com/sun/star/io/IOException.hpp"
|
|
|
|
#include "com/sun/star/uno/Any.hxx"
|
|
|
|
#include "com/sun/star/uno/Exception.hpp"
|
|
|
|
#include "com/sun/star/uno/Reference.hxx"
|
|
|
|
#include "com/sun/star/uno/RuntimeException.hpp"
|
|
|
|
#include "com/sun/star/uno/Sequence.hxx"
|
|
|
|
#include "com/sun/star/uno/Type.hxx"
|
|
|
|
#include "com/sun/star/uno/XCurrentContext.hpp"
|
|
|
|
#include "com/sun/star/uno/XInterface.hpp"
|
|
|
|
#include "cppu/unotype.hxx"
|
|
|
|
#include "rtl/byteseq.h"
|
|
|
|
#include "rtl/ustring.hxx"
|
2015-04-22 09:42:28 +02:00
|
|
|
#include "sal/log.hxx"
|
2011-01-26 09:26:59 +01:00
|
|
|
#include "sal/types.h"
|
|
|
|
#include "typelib/typeclass.h"
|
|
|
|
#include "typelib/typedescription.h"
|
|
|
|
#include "typelib/typedescription.hxx"
|
|
|
|
|
|
|
|
#include "binaryany.hxx"
|
|
|
|
#include "bridge.hxx"
|
|
|
|
#include "incomingreply.hxx"
|
|
|
|
#include "incomingrequest.hxx"
|
|
|
|
#include "outgoingrequest.hxx"
|
|
|
|
#include "reader.hxx"
|
|
|
|
#include "specialfunctionids.hxx"
|
|
|
|
#include "unmarshal.hxx"
|
|
|
|
|
|
|
|
namespace binaryurp {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
css::uno::Sequence< sal_Int8 > read(
|
|
|
|
css::uno::Reference< css::connection::XConnection > const & connection,
|
|
|
|
sal_uInt32 size, bool eofOk)
|
|
|
|
{
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(connection.is());
|
2011-01-26 09:26:59 +01:00
|
|
|
if (size > SAL_MAX_INT32) {
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"binaryurp::Reader: block size too large");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
css::uno::Sequence< sal_Int8 > buf;
|
|
|
|
sal_Int32 n = connection->read(buf, static_cast< sal_Int32 >(size));
|
|
|
|
if (n == 0 && eofOk) {
|
|
|
|
return css::uno::Sequence< sal_Int8 >();
|
|
|
|
}
|
|
|
|
if (n != static_cast< sal_Int32 >(size)) {
|
|
|
|
throw css::io::IOException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"binaryurp::Reader: premature end of input");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(buf.getLength() == static_cast< sal_Int32 >(size));
|
2011-01-26 09:26:59 +01:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void SAL_CALL request(void * pThreadSpecificData) {
|
2015-11-10 10:10:57 +01:00
|
|
|
assert(pThreadSpecificData != nullptr);
|
2015-02-15 20:41:33 +00:00
|
|
|
std::unique_ptr< IncomingRequest >(
|
2011-01-26 09:26:59 +01:00
|
|
|
static_cast< IncomingRequest * >(pThreadSpecificData))->
|
|
|
|
execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-23 10:30:08 +01:00
|
|
|
Reader::Reader(rtl::Reference< Bridge > const & bridge):
|
|
|
|
Thread("binaryurpReader"), bridge_(bridge)
|
|
|
|
{
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(bridge.is());
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Reader::~Reader() {}
|
|
|
|
|
2012-02-23 10:30:08 +01:00
|
|
|
void Reader::execute() {
|
2011-01-26 09:26:59 +01:00
|
|
|
try {
|
|
|
|
bridge_->sendRequestChangeRequest();
|
|
|
|
css::uno::Reference< css::connection::XConnection > con(
|
|
|
|
bridge_->getConnection());
|
|
|
|
for (;;) {
|
|
|
|
css::uno::Sequence< sal_Int8 > s(read(con, 8, true));
|
|
|
|
if (s.getLength() == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Unmarshal header(bridge_, state_, s);
|
|
|
|
sal_uInt32 size = header.read32();
|
|
|
|
sal_uInt32 count = header.read32();
|
|
|
|
header.done();
|
|
|
|
if (count == 0) {
|
|
|
|
throw css::io::IOException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"binaryurp::Reader: block with zero message count received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
Unmarshal block(bridge_, state_, read(con, size, false));
|
|
|
|
for (sal_uInt32 i = 0; i != count; ++i) {
|
|
|
|
readMessage(block);
|
|
|
|
}
|
|
|
|
block.done();
|
|
|
|
}
|
2011-11-30 11:05:16 +09:00
|
|
|
} catch (const css::uno::Exception & e) {
|
2011-11-28 21:11:28 +01:00
|
|
|
SAL_WARN("binaryurp", "caught UNO exception '" << e.Message << '\'');
|
2011-11-30 11:05:16 +09:00
|
|
|
} catch (const std::exception & e) {
|
2011-11-28 21:11:28 +01:00
|
|
|
SAL_WARN("binaryurp", "caught C++ exception '" << e.what() << '\'');
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
bridge_->terminate(false);
|
2014-02-07 14:28:07 +01:00
|
|
|
bridge_.clear();
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reader::readMessage(Unmarshal & unmarshal) {
|
|
|
|
sal_uInt8 flags1 = unmarshal.read8();
|
|
|
|
bool newType;
|
|
|
|
bool newOid;
|
|
|
|
bool newTid;
|
|
|
|
bool forceSynchronous;
|
|
|
|
sal_uInt16 functionId;
|
|
|
|
if ((flags1 & 0x80) != 0) { // bit 7: LONGHEADER
|
|
|
|
if ((flags1 & 0x40) == 0) { // bit 6: REQUEST
|
|
|
|
readReplyMessage(unmarshal, flags1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
newType = (flags1 & 0x20) != 0; // bit 5: NEWTYPE
|
|
|
|
newOid = (flags1 & 0x10) != 0; // bit 4: NEWOID
|
|
|
|
newTid = (flags1 & 0x08) != 0; // bit 3: NEWTID
|
|
|
|
if ((flags1 & 0x01) != 0) { // bit 0: MOREFLAGSS
|
|
|
|
sal_uInt8 flags2 = unmarshal.read8();
|
|
|
|
forceSynchronous = (flags2 & 0x80) != 0; // bit 7: MUSTREPLY
|
|
|
|
if (((flags2 & 0x40) != 0) != forceSynchronous) {
|
|
|
|
// bit 6: SYNCHRONOUS
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with MUSTREPLY != SYNCHRONOUS"
|
|
|
|
" received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
forceSynchronous = false;
|
|
|
|
}
|
|
|
|
functionId = ((flags1 & 0x04) != 0) // bit 2: FUNCTIONID16
|
|
|
|
? unmarshal.read16() : unmarshal.read8();
|
|
|
|
} else {
|
|
|
|
newType = false;
|
|
|
|
newOid = false;
|
|
|
|
newTid = false;
|
|
|
|
forceSynchronous = false;
|
|
|
|
functionId = ((flags1 & 0x40) != 0) // bit 6: FUNCTIONID14
|
|
|
|
? ((flags1 & 0x3F) << 8) | unmarshal.read8() : flags1 & 0x3F;
|
|
|
|
}
|
|
|
|
css::uno::TypeDescription type;
|
|
|
|
if (newType) {
|
|
|
|
type = unmarshal.readType();
|
|
|
|
lastType_ = type;
|
|
|
|
} else {
|
|
|
|
if (!lastType_.is()) {
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with NEWTYPE received when last"
|
|
|
|
" interface type has not yet been set");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
type = lastType_;
|
|
|
|
}
|
2012-08-18 15:05:22 -03:00
|
|
|
OUString oid;
|
2011-01-26 09:26:59 +01:00
|
|
|
if (newOid) {
|
|
|
|
oid = unmarshal.readOid();
|
2011-12-10 17:29:21 -02:00
|
|
|
if (oid.isEmpty()) {
|
2011-01-26 09:26:59 +01:00
|
|
|
throw css::io::IOException(
|
2016-07-03 20:24:00 +03:00
|
|
|
"binaryurp::Unmarshal: empty OID");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
lastOid_ = oid;
|
|
|
|
} else {
|
2011-12-10 17:29:21 -02:00
|
|
|
if (lastOid_.isEmpty()) {
|
2011-01-26 09:26:59 +01:00
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with NEWOID received when last OID has"
|
|
|
|
" not yet been set");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
oid = lastOid_;
|
|
|
|
}
|
|
|
|
rtl::ByteSequence tid(getTid(unmarshal, newTid));
|
|
|
|
lastTid_ = tid;
|
|
|
|
type.makeComplete();
|
|
|
|
if (type.get()->eTypeClass != typelib_TypeClass_INTERFACE) {
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with non-interface interface type received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
typelib_InterfaceTypeDescription * itd =
|
|
|
|
reinterpret_cast< typelib_InterfaceTypeDescription * >(type.get());
|
|
|
|
if (functionId >= itd->nMapFunctionIndexToMemberIndex) {
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with unknown function ID received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
sal_Int32 memberId = itd->pMapFunctionIndexToMemberIndex[functionId];
|
|
|
|
css::uno::TypeDescription memberTd(itd->ppAllMembers[memberId]);
|
|
|
|
memberTd.makeComplete();
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(memberTd.is());
|
2011-01-26 09:26:59 +01:00
|
|
|
bool protProps = bridge_->isProtocolPropertiesRequest(oid, type);
|
|
|
|
bool ccMode = !protProps && functionId != SPECIAL_FUNCTION_ID_RELEASE &&
|
|
|
|
bridge_->isCurrentContextMode();
|
|
|
|
css::uno::UnoInterfaceReference cc;
|
|
|
|
if (ccMode) {
|
|
|
|
css::uno::TypeDescription t(
|
2015-04-01 10:42:11 +02:00
|
|
|
cppu::UnoType<css::uno::XCurrentContext>::get());
|
2011-01-26 09:26:59 +01:00
|
|
|
cc.set(
|
|
|
|
*static_cast< uno_Interface ** >(
|
|
|
|
unmarshal.readValue(t).getValue(t)));
|
|
|
|
}
|
2013-11-28 08:25:50 +01:00
|
|
|
bool oneWay =
|
|
|
|
memberTd.get()->eTypeClass == typelib_TypeClass_INTERFACE_METHOD &&
|
2011-01-26 09:26:59 +01:00
|
|
|
(reinterpret_cast< typelib_InterfaceMethodTypeDescription * >(
|
|
|
|
memberTd.get())->
|
2013-11-28 08:25:50 +01:00
|
|
|
bOneWay);
|
|
|
|
SAL_INFO_IF(
|
|
|
|
!oneWay && forceSynchronous, "binaryurp",
|
|
|
|
("superfluous MUSTREPLY/SYNCHRONOUS ignored in request message with"
|
|
|
|
" non-oneway function ID"));
|
|
|
|
bool synchronous = !oneWay || forceSynchronous;
|
2015-09-25 11:41:53 +01:00
|
|
|
bool bSetter = false;
|
2011-01-26 09:26:59 +01:00
|
|
|
std::vector< BinaryAny > inArgs;
|
|
|
|
switch (memberTd.get()->eTypeClass) {
|
|
|
|
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
|
2015-09-25 11:41:53 +01:00
|
|
|
bSetter = itd->pMapMemberIndexToFunctionIndex[memberId] != functionId;
|
2011-01-26 09:26:59 +01:00
|
|
|
// pMapMemberIndexToFunctionIndex contains function index of
|
|
|
|
// attribute getter
|
2015-09-25 11:41:53 +01:00
|
|
|
if (bSetter) {
|
2011-01-26 09:26:59 +01:00
|
|
|
inArgs.push_back(
|
|
|
|
unmarshal.readValue(
|
|
|
|
css::uno::TypeDescription(
|
|
|
|
reinterpret_cast<
|
|
|
|
typelib_InterfaceAttributeTypeDescription * >(
|
|
|
|
memberTd.get())->
|
|
|
|
pAttributeTypeRef)));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_INTERFACE_METHOD:
|
|
|
|
{
|
|
|
|
typelib_InterfaceMethodTypeDescription * mtd =
|
|
|
|
reinterpret_cast< typelib_InterfaceMethodTypeDescription * >(
|
|
|
|
memberTd.get());
|
|
|
|
for (sal_Int32 i = 0; i != mtd->nParams; ++i) {
|
|
|
|
if (mtd->pParams[i].bIn) {
|
|
|
|
inArgs.push_back(
|
|
|
|
unmarshal.readValue(
|
|
|
|
css::uno::TypeDescription(
|
|
|
|
mtd->pParams[i].pTypeRef)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(false); // this cannot happen
|
2011-01-26 09:26:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge_->incrementCalls(
|
|
|
|
!protProps && functionId != SPECIAL_FUNCTION_ID_RELEASE);
|
|
|
|
if (protProps) {
|
|
|
|
switch (functionId) {
|
|
|
|
case SPECIAL_FUNCTION_ID_REQUEST_CHANGE:
|
|
|
|
bridge_->handleRequestChangeRequest(tid, inArgs);
|
|
|
|
break;
|
|
|
|
case SPECIAL_FUNCTION_ID_COMMIT_CHANGE:
|
|
|
|
bridge_->handleCommitChangeRequest(tid, inArgs);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with UrpProtocolProperties OID and"
|
|
|
|
" unknown function ID received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
css::uno::UnoInterfaceReference obj;
|
|
|
|
switch (functionId) {
|
|
|
|
case SPECIAL_FUNCTION_ID_QUERY_INTERFACE:
|
|
|
|
obj = bridge_->findStub(oid, type);
|
|
|
|
if (!obj.is()) {
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(
|
2011-01-26 09:26:59 +01:00
|
|
|
inArgs.size() == 1
|
|
|
|
&& inArgs[0].getType().equals(
|
|
|
|
css::uno::TypeDescription(
|
|
|
|
cppu::UnoType< css::uno::Type >::get())));
|
|
|
|
if (!(type.equals(
|
|
|
|
css::uno::TypeDescription(
|
|
|
|
cppu::UnoType<
|
|
|
|
css::uno::Reference<
|
|
|
|
css::uno::XInterface > >::get()))
|
|
|
|
&& (css::uno::TypeDescription(
|
|
|
|
*static_cast<
|
|
|
|
typelib_TypeDescriptionReference ** >(
|
|
|
|
inArgs[0].getValue(inArgs[0].getType()))).
|
|
|
|
equals(
|
|
|
|
css::uno::TypeDescription(
|
|
|
|
cppu::UnoType<
|
|
|
|
css::uno::Reference<
|
|
|
|
css::uno::XInterface > >::get())))))
|
|
|
|
{
|
|
|
|
throw css::uno::RuntimeException(
|
2015-06-04 09:21:50 +02:00
|
|
|
"URP: queryInterface request message with unknown OID '"
|
|
|
|
+ oid + "' received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SPECIAL_FUNCTION_ID_RESERVED:
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with unknown function ID 1 received");
|
2011-01-26 09:26:59 +01:00
|
|
|
case SPECIAL_FUNCTION_ID_RELEASE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
obj = bridge_->findStub(oid, type);
|
|
|
|
if (!obj.is()) {
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: request message with unknown OID received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-09-24 12:44:55 +02:00
|
|
|
std::unique_ptr< IncomingRequest > req(
|
2011-01-26 09:26:59 +01:00
|
|
|
new IncomingRequest(
|
|
|
|
bridge_, tid, oid, obj, type, functionId, synchronous, memberTd,
|
2015-09-25 11:41:53 +01:00
|
|
|
bSetter, inArgs, ccMode, cc));
|
2011-01-26 09:26:59 +01:00
|
|
|
if (synchronous) {
|
|
|
|
bridge_->incrementActiveCalls();
|
|
|
|
}
|
|
|
|
uno_threadpool_putJob(
|
|
|
|
bridge_->getThreadPool(), tid.getHandle(), req.get(), &request,
|
|
|
|
!synchronous);
|
|
|
|
req.release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) {
|
|
|
|
rtl::ByteSequence tid(getTid(unmarshal, (flags1 & 0x08) != 0));
|
|
|
|
// bit 3: NEWTID
|
|
|
|
lastTid_ = tid;
|
|
|
|
OutgoingRequest req(bridge_->lastOutgoingRequest(tid));
|
|
|
|
bool exc = (flags1 & 0x20) != 0; // bit 5: EXCEPTION
|
|
|
|
BinaryAny ret;
|
|
|
|
std::vector< BinaryAny > outArgs;
|
|
|
|
if (exc) {
|
|
|
|
ret = unmarshal.readValue(
|
|
|
|
css::uno::TypeDescription(cppu::UnoType< css::uno::Any >::get()));
|
|
|
|
if (!typelib_typedescription_isAssignableFrom(
|
|
|
|
(css::uno::TypeDescription(
|
|
|
|
cppu::UnoType< css::uno::RuntimeException >::get()).
|
|
|
|
get()),
|
|
|
|
ret.getType().get()))
|
|
|
|
{
|
|
|
|
sal_Int32 n = 0;
|
2015-11-10 10:10:57 +01:00
|
|
|
typelib_TypeDescriptionReference ** p = nullptr;
|
2011-01-26 09:26:59 +01:00
|
|
|
switch (req.member.get()->eTypeClass) {
|
|
|
|
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
|
|
|
|
{
|
|
|
|
typelib_InterfaceAttributeTypeDescription * atd =
|
|
|
|
reinterpret_cast<
|
|
|
|
typelib_InterfaceAttributeTypeDescription * >(
|
|
|
|
req.member.get());
|
|
|
|
n = req.setter ? atd->nSetExceptions : atd->nGetExceptions;
|
|
|
|
p = req.setter
|
|
|
|
? atd->ppSetExceptions : atd->ppGetExceptions;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case typelib_TypeClass_INTERFACE_METHOD:
|
|
|
|
{
|
|
|
|
typelib_InterfaceMethodTypeDescription * mtd =
|
|
|
|
reinterpret_cast<
|
|
|
|
typelib_InterfaceMethodTypeDescription * >(
|
|
|
|
req.member.get());
|
|
|
|
n = mtd->nExceptions;
|
|
|
|
p = mtd->ppExceptions;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(false); // this cannot happen
|
2011-01-26 09:26:59 +01:00
|
|
|
break;
|
|
|
|
}
|
2015-09-25 11:41:53 +01:00
|
|
|
bool bOk = false;
|
2011-01-26 09:26:59 +01:00
|
|
|
for (sal_Int32 i = 0; i != n; ++i) {
|
|
|
|
if (typelib_typedescriptionreference_isAssignableFrom(
|
|
|
|
p[i],
|
|
|
|
reinterpret_cast< typelib_TypeDescriptionReference * >(
|
|
|
|
ret.getType().get())))
|
|
|
|
{
|
2015-09-25 11:41:53 +01:00
|
|
|
bOk = true;
|
2011-01-26 09:26:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-09-25 11:41:53 +01:00
|
|
|
if (!bOk) {
|
2011-01-26 09:26:59 +01:00
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: reply message with bad exception type received");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (req.member.get()->eTypeClass) {
|
|
|
|
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
|
|
|
|
if (!req.setter) {
|
|
|
|
ret = unmarshal.readValue(
|
|
|
|
css::uno::TypeDescription(
|
|
|
|
reinterpret_cast<
|
|
|
|
typelib_InterfaceAttributeTypeDescription * >(
|
|
|
|
req.member.get())->
|
|
|
|
pAttributeTypeRef));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_INTERFACE_METHOD:
|
|
|
|
{
|
|
|
|
typelib_InterfaceMethodTypeDescription * mtd =
|
|
|
|
reinterpret_cast<
|
|
|
|
typelib_InterfaceMethodTypeDescription * >(
|
|
|
|
req.member.get());
|
|
|
|
ret = unmarshal.readValue(
|
|
|
|
css::uno::TypeDescription(mtd->pReturnTypeRef));
|
|
|
|
for (sal_Int32 i = 0; i != mtd->nParams; ++i) {
|
|
|
|
if (mtd->pParams[i].bOut) {
|
|
|
|
outArgs.push_back(
|
|
|
|
unmarshal.readValue(
|
|
|
|
css::uno::TypeDescription(
|
|
|
|
mtd->pParams[i].pTypeRef)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(false); // this cannot happen
|
2011-01-26 09:26:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (req.kind) {
|
|
|
|
case OutgoingRequest::KIND_NORMAL:
|
|
|
|
{
|
2014-09-24 12:44:55 +02:00
|
|
|
std::unique_ptr< IncomingReply > resp(
|
2011-01-26 09:26:59 +01:00
|
|
|
new IncomingReply(exc, ret, outArgs));
|
|
|
|
uno_threadpool_putJob(
|
2015-11-10 10:10:57 +01:00
|
|
|
bridge_->getThreadPool(), tid.getHandle(), resp.get(), nullptr,
|
2011-01-26 09:26:59 +01:00
|
|
|
false);
|
|
|
|
resp.release();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OutgoingRequest::KIND_REQUEST_CHANGE:
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(outArgs.empty());
|
2011-01-26 09:26:59 +01:00
|
|
|
bridge_->handleRequestChangeReply(exc, ret);
|
|
|
|
break;
|
|
|
|
case OutgoingRequest::KIND_COMMIT_CHANGE:
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(outArgs.empty());
|
2011-01-26 09:26:59 +01:00
|
|
|
bridge_->handleCommitChangeReply(exc, ret);
|
|
|
|
break;
|
|
|
|
default:
|
2011-11-28 21:11:28 +01:00
|
|
|
assert(false); // this cannot happen
|
2011-01-26 09:26:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::ByteSequence Reader::getTid(Unmarshal & unmarshal, bool newTid) const {
|
|
|
|
if (newTid) {
|
|
|
|
return unmarshal.readTid();
|
|
|
|
}
|
|
|
|
if (lastTid_.getLength() == 0) {
|
|
|
|
throw css::uno::RuntimeException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"URP: message with NEWTID received when last TID has not yet been"
|
|
|
|
" set");
|
2011-01-26 09:26:59 +01:00
|
|
|
}
|
|
|
|
return lastTid_;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2011-06-02 16:49:28 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|