1 /**
2  * @file sipe-core-private.h
3  *
4  * pidgin-sipe
5  *
6  * Copyright (C) 2010-2018 SIPE Project <http://sipe.sourceforge.net/>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22 
23 /* Forward declarations */
24 struct sip_address_data;
25 struct sip_csta;
26 struct sip_service_data;
27 struct sip_transport;
28 struct sipe_buddies;
29 struct sipe_calendar;
30 struct sipe_certificate;
31 struct sipe_ews_autodiscover;
32 struct sipe_groupchat;
33 struct sipe_groups;
34 struct sipe_http;
35 struct sipe_http_request;
36 struct sipe_lync_autodiscover;
37 struct sipe_media_call_private;
38 struct sipe_svc;
39 struct sipe_ucs;
40 struct sipe_webticket;
41 
42 /**
43  * Private part of the Sipe data structure
44  *
45  * This part contains the information only needed by the core
46  */
47 struct sipe_core_private {
48 	/**
49 	 * The public part is the first item, i.e. a pointer to the
50 	 * public part can also be used as a pointer to the private part.
51 	 */
52 	struct sipe_core_public public;
53 
54 	/* sip-transport.c private data */
55 	struct sip_transport *transport;
56 	GSList *lync_autodiscover_servers;           /* Lync autodiscover */
57 	const struct sip_service_data *service_data; /* autodiscovery SRV records */
58 	const struct sip_address_data *address_data; /* autodiscovery A records */
59 	gchar *user_agent;
60 	guint transport_type;
61 	guint authentication_type;
62 
63 	/* Account information */
64 	gchar *username;
65 	gchar *authuser;   /* NULL when SSO is enabled */
66 	gchar *password;   /* NULL when SSO is enabled */
67 	gchar *email;
68 	gchar *email_authuser;   /* NULL -> use default authentication */
69 	gchar *email_password;
70 
71 	/* SIPE protocol information */
72 	gchar *contact;
73 	gchar *register_callid;
74 	gchar *focus_factory_uri;
75 	GSList *sessions;
76 	GSList *sessions_to_accept;
77 	/* from REGISTER response: server events
78 	 *  we're allowed to subscribe to
79 	 */
80 	GSList *allowed_events;
81 
82 	/* Presence */
83 	gchar *status;
84 	gchar *note;
85 	time_t note_since;
86 	gboolean status_set_by_user;
87 
88 	/* [MS-SIP] deltaNum counters */
89 	guint deltanum_contacts;
90 	guint deltanum_acl;      /* setACE (OCS2005 only) */
91 
92 	/* [MS-PRES] */
93 	GSList *containers;
94 	GSList *our_publication_keys;
95 	GHashTable *our_publications;
96 	GHashTable *user_state_publications;
97 
98 	/* Buddies */
99 	struct sipe_groups *groups;
100 	struct sipe_buddies *buddies;
101 
102 	/* Calendar and related stuff */
103 	struct sipe_calendar *calendar;
104 
105 	/* EWS autodiscover */
106 	struct sipe_ews_autodiscover *ews_autodiscover;
107 
108 	/* Lync autodiscover */
109 	struct sipe_lync_autodiscover *lync_autodiscover;
110 
111 	/*
112 	 * 2005 Custom XML piece
113 	 *
114 	 * Possibly set by other point of presence or just other client at
115 	 * earlier time. It should be preserved/modified, not overwritten.
116 	 * This implies subscription to self-contact. Information kept:
117 	 *
118 	 * - User note
119 	 * - OOF flag
120 	 * - User status
121 	 */
122 	gchar *ocs2005_user_states;
123 
124 	/* Scheduling system */
125 	GSList *timeouts;
126 
127 	/* Active subscriptions */
128 	GHashTable *subscriptions;
129 
130 	/* Voice call */
131 	GHashTable *media_calls;
132 	gchar *test_call_bot_uri;
133 	gchar *uc_line_uri;
134 	/**
135 	 *  Provides the necessary information on where we can obtain
136 	 *  credentials for the A/V Edge server service.
137 	 */
138 	gchar *mras_uri;
139 	gchar *media_relay_username;
140 	gchar *media_relay_password;
141 	GSList *media_relays;
142 	SipeEncryptionPolicy server_av_encryption_policy;
143 
144 	/* Group chat */
145 	struct sipe_groupchat *groupchat;
146 	gchar *persistentChatPool_uri;
147 
148 	/* buddy menu memory allocation */
149 	GSList *blist_menu_containers;
150 
151 	/* For RCC - Remote Call Control */
152 	struct sip_csta *csta;
153 
154 	struct sipe_dns_query *dns_query;
155 
156 	/* HTTP service */
157 	struct sipe_http *http;
158 
159 	/* TLS-DSK: Certificates & Web services */
160 	struct sipe_certificate *certificate;
161 	struct sipe_webticket *webticket;
162 	struct sipe_svc *svc;
163 
164 	/* Unified Contact Store */
165 	struct sipe_ucs *ucs;
166 
167 	/* [MS-DLX] server URI */
168 	gchar *dlx_uri;
169 
170 	/* Addressbook server URI */
171 	gchar *addressbook_uri;
172 
173 	/* [MS-CONFPRO] CCCP request ID counter */
174 	guint cccp_request_id;
175 
176 	guint ms_filetransfer_request_id;
177 
178 	GSList *conf_mcu_types;
179 
180 	/* Dial-in conferencing phone numbers for different regions */
181 	GHashTable *access_numbers;
182 	const gchar *default_access_number;
183 
184 	/* Port ranges to use for media connections. Zero means any port. */
185 	guint min_media_port;
186 	guint max_media_port;
187 	guint min_audio_port;
188 	guint max_audio_port;
189 	guint min_video_port;
190 	guint max_video_port;
191 	guint min_appsharing_port;
192 	guint max_appsharing_port;
193 	guint min_filetransfer_port;
194 	guint max_filetransfer_port;
195 };
196 
197 /**
198  * Flags - stored in sipe_core_public.flags but names not exported
199  */
200 /* server is OCS2007+ */
201 #define SIPE_CORE_PRIVATE_FLAG_OCS2007            0x80000000
202 /* we are connected from outside the enterprise network boundary
203  * via Edge Server */
204 #define SIPE_CORE_PRIVATE_FLAG_REMOTE_USER        0x40000000
205 /* multiple points of presence detected */
206 #define SIPE_CORE_PRIVATE_FLAG_MPOP               0x20000000
207 /* if there is support for batched subscription*/
208 #define SIPE_CORE_PRIVATE_FLAG_BATCHED_SUPPORT    0x10000000
209 /* if note is out-of-office note */
210 #define SIPE_CORE_PRIVATE_FLAG_OOF_NOTE           0x08000000
211 /* whether we published our initial state or not */
212 #define SIPE_CORE_PRIVATE_FLAG_INITIAL_PUBLISH    0x04000000
213 /* whether basic access level is set or not */
214 #define SIPE_CORE_PRIVATE_FLAG_ACCESS_LEVEL_SET   0x02000000
215 /* whether subscribed to buddies presence or not */
216 #define SIPE_CORE_PRIVATE_FLAG_SUBSCRIBED_BUDDIES 0x01000000
217 /* user enabled Single-Sign On */
218 #define SIPE_CORE_PRIVATE_FLAG_SSO                0x00800000
219 /* server is Lync 2013+ */
220 #define SIPE_CORE_PRIVATE_FLAG_LYNC2013           0x00400000
221 /* server is Skype for Business (RTC/6.0 +) */
222 #define SIPE_CORE_PRIVATE_FLAG_SFB                0x00200000
223 
224 #define SIPE_CORE_PUBLIC_FLAG_IS(flag)    \
225 	((sipe_private->public.flags & SIPE_CORE_FLAG_ ## flag) == SIPE_CORE_FLAG_ ## flag)
226 #define SIPE_CORE_PUBLIC_FLAG_SET(flag)   \
227 	(sipe_private->public.flags |= SIPE_CORE_FLAG_ ## flag)
228 #define SIPE_CORE_PUBLIC_FLAG_UNSET(flag)				\
229 	(sipe_private->public.flags &= ~SIPE_CORE_FLAG_ ## flag)
230 #define SIPE_CORE_PRIVATE_FLAG_IS(flag)    \
231 	((sipe_private->public.flags & SIPE_CORE_PRIVATE_FLAG_ ## flag) == SIPE_CORE_PRIVATE_FLAG_ ## flag)
232 #define SIPE_CORE_PRIVATE_FLAG_SET(flag)   \
233 	(sipe_private->public.flags |= SIPE_CORE_PRIVATE_FLAG_ ## flag)
234 #define SIPE_CORE_PRIVATE_FLAG_UNSET(flag)				\
235 	(sipe_private->public.flags &= ~SIPE_CORE_PRIVATE_FLAG_ ## flag)
236 
237 /* Convenience macros */
238 #define SIPE_CORE_PRIVATE ((struct sipe_core_private *)sipe_public)
239 #define SIPE_CORE_PUBLIC  ((struct sipe_core_public *)sipe_private)
240 
241 /**
242  * sipe-core internal functions
243  */
244 void sipe_core_backend_initialized(struct sipe_core_private *sipe_private,
245 				   guint authentication);
246 void sipe_core_connection_cleanup(struct sipe_core_private *sipe_private);
247 void sipe_core_email_authentication(struct sipe_core_private *sipe_private,
248 				    struct sipe_http_request *request);
249 const gchar *sipe_core_user_agent(struct sipe_core_private *sipe_private);
250 
251 /*
252   Local Variables:
253   mode: c
254   c-file-style: "bsd"
255   indent-tabs-mode: t
256   tab-width: 8
257   End:
258 */
259