sipsetup.h 5.61 KB
Newer Older
smorlat's avatar
smorlat committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
linphone
Copyright (C) 2000  Simon MORLAT (simon.morlat@linphone.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


#ifndef sipsetup_h
#define sipsetup_h
smorlat's avatar
smorlat committed
23 24

#include "mediastreamer2/mscommon.h"
smorlat's avatar
smorlat committed
25

26 27 28 29
#ifndef LINPHONE_PUBLIC
#define LINPHONE_PUBLIC MS2_PUBLIC
#endif

smorlat's avatar
smorlat committed
30 31
struct _SipSetup;

smorlat's avatar
smorlat committed
32 33
struct _BuddyInfo;

34 35
struct _LinphoneXmlRpcSession;

smorlat's avatar
smorlat committed
36

smorlat's avatar
smorlat committed
37 38
struct _SipSetupContext{
	struct _SipSetup *funcs;
smorlat's avatar
smorlat committed
39
	struct _LinphoneProxyConfig *cfg;
40
	struct _LinphoneXmlRpcSession *xmlrpc_session;
smorlat's avatar
smorlat committed
41 42
	char domain[128];
	char username[128];
smorlat's avatar
smorlat committed
43 44 45 46 47
	void *data;
};

typedef struct _SipSetupContext SipSetupContext;

smorlat's avatar
smorlat committed
48 49 50 51
#define SIP_SETUP_CAP_PROXY_PROVIDER	(1)
#define SIP_SETUP_CAP_STUN_PROVIDER	(1<<1)
#define SIP_SETUP_CAP_RELAY_PROVIDER	(1<<2)
#define SIP_SETUP_CAP_BUDDY_LOOKUP	(1<<3)
52 53
#define SIP_SETUP_CAP_ACCOUNT_MANAGER	(1<<4)  /*can create accounts*/
#define SIP_SETUP_CAP_LOGIN		(1<<5)  /*can login to any account for a given proxy */
smorlat's avatar
smorlat committed
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
typedef enum _BuddyLookupStatus{
	BuddyLookupNone,
	BuddyLookupConnecting,
	BuddyLookupConnected,
	BuddyLookupReceivingResponse,
	BuddyLookupDone,
	BuddyLookupFailure
}BuddyLookupStatus;

typedef struct _BuddyAddress{
	char street[64];
	char zip[64];
	char town[64];
	char country[64];
} BuddyAddress;

typedef struct _BuddyInfo{
	char firstname[64];
	char lastname[64];
	char displayname[64];
	char sip_uri[128];
smorlat's avatar
smorlat committed
76
	char email[128];
77
	BuddyAddress address;
78 79 80
	char image_type[32];
	uint8_t *image_data;
	int image_length;
81 82
}BuddyInfo;

83 84 85 86 87 88 89 90 91 92 93 94 95 96
typedef struct _BuddyLookupRequest {
	char *key;
	int max_results;
	BuddyLookupStatus status;
	MSList *results; /*of BuddyInfo */
}BuddyLookupRequest;


typedef struct _BuddyLookupFuncs{
	BuddyLookupRequest * (*request_create)(SipSetupContext *ctx);
	int (*request_submit)(SipSetupContext *ctx, BuddyLookupRequest *req);
	int (*request_free)(SipSetupContext *ctx, BuddyLookupRequest *req);
}BuddyLookupFuncs;

smorlat's avatar
smorlat committed
97

smorlat's avatar
smorlat committed
98 99
struct _SipSetup{
	char *name;
smorlat's avatar
smorlat committed
100
	unsigned int capabilities;
smorlat's avatar
smorlat committed
101
	int initialized;
smorlat's avatar
smorlat committed
102
	bool_t (*init)(void);
smorlat's avatar
smorlat committed
103
	void (*exit)(void);
smorlat's avatar
smorlat committed
104
	void (*init_instance)(SipSetupContext *ctx);
smorlat's avatar
smorlat committed
105
	void (*uninit_instance)(SipSetupContext *ctx);
106
	int (*account_exists)(SipSetupContext *ctx, const char *uri);
Sylvain Berfini's avatar
Sylvain Berfini committed
107
	int (*create_account)(SipSetupContext *ctx, const char *uri, const char *passwd, const char *email, int suscribe);
108
	int (*login_account)(SipSetupContext *ctx, const char *uri, const char *passwd, const char *userid);
smorlat's avatar
smorlat committed
109 110 111
	int (*get_proxy)(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz);
	int (*get_stun_servers)(SipSetupContext *ctx, char *stun1, char *stun2, size_t size);
	int (*get_relay)(SipSetupContext *ctx, char *relay, size_t size);
smorlat's avatar
smorlat committed
112 113
	const char * (*get_notice)(SipSetupContext *ctx);
	const char ** (*get_domains)(SipSetupContext *ctx);
smorlat's avatar
smorlat committed
114
	int (*logout_account)(SipSetupContext *ctx);
115
	BuddyLookupFuncs *buddy_lookup_funcs;
Sylvain Berfini's avatar
Sylvain Berfini committed
116
	int (*account_validated)(SipSetupContext *ctx, const char *uri);
smorlat's avatar
smorlat committed
117 118 119 120
};

typedef struct _SipSetup SipSetup;

smorlat's avatar
smorlat committed
121

122

123 124 125
#ifdef __cplusplus
extern "C"{
#endif
smorlat's avatar
smorlat committed
126

127
BuddyInfo *buddy_info_new(void);
128 129
void buddy_info_free(BuddyInfo *info);

130
LINPHONE_PUBLIC void buddy_lookup_request_set_key(BuddyLookupRequest *req, const char *key);
131 132
void buddy_lookup_request_set_max_results(BuddyLookupRequest *req, int ncount);

133

smorlat's avatar
smorlat committed
134
void sip_setup_register(SipSetup *ss);
135
void sip_setup_register_all(MSFactory* factory);
smorlat's avatar
smorlat committed
136
SipSetup *sip_setup_lookup(const char *type_name);
smorlat's avatar
smorlat committed
137
void sip_setup_unregister_all(void);
138
LINPHONE_PUBLIC unsigned int sip_setup_get_capabilities(SipSetup *s);
smorlat's avatar
smorlat committed
139

smorlat's avatar
smorlat committed
140
SipSetupContext * sip_setup_context_new(SipSetup *s, struct _LinphoneProxyConfig *cfg);
141
int sip_setup_context_account_exists(SipSetupContext *ctx, const char *uri);
Sylvain Berfini's avatar
Sylvain Berfini committed
142 143
int sip_setup_context_account_validated(SipSetupContext *ctx, const char *uri);
int sip_setup_context_create_account(SipSetupContext *ctx, const char *uri, const char *passwd, const char *email, int suscribe);
144 145
LINPHONE_PUBLIC int sip_setup_context_get_capabilities(SipSetupContext *ctx);
LINPHONE_PUBLIC int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd, const char *userid);
smorlat's avatar
smorlat committed
146 147
int sip_setup_context_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz);
int sip_setup_context_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size);
smorlat's avatar
smorlat committed
148
int sip_setup_context_get_relay(SipSetupContext *ctx, char *relay, size_t size);
149

150 151 152
LINPHONE_PUBLIC BuddyLookupRequest *sip_setup_context_create_buddy_lookup_request(SipSetupContext *ctx);
LINPHONE_PUBLIC int sip_setup_context_buddy_lookup_submit(SipSetupContext *ctx , BuddyLookupRequest *req);
LINPHONE_PUBLIC int sip_setup_context_buddy_lookup_free(SipSetupContext *ctx , BuddyLookupRequest *req);
153

smorlat's avatar
smorlat committed
154 155 156
const char * sip_setup_context_get_notice(SipSetupContext *ctx);
const char ** sip_setup_context_get_domains(SipSetupContext *ctx);

smorlat's avatar
smorlat committed
157
void sip_setup_context_free(SipSetupContext *ctx);
158

159
LINPHONE_PUBLIC int sip_setup_context_logout(SipSetupContext *ctx);
smorlat's avatar
smorlat committed
160

161
/*internal methods for use WITHIN plugins: do not use elsewhere*/
smorlat's avatar
smorlat committed
162
struct _LinphoneProxyConfig *sip_setup_context_get_proxy_config(const SipSetupContext *ctx);
163
void buddy_lookup_request_free(BuddyLookupRequest *req);
smorlat's avatar
smorlat committed
164

165 166 167 168
#ifdef __cplusplus
}
#endif

smorlat's avatar
smorlat committed
169

smorlat's avatar
smorlat committed
170 171
#endif

smorlat's avatar
smorlat committed
172