notifier.h

00001 /* 
00002  * Copyright (C) 2005 iptelorg GmbH
00003  *
00004  * This file is part of ser, a free SIP server.
00005  *
00006  * ser is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * For a license to use the ser software under conditions
00012  * other than those described here, or to purchase support for this
00013  * software, please contact iptel.org by e-mail at the following addresses:
00014  *    info@iptel.org
00015  *
00016  * ser is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 
00026 #ifndef __NOTIFIER_H
00027 #define __NOTIFIER_H
00028 
00029 /* Notifier functions for notifier_domain */
00030 
00031 #include <presence/notifier_domain.h>
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 /* Returns the created notifier. Indicates error if NULL. */
00038 notifier_t *register_notifier(
00039         notifier_domain_t *domain,
00040         const str_t *package,
00041         server_subscribe_func subscribe,
00042         server_unsubscribe_func unsubscribe,
00043         void *user_data);
00044 
00045 void unregister_notifier(notifier_domain_t *domain, notifier_t *info);
00046 
00054 void accept_subscription(qsa_subscription_t *s);
00055 
00060 void release_subscription(qsa_subscription_t *s);
00061 
00066 typedef enum {
00067         qsa_subscription_active,
00068         qsa_subscription_pending,
00069         qsa_subscription_terminated,
00070         qsa_subscription_rejected
00071 } qsa_subscription_status_t;
00072 
00073 typedef struct {
00074         /* replacement for record_id, package, ... it is much more efficient */
00075         qsa_subscription_t *subscription; 
00076         qsa_content_type_t *content_type;
00077         void *data;
00078         int data_len;
00079         qsa_subscription_status_t status;
00080 } client_notify_info_t;
00081 
00082 
00083 void free_client_notify_info_content(client_notify_info_t *info);
00084 
00085 /* notifications SHOULD be sent through this method */
00086 int notify_subscriber(qsa_subscription_t *s, 
00087                 notifier_t *n,
00088                 qsa_content_type_t *content_type, 
00089                 void *data, 
00090                 qsa_subscription_status_t status);
00091 
00092 /* this can be called in notifier and the returned value is valid
00093  * before finishes "unsubscribe" processing */
00094 str_t *get_subscriber_id(qsa_subscription_t *s);
00095 
00096 /* this can be called in notifier and the returned value is valid
00097  * before finishes "unsubscribe" processing */
00098 str_t *get_record_id(qsa_subscription_t *s);
00099 
00100 /* this can be called in notifier and the returned value is valid
00101  * before finishes "unsubscribe" processing */
00102 void *get_subscriber_data(qsa_subscription_t *s);
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #endif