Frameworks/libpurple.framework/Versions/0.6.2/Headers/session.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 1739 Frameworks/libpurple.framework/Versions/0.6.0/Headers/session.h@8b0daad9656c
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     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 #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 "nexus.h"
    39 #include "httpconn.h"
    40 #include "oim.h"
    41 
    42 #include "userlist.h"
    43 #include "sync.h"
    44 
    45 /**
    46  * Types of errors.
    47  */
    48 typedef enum
    49 {
    50 	MSN_ERROR_SERVCONN,
    51 	MSN_ERROR_UNSUPPORTED_PROTOCOL,
    52 	MSN_ERROR_HTTP_MALFORMED,
    53 	MSN_ERROR_AUTH,
    54 	MSN_ERROR_BAD_BLIST,
    55 	MSN_ERROR_SIGN_OTHER,
    56 	MSN_ERROR_SERV_DOWN,
    57 	MSN_ERROR_SERV_UNAVAILABLE
    58 
    59 } MsnErrorType;
    60 
    61 /**
    62  * Login steps.
    63  */
    64 typedef enum
    65 {
    66 	MSN_LOGIN_STEP_START,
    67 	MSN_LOGIN_STEP_HANDSHAKE,
    68 	MSN_LOGIN_STEP_TRANSFER,
    69 	MSN_LOGIN_STEP_HANDSHAKE2,
    70 	MSN_LOGIN_STEP_AUTH_START,
    71 	MSN_LOGIN_STEP_AUTH,
    72 	MSN_LOGIN_STEP_GET_COOKIE,
    73 	MSN_LOGIN_STEP_AUTH_END,
    74 	MSN_LOGIN_STEP_SYN,
    75 	MSN_LOGIN_STEP_END
    76 
    77 } MsnLoginStep;
    78 
    79 #define MSN_LOGIN_STEPS MSN_LOGIN_STEP_END
    80 
    81 struct _MsnSession
    82 {
    83 	PurpleAccount *account;
    84 	MsnUser *user;
    85 
    86 	guint protocol_ver;
    87 
    88 	MsnLoginStep login_step; /**< The current step in the login process. */
    89 
    90 	gboolean connected;
    91 	gboolean logged_in; /**< A temporal flag to ignore local buddy list adds. */
    92 	int      adl_fqy; /**< A count of ADL/FQY so status is only changed once. */
    93 	gboolean destroying; /**< A flag that states if the session is being destroyed. */
    94 	gboolean http_method;
    95 
    96 	MsnNotification *notification;
    97 	MsnNexus        *nexus;
    98 	MsnOim          *oim;
    99 	MsnSync         *sync;
   100 	MsnUserList     *userlist;
   101 	char            *abch_cachekey;
   102 
   103 	int servconns_count; /**< The count of server connections. */
   104 	GList *switches; /**< The list of all the switchboards. */
   105 	GList *slplinks; /**< The list of all the slplinks. */
   106 
   107 	/*psm info*/
   108 	char *psm;
   109 
   110 #if 0
   111 	char *blocked_text;
   112 #endif
   113 
   114 	struct
   115 	{
   116 		char *kv;
   117 		char *sid;
   118 		char *mspauth;
   119 		unsigned long sl;
   120 		char *client_ip;
   121 		int client_port;
   122 		char *mail_url;
   123 		gulong mail_timestamp;
   124 		gboolean email_enabled;
   125 	} passport_info;
   126 
   127 	GHashTable *soap_table;
   128 	guint soap_cleanup_handle;
   129 };
   130 
   131 /**
   132  * Creates an MSN session.
   133  *
   134  * @param account The account.
   135  *
   136  * @return The new MSN session.
   137  */
   138 MsnSession *msn_session_new(PurpleAccount *account);
   139 
   140 /**
   141  * Destroys an MSN session.
   142  *
   143  * @param session The MSN session to destroy.
   144  */
   145 void msn_session_destroy(MsnSession *session);
   146 
   147 /**
   148  * Connects to and initiates an MSN session.
   149  *
   150  * @param session     The MSN session.
   151  * @param host        The dispatch server host.
   152  * @param port        The dispatch server port.
   153  * @param http_method Whether to use or not http_method.
   154  *
   155  * @return @c TRUE on success, @c FALSE on failure.
   156  */
   157 gboolean msn_session_connect(MsnSession *session,
   158 							 const char *host, int port,
   159 							 gboolean http_method);
   160 
   161 /**
   162  * Disconnects from an MSN session.
   163  *
   164  * @param session The MSN session.
   165  */
   166 void msn_session_disconnect(MsnSession *session);
   167 
   168  /**
   169  * Finds a switchboard with the given username.
   170  *
   171  * @param session The MSN session.
   172  * @param username The username to search for.
   173  *
   174  * @return The switchboard, if found.
   175  */
   176 MsnSwitchBoard *msn_session_find_swboard(MsnSession *session,
   177 										 const char *username);
   178 
   179  /**
   180  * Finds a switchboard with the given conversation.
   181  *
   182  * @param session The MSN session.
   183  * @param conv    The conversation to search for.
   184  *
   185  * @return The switchboard, if found.
   186  */
   187 MsnSwitchBoard *msn_session_find_swboard_with_conv(MsnSession *session,
   188 												   PurpleConversation *conv);
   189 /**
   190  * Finds a switchboard with the given chat ID.
   191  *
   192  * @param session The MSN session.
   193  * @param chat_id The chat ID to search for.
   194  *
   195  * @return The switchboard, if found.
   196  */
   197 MsnSwitchBoard *msn_session_find_swboard_with_id(const MsnSession *session,
   198 												 int chat_id);
   199 
   200 /**
   201  * Returns a switchboard to communicate with certain username.
   202  *
   203  * @param session The MSN session.
   204  * @param username The username to search for.
   205  * @param flag The flag of the switchboard
   206  *
   207  * @return The switchboard.
   208  */
   209 MsnSwitchBoard *msn_session_get_swboard(MsnSession *session,
   210 										const char *username, MsnSBFlag flag);
   211 
   212 /**
   213  * Sets an error for the MSN session.
   214  *
   215  * @param session The MSN session.
   216  * @param error The error.
   217  * @param info Extra information.
   218  */
   219 void msn_session_set_error(MsnSession *session, MsnErrorType error,
   220 						   const char *info);
   221 
   222 /**
   223  * Sets the current step in the login proccess.
   224  *
   225  * @param session The MSN session.
   226  * @param step The current step.
   227  */
   228 void msn_session_set_login_step(MsnSession *session, MsnLoginStep step);
   229 
   230 /**
   231  * Finish the login proccess.
   232  *
   233  * @param session The MSN session.
   234  */
   235 void msn_session_finish_login(MsnSession *session);
   236 
   237 /*post message to User*/
   238 void msn_session_report_user(MsnSession *session,const char *passport,
   239 							const char *msg,PurpleMessageFlags flags);
   240 
   241 #endif /* _MSN_SESSION_H_ */