Beispiel #1
0
void Scanner::finalizeReply()
{
    const SerializationInfo* s = _deserializer->si().findMember("error");

    if (s && !s->isNull())
    {
        log_debug("remote error detected category=" << s->category() << " type=" << s->typeName());

        std::string msg;
        if (s->category() == SerializationInfo::Object)
        {
            int rc = 0;
            s->getMember("code", rc);
            s->getMember("message", msg);
            throw RemoteException(msg, rc);
        }
        else
        {
            s->getValue(msg);
            if (msg.empty())
                msg = "remote exception";

            throw RemoteException(msg);
        }
    }

    _composer->fixup(
        _deserializer->si().getMember("result"));
}
Beispiel #2
0
void Binder::transact(int32_t what, int32_t arg1, int32_t arg2, const sp<Object>& obj, const sp<Awaitable>& result, int32_t flags) {
	sp<Message> message = mMessenger->obtainMessage(what, arg1, arg2, obj);
	if (flags == FLAG_ONEWAY) {
		message->sendToTarget();
	} else {
		message->result = result;
		message->sendToTarget();
		try {
			result->await();
		} catch (const CancellationException& e) {
			throw RemoteException(EXCEPTION_MESSAGE);
		} catch (const ExecutionException& e) {
			throw RemoteException(EXCEPTION_MESSAGE);
		}
	}
}
Beispiel #3
0
void Parcel::putShort(short value) {
    checkOutput();
    try {
        mDataOutputStream->writeShort(value);
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #4
0
void Parcel::putChar(char value) {
    checkOutput();
    try {
        mDataOutputStream->writeChar(value);
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #5
0
void Parcel::putByte(uint8_t value) {
    checkOutput();
    try {
        mDataOutputStream->writeByte(value);
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #6
0
void Parcel::putBoolean(bool value) {
    checkOutput();
    try {
        mDataOutputStream->writeBoolean(value);
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #7
0
sp<String> Parcel::getString() {
    checkInput();
    try {
        return mDataInputStream->readUTF();
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #8
0
double Parcel::getDouble() {
    checkInput();
    try {
        return mDataInputStream->readDouble();
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #9
0
uint64_t Parcel::getLong() {
    checkInput();
    try {
        return mDataInputStream->readLong();
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #10
0
bool Parcel::getBoolean() {
    checkInput();
    try {
        return mDataInputStream->readBoolean();
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #11
0
void Parcel::putString(const sp<String>& value) {
    checkOutput();
    try {
        mDataOutputStream->writeUTF(value);
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #12
0
void Parcel::putDouble(double value) {
    checkOutput();
    try {
        mDataOutputStream->writeDouble(value);
    } catch (const IOException& e) {
        throw RemoteException(e);
    }
}
Beispiel #13
0
sp<URI> Parcel::toUri(const sp<IBinder>& base, const sp<IBinder>& binder) {
    try {
        sp<URI> descriptor = new URI(binder->getInterfaceDescriptor());
        sp<URI> uri = new URI(base->getUri()->getScheme(), binder->getUri()->getAuthority(), String::format("/if=%s", descriptor->getPath()->substring(1)->c_str()), descriptor->getQuery(), nullptr);
        return uri;
    } catch (const URISyntaxException& e) {
        throw RemoteException(e);
    }
}
void ControlMessage::checkRetCode()
{
  UINT32 messageId = m_gate->readUInt32();

  switch (messageId) {
  case ControlProto::REPLY_ERROR:
    {
      StringStorage message;
      m_gate->readUTF8(&message);
      throw RemoteException(message.getString());
    }
    break;
  case ControlProto::REPLY_OK:
    break;
  default:
    _ASSERT(FALSE);
    throw RemoteException(_T("Unknown ret code."));
  }
}
Beispiel #15
0
void ControlMessage::checkRetCode()
{
  UINT32 messageId = m_gate->readUInt32();

  switch (messageId) {
  case ControlProto::REPLY_ERROR:
    {
      StringStorage message;
      m_gate->readUTF8(&message);
      throw RemoteException(message.getString());
    }
    break;
  case ControlProto::REPLY_AUTH_NEEDED:
    if (m_passwordFile.getLength() != 0) {
      authFromFile();
    } else if (m_getPassFromConfigEnabled) {
      authFromRegistry();
    } else {
      ControlAuthDialog authDialog;

      int retCode = authDialog.showModal();
      switch (retCode) {
      case IDCANCEL:
        throw ControlAuthException(StringTable::getString(IDS_USER_CANCEL_CONTROL_AUTH), true);
      case IDOK:
        ControlAuth auth(m_gate, authDialog.getPassword());
        send();
        break;
      }
    }
    break;
  case ControlProto::REPLY_OK:
    break;
  default:
    _ASSERT(FALSE);
    throw RemoteException(_T("Unknown ret code."));
  }
}
Beispiel #16
0
    void ClientStub::requestTransportFilters(const std::vector<FilterPtr> &filters)
    {
        if (getRuntimeVersion() <= 11)
        {
            requestTransportFilters_Legacy(filters);
            return;
        }

        ClientStub stub(*this);
        stub.setTransport( releaseTransport());
        stub.setTargetToken( Token());

        RestoreClientTransportGuard guard(*this, stub);

        // Set OOB request.
        OobRequestTransportFilters msg(getRuntimeVersion(), filters);
        ByteBuffer controlRequest;
        msg.encodeRequest(controlRequest);
        stub.setOutofBandRequest(controlRequest);

        stub.ping(RCF::Twoway);

        // Get OOB response.
        ByteBuffer controlResponse = stub.getOutOfBandResponse();
        stub.setOutofBandRequest(ByteBuffer());
        stub.setOutofBandResponse(ByteBuffer());
        msg.decodeResponse(controlResponse);

        int ret = msg.mResponseError; 
        RCF_VERIFY(ret == RcfError_Ok, RemoteException( Error(ret) ));

        for (std::size_t i=0; i<filters.size(); ++i)
        {
            filters[i]->resetState();
        }

        stub.getTransport().setTransportFilters(filters);
    }