Frameworks/libpurple.framework/Versions/2.10.12r8d2874a79747/Headers/session.h
branchadium-1.5.11
changeset 6014 fcb71cb71a3d
parent 5941 307f53385811
parent 6013 f8d0dc659e3f
child 6016 325e2ab3406f
equal deleted inserted replaced
5941:307f53385811 6014:fcb71cb71a3d
     1 /**
       
     2  * @file session.h MSN session functions
       
     3  *
       
     4  * purple
       
     5  *
       
     6  * Purple 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., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
       
    23  */
       
    24 #ifndef MSN_SESSION_H
       
    25 #define MSN_SESSION_H
       
    26 
       
    27 typedef struct _MsnSession MsnSession;
       
    28 
       
    29 /**
       
    30  * Types of errors.
       
    31  */
       
    32 typedef enum
       
    33 {
       
    34 	MSN_ERROR_SERVCONN,
       
    35 	MSN_ERROR_UNSUPPORTED_PROTOCOL,
       
    36 	MSN_ERROR_HTTP_MALFORMED,
       
    37 	MSN_ERROR_AUTH,
       
    38 	MSN_ERROR_BAD_BLIST,
       
    39 	MSN_ERROR_SIGN_OTHER,
       
    40 	MSN_ERROR_SERV_DOWN,
       
    41 	MSN_ERROR_SERV_UNAVAILABLE
       
    42 } MsnErrorType;
       
    43 
       
    44 /**
       
    45  * Login steps.
       
    46  */
       
    47 typedef enum
       
    48 {
       
    49 	MSN_LOGIN_STEP_START,
       
    50 	MSN_LOGIN_STEP_HANDSHAKE,
       
    51 	MSN_LOGIN_STEP_TRANSFER,
       
    52 	MSN_LOGIN_STEP_HANDSHAKE2,
       
    53 	MSN_LOGIN_STEP_AUTH_START,
       
    54 	MSN_LOGIN_STEP_GET_COOKIE,
       
    55 	MSN_LOGIN_STEP_AUTH_END,
       
    56 	MSN_LOGIN_STEP_SYN,
       
    57 	MSN_LOGIN_STEP_END
       
    58 } MsnLoginStep;
       
    59 
       
    60 #define MSN_LOGIN_STEPS MSN_LOGIN_STEP_END
       
    61 
       
    62 #define MSN_LOGIN_FQY_TIMEOUT 30
       
    63 
       
    64 #define MSN_LOGIN_FQY_TIMEOUT 30
       
    65 
       
    66 #include "nexus.h"
       
    67 #include "notification.h"
       
    68 #include "oim.h"
       
    69 #include "switchboard.h"
       
    70 #include "user.h"
       
    71 #include "userlist.h"
       
    72 
       
    73 struct _MsnSession
       
    74 {
       
    75 	PurpleAccount *account;
       
    76 	MsnUser *user;
       
    77 
       
    78 	guint protocol_ver;
       
    79 
       
    80 	MsnLoginStep login_step; /**< The current step in the login process. */
       
    81 
       
    82 	gboolean connected:1;
       
    83 	gboolean logged_in:1; /**< A temporal flag to ignore local buddy list adds. */
       
    84 	gboolean destroying:1; /**< A flag that states if the session is being destroyed. */
       
    85 	gboolean http_method:1;
       
    86 	gboolean enable_mpop:1; /**< Use Multiple Points of Presence? */
       
    87 	int      adl_fqy; /**< A count of ADL/FQY so status is only changed once. */
       
    88 	guint    login_timeout; /**< Timeout to force status change if ADL/FQY fail. */
       
    89 
       
    90 	MsnNotification *notification;
       
    91 	MsnNexus        *nexus;
       
    92 	MsnOim          *oim;
       
    93 	MsnUserList     *userlist;
       
    94 	char            *abch_cachekey;
       
    95 
       
    96 	int servconns_count; /**< The count of server connections. */
       
    97 	GList *switches; /**< The list of all the switchboards. */
       
    98 	GList *slplinks; /**< The list of all the slplinks. */
       
    99 
       
   100 	/*psm info*/
       
   101 	char *psm;
       
   102 
       
   103 #if 0
       
   104 	char *blocked_text;
       
   105 #endif
       
   106 
       
   107 	struct
       
   108 	{
       
   109 		char *sid;
       
   110 		char *mspauth;
       
   111 		unsigned long sl;
       
   112 		char *client_ip;
       
   113 		int client_port;
       
   114 		char *mail_url;
       
   115 		gulong mail_timestamp;
       
   116 		gboolean email_enabled;
       
   117 	} passport_info;
       
   118 
       
   119 	GHashTable *soap_table;
       
   120 	guint soap_cleanup_handle;
       
   121 	char *guid;
       
   122 
       
   123 	GSList *url_datas; /**< PurpleUtilFetchUrlData to be cancelled on exit */
       
   124 };
       
   125 
       
   126 /**
       
   127  * Creates an MSN session.
       
   128  *
       
   129  * @param account The account.
       
   130  *
       
   131  * @return The new MSN session.
       
   132  */
       
   133 MsnSession *msn_session_new(PurpleAccount *account);
       
   134 
       
   135 /**
       
   136  * Destroys an MSN session.
       
   137  *
       
   138  * @param session The MSN session to destroy.
       
   139  */
       
   140 void msn_session_destroy(MsnSession *session);
       
   141 
       
   142 /**
       
   143  * Connects to and initiates an MSN session.
       
   144  *
       
   145  * @param session     The MSN session.
       
   146  * @param host        The dispatch server host.
       
   147  * @param port        The dispatch server port.
       
   148  * @param http_method Whether to use or not http_method.
       
   149  *
       
   150  * @return @c TRUE on success, @c FALSE on failure.
       
   151  */
       
   152 gboolean msn_session_connect(MsnSession *session,
       
   153 							 const char *host, int port,
       
   154 							 gboolean http_method);
       
   155 
       
   156 /**
       
   157  * Disconnects from an MSN session.
       
   158  *
       
   159  * @param session The MSN session.
       
   160  */
       
   161 void msn_session_disconnect(MsnSession *session);
       
   162 
       
   163  /**
       
   164  * Finds a switchboard with the given username.
       
   165  *
       
   166  * @param session The MSN session.
       
   167  * @param username The username to search for.
       
   168  *
       
   169  * @return The switchboard, if found.
       
   170  */
       
   171 MsnSwitchBoard *msn_session_find_swboard(MsnSession *session,
       
   172 										 const char *username);
       
   173 
       
   174  /**
       
   175  * Finds a switchboard with the given conversation.
       
   176  *
       
   177  * @param session The MSN session.
       
   178  * @param conv    The conversation to search for.
       
   179  *
       
   180  * @return The switchboard, if found.
       
   181  */
       
   182 MsnSwitchBoard *msn_session_find_swboard_with_conv(MsnSession *session,
       
   183 												   PurpleConversation *conv);
       
   184 /**
       
   185  * Finds a switchboard with the given chat ID.
       
   186  *
       
   187  * @param session The MSN session.
       
   188  * @param chat_id The chat ID to search for.
       
   189  *
       
   190  * @return The switchboard, if found.
       
   191  */
       
   192 MsnSwitchBoard *msn_session_find_swboard_with_id(const MsnSession *session,
       
   193 												 int chat_id);
       
   194 
       
   195 /**
       
   196  * Returns a switchboard to communicate with certain username.
       
   197  *
       
   198  * @param session The MSN session.
       
   199  * @param username The username to search for.
       
   200  * @param flag The flag of the switchboard
       
   201  *
       
   202  * @return The switchboard.
       
   203  */
       
   204 MsnSwitchBoard *msn_session_get_swboard(MsnSession *session,
       
   205 										const char *username, MsnSBFlag flag);
       
   206 
       
   207 /**
       
   208  * Sets an error for the MSN session.
       
   209  *
       
   210  * @param session The MSN session.
       
   211  * @param error The error.
       
   212  * @param info Extra information.
       
   213  */
       
   214 void msn_session_set_error(MsnSession *session, MsnErrorType error,
       
   215 						   const char *info);
       
   216 
       
   217 /**
       
   218  * Starts a timeout to initiate finishing login. Sometimes the server ignores
       
   219  * our FQY requests, so this forces ourselves online eventually.
       
   220  *
       
   221  * @param session The MSN session.
       
   222  */
       
   223 void
       
   224 msn_session_activate_login_timeout(MsnSession *session);
       
   225 
       
   226 /**
       
   227  * Sets the current step in the login process.
       
   228  *
       
   229  * @param session The MSN session.
       
   230  * @param step The current step.
       
   231  */
       
   232 void msn_session_set_login_step(MsnSession *session, MsnLoginStep step);
       
   233 
       
   234 /**
       
   235  * Finish the login proccess.
       
   236  *
       
   237  * @param session The MSN session.
       
   238  */
       
   239 void msn_session_finish_login(MsnSession *session);
       
   240 
       
   241 /*post message to User*/
       
   242 void msn_session_report_user(MsnSession *session,const char *passport,
       
   243 							const char *msg,PurpleMessageFlags flags);
       
   244 
       
   245 #endif /* MSN_SESSION_H */