1 /* 2 linphone 3 Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License 7 as published by the Free Software Foundation; either version 2 8 of the License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 21 #ifndef sipsetup_h 22 #define sipsetup_h 23 24 #include "mediastreamer2/mscommon.h" 25 26 struct _SipSetup; 27 28 struct _BuddyInfo; 29 30 struct _LinphoneXmlRpcSession; 31 32 33 struct _SipSetupContext{ 34 struct _SipSetup *funcs; 35 struct _LinphoneProxyConfig *cfg; 36 struct _LinphoneXmlRpcSession *xmlrpc_session; 37 char domain[128]; 38 char username[128]; 39 void *data; 40 }; 41 42 typedef struct _SipSetupContext SipSetupContext; 43 44 #define SIP_SETUP_CAP_PROXY_PROVIDER (1) 45 #define SIP_SETUP_CAP_STUN_PROVIDER (1<<1) 46 #define SIP_SETUP_CAP_RELAY_PROVIDER (1<<2) 47 #define SIP_SETUP_CAP_BUDDY_LOOKUP (1<<3) 48 #define SIP_SETUP_CAP_ACCOUNT_MANAGER (1<<4) /*can create accounts*/ 49 #define SIP_SETUP_CAP_LOGIN (1<<5) /*can login to any account for a given proxy */ 50 51 typedef enum _BuddyLookupStatus{ 52 BuddyLookupNone, 53 BuddyLookupConnecting, 54 BuddyLookupConnected, 55 BuddyLookupReceivingResponse, 56 BuddyLookupDone, 57 BuddyLookupFailure 58 }BuddyLookupStatus; 59 60 typedef struct _BuddyAddress{ 61 char street[64]; 62 char zip[64]; 63 char town[64]; 64 char country[64]; 65 } BuddyAddress; 66 67 typedef struct _BuddyInfo{ 68 char firstname[64]; 69 char lastname[64]; 70 char displayname[64]; 71 char sip_uri[128]; 72 char email[128]; 73 BuddyAddress address; 74 char image_type[32]; 75 uint8_t *image_data; 76 int image_length; 77 }BuddyInfo; 78 79 typedef struct _BuddyLookupRequest { 80 char *key; 81 int max_results; 82 BuddyLookupStatus status; 83 MSList *results; /*of BuddyInfo */ 84 }BuddyLookupRequest; 85 86 87 typedef struct _BuddyLookupFuncs{ 88 BuddyLookupRequest * (*request_create)(SipSetupContext *ctx); 89 int (*request_submit)(SipSetupContext *ctx, BuddyLookupRequest *req); 90 int (*request_free)(SipSetupContext *ctx, BuddyLookupRequest *req); 91 }BuddyLookupFuncs; 92 93 94 struct _SipSetup{ 95 char *name; 96 unsigned int capabilities; 97 int initialized; 98 bool_t (*init)(void); 99 void (*exit)(void); 100 void (*init_instance)(SipSetupContext *ctx); 101 void (*uninit_instance)(SipSetupContext *ctx); 102 int (*account_exists)(SipSetupContext *ctx, const char *uri); 103 int (*create_account)(SipSetupContext *ctx, const char *uri, const char *passwd, const char *email, int suscribe); 104 int (*login_account)(SipSetupContext *ctx, const char *uri, const char *passwd, const char *userid); 105 int (*get_proxy)(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz); 106 int (*get_stun_servers)(SipSetupContext *ctx, char *stun1, char *stun2, size_t size); 107 int (*get_relay)(SipSetupContext *ctx, char *relay, size_t size); 108 const char * (*get_notice)(SipSetupContext *ctx); 109 const char ** (*get_domains)(SipSetupContext *ctx); 110 int (*logout_account)(SipSetupContext *ctx); 111 BuddyLookupFuncs *buddy_lookup_funcs; 112 int (*account_validated)(SipSetupContext *ctx, const char *uri); 113 }; 114 115 typedef struct _SipSetup SipSetup; 116 117 118 119 #ifdef __cplusplus 120 extern "C"{ 121 #endif 122 123 BuddyInfo *buddy_info_new(void); 124 void buddy_info_free(BuddyInfo *info); 125 126 LINPHONE_PUBLIC void buddy_lookup_request_set_key(BuddyLookupRequest *req, const char *key); 127 void buddy_lookup_request_set_max_results(BuddyLookupRequest *req, int ncount); 128 129 130 void sip_setup_register(SipSetup *ss); 131 void sip_setup_register_all(MSFactory* factory); 132 SipSetup *sip_setup_lookup(const char *type_name); 133 void sip_setup_unregister_all(void); 134 LINPHONE_PUBLIC unsigned int sip_setup_get_capabilities(SipSetup *s); 135 136 SipSetupContext * sip_setup_context_new(SipSetup *s, struct _LinphoneProxyConfig *cfg); 137 int sip_setup_context_account_exists(SipSetupContext *ctx, const char *uri); 138 int sip_setup_context_account_validated(SipSetupContext *ctx, const char *uri); 139 LinphoneStatus sip_setup_context_create_account(SipSetupContext *ctx, const char *uri, const char *passwd, const char *email, int suscribe); 140 LINPHONE_PUBLIC int sip_setup_context_get_capabilities(SipSetupContext *ctx); 141 LINPHONE_PUBLIC LinphoneStatus sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd, const char *userid); 142 LinphoneStatus sip_setup_context_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz); 143 LinphoneStatus sip_setup_context_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size); 144 LinphoneStatus sip_setup_context_get_relay(SipSetupContext *ctx, char *relay, size_t size); 145 146 LINPHONE_PUBLIC BuddyLookupRequest *sip_setup_context_create_buddy_lookup_request(SipSetupContext *ctx); 147 LINPHONE_PUBLIC LinphoneStatus sip_setup_context_buddy_lookup_submit(SipSetupContext *ctx , BuddyLookupRequest *req); 148 LINPHONE_PUBLIC LinphoneStatus sip_setup_context_buddy_lookup_free(SipSetupContext *ctx , BuddyLookupRequest *req); 149 150 const char * sip_setup_context_get_notice(SipSetupContext *ctx); 151 const char ** sip_setup_context_get_domains(SipSetupContext *ctx); 152 153 void sip_setup_context_free(SipSetupContext *ctx); 154 155 LINPHONE_PUBLIC LinphoneStatus sip_setup_context_logout(SipSetupContext *ctx); 156 157 /*internal methods for use WITHIN plugins: do not use elsewhere*/ 158 struct _LinphoneProxyConfig *sip_setup_context_get_proxy_config(const SipSetupContext *ctx); 159 void buddy_lookup_request_free(BuddyLookupRequest *req); 160 161 #ifdef __cplusplus 162 } 163 #endif 164 165 166 #endif 167 168 169