| 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 | |
|---|
| 31 | struct _SipSetupContext{ |
|---|
| 32 | struct _SipSetup *funcs; |
|---|
| 33 | struct _LinphoneProxyConfig *cfg; |
|---|
| 34 | char domain[128]; |
|---|
| 35 | char username[128]; |
|---|
| 36 | void *data; |
|---|
| 37 | }; |
|---|
| 38 | |
|---|
| 39 | typedef struct _SipSetupContext SipSetupContext; |
|---|
| 40 | |
|---|
| 41 | #define SIP_SETUP_CAP_PROXY_PROVIDER (1) |
|---|
| 42 | #define SIP_SETUP_CAP_STUN_PROVIDER (1<<1) |
|---|
| 43 | #define SIP_SETUP_CAP_RELAY_PROVIDER (1<<2) |
|---|
| 44 | #define SIP_SETUP_CAP_BUDDY_LOOKUP (1<<3) |
|---|
| 45 | #define SIP_SETUP_CAP_ACCOUNT_MANAGER (1<<4) |
|---|
| 46 | |
|---|
| 47 | typedef enum _BuddyLookupStatus{ |
|---|
| 48 | BuddyLookupNone, |
|---|
| 49 | BuddyLookupConnecting, |
|---|
| 50 | BuddyLookupConnected, |
|---|
| 51 | BuddyLookupReceivingResponse, |
|---|
| 52 | BuddyLookupDone, |
|---|
| 53 | BuddyLookupFailure |
|---|
| 54 | }BuddyLookupStatus; |
|---|
| 55 | |
|---|
| 56 | typedef struct _BuddyAddress{ |
|---|
| 57 | char street[64]; |
|---|
| 58 | char zip[64]; |
|---|
| 59 | char town[64]; |
|---|
| 60 | char country[64]; |
|---|
| 61 | } BuddyAddress; |
|---|
| 62 | |
|---|
| 63 | typedef struct _BuddyInfo{ |
|---|
| 64 | char firstname[64]; |
|---|
| 65 | char lastname[64]; |
|---|
| 66 | char displayname[64]; |
|---|
| 67 | char sip_uri[128]; |
|---|
| 68 | BuddyAddress address; |
|---|
| 69 | }BuddyInfo; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | struct _SipSetup{ |
|---|
| 73 | char *name; |
|---|
| 74 | unsigned int capabilities; |
|---|
| 75 | bool_t (*init)(void); |
|---|
| 76 | int (*init_instance)(SipSetupContext *ctx); |
|---|
| 77 | int (*create_account)( const char *uri, const char *passwd); |
|---|
| 78 | int (*login_account)(SipSetupContext *ctx, const char *uri, const char *passwd); |
|---|
| 79 | int (*get_proxy)(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz); |
|---|
| 80 | int (*get_stun_servers)(SipSetupContext *ctx, char *stun1, char *stun2, size_t size); |
|---|
| 81 | int (*get_relay)(SipSetupContext *ctx, char *relay, size_t size); |
|---|
| 82 | int (*lookup_buddy)(SipSetupContext *ctx, const char *key); |
|---|
| 83 | BuddyLookupStatus (*get_buddy_lookup_status)(SipSetupContext *ctx); |
|---|
| 84 | int (*get_buddy_lookup_results)(SipSetupContext *ctx, MSList **results); |
|---|
| 85 | void (*exit)(void); |
|---|
| 86 | bool_t initialized; |
|---|
| 87 | }; |
|---|
| 88 | |
|---|
| 89 | typedef struct _SipSetup SipSetup; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | #ifdef __cplusplus |
|---|
| 93 | extern "C"{ |
|---|
| 94 | #endif |
|---|
| 95 | |
|---|
| 96 | void sip_setup_register(SipSetup *ss); |
|---|
| 97 | void sip_setup_register_all(void); |
|---|
| 98 | SipSetup *sip_setup_lookup(const char *type_name); |
|---|
| 99 | void sip_setup_unregister_all(void); |
|---|
| 100 | |
|---|
| 101 | int sip_setup_new_account(SipSetup *s, const char *uri, const char *passwd); |
|---|
| 102 | SipSetupContext * sip_setup_context_new(SipSetup *s, struct _LinphoneProxyConfig *cfg); |
|---|
| 103 | int sip_setup_context_get_capabilities(SipSetupContext *ctx); |
|---|
| 104 | int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd); |
|---|
| 105 | int sip_setup_context_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz); |
|---|
| 106 | int sip_setup_context_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size); |
|---|
| 107 | int sip_setup_context_get_relay(SipSetupContext *ctx, char *relay, size_t size); |
|---|
| 108 | int sip_setup_context_lookup_buddy(SipSetupContext *ctx, const char *key); |
|---|
| 109 | BuddyLookupStatus sip_setup_context_get_buddy_lookup_status(SipSetupContext *ctx); |
|---|
| 110 | int sip_setup_context_get_buddy_lookup_results(SipSetupContext *ctx, MSList **results /*of BuddyInfo */); |
|---|
| 111 | void sip_setup_context_free_results(MSList *results); |
|---|
| 112 | void sip_setup_context_free(SipSetupContext *ctx); |
|---|
| 113 | |
|---|
| 114 | /*internal methods*/ |
|---|
| 115 | struct _LinphoneProxyConfig *sip_setup_context_get_proxy_config(const SipSetupContext *ctx); |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | #ifdef __cplusplus |
|---|
| 119 | } |
|---|
| 120 | #endif |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | #endif |
|---|
| 124 | |
|---|
| 125 | |
|---|