Avis Client Library: avis/elvin.h Source File

- Main Page
- Data Structures
- Files

# avis/elvin.h

Go to the documentation of this file.

    00001 /*
    00002  *  Avis Elvin client library for C.
    00003  *
    00004  *  Copyright (C) 2008 Matthew Phillips <avis@mattp.name>
    00005  *
    00006  *  This program is free software; you can redistribute it and/or
    00007  *  modify it under the terms of version 3 of the GNU Lesser General
    00008  *  Public License as published by the Free Software Foundation.
    00009  *
    00010  *  This program is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    00013  *  General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU General Public License
    00016  *  along with this program. If not, see <http://www.gnu.org/licenses/>.
    00017  */
    00039 #ifndef AVIS_ELVIN_H
    00040 #define AVIS_ELVIN_H
    00041
    00042 #include <avis/defs.h>
    00043 #include <avis/keys.h>
    00044 #include <avis/attributes.h>
    00045 #include <avis/stdtypes.h>
    00046 #include <avis/elvin_uri.h>
    00047 #include <avis/errors.h>
    00048 #include <avis/arrays.h>
    00049 #include <avis/net.h>
    00050
    00051 #define AVIS_LISTENERS_TYPE
    00052
    00053 typedef ArrayList * Listeners;
    00054
    00076 typedef struct
    00077 {
    00078   socket_t    router_socket;
    00079   socket_t    control_socket_read;
    00080   socket_t    control_socket_write;
    00081   ArrayList   subscriptions;
    00082   Listeners   close_listeners;
    00083   Listeners   notification_listeners;
    00084   Keys *      notification_keys;
    00085   Keys *      subscription_keys;
    00086   bool        polling;
    00087   ElvinError  error;
    00088   time_t      last_receive_time;
    00089 } Elvin;
    00090
    00094 typedef enum
    00095 {
    00096   REQUIRE_SECURE_DELIVERY = 0,
    00097   ALLOW_INSECURE_DELIVERY = 1
    00098 } SecureMode;
    00099
    00105 typedef struct
    00106 {
    00107   Elvin *      elvin;
    00108   char *       subscription_expr;
    00109   uint64_t     id;
    00110   SecureMode   security;
    00111   Listeners    listeners;
    00112   Keys *       keys;
    00113 } Subscription;
    00114
    00115 typedef enum
    00116 {
    00118   REASON_CLIENT_SHUTDOWN,
    00119
    00121   REASON_ROUTER_SHUTDOWN,
    00122
    00128   REASON_PROTOCOL_VIOLATION,
    00129
    00134   REASON_ROUTER_STOPPED_RESPONDING
    00135 } CloseReason;
    00136
    00154 typedef void (*SubscriptionListener) (Subscription *subscription,
    00155                                       Attributes *attributes, bool secure,
    00156                                       void *user_data);
    00157
    00169 typedef void (*CloseListener) (Elvin *elvin, CloseReason reason,
    00170                                const char *message,
    00171                                void *user_data);
    00172
    00190 typedef void (*GeneralNotificationListener)
    00191   (Elvin *elvin, Attributes *attributes, bool secure, void *user_data);
    00192
    00199 typedef void (*InvokeHandler) (Elvin *elvin, void *parameter);
    00200
    00227 AVIS_PUBLIC
    00228 bool elvin_open (Elvin *elvin, const char *router_uri);
    00229
    00240 AVIS_PUBLIC
    00241 bool elvin_open_uri (Elvin *elvin, ElvinURI *uri);
    00242
    00262 AVIS_PUBLIC
    00263 bool elvin_open_with_keys (Elvin *elvin, ElvinURI *uri,
    00264                            Keys *notification_keys, Keys *subscription_keys);
    00265
    00283 AVIS_PUBLIC
    00284 bool elvin_set_keys (Elvin *elvin,
    00285                      Keys *notification_keys, Keys *subscription_keys);
    00286
    00310 AVIS_PUBLIC
    00311 bool elvin_send (Elvin *elvin, Attributes *notification);
    00312
    00328 AVIS_PUBLIC
    00329 bool elvin_send_with_keys (Elvin *elvin, Attributes *notification,
    00330                            Keys *notification_keys, SecureMode security);
    00331
    00360 AVIS_PUBLIC
    00361 Subscription *elvin_subscribe (Elvin *elvin, const char *subscription_expr);
    00362
    00406 AVIS_PUBLIC
    00407 Subscription *elvin_subscribe_with_keys (Elvin *elvin,
    00408                                          const char *subscription_expr,
    00409                                          Keys *keys,
    00410                                          SecureMode security);
    00411
    00424 AVIS_PUBLIC
    00425 bool elvin_unsubscribe (Elvin *elvin, Subscription *subscription);
    00426
    00435 AVIS_PUBLIC
    00436 bool elvin_subscription_set_expr (Subscription *subscription,
    00437                                   const char *subscription_expr);
    00438
    00453 AVIS_PUBLIC
    00454 bool elvin_subscription_set_keys (Subscription *subscription,
    00455                                   Keys *subscription_keys,
    00456                                   SecureMode security);
    00457
    00471 AVIS_PUBLIC
    00472 void elvin_subscription_add_listener (Subscription *subscription,
    00473                                       SubscriptionListener listener,
    00474                                       void *user_data);
    00475
    00486 AVIS_PUBLIC
    00487 bool elvin_subscription_remove_listener (Subscription *subscription,
    00488                                          SubscriptionListener listener);
    00496 AVIS_PUBLIC
    00497 bool elvin_is_open (const Elvin *elvin);
    00498
    00509 AVIS_PUBLIC
    00510 bool elvin_close (Elvin *elvin);
    00511
    00519 AVIS_PUBLIC
    00520 void elvin_reset (Elvin *elvin);
    00521
    00539 AVIS_PUBLIC
    00540 bool elvin_invoke (Elvin *elvin, InvokeHandler handler, void *parameter);
    00541
    00546 AVIS_PUBLIC
    00547 bool elvin_invoke_close (Elvin *elvin);
    00548
    00561 AVIS_PUBLIC
    00562 void elvin_add_close_listener (Elvin *elvin, CloseListener listener,
    00563                                void *user_data);
    00564
    00575 AVIS_PUBLIC
    00576 bool elvin_remove_close_listener (Elvin *elvin, CloseListener listener);
    00577
    00593 AVIS_PUBLIC
    00594 void elvin_add_notification_listener (Elvin *elvin,
    00595                                       GeneralNotificationListener listener,
    00596                                       void *user_data);
    00597
    00608 AVIS_PUBLIC
    00609 bool elvin_remove_notification_listener (Elvin *elvin,
    00610                                          GeneralNotificationListener listener);
    00611
    00640 AVIS_PUBLIC
    00641 bool elvin_event_loop (Elvin *elvin);
    00642
    00661 AVIS_PUBLIC
    00662 bool elvin_poll (Elvin *elvin);
    00663
    00664 #endif /* AVIS_ELVIN_H */