Implement DisableDataBoxExternally
[libisds.git] / src / isds.h
blobf8c81c15a7f5a80bf10d1b540aa1e68d3da7cff7
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_2SMALL,
41 IE_NOTUNIQ,
42 IE_NOTEQUAL,
43 IE_PARTIAL_SUCCESS
44 } isds_error;
46 typedef enum {
47 ILL_NONE = 0,
48 ILL_CRIT = 10,
49 ILL_ERR = 20,
50 ILL_WARNING = 30,
51 ILL_INFO = 40,
52 ILL_DEBUG = 50,
53 ILL_ALL = 100
54 } isds_log_level;
56 typedef enum {
57 ILF_NONE = 0x0,
58 ILF_HTTP = 0x1,
59 ILF_SOAP = 0x2,
60 ILF_ISDS = 0x4,
61 ILF_FILE = 0x8,
62 ILF_SEC = 0x10,
63 ILF_XML = 0x20,
64 ILF_ALL = 0xFF
65 } isds_log_facility;
67 /* Return text description of ISDS error */
68 const char *isds_strerror(const isds_error error);
70 /* TLS libisds options */
71 typedef enum {
72 ITLS_VERIFY_SERVER, /* _Bool: Verify server idetity? */
73 ITLS_CA_FILE, /* char *: File name with CA certificates */
74 ITLS_CA_DIRECTORY /* char *: Directory name with CA certificates */
75 } isds_tls_option;
77 /* Box type */
78 typedef enum {
79 DBTYPE_SYSTEM = 0, /* This is special sender value for messages
80 sent by ISDS. */
81 DBTYPE_OVM = 10,
82 DBTYPE_OVM_NOTAR = 11,
83 DBTYPE_OVM_EXEKUT = 12,
84 DBTYPE_OVM_REQ = 13,
85 DBTYPE_PO = 20,
86 DBTYPE_PO_ZAK = 21,
87 DBTYPE_PO_REQ = 22,
88 DBTYPE_PFO = 30,
89 DBTYPE_PFO_ADVOK = 31,
90 DBTYPE_PFO_DANPOR = 32,
91 DBTYPE_PFO_INSSPR = 33,
92 DBTYPE_FO = 40
93 } isds_DbType;
95 /* Box status from point of view of accesibilty */
96 typedef enum {
97 DBSTATE_ACCESSIBLE = 1,
98 DBSTATE_TEMP_UNACCESSIBLE = 2,
99 DBSTATE_NOT_YET_ACCESSIBLE = 3,
100 DBSTATE_PERM_UNACCESSIBLE = 4,
101 DBSTATE_REMOVED = 5
102 } isds_DbState;
104 /* User permissions from point of view of ISDS.
105 * Instances can be bitmaps of any discrete values. */
106 typedef enum {
107 PRIVIL_READ_NON_PERSONAL = 0x1, /* Can download and read messages with
108 dmPersonalDelivery == false */
109 PRIVIL_READ_ALL = 0x2, /* Can download and read messages with
110 dmPersonalDelivery == true */
111 PRIVIL_CREATE_DM = 0x4, /* Can create and sent messages,
112 can dowload outgoing (sent) messages */
113 PRIVIL_VIEW_INFO = 0x8, /* Can list messages and data about
114 post and delivery */
115 PRIVIL_SEARCH_DB = 0x10, /* Can search for boxes */
116 PRIVIL_OWNER_ADM = 0x20, /* Can administer his box (add/remove
117 permitted users and theirs
118 permissions) */
119 PRIVIL_READ_VAULT = 0x40, /* Cen read message stored in data safe */
120 PRIVIL_ERASE_VAULT = 0x80 /* Can delete messages from data safe */
121 } isds_priviledges;
123 /* Message status */
124 typedef enum {
125 MESSAGESTATE_SENT = 0x2, /* Message has been put into ISDS */
126 MESSAGESTATE_STAMPED = 0x4, /* Message stamped by TSA */
127 MESSAGESTATE_INFECTED = 0x8, /* Message included virues,
128 infected document has been removed */
129 MESSAGESTATE_DELIVERED = 0x10, /* Message delivered
130 (dmDeliveryTime stored) */
131 MESSAGESTATE_SUBSTITUTED = 0x20, /* Message delivered through fiction,
132 dmAcceptanceTime stored */
133 MESSAGESTATE_RECEIVED = 0x40, /* Message accepted (by user login or
134 user explicit request),
135 dmAcceptanceTime stored */
136 MESSAGESTATE_READ = 0x80, /* Message has been read by user */
137 MESSAGESTATE_UNDELIVERABLE = 0x100, /* Message could not been delivered
138 (e.g. recipent box has been made
139 unaccessible meantime) */
140 MESSAGESTATE_REMOVED = 0x200, /* Message content deleted */
141 MESSAGESTATE_IN_SAFE = 0x400 /* Message stored in data safe */
143 } isds_message_status;
144 #define MESSAGESTATE_ANY 0x7FE /* Union of all isds_message_status
145 values */
147 /* Hash algoritm types */
148 typedef enum {
149 HASH_ALGORITHM_MD5,
150 HASH_ALGORITHM_SHA_1,
151 HASH_ALGORITHM_SHA_256,
152 HASH_ALGORITHM_SHA_512,
153 } isds_hash_algorithm;
155 /* Buffer storage strategy.
156 * How function should embed application provided buffer into raw element of
157 * output structure. */
158 typedef enum {
159 BUFFER_DONT_STORE, /* Don't fill raw memeber */
160 BUFFER_COPY, /* Copy buffer content into newly allocated raw */
161 BUFFER_MOVE /* Just copy pointer.
162 But leave deallocation to isds_*_free(). */
163 } isds_buffer_strategy;
165 /* Hash value storage */
166 struct isds_hash {
167 isds_hash_algorithm algorithm; /* Hash algoritgm */
168 size_t length; /* Hash value lenght in bytes */
169 void *value; /* Hash value */
172 /* Name of person */
173 struct isds_PersonName {
174 char *pnFirstName;
175 char *pnMiddleName;
176 char *pnLastName;
177 char *pnLastNameAtBirth;
180 /* Date and place of birth */
181 struct isds_BirthInfo {
182 struct tm *biDate; /* Date of Birth in local time at birth place,
183 only tm_year, tm_mon and tm_mday carry sane
184 value */
185 char *biCity;
186 char *biCounty; /* German: Bezirk, Czech: okres */
187 char *biState;
190 /* Post address */
191 struct isds_Address {
192 char *adCity;
193 char *adStreet;
194 char *adNumberInStreet;
195 char *adNumberInMunicipality;
196 char *adZipCode;
197 char *adState;
200 /* Data about box and his owner.
201 * NULL pointer means undefined value */
202 struct isds_DbOwnerInfo {
203 char *dbID; /* Box ID [Max. 7 chars] */
204 isds_DbType *dbType; /* Box Type */
205 char *ic; /* ID */
206 struct isds_PersonName *personName; /* Name of person */
207 char *firmName; /* Name of firm */
208 struct isds_BirthInfo *birthInfo; /* Birth of person */
209 struct isds_Address *address; /* Post address */
210 char *nationality;
211 char *email;
212 char *telNumber;
213 char *identifier; /* External box identifier for data
214 provider (OVM, PO, maybe PFO)
215 [Max. 20 chars] */
216 char *registryCode; /* PFO External registry code
217 [Max. 5 chars] */
218 long int *dbState; /* Box state; 1 <=> active box;
219 long int beacause xsd:integer
220 TODO: enum? */
221 _Bool *dbEffectiveOVM; /* Box has OVM role (§ 5a) */
222 _Bool *dbOpenAddressing; /* Non-OVM Box is free to recieve
223 messages from anybody */
226 /* User type */
227 typedef enum {
228 USERTYPE_PRIMARY, /* Owner of the box */
229 USERTYPE_ENTRUSTED, /* User with limited access to the box */
230 USERTYPE_ADMINISTRATOR, /* User to manage ENTRUSTED_USERs */
231 USERTYPE_OFFICIAL /* ??? */
232 } isds_UserType;
234 /* Data about user.
235 * NULL pointer means undefined value */
236 struct isds_DbUserInfo {
237 char *userID; /* User ID [Min. 6, max. 12 characters] */
238 isds_UserType *userType; /* User type */
239 long int *userPrivils; /* Set of user permissions */
240 struct isds_PersonName *personName; /* Name of the person */
241 struct isds_Address *address; /* Post address */
242 struct tm *biDate; /* Date of birth in local time,
243 only tm_year, tm_mon and tm_mday carry sane
244 value */
245 char *ic; /* ID of a supervising firm [Max. 8 chars] */
246 char *firmName; /* Name of a supervising firm
247 [Max. 100 chars] */
248 char *caStreet; /* Street and number of contact address */
249 char *caCity; /* Czech City of contact address */
250 char *caZipCode; /* Post office code of contact address */
253 /* Message event type */
254 typedef enum {
255 EVENT_UKNOWN, /* Event unknown to this library */
256 EVENT_ACCEPTED_BY_RECIPIENT, /* Message has been delivered and accepted
257 by recipeint action */
258 EVENT_ACCEPTED_BY_FICTION, /* Message has been delivered, acceptance
259 timed out, considered as accepted */
260 EVENT_UNDELIVERABLE, /* Recipient box made unaccessible,
261 thus message is undelivarable */
262 EVENT_COMMERCIAL_ACCEPTED /* Recipient confirmed acceptace of
263 commercial message */
264 } isds_event_type;
266 /* Message event
267 * Alle members are optional as specification states so. */
268 struct isds_event {
269 struct timeval *time; /* When the event occurred */
270 isds_event_type *type; /* Type of the event */
271 char *description; /* Human readable event description
272 generated by ISDS (Czech) */
275 /* Message envelope
276 * Be ware that the string length contraints are forced only on output
277 * memebers transmitted to ISDS. The other direction (downloded from ISDS)
278 * can break these rules. It should not happen, but nobody knows how much
279 * incompatible new version of ISDS protocol will be. This is the gold
280 * Internet rule: be strict on what you put, be tollerant on what you get. */
281 struct isds_envelope {
282 /* Following memebers apply to incoming messages only: */
283 char *dmID; /* Message ID.
284 Maximal length is 20 characters. */
285 char *dbIDSender; /* Box ID of sender.
286 Special value "aaaaaaa" means sent by
287 ISDS.
288 Maximal length is 7 characters. */
289 char *dmSender; /* Sender name;
290 Maximal length is 100 characters. */
291 char *dmSenderAddress; /* Postal address of sender;
292 Maximal length is 100 characters. */
293 long int *dmSenderType; /* Gross Box type of sender
294 TODO: isds_DbType ? */
295 char *dmRecipient; /* Recipient name;
296 Maximal length is 100 characters. */
297 char *dmRecipientAddress; /* Postal address of recipient;
298 Maximal length is 100 characters. */
299 _Bool *dmAmbiguousRecipient; /* Recipient has OVM role */
300 char *dmType; /* Message type:
301 "V" is public message
302 "K" is commercial message */
304 /* Following memebers are assigned by ISDS in different phases of message
305 * life cycle. */
306 unsigned long int *dmOrdinal; /* Ordinal number in list of
307 incoming/outgoing messages */
308 isds_message_status *dmMessageStatus; /* Message state */
309 long int *dmAttachmentSize; /* Size of message documents in
310 kilobytes (rounded). */
311 struct timeval *dmDeliveryTime; /* Time of delivery into a box
312 NULL, if message has not been
313 delivered yet */
314 struct timeval *dmAcceptanceTime; /* Time of accpetance of the message
315 by an user. NULL if message has not
316 been accepted yet. */
317 struct isds_hash *hash; /* Message hash.
318 This is hash of isds:dmDM subtree. */
319 void *timestamp; /* Qualified time stamp */
320 size_t timestamp_length; /* Lenght of timestamp in bytes */
321 struct isds_list *events; /* Events message passed trough;
322 List of isds_event's. */
325 /* Following members apply to both outgoing and incoming messages: */
326 char *dmSenderOrgUnit; /* Organisation unit of sender as string;
327 Optional. */
328 long int *dmSenderOrgUnitNum; /* Organisation unit of sender as number;
329 Optional. */
330 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
331 Maximal length is 7 characters. */
332 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
333 string; Optional. */
334 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
335 number; Optional. */
336 char *dmToHands; /* Person in recipient organisation;
337 Optional. */
338 char *dmAnnotation; /* Subject (title) of the message.
339 Maximal length is 255 characters. */
340 char *dmRecipientRefNumber; /* Czech: číslo jednací příjemce; Optional.
341 Maximal length is 50 characters. */
342 char *dmSenderRefNumber; /* Czech: číslo jednací odesílatele;
343 Optional. Maximal lenght is 50 chars. */
344 char *dmRecipientIdent; /* Czech: spisová značka příjemce; Optional.
345 Maximal length is 50 characters. */
346 char *dmSenderIdent; /* Czech: spisová značka odesílatele;
347 Optional. Maximal lenght is 50 chars. */
349 /* Act addressing in Czech Republic:
350 * Point (Parahraph) § Section Law/Year Coll. */
351 long int *dmLegalTitleLaw; /* Number of act mandating authority */
352 long int *dmLegalTitleYear; /* Year of act issue mandating authority */
353 char *dmLegalTitleSect; /* Section of act mandating authority.
354 Czech: paragraf */
355 char *dmLegalTitlePar; /* Parahraph of act mandating authority.
356 Czech: odstavec */
357 char *dmLegalTitlePoint; /* Point of act mandating authority.
358 Czech: písmeno */
360 _Bool *dmPersonalDelivery; /* If true, only person with higher
361 priviledges can read this message */
362 _Bool *dmAllowSubstDelivery; /* Allow delivery through fiction.
363 I.e. Even if recipient did not read this
364 message, message is considered as
365 delivered after (currently) 10 days.
366 This is delivery through fiction.
367 Applies only to OVM dbType sender. */
368 _Bool *dmOVM; /* OVM sending mode.
369 Non-OVM dbType boxes that has
370 dbEffectiveOVM == true MUST select
371 between true (OVM mode) and
372 false (non-OVM mode).
373 Optionable; Implicit value is true. */
377 /* Document type from point of hiearchy */
378 typedef enum {
379 FILEMETATYPE_MAIN, /* Main document */
380 FILEMETATYPE_ENCLOSURE, /* Appendix */
381 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
382 FILEMETATYPE_META /* XML document for ESS (electronic
383 document information system) purposes */
384 } isds_FileMetaType;
386 /* Document */
387 struct isds_document {
388 void *data; /* Document content.
389 The encoding and interpretation depends
390 on dmMimeType.
391 TODO: inline XML */
392 size_t data_length; /* Length of the data in bytes */
393 char *dmMimeType; /* MIME type of data; Mandatory. */
394 isds_FileMetaType dmFileMetaType; /* Document type to create hierarchy */
395 char *dmFileGuid; /* Message-local document identifier;
396 Optional. */
397 char *dmUpFileGuid; /* Reference to upper document identifier
398 (dmFileGuid); Optional. */
399 char *dmFileDescr; /* Document name (title). E.g. file name;
400 Mandatory. */
401 char *dmFormat; /* Reference to XML form definition;
402 Defines howto interpret XML document;
403 Optional. */
406 /* Raw message representation content type.
407 * This is necessary to distinguish between different representations without
408 * expensive repated detection.
409 * Infix explanation:
410 * PLAIN_SIGNED data are XML with namespace mangled to signed alternative
411 * CMS_SIGNED data are XML with signed namespace encapsulated in CMS */
412 typedef enum {
413 RAWTYPE_INCOMING_MESSAGE,
414 RAWTYPE_PLAIN_SIGNED_INCOMING_MESSAGE,
415 RAWTYPE_CMS_SIGNED_INCOMING_MESSAGE,
416 RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE,
417 RAWTYPE_CMS_SIGNED_OUTGOING_MESSAGE,
418 RAWTYPE_DELIVERYINFO,
419 RAWTYPE_PLAIN_SIGNED_DELIVERYINFO,
420 RAWTYPE_CMS_SIGNED_DELIVERYINFO
421 } isds_raw_type;
423 /* Message */
424 struct isds_message {
425 void *raw; /* Raw message in XML format as send to or
426 from the ISDS. You can use it to store
427 local copy. This is binary buffer. */
428 size_t raw_length; /* Lenght of raw message in bytes */
429 isds_raw_type raw_type; /* Content type of raw representation
430 Meaningfull only with non-NULL raw
431 member */
432 struct isds_envelope *envelope; /* Message envelope */
433 struct isds_list *documents; /* List of isds_document's.
434 Valid message must contain exactly one
435 document of type FILEMETATYPE_MAIN and
436 can contain any number of other type
437 documents. Totol size of documents
438 must not exceed 10 MB. */
441 /* Message copy recipient and assigned message ID */
442 struct isds_message_copy {
443 /* Input members defined by application */
444 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
445 Maximal length is 7 characters. */
446 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
447 string; Optional. */
448 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
449 number; Optional. */
450 char *dmToHands; /* Person in recipient organisation;
451 Optional. */
453 /* Output members returned from ISDS */
454 isds_error error; /* libisds compatible error of delivery to o ne recipient */
455 char *dmStatus; /* Error description returned by ISDS;
456 Optional. */
457 char *dmID; /* Assigned message ID; Meaningfull only
458 for error == IE_SUCCESS */
461 /* General linked list */
462 struct isds_list {
463 struct isds_list *next; /* Next list item,
464 or NULL if current is last */
465 void *data; /* Payload */
466 void (*destructor) (void **); /* Payload deallocator */
469 /* Free isds_list with all member data.
470 * @list list to free, on return will be NULL */
471 void isds_list_free(struct isds_list **list);
474 /* Initialize ISDS library.
475 * Global function, must be called before other functions.
476 * If it failes you can not use ISDS library and must call isds_cleanup() to
477 * free partially inititialized global variables. */
478 isds_error isds_init(void);
480 /* Deinicialize ISDS library.
481 * Global function, must be called as last library function. */
482 isds_error isds_cleanup(void);
484 /* Create ISDS context.
485 * Each context can be used for different sessions to (possibly) different
486 * ISDS server with different credentials.
487 * Returns new context, or NULL */
488 struct isds_ctx *isds_ctx_create(void);
490 /* Destroy ISDS context and free memmory.
491 * @context will be NULLed on success. */
492 isds_error isds_ctx_free(struct isds_ctx **context);
494 /* Return long message text produced by library fucntion, e.g. detailed error
495 * mesage. Returned pointer is only valid until new library function is
496 * called for the same context. Could be NULL, especially if NULL context is
497 * supplied. Return string is locale encoded. */
498 char *isds_long_message(const struct isds_ctx *context);
500 /* Set logging up.
501 * @facilities is bitmask of isds_log_facility values,
502 * @level is verbosity level. */
503 void isds_set_logging(const unsigned int facilities,
504 const isds_log_level level);
507 /* Set timeout in miliseconds for each network job like connecting to server
508 * or sending message. Use 0 to disable timeout limits. */
509 isds_error isds_set_timeout(struct isds_ctx *context,
510 const unsigned int timeout);
512 /* Function provided by application libsds will call with
513 * following five arguments. Value zero of any argument means the value is
514 * unknown.
515 * @upload_total is expected total upload,
516 * @upload_current is cumulative current upload progress
517 * @dowload_total is expected total download
518 * @download_current is cumulative current download progress
519 * @data is pointer that will be passed unchanged to this function at run-time
520 * @return 0 to continue HTTP transfaer, or non-zero to abort transfer */
521 typedef int (*isds_progress_callback)(
522 double upload_total, double upload_current,
523 double download_total, double download_current,
524 void *data);
526 /* Register callback function libisds calls periodocally during HTTP data
527 * transfer.
528 * @context is session context
529 * @callback is function provided by application libsds will call. See type
530 * defition for @callback argument explanation.
531 * @data is application specific data @callback gets as last argument */
532 isds_error isds_set_progress_callback(struct isds_ctx *context,
533 isds_progress_callback callback, void *data);
535 /* Change SSL/TLS settings.
536 * @context is context which setting vill be applied to
537 * @option is name of option. It determines the type of last argument. See
538 * isds_tls_option definition for more info.
539 * @... is value of new setting. Type is determined by @option
540 * */
541 isds_error isds_set_tls(struct isds_ctx *context, const isds_tls_option option,
542 ...);
544 /* Connect and log in into ISDS server.
545 * @url is address of ISDS web service
546 * @username is user name of ISDS user
547 * @password is user's secret password
548 * @certificate is NULL terminated string with PEM formated client's
549 * certificate. Use NULL if only password autentication should be performed.
550 * @key is private key for client's certificate as (base64 encoded?) NULL
551 * terminated string. Use NULL if only password autentication is desired.
552 * */
553 isds_error isds_login(struct isds_ctx *context, const char *url,
554 const char *username, const char *password,
555 const char *certificate, const char* key);
557 /* Log out from ISDS server and close connection. */
558 isds_error isds_logout(struct isds_ctx *context);
560 /* Verify connection to ISDS is alive and server is responding.
561 * Sent dumy request to ISDS and expect dummy response. */
562 isds_error isds_ping(struct isds_ctx *context);
564 /* Get data about logged in user and his box. */
565 isds_error isds_GetOwnerInfoFromLogin(struct isds_ctx *context,
566 struct isds_DbOwnerInfo **db_owner_info);
568 /* Get data about logged in user. */
569 isds_error isds_GetUserInfoFromLogin(struct isds_ctx *context,
570 struct isds_DbUserInfo **db_user_info);
572 /* Get expiration time of current password
573 * @context is session context
574 * @expiration is automatically reallocated time when password expires, In
575 * case of error will be nulled. */
576 isds_error isds_get_password_expiration(struct isds_ctx *context,
577 struct timeval **expiration);
579 /* Change user password in ISDS.
580 * User must supply old password, new password will takes effect after some
581 * time, current session can continue. Password must fulfill some constraints.
582 * @context is session context
583 * @old_password is current password.
584 * @new_password is requested new password */
585 isds_error isds_change_password(struct isds_ctx *context,
586 const char *old_password, const char *new_password);
588 /* Get data about all users assigned to given box.
589 * @context is session context
590 * @box_id is box ID
591 * @users is automatically reallocated list of struct isds_DbUserInfo */
592 isds_error isds_GetDataBoxUsers(struct isds_ctx *context, const char *box_id,
593 struct isds_list **users);
595 /* Update data about user assigned to given box.
596 * @context is session context
597 * @box is box identification
598 * @old_user identifies user to update
599 * @new_user are updated data about @old_user
600 * @refnumber is reallocated serial number of request assigned by ISDS. Use
601 * NULL, if you don't care.*/
602 isds_error isds_UpdateDataBoxUser(struct isds_ctx *context,
603 const struct isds_DbOwnerInfo *box,
604 const struct isds_DbUserInfo *old_user,
605 const struct isds_DbUserInfo *new_user,
606 char **refnumber);
608 /* Find boxes suiting given criteria.
609 * @context is ISDS session context.
610 * @criteria is filter. You should fill in at least some members.
611 * @boxes is automatically reallocated list of isds_DbOwnerInfo structures,
612 * possibly empty. Input NULL or valid old structure.
613 * @return:
614 * IE_SUCCESS if search sucseeded, @boxes contains usefull data
615 * IE_NOEXIST if no such box exists, @boxes will be NULL
616 * IE_2BIG if too much boxes exist and server truncated the resuluts, @boxes
617 * contains still valid data
618 * other code if something bad happens. @boxes will be NULL. */
619 isds_error isds_FindDataBox(struct isds_ctx *context,
620 const struct isds_DbOwnerInfo *criteria,
621 struct isds_list **boxes);
623 /* Get status of a box.
624 * @context is ISDS session context.
625 * @box_id is UTF-8 encoded box identifier as zero terminated string
626 * @box_status is return value of box status.
627 * @return:
628 * IE_SUCCESS if box has been found and its status retrieved
629 * IE_NOEXIST if box is not known to ISDS server
630 * or other appropriate error.
631 * You can use isds_DbState to enumerate box status. However out of enum
632 * range value can be returned too. This is feature because ISDS
633 * specification leaves the set of values open.
634 * Be ware that status DBSTATE_REMOVED is signaled as IE_SUCCESS. That means
635 * the box has been deleted, but ISDS still lists its former existence. */
636 isds_error isds_CheckDataBox(struct isds_ctx *context, const char *box_id,
637 long int *box_status);
639 /* Switch box into state where box can receive commercial messages (off by
640 * default)
641 * @context is ISDS session context.
642 * @box_id is UTF-8 encoded box identifier as zero terminated string
643 * @allow is true for enable, false for disable commercial messages income
644 * @refnumber is reallocated serial number of request assigned by ISDS. Use
645 * NULL, if you don't care. */
646 isds_error isds_switch_commercial_receiving(struct isds_ctx *context,
647 const char *box_id, const _Bool allow, char **refnumber);
649 /* Switch box into / out of state where non-OVM box can act as OVM (e.g. force
650 * message acceptance). This is just a box permission. Sender must apply
651 * such role by sending each message.
652 * @context is ISDS session context.
653 * @box_id is UTF-8 encoded box identifier as zero terminated string
654 * @allow is true for enable, false for disable OVM role permission
655 * @refnumber is reallocated serial number of request assigned by ISDS. Use
656 * NULL, if you don't care. */
657 isds_error isds_switch_effective_ovm(struct isds_ctx *context,
658 const char *box_id, const _Bool allow, char **refnumber);
660 /* Switch box accessibility state on request of box owner.
661 * Despite the name, owner must do the requst off-line. This function is
662 * designed for such off-line meeting points (e.g. Czech POINT).
663 * @context is ISDS session context.
664 * @box identifies box to swith accesibilty state.
665 * @allow is true for making accesibale, false to disallow access.
666 * @refnumber is reallocated serial number of request assigned by ISDS. Use
667 * NULL, if you don't care. */
668 isds_error isds_switch_box_accessibility_on_owner_request(
669 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
670 const _Bool allow, char **refnumber);
672 /* Disable box accessibility on law enforcement (e.g. by prison) since exact
673 * date.
674 * @context is ISDS session context.
675 * @box identifies box to swith accesibilty state.
676 * @since is date since accesseibility has been denied. This can be past too.
677 * Only tm_year, tm_mon and tm_mday carry sane value.
678 * @refnumber is reallocated serial number of request assigned by ISDS. Use
679 * NULL, if you don't care. */
680 isds_error isds_disable_box_accessibility_externaly(
681 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
682 const struct tm *since, char **refnumber);
684 /* Send a message via ISDS to a recipent
685 * @context is session context
686 * @outgoing_message is message to send; Some memebers are mandatory (like
687 * dbIDRecipient), some are optional and some are irrelevant (especialy data
688 * about sender). Included pointer to isds_list documents must contain at
689 * least one document of FILEMETATYPE_MAIN. This is read-write structure, some
690 * members will be filled with valid data from ISDS. Exact list of write
691 * members is subject to change. Currently dmId is changed.
692 * @return ISDS_SUCCESS, or other error code if something goes wrong. */
693 isds_error isds_send_message(struct isds_ctx *context,
694 struct isds_message *outgoing_message);
696 /* Send a message via ISDS to a multiple recipents
697 * @context is session context
698 * @outgoing_message is message to send; Some memebers are mandatory,
699 * some are optional and some are irrelevant (especialy data
700 * about sender). Data about recipient will be substituted by ISDS from
701 * @copies. Included pointer to isds_list documents must
702 * contain at least one document of FILEMETATYPE_MAIN.
703 * @copies is list of isds_message_copy structures addressing all desired
704 * recipients. This is read-write structure, some members will be filled with
705 * valid data from ISDS (message IDs, error codes, error descriptions).
706 * @return
707 * ISDS_SUCCESS if all messages have been sent
708 * ISDS_PARTIAL_SUCCESS if sending of some messages has failed (failed and
709 * succesed messages can be identified by copies->data->error),
710 * or other error code if something other goes wrong. */
711 isds_error isds_send_message_to_multiple_recipients(struct isds_ctx *context,
712 const struct isds_message *outgoing_message,
713 struct isds_list *copies);
715 /* Get list of outgoing (already sent) messages.
716 * Any criterion argument can be NULL, if you don't care about it.
717 * @context is session context. Must not be NULL.
718 * @from_time is minimal time and date of message sending inclusive.
719 * @to_time is maximal time and date of message sending inclusive
720 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
721 * @status_filter is bit field of isds_message_status values. Use special
722 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
723 * all values, you can use bitwise arithmetic if you want.)
724 * @offset is index of first message we are interested in. First message is 1.
725 * Set to 0 (or 1) if you don't care.
726 * @number is maximal length of list you want to get as input value, outputs
727 * number of messages matching these criteria. Can be NULL if you don't care
728 * (applies to output value either).
729 * @messages is automatically reallocated list of isds_message's. Be ware that
730 * it returns only brief overview (envelope and some other fields) about each
731 * message, not the complete message. FIXME: Specify exact fields.
732 * The list is sorted by delivery time in ascending order.
733 * Use NULL if you don't care about the metadata (useful if you want to know
734 * only the @number). If you provide &NULL, list will be allocated on heap,
735 * if you provide pointer to non-NULL, list will be freed automacally at first.
736 * Also in case of error the list will be NULLed.
737 * @return IE_SUCCESS or appropriate error code. */
738 isds_error isds_get_list_of_sent_messages(struct isds_ctx *context,
739 const struct timeval *from_time, const struct timeval *to_time,
740 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
741 const unsigned long int offset, unsigned long int *number,
742 struct isds_list **messages);
744 /* Get list of incoming (addressed to you) messages.
745 * Any criterion argument can be NULL, if you don't care about it.
746 * @context is session context. Must not be NULL.
747 * @from_time is minimal time and date of message sending inclusive.
748 * @to_time is maximal time and date of message sending inclusive
749 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
750 * @status_filter is bit field of isds_message_status values. Use special
751 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
752 * all values, you can use bitwise arithmetic if you want.)
753 * @offset is index of first message we are interested in. First message is 1.
754 * Set to 0 (or 1) if you don't care.
755 * @number is maximal length of list you want to get as input value, outputs
756 * number of messages matching these criteria. Can be NULL if you don't care
757 * (applies to output value either).
758 * @messages is automatically reallocated list of isds_message's. Be ware that
759 * it returns only brief overview (envelope and some other fields) about each
760 * message, not the complete message. FIXME: Specify exact fields.
761 * Use NULL if you don't care about the metadata (useful if you want to know
762 * only the @number). If you provide &NULL, list will be allocated on heap,
763 * if you provide pointer to non-NULL, list will be freed automacally at first.
764 * Also in case of error the list will be NULLed.
765 * @return IE_SUCCESS or appropriate error code. */
766 isds_error isds_get_list_of_received_messages(struct isds_ctx *context,
767 const struct timeval *from_time, const struct timeval *to_time,
768 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
769 const unsigned long int offset, unsigned long int *number,
770 struct isds_list **messages);
772 /* Download incoming message envelope identified by ID.
773 * @context is session context
774 * @message_id is message identifier (you can get them from
775 * isds_get_list_of_received_messages())
776 * @message is automatically reallocated message retrieved from ISDS.
777 * It will miss documents per se. Use isds_get_received_message(), if you are
778 * interrested in documents (content) too.
779 * Returned hash and timestamp require documents to be verifiable. */
780 isds_error isds_get_received_envelope(struct isds_ctx *context,
781 const char *message_id, struct isds_message **message);
783 /* Download signed delivery infosheet of given message identified by ID.
784 * @context is session context
785 * @message_id is message identifier (you can get them from
786 * isds_get_list_of_{sent,received}_messages())
787 * @message is automatically reallocated message retrieved from ISDS.
788 * It will miss documents per se. Use isds_get_signed_received_message(),
789 * if you are interrested in documents (content). OTOH, only this function
790 * can get list events message has gone through. */
791 isds_error isds_get_signed_delivery_info(struct isds_ctx *context,
792 const char *message_id, struct isds_message **message);
794 /* Load delivery info of any format from buffer.
795 * @context is session context
796 * @raw_type advertises format of @buffer content. Only delivery info types
797 * are accepted.
798 * @buffer is DER encoded PKCS#7 structure with signed delivery info. You can
799 * retrieve such data from message->raw after calling
800 * isds_get_signed_delivery_info().
801 * @length is length of buffer in bytes.
802 * @message is automatically reallocated message parsed from @buffer.
803 * @strategy selects how buffer will be attached into raw isds_message member.
804 * */
805 isds_error isds_load_delivery_info(struct isds_ctx *context,
806 const isds_raw_type raw_type,
807 const void *buffer, const size_t length,
808 struct isds_message **message, const isds_buffer_strategy strategy);
810 /* Download delivery infosheet of given message identified by ID.
811 * @context is session context
812 * @message_id is message identifier (you can get them from
813 * isds_get_list_of_{sent,received}_messages())
814 * @message is automatically reallocated message retrieved from ISDS.
815 * It will miss documents per se. Use isds_get_received_message(), if you are
816 * interrested in documents (content). OTOH, only this function can get list
817 * events message has gone through. */
818 isds_error isds_get_delivery_info(struct isds_ctx *context,
819 const char *message_id, struct isds_message **message);
821 /* Deprecated: Use isds_load_message() instead. */
822 /* Load incoming message from buffer.
823 * @context is session context
824 * @buffer XML stream with unsigned message. You can retrieve such data from
825 * message->raw after calling isds_get_received_message().
826 * @length is length of buffer in bytes.
827 * @message is automatically reallocated message parsed from @buffer.
828 * @strategy selects how buffer will be attached into raw isds_message member.
829 * */
830 isds_error isds_load_received_message(struct isds_ctx *context,
831 const void *buffer, const size_t length,
832 struct isds_message **message, const isds_buffer_strategy strategy)
833 _deprecated;
835 /* Download incoming message identified by ID.
836 * @context is session context
837 * @message_id is message identifier (you can get them from
838 * isds_get_list_of_received_messages())
839 * @message is automatically reallocated message retrieved from ISDS */
840 isds_error isds_get_received_message(struct isds_ctx *context,
841 const char *message_id, struct isds_message **message);
843 /* Deprecated: Use isds_load_message() instead. */
844 /* Load signed message from buffer.
845 * @context is session context
846 * @outgoing is true if message is outgoing, false if message is incoming
847 * @buffer is DER encoded PKCS#7 structure with signed message. You can
848 * retrieve such data from message->raw after calling
849 * isds_get_signed{received,sent}_message().
850 * @length is length of buffer in bytes.
851 * @message is automatically reallocated message parsed from @buffer.
852 * @strategy selects how buffer will be attached into raw isds_message member.
853 * */
854 isds_error isds_load_signed_message(struct isds_ctx *context,
855 const _Bool outgoing, const void *buffer, const size_t length,
856 struct isds_message **message, const isds_buffer_strategy strategy)
857 _deprecated;
859 /* Load message of any type from buffer.
860 * @context is session context
861 * @raw_type defines content type of @buffer. Only message types are allowed.
862 * @buffer is message raw representation. Format (CMS, plain signed,
863 * message direction) is defined in @raw_type. You can retrieve such data
864 * from message->raw after calling isds_get_[signed]{received,sent}_message().
865 * @length is length of buffer in bytes.
866 * @message is automatically reallocated message parsed from @buffer.
867 * @strategy selects how buffer will be attached into raw isds_message member.
868 * */
869 isds_error isds_load_message(struct isds_ctx *context,
870 const isds_raw_type raw_type, const void *buffer, const size_t length,
871 struct isds_message **message, const isds_buffer_strategy strategy);
873 /* Download signed incoming message identified by ID.
874 * @context is session context
875 * @message_id is message identifier (you can get them from
876 * isds_get_list_of_received_messages())
877 * @message is automatically reallocated message retrieved from ISDS. The raw
878 * memeber will be filled with PKCS#7 structure in DER format. */
879 isds_error isds_get_signed_received_message(struct isds_ctx *context,
880 const char *message_id, struct isds_message **message);
882 /* Download signed outgoing message identified by ID.
883 * @context is session context
884 * @message_id is message identifier (you can get them from
885 * isds_get_list_of_sent_messages())
886 * @message is automatically reallocated message retrieved from ISDS. The raw
887 * memeber will be filled with PKCS#7 structure in DER format. */
888 isds_error isds_get_signed_sent_message(struct isds_ctx *context,
889 const char *message_id, struct isds_message **message);
891 /* Retrieve hash of message identified by ID stored in ISDS.
892 * @context is session context
893 * @message_id is message identifier
894 * @hash is automatically reallocated message hash downloaded from ISDS.
895 * Message must exist in system and must not be deleted. */
896 isds_error isds_download_message_hash(struct isds_ctx *context,
897 const char *message_id, struct isds_hash **hash);
899 /* Compute hash of message from raw representation and store it into envelope.
900 * Original hash structure will be destroyed in envelope.
901 * @context is session context
902 * @message is message carrying raw XML message blob
903 * @algorithm is desired hash algorithm to use */
904 isds_error isds_compute_message_hash(struct isds_ctx *context,
905 struct isds_message *message, const isds_hash_algorithm algorithm);
907 /* Compare two hashes.
908 * @h1 is first hash
909 * @h2 is another hash
910 * @return
911 * IE_SUCCESS if hashes equal
912 * IE_NOTUNIQ if hashes are comparable, but they don't equal
913 * IE_ENUM if not comparable, but both structures defined
914 * IE_INVAL if some of the structures are undefined (NULL)
915 * IE_ERROR if internal error occurs */
916 isds_error isds_hash_cmp(const struct isds_hash *h1,
917 const struct isds_hash *h2);
919 /* Check message has gone through ISDS by comparing message hash stored in
920 * ISDS and locally computed hash. You must provide message with valid raw
921 * member (do not use isds_load_message(..., BUFFER_DONT_STORE)).
922 * This is convenient wrapper for isds_download_message_hash(),
923 * isds_compute_message_hash(), and isds_hash_cmp() sequence.
924 * @context is session context
925 * @message is message with valid raw and envelope member; envelope->hash
926 * member will be changed during funcion run. Use envelope on heap only.
927 * @return
928 * IE_SUCCESS if message originates in ISDS
929 * IE_NOTEQUAL if message is unknown to ISDS
930 * other code for other errors */
931 isds_error isds_verify_message_hash(struct isds_ctx *context,
932 struct isds_message *message);
934 /* Mark message as read. This is a transactional commit function to acknoledge
935 * to ISDS the message has been downloaded and processed by client properly.
936 * @context is session context
937 * @message_id is message identifier. */
938 isds_error isds_mark_message_read(struct isds_ctx *context,
939 const char *message_id);
941 /* Mark message as received by recipient. This is applicable only to
942 * commercial message. There is no specified way how to distinguishe
943 * commercial message from government message yet. Government message is
944 * received automatically (by law), commenrcial message on recipient request.
945 * @context is session context
946 * @message_id is message identifier. */
947 isds_error isds_mark_message_received(struct isds_ctx *context,
948 const char *message_id);
950 /* Send bogus request to ISDS.
951 * Just for test purposes */
952 isds_error isds_bogus_request(struct isds_ctx *context);
954 /* Search for document by document ID in list of documents. IDs are compared
955 * as UTF-8 string.
956 * @documents is list of isds_documents
957 * @id is document identifier
958 * @return first matching document or NULL. */
959 const struct isds_document *isds_find_document_by_id(
960 const struct isds_list *documents, const char *id);
962 /* Deallocate structure isds_hash and NULL it.
963 * @hash hash to to free */
964 void isds_hash_free(struct isds_hash **hash);
966 /* Deallocate structure isds_DbOwnerInfo recursively and NULL it */
967 void isds_DbOwnerInfo_free(struct isds_DbOwnerInfo **db_owner_info);
969 /* Deallocate structure isds_DbUserInfo recursively and NULL it */
970 void isds_DbUserInfo_free(struct isds_DbUserInfo **db_user_info);
972 /* Deallocate struct isds_event recursively and NULL it */
973 void isds_event_free(struct isds_event **event);
975 /* Deallocate struct isds_envelope recursively and NULL it */
976 void isds_envelope_free(struct isds_envelope **envelope);
978 /* Deallocate struct isds_document recursively and NULL it */
979 void isds_document_free(struct isds_document **document);
981 /* Deallocate struct isds_message recursively and NULL it */
982 void isds_message_free(struct isds_message **message);
984 /* Deallocate struct isds_message_copy recursively and NULL it */
985 void isds_message_copy_free(struct isds_message_copy **copy);
987 /* Copy structure isds_PersonName recursively */
988 struct isds_PersonName *isds_PersonName_duplicate(
989 struct isds_PersonName *template);
991 /* Copy structure isds_Address recursively */
992 struct isds_Address *isds_Address_duplicate(struct isds_Address *template);
994 /* Copy structure isds_DbUserInfo recursively */
995 struct isds_DbUserInfo *isds_DbUserInfo_duplicate(
996 const struct isds_DbUserInfo *template);
998 #endif