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