Event type EVENT_DELIVERED_BY_FICTION renamed to EVENT_ACCEPTED_BY_FICTION
[libisds.git] / src / isds.h
blob10b683bf4aa4e4e163b2a014cd7ba0ca27f765df
1 #ifndef __ISDS_ISDS_H__
2 #define __ISDS_ISDS_H__
4 /* Public interface for libisds.
5 * Private declarations in isds_priv.h. */
7 #include <stdlib.h> /* For size_t */
8 #include <sys/time.h> /* For struct timeval */
10 struct isds_ctx; /* Context for specific ISDS box */
12 typedef enum {
13 IE_SUCCESS = 0, /* No error, just for C conveniece (0 means Ok) */
14 IE_ERROR, /* Unspecified error */
15 IE_NOTSUP,
16 IE_INVAL,
17 IE_INVALID_CONTEXT,
18 IE_NOT_LOGGED_IN,
19 IE_CONNECTION_CLOSED,
20 IE_TIMED_OUT,
21 IE_NOEXIST,
22 IE_NOMEM,
23 IE_NETWORK,
24 IE_HTTP,
25 IE_SOAP,
26 IE_XML,
27 IE_ISDS,
28 IE_ENUM,
29 IE_DATE,
30 IE_2BIG,
31 IE_NOTUNIQ
32 } isds_error;
34 typedef enum {
35 ILL_NONE = 0,
36 ILL_CRIT = 10,
37 ILL_ERR = 20,
38 ILL_WARNING = 30,
39 ILL_INFO = 40,
40 ILL_DEBUG = 50,
41 ILL_ALL = 100
42 } isds_log_level;
44 typedef enum {
45 ILF_NONE = 0x0,
46 ILF_HTTP = 0x1,
47 ILF_SOAP = 0x2,
48 ILF_ISDS = 0x4,
49 ILF_FILE = 0x8,
50 ILF_SEC = 0x10,
51 ILF_ALL = 0xFF
52 } isds_log_facility;
54 /* Return text description of ISDS error */
55 char *isds_strerror(const isds_error error);
57 /* TLS libisds options */
58 typedef enum {
59 ITLS_VERIFY_SERVER, /* _Bool: Verify server idetity? */
60 ITLS_CA_FILE, /* char *: File name with CA certificates */
61 ITLS_CA_DIRECTORY /* char *: Directory name with CA certificates */
62 } isds_tls_option;
64 /* Box type */
65 typedef enum {
66 DBTYPE_SYSTEM = 0, /* This is special sender value for messages
67 sent by ISDS. */
68 DBTYPE_OVM = 10,
69 DBTYPE_OVM_NOTAR = 11,
70 DBTYPE_OVM_EXEKUT = 12,
71 DBTYPE_OVM_REQ = 13,
72 DBTYPE_PO = 20,
73 DBTYPE_PO_ZAK = 21,
74 DBTYPE_PO_REQ = 22,
75 DBTYPE_PFO = 30,
76 DBTYPE_PFO_ADVOK = 31,
77 DBTYPE_PFO_DANPOR = 32,
78 DBTYPE_PFO_INSSPR = 33,
79 DBTYPE_FO = 40
80 } isds_DbType;
82 /* Box status from point of view of accesibilty */
83 typedef enum {
84 DBSTATE_ACCESSIBLE = 1,
85 DBSTATE_TEMP_UNACCESSIBLE = 2,
86 DBSTATE_NOT_YET_ACCESSIBLE = 3,
87 DBSTATE_PERM_UNACCESSIBLE = 4,
88 DBSTATE_REMOVED = 5
89 } isds_DbState;
91 /* User permissions from point of view of ISDS.
92 * Instances can be bitmas of any discrete values. */
93 typedef enum {
94 PRIVIL_READ_NON_PERSONAL = 0x1, /* Can download and read messages with
95 dmPersonalDelivery == false */
96 PRIVIL_READ_ALL = 0x2, /* Can download and read messages with
97 dmPersonalDelivery == true */
98 PRIVIL_CREATE_DM = 0x4, /* Can create and sent messages,
99 can dowload outgoing (sent) messages */
100 PRIVIL_VIEW_INFO = 0x8, /* Can list messages and data about
101 post and delivery */
102 PRIVIL_SEARCH_DB = 0x10, /* Can search for boxes */
103 PRIVIL_OWNER_ADM = 0x20 /* Can administer his box (add/remove
104 permitted users and theirs
105 permissions) */
106 } isds_priviledges;
108 /* Message status */
109 typedef enum {
110 MESSAGESTATE_SENT = 0x2, /* Message has been put into ISDS */
111 MESSAGESTATE_STAMPED = 0x4, /* Message stamped by TSA */
112 MESSAGESTATE_INFECTED = 0x8, /* Message included virues,
113 infected document has been removed */
114 MESSAGESTATE_DELIVERED = 0x10, /* Message delivered
115 (dmDeliveryTime stored) */
116 MESSAGESTATE_SUBSTITUTED = 0x20, /* Message delivered through fiction,
117 dmAcceptanceTime stored */
118 MESSAGESTATE_RECIEVED = 0x40, /* Message devlivered by user login
119 dmAcceptanceTime stored */
120 MESSAGESTATE_READ = 0x80, /* Message has been read by user */
121 MESSAGESTATE_UNDELIVERABLE = 0x100, /* Message could not been delivered
122 (e.g. recipent box has been made
123 unaccessible meantime) */
124 MESSAGESTATE_REMOVED = 0x200 /* Message content deleted */
126 } isds_message_status;
127 #define MESSAGESTATE_ANY 0x3FE /* Union of all isds_message_status
128 values */
130 /* Hash algoritm types */
131 typedef enum {
132 HASH_ALGORITHM_MD5,
133 HASH_ALGORITHM_SHA_1,
134 HASH_ALGORITHM_SHA_256,
135 HASH_ALGORITHM_SHA_512,
136 } isds_hash_algorithm;
138 /* Buffer storage strategy.
139 * How function should embed application provided buffer into raw element of
140 * output structure. */
141 typedef enum {
142 BUFFER_DONT_STORE, /* Don't fill raw memeber */
143 BUFFER_COPY, /* Copy buffer content into newly allocated raw */
144 BUFFER_MOVE /* Just copy pointer.
145 But leave deallocation to isds_*_free(). */
146 } isds_buffer_strategy;
148 /* Hash value storage */
149 struct isds_hash {
150 isds_hash_algorithm algorithm; /* Hash algoritgm */
151 size_t length; /* Hash value lenght in bytes */
152 void *value; /* Hash value */
155 /* Name of person */
156 struct isds_PersonName {
157 char *pnFirstName;
158 char *pnMiddleName;
159 char *pnLastName;
160 char *pnLastNameAtBirth;
163 /* Date and place of birth */
164 struct isds_BirthInfo {
165 struct tm *biDate; /* Date of Birth in local time at birth place,
166 only tm_year, tm_mon and tm_mday carry sane
167 value */
168 char *biCity;
169 char *biCounty; /* German: Bezirk, Czech: okres */
170 char *biState;
173 /* Post address */
174 struct isds_Address {
175 char *adCity;
176 char *adStreet;
177 char *adNumberInStreet;
178 char *adNumberInMunicipality;
179 char *adZipCode;
180 char *adState;
183 /* Data about box and his owner.
184 * NULL pointer means undefined value */
185 struct isds_DbOwnerInfo {
186 char *dbID; /* Box ID */
187 isds_DbType *dbType; /* Box Type */
188 char *ic; /* ID */
189 struct isds_PersonName *personName; /* Name of person */
190 char *firmName; /* Name of firm */
191 struct isds_BirthInfo *birthInfo; /* Birth of person */
192 struct isds_Address *address; /* Post address */
193 char *nationality;
194 char *email;
195 char *telNumber;
196 char *identifier; /* External box identifier for data
197 provider (OVM, PO, maybe PFO)
198 [Max. 20 chars] */
199 char *registryCode; /* PFO External registry code
200 [Max. 5 chars] */
201 long int *dbState; /* Box state; 1 <=> active box;
202 long int beacause xsd:integer
203 TODO: enum? */
204 _Bool *dbEffectiveOVM; /* Box has OVM role (§ 5a) */
205 _Bool *dbOpenAddressing; /* Non-OVM Box is free to recieve
206 messages from anybody */
209 /* Message event type */
210 typedef enum {
211 EVENT_UKNOWN, /* Event unknown to this library */
212 EVENT_ACCEPTED_BY_RECIPIENT, /* Message has been delivered and accepted
213 by recipeint action */
214 EVENT_ACCEPTED_BY_FICTION, /* Message has been delivered, acceptance
215 timed out, considered as accepted */
216 EVENT_UNDELIVERABLE /* Recipient box made unaccessible,
217 thus message is undelivarable */
218 } isds_event_type;
220 /* Message event
221 * Alle members are optional as specification states so. */
222 struct isds_event {
223 struct timeval *time; /* When the event occurred */
224 isds_event_type *type; /* Type of the event */
225 char *description; /* Human readable event description
226 generated by ISDS (Czech) */
229 /* Message envelope
230 * Be ware that the string length contraints are forced only on output
231 * memebers transmitted to ISDS. The other direction (downloded from ISDS)
232 * can break these rules. It should not happen, but nobody knows how much
233 * incompatible new version of ISDS protocol will be. This is the gold
234 * Internet rule: be strict on what you put, be tollerant on what you get. */
235 struct isds_envelope {
236 /* Following memebers apply to incoming messages only: */
237 char *dmID; /* Message ID.
238 Maximal length is 20 characters. */
239 char *dbIDSender; /* Box ID of sender.
240 Special value "aaaaaaa" means sent by
241 ISDS.
242 Maximal length is 7 characters. */
243 char *dmSender; /* Sender name;
244 Maximal length is 100 characters. */
245 char *dmSenderAddress; /* Postal address of sender;
246 Maximal length is 100 characters. */
247 long int *dmSenderType; /* Gross Box type of sender
248 TODO: isds_DbType ? */
249 char *dmRecipient; /* Recipient name;
250 Maximal length is 100 characters. */
251 char *dmRecipientAddress; /* Postal address of recipient;
252 Maximal length is 100 characters. */
253 _Bool *dmAmbiguousRecipient; /* Recipient has OVM role */
255 /* Following memebers are assigned by ISDS in different phases of message
256 * life cycle. */
257 unsigned long int *dmOrdinal; /* Ordinal number in list of
258 incoming/outgoing messages */
259 isds_message_status *dmMessageStatus; /* Message state */
260 long int *dmAttachmentSize; /* Size of message documents in
261 kilobytes (rounded). */
262 struct timeval *dmDeliveryTime; /* Time of delivery into a box
263 NULL, if message has not been
264 delivered yet */
265 struct timeval *dmAcceptanceTime; /* Time of accpetance of the message
266 by an user. NULL if message has not
267 been accepted yet. */
268 struct isds_hash *hash; /* Message hash.
269 This is hash of isds:dmDM subtree. */
270 void *timestamp; /* Qualified time stamp */
271 size_t timestamp_length; /* Lenght of timestamp in bytes */
272 struct isds_list *events; /* Events message passed trough;
273 List of isds_event's. */
276 /* Following members apply to both outgoing and incoming messages: */
277 char *dmSenderOrgUnit; /* Organisation unit of sender as string;
278 Optional. */
279 long int *dmSenderOrgUnitNum; /* Organisation unit of sender as number;
280 Optional. */
281 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
282 Maximal length is 7 characters. */
283 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
284 string; Optional. */
285 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
286 number; Optional. */
287 char *dmToHands; /* Person in recipient organisation;
288 Optional. */
289 char *dmAnnotation; /* Subject (title) of the message.
290 Maximal length is 255 characters. */
291 char *dmRecipientRefNumber; /* Czech: číslo jednací příjemce; Optional.
292 Maximal length is 50 characters. */
293 char *dmSenderRefNumber; /* Czech: číslo jednací odesílatele;
294 Optional. Maximal lenght is 50 chars. */
295 char *dmRecipientIdent; /* Czech: spisová značka příjemce; Optional.
296 Maximal length is 50 characters. */
297 char *dmSenderIdent; /* Czech: spisová značka odesílatele;
298 Optional. Maximal lenght is 50 chars. */
300 /* Act addressing in Czech Republic:
301 * Point (Parahraph) § Section Law/Year Coll. */
302 long int *dmLegalTitleLaw; /* Number of act mandating authority */
303 long int *dmLegalTitleYear; /* Year of act issue mandating authority */
304 char *dmLegalTitleSect; /* Section of act mandating authority.
305 Czech: paragraf */
306 char *dmLegalTitlePar; /* Parahraph of act mandating authority.
307 Czech: odstavec */
308 char *dmLegalTitlePoint; /* Point of act mandating authority.
309 Czech: písmeno */
311 _Bool *dmPersonalDelivery; /* If true, only person with higher
312 priviledges can read this message */
313 _Bool *dmAllowSubstDelivery; /* Allow delivery through fiction.
314 I.e. Even if recipient did not read this
315 message, message is considered as
316 delivered after (currently) 10 days.
317 This is delivery through fiction.
318 Applies only to OVM dbType sender. */
319 _Bool *dmOVM; /* OVM sending mode.
320 Non-OVM dbType boxes that has
321 dbEffectiveOVM == true MUST select
322 between true (OVM mode) and
323 false (non-OVM mode).
324 Optionable; Implicit value is true. */
328 /* Document type from point of hiearchy */
329 typedef enum {
330 FILEMETATYPE_MAIN, /* Main document */
331 FILEMETATYPE_ENCLOSURE, /* Appendix */
332 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
333 FILEMETATYPE_META /* XML document for ESS (electronic
334 document information system) purposes */
335 } isds_FileMetaType;
337 /* Document */
338 struct isds_document {
339 void *data; /* Document content.
340 The encoding and interpretation depends
341 on dmMimeType.
342 TODO: inline XML */
343 size_t data_length; /* Length of the data in bytes */
344 char *dmMimeType; /* MIME type of data; Mandatory. */
345 isds_FileMetaType dmFileMetaType; /* Document type to create hierarchy */
346 char *dmFileGuid; /* Message-local document identifier;
347 Optional. */
348 char *dmUpFileGuid; /* Reference to upper document identifier
349 (dmFileGuid); Optional. */
350 char *dmFileDescr; /* Document name (title). E.g. file name;
351 Mandatory. */
352 char *dmFormat; /* Reference to XML form definition;
353 Defines howto interpret XML document;
354 Optional. */
357 /* Message */
358 struct isds_message {
359 void *raw; /* Raw message in XML format as send to or
360 from the ISDS. You can use it to store
361 local copy. This is binary buffer. */
362 size_t raw_length; /* Lenght of raw message in bytes */
363 struct isds_envelope *envelope; /* Message envelope */
364 struct isds_list *documents; /* List of isds_document's.
365 Valid message must contain exactly one
366 document of type FILEMETATYPE_MAIN and
367 can contain any number of other type
368 documents. Totol size of documents
369 must not exceed 10 MB. */
372 /* General linked list */
373 struct isds_list {
374 struct isds_list *next; /* Next list item,
375 or NULL if current is last */
376 void *data; /* Payload */
377 void (*destructor) (void **); /* Payload deallocator */
380 /* Free isds_list with all member data.
381 * @list list to free, on return will be NULL */
382 void isds_list_free(struct isds_list **list);
385 /* Initialize ISDS library.
386 * Global function, must be called before other functions.
387 * If it failes you can not use ISDS library and must call isds_cleanup() to
388 * free partially inititialized global variables. */
389 isds_error isds_init(void);
391 /* Deinicialize ISDS library.
392 * Global function, must be called as last library function. */
393 isds_error isds_cleanup(void);
395 /* Create ISDS context.
396 * Each context can be used for different sessions to (possibly) different
397 * ISDS server with different credentials.
398 * Returns new context, or NULL */
399 struct isds_ctx *isds_ctx_create(void);
401 /* Destroy ISDS context and free memmory.
402 * @context will be NULLed on success. */
403 isds_error isds_ctx_free(struct isds_ctx **context);
405 /* Return long message text produced by library fucntion, e.g. detailed error
406 * mesage. Returned pointer is only valid until new library function is
407 * called for the same context. Could be NULL, especially if NULL context is
408 * supplied. Return string is locale encoded. */
409 char *isds_long_message(const struct isds_ctx *context);
411 /* Set logging up.
412 * @facilities is bitmask of isds_log_facility values,
413 * @level is verbosity level. */
414 void isds_set_logging(const unsigned int facilities,
415 const isds_log_level level);
417 /* Connect to given url.
418 * It just makes TCP connection to ISDS server found in @url hostname part. */
419 /*int isds_connect(struct isds_ctx *context, const char *url);*/
421 /* Set timeout in miliseconds for each network job like connecting to server
422 * or sending message. Use 0 to disable timeout limits. */
423 isds_error isds_set_timeout(struct isds_ctx *context,
424 const unsigned int timeout);
427 /* Change SSL/TLS settings.
428 * @context is context which setting vill be applied to
429 * @option is name of option. It determines the type of last argument. See
430 * isds_tls_option definition for more info.
431 * @... is value of new setting. Type is determined by @option
432 * */
433 isds_error isds_set_tls(struct isds_ctx *context, const isds_tls_option option,
434 ...);
436 /* Connect and log in into ISDS server.
437 * @url is address of ISDS web service
438 * @username is user name of ISDS user
439 * @password is user's secret password
440 * @certificate is NULL terminated string with PEM formated client's
441 * certificate. Use NULL if only password autentication should be performed.
442 * @key is private key for client's certificate as (base64 encoded?) NULL
443 * terminated string. Use NULL if only password autentication is desired.
444 * */
445 isds_error isds_login(struct isds_ctx *context, const char *url,
446 const char *username, const char *password,
447 const char *certificate, const char* key);
449 /* Log out from ISDS server and close connection. */
450 isds_error isds_logout(struct isds_ctx *context);
452 /* Verify connection to ISDS is alive and server is responding.
453 * Sent dumy request to ISDS and expect dummy response. */
454 isds_error isds_ping(struct isds_ctx *context);
456 /* Get data about logged in user and his box. */
457 isds_error isds_GetOwnerInfoFromLogin(struct isds_ctx *context,
458 struct isds_DbOwnerInfo **db_owner_info);
460 /* Find boxes suiting given criteria.
461 * @context is ISDS session context.
462 * @criteria is filter. You should fill in at least some members.
463 * @boxes is automatically reallocated list of isds_DbOwnerInfo structures,
464 * possibly empty. Input NULL or valid old structure.
465 * @return:
466 * IE_SUCCESS if search sucseeded, @boxes contains usefull data
467 * IE_NOEXIST if no such box exists, @boxes will be NULL
468 * IE_2BIG if too much boxes exist and server truncated the resuluts, @boxes
469 * contains still valid data
470 * other code if something bad happens. @boxes will be NULL. */
471 isds_error isds_FindDataBox(struct isds_ctx *context,
472 const struct isds_DbOwnerInfo *criteria,
473 struct isds_list **boxes);
475 /* Get status of a box.
476 * @context is ISDS session context.
477 * @box_id is UTF-8 encoded box identifier as zero terminated string
478 * @box_status is return value of box status.
479 * @return:
480 * IE_SUCCESS if box has been found and its status retrieved
481 * IE_NOEXIST if box is not known to ISDS server
482 * or other appropriate error.
483 * You can use isds_DbState to enumerate box status. However out of enum
484 * range value can be returned too. This is feature because ISDS
485 * specification leaves the set of values open.
486 * Be ware that status DBSTATE_REMOVED is signaled as IE_SUCCESS. That means
487 * the box has been deleted, but ISDS still lists its former existence. */
488 isds_error isds_CheckDataBox(struct isds_ctx *context, const char *box_id,
489 long int *box_status);
491 /* Send a message via ISDS to a recipent
492 * @context is session context
493 * @outgoing_message is message to send; Some memebers are mandatory (like
494 * dbIDRecipient), some are optional and some are irrelevant (especialy data
495 * about sender). Included pointer to isds_list documents must contain at
496 * least one document of FILEMETATYPE_MAIN. This is read-write structure, some
497 * members will be filled with valid data from ISDS. Exact list of write
498 * members is subject to change. Currently dmId is changed.
499 * @return ISDS_SUCCESS, or other error code if something goes wrong. */
500 isds_error isds_send_message(struct isds_ctx *context,
501 struct isds_message *outgoing_message);
503 /* Get list of outgoing (already sent) messages.
504 * Any criterion argument can be NULL, if you don't care about it.
505 * @context is session context. Must not be NULL.
506 * @from_time is minimal time and date of message sending inclusive.
507 * @to_time is maximal time and date of message sending inclusive
508 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
509 * @status_filter is bit field of isds_message_status values. Use special
510 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
511 * all values, you can use bitwise arithmetic if you want.)
512 * @offset is index of first message we are interested in. First message is 1.
513 * Set to 0 (or 1) if you don't care.
514 * @number is maximal length of list you want to get as input value, outputs
515 * number of messages matching these criteria. Can be NULL if you don't care
516 * (applies to output value either).
517 * @messages is automatically reallocated list of isds_message's. Be ware that
518 * it returns only brief overview (envelope and some other fields) about each
519 * message, not the complete message. FIXME: Specify exact fields.
520 * The list is sorted by delivery time in ascending order.
521 * Use NULL if you don't care about the metadata (useful if you want to know
522 * only the @number). If you provide &NULL, list will be allocated on heap,
523 * if you provide pointer to non-NULL, list will be freed automacally at first.
524 * Also in case of error the list will be NULLed.
525 * @return IE_SUCCESS or appropriate error code. */
526 isds_error isds_get_list_of_sent_messages(struct isds_ctx *context,
527 const struct timeval *from_time, const struct timeval *to_time,
528 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
529 const unsigned long int offset, unsigned long int *number,
530 struct isds_list **messages);
532 /* Get list of incoming (addressed to you) messages.
533 * Any criterion argument can be NULL, if you don't care about it.
534 * @context is session context. Must not be NULL.
535 * @from_time is minimal time and date of message sending inclusive.
536 * @to_time is maximal time and date of message sending inclusive
537 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
538 * @status_filter is bit field of isds_message_status values. Use special
539 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
540 * all values, you can use bitwise arithmetic if you want.)
541 * @offset is index of first message we are interested in. First message is 1.
542 * Set to 0 (or 1) if you don't care.
543 * @number is maximal length of list you want to get as input value, outputs
544 * number of messages matching these criteria. Can be NULL if you don't care
545 * (applies to output value either).
546 * @messages is automatically reallocated list of isds_message's. Be ware that
547 * it returns only brief overview (envelope and some other fields) about each
548 * message, not the complete message. FIXME: Specify exact fields.
549 * Use NULL if you don't care about the metadata (useful if you want to know
550 * only the @number). If you provide &NULL, list will be allocated on heap,
551 * if you provide pointer to non-NULL, list will be freed automacally at first.
552 * Also in case of error the list will be NULLed.
553 * @return IE_SUCCESS or appropriate error code. */
554 isds_error isds_get_list_of_received_messages(struct isds_ctx *context,
555 const struct timeval *from_time, const struct timeval *to_time,
556 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
557 const unsigned long int offset, unsigned long int *number,
558 struct isds_list **messages);
560 /* Download incoming message envelope identified by ID.
561 * @context is session context
562 * @message_id is message identifier (you can get them from
563 * isds_get_list_of_received_messages())
564 * @message is automatically reallocated message retrieved from ISDS.
565 * It will miss documents per se. Use isds_get_received_message(), if you are
566 * interrested in documents (content) too.
567 * Returned hash and timestamp require documents to be verifiable. */
568 isds_error isds_get_received_envelope(struct isds_ctx *context,
569 const char *message_id, struct isds_message **message);
571 /* Load signed delivery info from buffer.
572 * @context is session context
573 * @buffer is DER encoded PKCS#7 structure with signed delivery info. You can
574 * retrieve such data from message->raw after calling
575 * isds_get_signed_delivery_info().
576 * @length is length of buffer in bytes.
577 * @message is automatically reallocated message parsed from @buffer.
578 * @strategy selects how buffer will be attached into raw isds_message member.
579 * */
580 isds_error isds_load_signed_delivery_info(struct isds_ctx *context,
581 const void *buffer, const size_t length,
582 struct isds_message **message, const isds_buffer_strategy strategy);
584 /* Download delivery infosheet of given message identified by ID.
585 * @context is session context
586 * @message_id is message identifier (you can get them from
587 * isds_get_list_of_{sent,received}_messages())
588 * @message is automatically reallocated message retrieved from ISDS.
589 * It will miss documents per se. Use isds_get_received_message(), if you are
590 * interrested in documents (content). OTOH, only this function can get list
591 * events message has gone through. */
592 isds_error isds_get_delivery_info(struct isds_ctx *context,
593 const char *message_id, struct isds_message **message);
595 /* Load incoming message from buffer.
596 * @context is session context
597 * @buffer XML stream with unsigned message. You can retrieve such data from
598 * message->raw after calling isds_get_received_message().
599 * @length is length of buffer in bytes.
600 * @message is automatically reallocated message parsed from @buffer.
601 * @strategy selects how buffer will be attached into raw isds_message member.
602 * */
603 isds_error isds_load_received_message(struct isds_ctx *context,
604 const void *buffer, const size_t length,
605 struct isds_message **message, const isds_buffer_strategy strategy);
607 /* Download incoming message identified by ID.
608 * @context is session context
609 * @message_id is message identifier (you can get them from
610 * isds_get_list_of_received_messages())
611 * @message is automatically reallocated message retrieved from ISDS */
612 isds_error isds_get_received_message(struct isds_ctx *context,
613 const char *message_id, struct isds_message **message);
615 /* Load signed message from buffer.
616 * @context is session context
617 * @outgoing is true if message is outgoing, false if message is incoming
618 * @buffer is DER encoded PKCS#7 structure with signed message. You can
619 * retrieve such data from message->raw after calling
620 * isds_get_signed{received,sent}_message().
621 * @length is length of buffer in bytes.
622 * @message is automatically reallocated message parsed from @buffer.
623 * @strategy selects how buffer will be attached into raw isds_message member.
624 * */
625 isds_error isds_load_signed_message(struct isds_ctx *context,
626 const _Bool outgoing, const void *buffer, const size_t length,
627 struct isds_message **message, const isds_buffer_strategy strategy);
629 /* Download signed incoming message identified by ID.
630 * @context is session context
631 * @message_id is message identifier (you can get them from
632 * isds_get_list_of_received_messages())
633 * @message is automatically reallocated message retrieved from ISDS. The raw
634 * memeber will be filled with PKCS#7 structure in DER format. */
635 isds_error isds_get_signed_received_message(struct isds_ctx *context,
636 const char *message_id, struct isds_message **message);
638 /* Download signed outgoing message identified by ID.
639 * @context is session context
640 * @message_id is message identifier (you can get them from
641 * isds_get_list_of_sent_messages())
642 * @message is automatically reallocated message retrieved from ISDS. The raw
643 * memeber will be filled with PKCS#7 structure in DER format. */
644 isds_error isds_get_signed_sent_message(struct isds_ctx *context,
645 const char *message_id, struct isds_message **message);
647 /* Retrieve hash of message identified by ID stored in ISDS.
648 * @context is session context
649 * @message_id is message identifier
650 * @hash is automatically reallocated message hash downloaded from ISDS.
651 * Message must exist in system and must not be deleted. */
652 isds_error isds_download_message_hash(struct isds_ctx *context,
653 const char *message_id, struct isds_hash **hash);
655 /* Compute hash of message from raw representation and store it into envelope.
656 * Original hash structure will be destroyed in envelope.
657 * @context is session context
658 * @message is message carrying raw XML message blob
659 * @algorithm is desired hash algorithm to use */
660 isds_error isds_compute_message_hash(struct isds_ctx *context,
661 struct isds_message *message, const isds_hash_algorithm algorithm);
663 /* Mark message as read. This is a transactional commit function to acknoledge
664 * to ISDS the message has been downloaded and processed by client properly.
665 * @context is session context
666 * @message_id is message identifier. */
667 isds_error isds_mark_message_read(struct isds_ctx *context,
668 const char *message_id);
670 /* Send bogus request to ISDS.
671 * Just for test purposes */
672 isds_error isds_bogus_request(struct isds_ctx *context);
674 /* Search for document by document ID in list of documents. IDs are compared
675 * as UTF-8 string.
676 * @documents is list of isds_documents
677 * @id is document identifier
678 * @return first matching document or NULL. */
679 const struct isds_document *isds_find_document_by_id(
680 const struct isds_list *documents, const char *id);
682 /* Deallocate structure isds_hash and NULL it.
683 * @hash hash to to free */
684 void isds_hash_free(struct isds_hash **hash);
686 /* Deallocate structure isds_DbOwnerInfo recursively and NULL it */
687 void isds_DbOwnerInfo_free(struct isds_DbOwnerInfo **db_owner_info);
689 /* Deallocate struct isds_event recursively and NULL it */
690 void isds_event_free(struct isds_event **event);
692 /* Deallocate struct isds_envelope recursively and NULL it */
693 void isds_envelope_free(struct isds_envelope **envelope);
695 /* Deallocate struct isds_document recursively and NULL it */
696 void isds_document_free(struct isds_document **document);
698 /* Deallocate struct isds_message recursively and NULL it */
699 void isds_message_free(struct isds_message **message);
701 #endif