| 1 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 2 |
# or more contributor license agreements. See the NOTICE file |
| 3 |
# distributed with this work for additional information |
| 4 |
# regarding copyright ownership. The ASF licenses this file |
| 5 |
# to you under the Apache License, Version 2.0 (the |
| 6 |
# "License"); you may not use this file except in compliance |
| 7 |
# with the License. You may obtain a copy of the License at |
| 8 |
# |
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
# |
| 11 |
# Unless required by applicable law or agreed to in writing, |
| 12 |
# software distributed under the License is distributed on an |
| 13 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 |
# KIND, either express or implied. See the License for the |
| 15 |
# specific language governing permissions and limitations |
| 16 |
# under the License. |
| 17 |
|
| 18 |
|
| 19 |
module Qpid::Proton |
| 20 |
|
| 21 |
# Status of a message transfer on a {Link} |
| 22 |
# Common base class for {Tracker} and {Delivery}. |
| 23 |
class Transfer |
| 24 |
include Util::Deprecation |
| 25 |
|
| 26 |
# @!private |
| 27 |
PROTON_METHOD_PREFIX = "pn_delivery" |
| 28 |
# @!private |
| 29 |
include Util::Wrapper |
| 30 |
|
| 31 |
def self.wrap(impl) |
| 32 |
return unless impl |
| 33 |
self.fetch_instance(impl, :pn_delivery_attachments) || |
| 34 |
(Cproton.pn_link_is_sender(Cproton.pn_delivery_link(impl)) ? Tracker : Delivery).new(impl) |
| 35 |
end |
| 36 |
|
| 37 |
def initialize(impl) |
| 38 |
@impl = impl |
| 39 |
@inspect = nil |
| 40 |
self.class.store_instance(self, :pn_delivery_attachments) |
| 41 |
end |
| 42 |
|
| 43 |
public |
| 44 |
|
| 45 |
State = Disposition::State |
| 46 |
include State |
| 47 |
|
| 48 |
# @return [String] Unique ID for the transfer in the context of the {#link} |
| 49 |
def id() Cproton.pn_delivery_tag(@impl); end |
| 50 |
|
| 51 |
# @deprecated use {#id} |
| 52 |
deprecated_alias :tag, :id |
| 53 |
|
| 54 |
# @return [Boolean] True if the transfer is remotely settled. |
| 55 |
proton_caller :settled? |
| 56 |
|
| 57 |
# @return [Integer] Remote state of the transfer, one of the values in {State} |
| 58 |
def state() Cproton.pn_delivery_remote_state(@impl); end |
| 59 |
|
| 60 |
# @return [Link] The parent link. |
| 61 |
def link() Link.wrap(Cproton.pn_delivery_link(@impl)); end |
| 62 |
|
| 63 |
# @return [Session] The parent session. |
| 64 |
def session() link.session; end |
| 65 |
|
| 66 |
# @return [Connection] The parent connection. |
| 67 |
def connection() self.session.connection; end |
| 68 |
|
| 69 |
# @return [Transport] The parent connection's transport. |
| 70 |
def transport() self.connection.transport; end |
| 71 |
|
| 72 |
# @return [WorkQueue] The parent connection's work-queue. |
| 73 |
def work_queue() self.connection.work_queue; end |
| 74 |
|
| 75 |
# @deprecated internal use only |
| 76 |
proton_caller :writable? |
| 77 |
# @deprecated internal use only |
| 78 |
proton_caller :readable? |
| 79 |
# @deprecated internal use only |
| 80 |
proton_caller :updated? |
| 81 |
# @deprecated internal use only |
| 82 |
proton_caller :clear |
| 83 |
# @deprecated internal use only |
| 84 |
proton_caller :pending |
| 85 |
# @deprecated internal use only |
| 86 |
proton_caller :partial? |
| 87 |
# @deprecated internal use only |
| 88 |
def update(state) Cproton.pn_delivery_update(@impl, state); end |
| 89 |
# @deprecated internal use only |
| 90 |
proton_caller :buffered? |
| 91 |
# @deprecated internal use only |
| 92 |
def local_state() Cproton.pn_delivery_local_state(@impl); end |
| 93 |
# @deprecated use {#state} |
| 94 |
deprecated_alias :remote_state, :state |
| 95 |
# @deprecated internal use only |
| 96 |
def settle(state = nil) |
| 97 |
update(state) unless state.nil? |
| 98 |
Cproton.pn_delivery_settle(@impl) |
| 99 |
@inspect = inspect # Save the inspect string, the delivery pointer will go bad. |
| 100 |
end |
| 101 |
|
| 102 |
def inspect() @inspect || super; end |
| 103 |
def to_s() inspect; end |
| 104 |
end |
| 105 |
end |