xref: /haiku/docs/user/netservices/NetServicesDefs.dox (revision a127b88ecbfab58f64944c98aa47722a18e363b2)
1/*
2 * Copyright 2021 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Niels Sascha Reedijk, niels.reedijk@gmail.com
7 *
8 * Corresponds to:
9 *		headers/private/netservices2/NetServicesDefs.h	hrev?????
10 */
11
12
13#if __cplusplus >= 201703L
14
15namespace BPrivate {
16
17namespace Network {
18
19
20/*!
21	\file NetServicesDefs.h
22	\ingroup netservices
23	\brief Various standardized error and notification types used by multiple protocols of the
24		Network Services Kit.
25
26	\since Haiku R1
27*/
28
29
30/*!
31	\class BUnsupportedProtocol
32	\ingroup netservices
33	\brief Error that indicates that the protocol is not supported.
34
35	\since Haiku R1
36*/
37
38
39/*!
40	\fn BUnsupportedProtocol::BUnsupportedProtocol(const char* origin,
41		BUrl url, BStringList supportedProtocols)
42	\brief Create a new unsupported protocol error.
43
44	\param origin A string representing where this error occured. It is advised
45		to initialize it to \c __PRETTY_FUNCTION__ by default.
46	\param url The URL object with the unsupported protocol.
47	\param supportedProtocols A list with the supported protocols.
48
49	\since Haiku R1
50*/
51
52
53/*!
54	\fn BUnsupportedProtocol::BUnsupportedProtocol(BString origin, BUrl url,
55		BStringList supportedProtocols)
56	\copydoc BUnsupportedProtocol(const char*, BUrl, BStringList)
57
58	\since Haiku R1
59*/
60
61
62/*!
63	\fn virtual const char* BUnsupportedProtocol::Message() const noexcept override
64	\brief Access the string representation of the message.
65
66	\since Haiku R1
67*/
68
69
70/*!
71	\fn const BUrl& BUnsupportedProtocol::Url() const
72	\brief The URL that caused the issue.
73
74	\since Haiku R1
75*/
76
77
78/*!
79	\fn const BStringList& BUnsupportedProtocol::SupportedProtocols() const
80	\brief A list of protocols that are supported.
81
82	\since Haiku R1
83*/
84
85
86/*!
87	\class BInvalidUrl
88	\ingroup netservices
89	\brief Error that indicates that the URL is not valid.
90
91	This error is raised as an exception when the caller tries to pass a
92	\ref BUrl object that does not contain a valid URL.
93
94	\see \ref BUrl::IsValid()
95
96	\since Haiku R1
97*/
98
99
100/*!
101	\fn BInvalidUrl::BInvalidUrl(const char* origin, BUrl url)
102	\brief Create a new error invalid URL error.
103
104	\param origin A string representing where this error occured. It is advised
105		to initialize it to \c __PRETTY_FUNCTION__ by default.
106	\param url The URL object that did not contain a valid URL.
107
108	\since Haiku R1
109*/
110
111
112/*!
113	\fn BInvalidUrl::BInvalidUrl(BString origin, BUrl url)
114	\copydoc BInvalidUrl::BInvalidUrl(const char* origin, BUrl url)
115*/
116
117
118/*!
119	\fn virtual const char* BInvalidUrl::Message() const noexcept override
120	\brief Access the string representation of the message.
121
122	\since Haiku R1
123*/
124
125
126/*!
127	\fn const BUrl& BInvalidUrl::Url() const
128	\brief The URL that caused the issue.
129
130	\since Haiku R1
131*/
132
133
134/*!
135	\class BNetworkRequestError
136	\ingroup netservices
137	\brief Error that indicates there was an issue executing the network request.
138
139	\since Haiku R1
140*/
141
142
143/*!
144	\enum BNetworkRequestError::ErrorType
145	\ingroup netservices
146	\brief A list of errors that can occur while executing a network request.
147
148	\since Haiku R1
149*/
150
151
152/*!
153	\var BNetworkRequestError::ErrorType BNetworkRequestError::HostnameError
154	\brief Error resolving the hostname.
155
156	\ref ErrorCode() will be set to contain the underlying error code.
157
158	\since Haiku R1
159*/
160
161
162/*!
163	\var BNetworkRequestError::ErrorType BNetworkRequestError::NetworkError
164	\brief The request was interrupted due to a network error.
165
166	This may occur when reading or writing fails due to an underlying network error, like an
167	unexpected closed connection.
168
169	\ref ErrorCode() will be set to contain the underlying error code.
170
171	\since Haiku R1
172*/
173
174
175/*!
176	\var BNetworkRequestError::ErrorType BNetworkRequestError::ProtocolError
177	\brief The request did not complete because the response did not conform to the protocol.
178
179	The server gave an unexpected or incorrect response. The network request could not complete
180	because of this.
181
182	There will not be any \ref ErrorCode() set.
183
184	\since Haiku R1
185*/
186
187
188/*!
189	\var BNetworkRequestError::ErrorType BNetworkRequestError::SystemError
190	\brief Other internal error while handling the request.
191
192	There could have been issues initializing buffers or decompression engines.
193
194	\ref ErrorCode() will be set to contain the underlying error code.
195
196	\since Haiku R1
197*/
198
199
200/*!
201	\var BNetworkRequestError::ErrorType BNetworkRequestError::Canceled
202	\brief The request was canceled before it was completed.
203
204	This could either have been done through the API, or because the session that schedules and
205	executes the requests was destroyed.
206
207	There will not be any \ref ErrorCode() set.
208
209	\since Haiku R1
210*/
211
212
213/*!
214	\fn BNetworkRequestError::BNetworkRequestError(const char *origin, ErrorType type,
215		status_t errorCode, const BString& customMessage = BString())
216	\brief Create a new network request error.
217
218	\param origin A string representing where this error occured. It is advised
219		to initialize it to \c __PRETTY_FUNCTION__ by default.
220	\param type The error type that describes what the issue was that prevented the completion of
221		the request.
222	\param errorCode The underlying system error. See the \ref BNetworkRequestError::ErrorType
223		documentation on which error types expect a system error.
224	\param customMessage Optional custom message describing the reason or cause for the error.
225
226	\since Haiku R1
227*/
228
229
230/*!
231	\fn BNetworkRequestError::BNetworkRequestError(const char *origin, ErrorType type,
232		const BString& customMessage = BString())
233	\brief Create a new network request error.
234
235	\param origin A string representing where this error occured. It is advised
236		to initialize it to \c __PRETTY_FUNCTION__ by default.
237	\param type The error type that describes what the issue was that prevented the completion of
238		the request.
239	\param customMessage Optional custom message describing the reason or cause for the error.
240
241	\since Haiku R1
242*/
243
244
245/*!
246	\fn status_t BNetworkRequestError::ErrorCode() const noexcept
247	\brief Get the underlying system error code.
248
249	\return A \c status_t error code when the associated \ref BNetworkRequestError::ErrorType sets
250		the system error, or \c B_OK if there is no additional error code available.
251
252	\since Haiku R1
253*/
254
255
256/*!
257	\fn ErrorType BNetworkRequestError::Type() const noexcept
258	\brief Get the error type.
259
260	\return Get the \ref BNetworkRequestError::ErrorType that describes the cause for the request
261		to fail.
262
263	\since Haiku R1
264*/
265
266
267/*!
268	\fn const char* BNetworkRequestError::CustomMessage() const noexcept
269	\brief Get the custom error message.
270
271	\return Get the custom error message. This may be an empty string if it was not set.
272
273	\since Haiku R1
274*/
275
276
277/*!
278	\fn BString encode_to_base64(const BString& string)
279	\brief Utility function that encodes a \a string to base64 and returns the result.
280
281	\since Haiku R1
282*/
283
284
285/*!
286	\namespace BPrivate::Network::UrlEvent
287	\brief Contains the message constants that are sent by the various protocols.
288
289	Please see the \link netservices kit documentation \endlink for details which messages are sent
290	at which stage, and what data they contain.
291
292	\since Haiku R1
293*/
294
295
296/*!
297	\var UrlEvent::HostNameResolved
298	\brief The hostname for the request is resolved.
299
300	\since Haiku R1
301*/
302
303
304/*!
305	\var UrlEvent::ConnectionOpened
306	\brief The connection for the request is opened and the request will be sent.
307
308	\since Haiku R1
309*/
310
311
312/*!
313	\var UrlEvent::UploadProgress
314	\brief There is progress sending the body for the request.
315
316	\since Haiku R1
317*/
318
319
320/*!
321	\var UrlEvent::ResponseStarted
322	\brief The request was sent, and the response is now incoming.
323
324	\since Haiku R1
325*/
326
327
328/*!
329	\var UrlEvent::DownloadProgress
330	\brief There is progress receiving the body of the request.
331
332	\since Haiku R1
333*/
334
335
336/*!
337	\var UrlEvent::BytesWritten
338	\brief There are bytes written to the target of the body.
339
340	\since Haiku R1
341*/
342
343
344/*!
345	\var UrlEvent::RequestCompleted
346	\brief The request was completed.
347
348	\since Haiku R1
349*/
350
351
352/*!
353	\var UrlEvent::DebugMessage
354	\brief There is a debug message for a request or for a protocol.
355
356	\since Haiku R1
357*/
358
359
360/*!
361	\namespace BPrivate::Network::UrlEventData
362	\brief Contains the names of the data in the messages that are sent by the various protocols.
363
364	Please see the \link netservices kit documentation \endlink for details which messages are sent
365	at which stage, and what data they contain.
366
367	\since Haiku R1
368*/
369
370
371/*!
372	\var const char* UrlEventData::Id
373	\brief An \c int32 that identifies the request the message pertains to.
374
375	\since Haiku R1
376*/
377
378
379/*!
380	\var const char* UrlEventData::HostName
381	\brief A \ref BString that represents the hostname that was resolved.
382
383	\since Haiku R1
384*/
385
386
387/*!
388	\var const char* UrlEventData::NumBytes
389	\brief An \c int64/off_t represening the number of bytes transferred to now.
390
391	\since Haiku R1
392*/
393
394
395/*!
396	\var const char* UrlEventData::TotalBytes
397	\brief An \c int64/off_t representing the total number of bytes that will be sent/received.
398
399	\since Haiku R1
400*/
401
402
403/*!
404	\var const char* UrlEventData::Success
405	\brief A \c bool that indicates whether an activity was succesful.
406
407	\since Haiku R1
408*/
409
410
411/*!
412	\var const char* UrlEventData::DebugType
413	\brief An \c uint32 representing a debug type constant.
414
415	The value is one of \ref UrlEventData::DebugError, \ref UrlEventData::DebugWarning or
416	\ref UrlEventData::DebugInfo.
417
418	\since Haiku R1
419*/
420
421
422/*!
423	\var const char* UrlEventData::DebugMessage
424	\brief A \ref BString that contains the debug message.
425
426	\since Haiku R1
427*/
428
429
430/*!
431	\var UrlEventData::DebugInfo
432	\brief Value for \ref UrlEventData::DebugType indicating that the message is an info messsage.
433
434	\since Haiku R1
435*/
436
437
438/*!
439	\var UrlEventData::DebugWarning
440	\brief Value for \ref UrlEventData::DebugType indicating that the message is a warning
441		messsage.
442
443	\since Haiku R1
444*/
445
446
447/*!
448	\var UrlEventData::DebugError
449	\brief Value for \ref UrlEventData::DebugType indicating that the message is an error messsage.
450
451	\since Haiku R1
452*/
453
454
455} // namespace Network
456
457} // namespace BPrivate
458
459#endif
460