src/protocols/msn/session.h

branch
cpw.khc.msnp14
changeset 20472
6a6d2ef151e6
parent 13912
463b4fa9f067
parent 20469
b2836a24d81e
child 20473
91e1b3a49d10
equal deleted inserted replaced
13912:463b4fa9f067 20472:6a6d2ef151e6
1 /**
2 * @file session.h MSN session functions
3 *
4 * gaim
5 *
6 * Gaim is the legal property of its developers, whose names are too numerous
7 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * source distribution.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 #ifndef _MSN_SESSION_H_
25 #define _MSN_SESSION_H_
26
27 typedef struct _MsnSession MsnSession;
28
29 #include "sslconn.h"
30
31 #include "user.h"
32 #include "slpcall.h"
33
34 #include "notification.h"
35 #include "switchboard.h"
36 #include "group.h"
37
38 #include "cmdproc.h"
39 #include "nexus.h"
40 #include "httpconn.h"
41 #include "contact.h"
42 #include "oim.h"
43
44 #include "userlist.h"
45 #include "sync.h"
46
47 /**
48 * Types of errors.
49 */
50 typedef enum
51 {
52 MSN_ERROR_SERVCONN,
53 MSN_ERROR_UNSUPPORTED_PROTOCOL,
54 MSN_ERROR_HTTP_MALFORMED,
55 MSN_ERROR_AUTH,
56 MSN_ERROR_BAD_BLIST,
57 MSN_ERROR_SIGN_OTHER,
58 MSN_ERROR_SERV_DOWN,
59 MSN_ERROR_SERV_UNAVAILABLE
60
61 } MsnErrorType;
62
63 /**
64 * Login steps.
65 */
66 typedef enum
67 {
68 MSN_LOGIN_STEP_START,
69 MSN_LOGIN_STEP_HANDSHAKE,
70 MSN_LOGIN_STEP_TRANSFER,
71 MSN_LOGIN_STEP_HANDSHAKE2,
72 MSN_LOGIN_STEP_AUTH_START,
73 MSN_LOGIN_STEP_AUTH,
74 MSN_LOGIN_STEP_GET_COOKIE,
75 MSN_LOGIN_STEP_AUTH_END,
76 MSN_LOGIN_STEP_SYN,
77 MSN_LOGIN_STEP_END
78
79 } MsnLoginStep;
80
81 #define MSN_LOGIN_STEPS MSN_LOGIN_STEP_END
82
83 struct _MsnSession
84 {
85 GaimAccount *account;
86 MsnUser *user;
87
88 guint protocol_ver;
89
90 MsnLoginStep login_step; /**< The current step in the login process. */
91
92 gboolean connected;
93 gboolean logged_in; /**< A temporal flag to ignore local buddy list adds. */
94 gboolean destroying; /**< A flag that states if the session is being destroyed. */
95 gboolean http_method;
96
97 MsnNotification *notification;
98 MsnNexus *nexus;
99 MsnContact *contact;
100 MsnOim *oim;
101 MsnSync *sync;
102
103 MsnUserList *userlist;
104
105 int servconns_count; /**< The count of server connections. */
106 GList *switches; /**< The list of all the switchboards. */
107 GList *directconns; /**< The list of all the directconnections. */
108 GList *slplinks; /**< The list of all the slplinks. */
109
110 int conv_seq; /**< The current conversation sequence number. */
111
112 /*psm info*/
113 char *psm;
114
115 /*first blist contact node*/
116 GaimBlistNode *bnode;
117
118 struct
119 {
120 /*t and p, get via USR TWN*/
121 char *t;
122 char *p;
123
124 char *kv;
125 char *sid;
126 char *mspauth;
127 unsigned long sl;
128 char *file;
129 char *client_ip;
130 int client_port;
131 } passport_info;
132 };
133
134 /**
135 * Creates an MSN session.
136 *
137 * @param account The account.
138 *
139 * @return The new MSN session.
140 */
141 MsnSession *msn_session_new(GaimAccount *account);
142
143 /**
144 * Destroys an MSN session.
145 *
146 * @param session The MSN session to destroy.
147 */
148 void msn_session_destroy(MsnSession *session);
149
150 /**
151 * Connects to and initiates an MSN session.
152 *
153 * @param session The MSN session.
154 * @param host The dispatch server host.
155 * @param port The dispatch server port.
156 * @param http_method Whether to use or not http_method.
157 *
158 * @return @c TRUE on success, @c FALSE on failure.
159 */
160 gboolean msn_session_connect(MsnSession *session,
161 const char *host, int port,
162 gboolean http_method);
163
164 /**
165 * Disconnects from an MSN session.
166 *
167 * @param session The MSN session.
168 */
169 void msn_session_disconnect(MsnSession *session);
170
171 /**
172 * Finds a switchboard with the given username.
173 *
174 * @param session The MSN session.
175 * @param username The username to search for.
176 *
177 * @return The switchboard, if found.
178 */
179 MsnSwitchBoard *msn_session_find_swboard(MsnSession *session,
180 const char *username);
181
182 /**
183 * Finds a switchboard with the given conversation.
184 *
185 * @param session The MSN session.
186 * @param conv The conversation to search for.
187 *
188 * @return The switchboard, if found.
189 */
190 MsnSwitchBoard *msn_session_find_swboard_with_conv(MsnSession *session,
191 GaimConversation *conv);
192 /**
193 * Finds a switchboard with the given chat ID.
194 *
195 * @param session The MSN session.
196 * @param chat_id The chat ID to search for.
197 *
198 * @return The switchboard, if found.
199 */
200 MsnSwitchBoard *msn_session_find_swboard_with_id(const MsnSession *session,
201 int chat_id);
202
203 /**
204 * Returns a switchboard to communicate with certain username.
205 *
206 * @param session The MSN session.
207 * @param username The username to search for.
208 * @param flag The flag of the switchboard
209 *
210 * @return The switchboard.
211 */
212 MsnSwitchBoard *msn_session_get_swboard(MsnSession *session,
213 const char *username, MsnSBFlag flag);
214
215 /**
216 * Sets an error for the MSN session.
217 *
218 * @param session The MSN session.
219 * @param error The error.
220 * @param info Extra information.
221 */
222 void msn_session_set_error(MsnSession *session, MsnErrorType error,
223 const char *info);
224
225 /**
226 * Sets the current step in the login proccess.
227 *
228 * @param session The MSN session.
229 * @param step The current step.
230 */
231 void msn_session_set_login_step(MsnSession *session, MsnLoginStep step);
232
233 /**
234 * Finish the login proccess.
235 *
236 * @param session The MSN session.
237 */
238 void msn_session_finish_login(MsnSession *session);
239
240 /*get conversation via session,
241 * If has one, return that,else create a new one;
242 */
243 GaimConversation *msn_session_get_conv(MsnSession *session,const char *passport);
244
245 /*post message to User*/
246 void msn_session_report_user(MsnSession *session,const char *passport,
247 char *msg,GaimMessageFlags flags);
248
249 void msn_session_set_bnode(MsnSession *session);
250
251 GaimBlistNode *msn_session_get_bnode(MsnSession *session);
252
253 #endif /* _MSN_SESSION_H_ */

mercurial