| 1 |
#ifndef PROTON_DISPOSITION_H |
| 2 |
#define PROTON_DISPOSITION_H 1 |
| 3 |
|
| 4 |
/* |
| 5 |
* |
| 6 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 7 |
* or more contributor license agreements. See the NOTICE file |
| 8 |
* distributed with this work for additional information |
| 9 |
* regarding copyright ownership. The ASF licenses this file |
| 10 |
* to you under the Apache License, Version 2.0 (the |
| 11 |
* "License"); you may not use this file except in compliance |
| 12 |
* with the License. You may obtain a copy of the License at |
| 13 |
* |
| 14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
* |
| 16 |
* Unless required by applicable law or agreed to in writing, |
| 17 |
* software distributed under the License is distributed on an |
| 18 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 19 |
* KIND, either express or implied. See the License for the |
| 20 |
* specific language governing permissions and limitations |
| 21 |
* under the License. |
| 22 |
* |
| 23 |
*/ |
| 24 |
|
| 25 |
#include <proton/import_export.h> |
| 26 |
#include <proton/type_compat.h> |
| 27 |
#include <proton/condition.h> |
| 28 |
#include <stddef.h> |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" { |
| 32 |
#endif |
| 33 |
|
| 34 |
/** |
| 35 |
* @file |
| 36 |
* |
| 37 |
* @copybrief pn_disposition_t |
| 38 |
* |
| 39 |
* @addtogroup delivery |
| 40 |
* @{ |
| 41 |
*/ |
| 42 |
|
| 43 |
/** |
| 44 |
* A delivery state. |
| 45 |
* |
| 46 |
* Dispositions record the current state or final outcome of a |
| 47 |
* transfer. Every delivery contains both a local and remote |
| 48 |
* disposition. The local disposition holds the local state of the |
| 49 |
* delivery, and the remote disposition holds the last known remote |
| 50 |
* state of the delivery. |
| 51 |
*/ |
| 52 |
typedef struct pn_disposition_t pn_disposition_t; |
| 53 |
|
| 54 |
/** |
| 55 |
* The PN_RECEIVED delivery state is a non terminal state indicating |
| 56 |
* how much (if any) message data has been received for a delivery. |
| 57 |
*/ |
| 58 |
#define PN_RECEIVED (0x0000000000000023) |
| 59 |
|
| 60 |
/** |
| 61 |
* The PN_ACCEPTED delivery state is a terminal state indicating that |
| 62 |
* the delivery was successfully processed. Once in this state there |
| 63 |
* will be no further state changes prior to the delivery being |
| 64 |
* settled. |
| 65 |
*/ |
| 66 |
#define PN_ACCEPTED (0x0000000000000024) |
| 67 |
|
| 68 |
/** |
| 69 |
* The PN_REJECTED delivery state is a terminal state indicating that |
| 70 |
* the delivery could not be processed due to some error condition. |
| 71 |
* Once in this state there will be no further state changes prior to |
| 72 |
* the delivery being settled. |
| 73 |
*/ |
| 74 |
#define PN_REJECTED (0x0000000000000025) |
| 75 |
|
| 76 |
/** |
| 77 |
* The PN_RELEASED delivery state is a terminal state indicating that |
| 78 |
* the delivery is being returned to the sender. Once in this state |
| 79 |
* there will be no further state changes prior to the delivery being |
| 80 |
* settled. |
| 81 |
*/ |
| 82 |
#define PN_RELEASED (0x0000000000000026) |
| 83 |
|
| 84 |
/** |
| 85 |
* The PN_MODIFIED delivery state is a terminal state indicating that |
| 86 |
* the delivery is being returned to the sender and should be |
| 87 |
* annotated by the sender prior to further delivery attempts. Once in |
| 88 |
* this state there will be no further state changes prior to the |
| 89 |
* delivery being settled. |
| 90 |
*/ |
| 91 |
#define PN_MODIFIED (0x0000000000000027) |
| 92 |
|
| 93 |
/** |
| 94 |
* Get the type of a disposition. |
| 95 |
* |
| 96 |
* Defined values are: |
| 97 |
* |
| 98 |
* - ::PN_RECEIVED |
| 99 |
* - ::PN_ACCEPTED |
| 100 |
* - ::PN_REJECTED |
| 101 |
* - ::PN_RELEASED |
| 102 |
* - ::PN_MODIFIED |
| 103 |
* |
| 104 |
* @param[in] disposition a disposition object |
| 105 |
* @return the type of the disposition |
| 106 |
*/ |
| 107 |
PN_EXTERN uint64_t pn_disposition_type(pn_disposition_t *disposition); |
| 108 |
|
| 109 |
/** |
| 110 |
* Name of a disposition type for logging and debugging: "received", "accepted" etc. |
| 111 |
*/ |
| 112 |
PN_EXTERN const char *pn_disposition_type_name(uint64_t disposition_type); |
| 113 |
|
| 114 |
/** |
| 115 |
* Access the condition object associated with a disposition. |
| 116 |
* |
| 117 |
* The ::pn_condition_t object retrieved by this operation may be |
| 118 |
* modified prior to updating a delivery. When a delivery is updated, |
| 119 |
* the condition described by the disposition is reported to the peer |
| 120 |
* if applicable to the current delivery state, e.g. states such as |
| 121 |
* ::PN_REJECTED. |
| 122 |
* |
| 123 |
* The pointer returned by this operation is valid until the parent |
| 124 |
* delivery is settled. |
| 125 |
* |
| 126 |
* @param[in] disposition a disposition object |
| 127 |
* @return a pointer to the disposition condition |
| 128 |
*/ |
| 129 |
PN_EXTERN pn_condition_t *pn_disposition_condition(pn_disposition_t *disposition); |
| 130 |
|
| 131 |
/** |
| 132 |
* Access the disposition as a raw pn_data_t. |
| 133 |
* |
| 134 |
* Dispositions are an extension point in the AMQP protocol. The |
| 135 |
* disposition interface provides setters/getters for those |
| 136 |
* dispositions that are predefined by the specification, however |
| 137 |
* access to the raw disposition data is provided so that other |
| 138 |
* dispositions can be used. |
| 139 |
* |
| 140 |
* The ::pn_data_t pointer returned by this operation is valid until |
| 141 |
* the parent delivery is settled. |
| 142 |
* |
| 143 |
* @param[in] disposition a disposition object |
| 144 |
* @return a pointer to the raw disposition data |
| 145 |
*/ |
| 146 |
PN_EXTERN pn_data_t *pn_disposition_data(pn_disposition_t *disposition); |
| 147 |
|
| 148 |
/** |
| 149 |
* Get the section number associated with a disposition. |
| 150 |
* |
| 151 |
* @param[in] disposition a disposition object |
| 152 |
* @return a section number |
| 153 |
*/ |
| 154 |
PN_EXTERN uint32_t pn_disposition_get_section_number(pn_disposition_t *disposition); |
| 155 |
|
| 156 |
/** |
| 157 |
* Set the section number associated with a disposition. |
| 158 |
* |
| 159 |
* @param[in] disposition a disposition object |
| 160 |
* @param[in] section_number a section number |
| 161 |
*/ |
| 162 |
PN_EXTERN void pn_disposition_set_section_number(pn_disposition_t *disposition, uint32_t section_number); |
| 163 |
|
| 164 |
/** |
| 165 |
* Get the section offset associated with a disposition. |
| 166 |
* |
| 167 |
* @param[in] disposition a disposition object |
| 168 |
* @return a section offset |
| 169 |
*/ |
| 170 |
PN_EXTERN uint64_t pn_disposition_get_section_offset(pn_disposition_t *disposition); |
| 171 |
|
| 172 |
/** |
| 173 |
* Set the section offset associated with a disposition. |
| 174 |
* |
| 175 |
* @param[in] disposition a disposition object |
| 176 |
* @param[in] section_offset a section offset |
| 177 |
*/ |
| 178 |
PN_EXTERN void pn_disposition_set_section_offset(pn_disposition_t *disposition, uint64_t section_offset); |
| 179 |
|
| 180 |
/** |
| 181 |
* Check if a disposition has the failed flag set. |
| 182 |
* |
| 183 |
* @param[in] disposition a disposition object |
| 184 |
* @return true if the disposition has the failed flag set, false otherwise |
| 185 |
*/ |
| 186 |
PN_EXTERN bool pn_disposition_is_failed(pn_disposition_t *disposition); |
| 187 |
|
| 188 |
/** |
| 189 |
* Set the failed flag on a disposition. |
| 190 |
* |
| 191 |
* @param[in] disposition a disposition object |
| 192 |
* @param[in] failed the value of the failed flag |
| 193 |
*/ |
| 194 |
PN_EXTERN void pn_disposition_set_failed(pn_disposition_t *disposition, bool failed); |
| 195 |
|
| 196 |
/** |
| 197 |
* Check if a disposition has the undeliverable flag set. |
| 198 |
* |
| 199 |
* @param[in] disposition a disposition object |
| 200 |
* @return true if the disposition has the undeliverable flag set, false otherwise |
| 201 |
*/ |
| 202 |
PN_EXTERN bool pn_disposition_is_undeliverable(pn_disposition_t *disposition); |
| 203 |
|
| 204 |
/** |
| 205 |
* Set the undeliverable flag on a disposition. |
| 206 |
* |
| 207 |
* @param[in] disposition a disposition object |
| 208 |
* @param[in] undeliverable the value of the undeliverable flag |
| 209 |
*/ |
| 210 |
PN_EXTERN void pn_disposition_set_undeliverable(pn_disposition_t *disposition, bool undeliverable); |
| 211 |
|
| 212 |
/** |
| 213 |
* Access the annotations associated with a disposition. |
| 214 |
* |
| 215 |
* The ::pn_data_t object retrieved by this operation may be modified |
| 216 |
* prior to updating a delivery. When a delivery is updated, the |
| 217 |
* annotations described by the ::pn_data_t are reported to the peer |
| 218 |
* if applicable to the current delivery state, e.g. states such as |
| 219 |
* ::PN_MODIFIED. The ::pn_data_t must be empty or contain a symbol |
| 220 |
* keyed map. |
| 221 |
* |
| 222 |
* The pointer returned by this operation is valid until the parent |
| 223 |
* delivery is settled. |
| 224 |
* |
| 225 |
* @param[in] disposition a disposition object |
| 226 |
* @return the annotations associated with the disposition |
| 227 |
*/ |
| 228 |
PN_EXTERN pn_data_t *pn_disposition_annotations(pn_disposition_t *disposition); |
| 229 |
|
| 230 |
/** |
| 231 |
* @} |
| 232 |
*/ |
| 233 |
|
| 234 |
#ifdef __cplusplus |
| 235 |
} |
| 236 |
#endif |
| 237 |
|
| 238 |
#endif /* disposition.h */ |