[b7d3cc34] | 1 | /********************************************************************\ |
---|
| 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
[21029d0] | 4 | * Copyright 2002-2010 Wilmer van der Gaast and others * |
---|
[b7d3cc34] | 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* MSN module */ |
---|
| 8 | |
---|
| 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 with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
| 22 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
| 23 | Suite 330, Boston, MA 02111-1307 USA |
---|
| 24 | */ |
---|
| 25 | |
---|
[a830512] | 26 | #ifndef _MSN_H |
---|
| 27 | #define _MSN_H |
---|
| 28 | |
---|
[b7d3cc34] | 29 | /* Some hackish magicstrings to make special-purpose messages/switchboards. |
---|
| 30 | */ |
---|
| 31 | #define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r" |
---|
[9c84617] | 32 | #define NUDGE_MESSAGE "\r\r\rSHAKE THAT THING\r\r\r" |
---|
[b7d3cc34] | 33 | #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r" |
---|
[9bf2481] | 34 | #define SB_KEEPALIVE_MESSAGE "\r\r\rDONT HANG UP ON ME!\r\r\r" |
---|
[b7d3cc34] | 35 | |
---|
[aa31117] | 36 | #ifdef DEBUG_MSN |
---|
[59f527b6] | 37 | #define debug( text... ) imcb_log( ic, text ); |
---|
[b7d3cc34] | 38 | #else |
---|
| 39 | #define debug( text... ) |
---|
| 40 | #endif |
---|
| 41 | |
---|
[be7a180] | 42 | /* This should be MSN Messenger 7.0.0813 |
---|
| 43 | #define MSNP11_PROD_KEY "CFHUR$52U_{VIX5T" |
---|
| 44 | #define MSNP11_PROD_ID "PROD0101{0RM?UBW" |
---|
| 45 | */ |
---|
[e5a8118] | 46 | |
---|
[bae0617] | 47 | #define MSN_NS_HOST "messenger.hotmail.com" |
---|
| 48 | #define MSN_NS_PORT 1863 |
---|
| 49 | |
---|
[be7a180] | 50 | /* Some other version. |
---|
[e5a8118] | 51 | #define MSNP11_PROD_KEY "O4BG@C7BWLYQX?5G" |
---|
| 52 | #define MSNP11_PROD_ID "PROD01065C%ZFN6F" |
---|
[be7a180] | 53 | */ |
---|
| 54 | |
---|
[bc676ac] | 55 | /* <= BitlBee 3.0.5 |
---|
[91d6e91] | 56 | #define MSNP11_PROD_KEY "ILTXC!4IXB5FB*PX" |
---|
| 57 | #define MSNP11_PROD_ID "PROD0119GSJUC$18" |
---|
[bc676ac] | 58 | */ |
---|
| 59 | |
---|
| 60 | #define MSNP11_PROD_KEY "C1BX{V4W}Q3*10SM" |
---|
| 61 | #define MSNP11_PROD_ID "PROD0120PW!CCV9@" |
---|
| 62 | #define MSNP_VER "MSNP18" |
---|
| 63 | #define MSNP_BUILD "14.0.8117.416" |
---|
[21029d0] | 64 | |
---|
[b7d3cc34] | 65 | #define MSN_SB_NEW -24062002 |
---|
| 66 | |
---|
| 67 | #define MSN_MESSAGE_HEADERS "MIME-Version: 1.0\r\n" \ |
---|
| 68 | "Content-Type: text/plain; charset=UTF-8\r\n" \ |
---|
| 69 | "User-Agent: BitlBee " BITLBEE_VERSION "\r\n" \ |
---|
| 70 | "X-MMS-IM-Format: FN=MS%20Shell%20Dlg; EF=; CO=0; CS=0; PF=0\r\n" \ |
---|
| 71 | "\r\n" |
---|
| 72 | |
---|
| 73 | #define MSN_TYPING_HEADERS "MIME-Version: 1.0\r\n" \ |
---|
| 74 | "Content-Type: text/x-msmsgscontrol\r\n" \ |
---|
| 75 | "TypingUser: %s\r\n" \ |
---|
| 76 | "\r\n\r\n" |
---|
| 77 | |
---|
[9c84617] | 78 | #define MSN_NUDGE_HEADERS "MIME-Version: 1.0\r\n" \ |
---|
| 79 | "Content-Type: text/x-msnmsgr-datacast\r\n" \ |
---|
| 80 | "\r\n" \ |
---|
| 81 | "ID: 1\r\n" \ |
---|
| 82 | "\r\n" |
---|
| 83 | |
---|
| 84 | #define MSN_SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \ |
---|
| 85 | "Content-Type: text/x-ping\r\n" \ |
---|
| 86 | "\r\n\r\n" |
---|
[9bf2481] | 87 | |
---|
[b7d3cc34] | 88 | #define PROFILE_URL "http://members.msn.com/" |
---|
| 89 | |
---|
[80175a1] | 90 | typedef enum |
---|
| 91 | { |
---|
| 92 | MSN_GOT_PROFILE = 1, |
---|
| 93 | MSN_GOT_PROFILE_DN = 2, |
---|
| 94 | MSN_DONE_ADL = 4, |
---|
[27053b5] | 95 | MSN_REAUTHING = 8, |
---|
[ed0589c] | 96 | MSN_EMAIL_UNVERIFIED = 16, |
---|
[80175a1] | 97 | } msn_flags_t; |
---|
| 98 | |
---|
[bae0617] | 99 | struct msn_handler_data |
---|
| 100 | { |
---|
| 101 | int fd, inpa; |
---|
| 102 | int rxlen; |
---|
| 103 | char *rxq; |
---|
| 104 | |
---|
| 105 | int msglen; |
---|
| 106 | char *cmd_text; |
---|
| 107 | |
---|
| 108 | /* Either ic or sb */ |
---|
| 109 | gpointer data; |
---|
| 110 | |
---|
| 111 | int (*exec_command) ( struct msn_handler_data *handler, char **cmd, int count ); |
---|
| 112 | int (*exec_message) ( struct msn_handler_data *handler, char *msg, int msglen, char **cmd, int count ); |
---|
| 113 | }; |
---|
| 114 | |
---|
[b7d3cc34] | 115 | struct msn_data |
---|
| 116 | { |
---|
[0da65d5] | 117 | struct im_connection *ic; |
---|
[b7d3cc34] | 118 | |
---|
[27053b5] | 119 | struct msn_handler_data ns[1]; |
---|
[80175a1] | 120 | msn_flags_t flags; |
---|
[b7d3cc34] | 121 | |
---|
| 122 | int trId; |
---|
[80175a1] | 123 | char *tokens[4]; |
---|
[4aa8a04] | 124 | char *lock_key, *pp_policy; |
---|
[f9258ae] | 125 | char *uuid; |
---|
[b7d3cc34] | 126 | |
---|
[4aa8a04] | 127 | GSList *msgq, *grpq, *soapq; |
---|
[b7d3cc34] | 128 | GSList *switchboards; |
---|
[59f527b6] | 129 | int sb_failures; |
---|
| 130 | time_t first_sb_failure; |
---|
[bc736cfa] | 131 | |
---|
[59f527b6] | 132 | const struct msn_away_state *away_state; |
---|
[ff27648] | 133 | GSList *groups; |
---|
[76c89dc7] | 134 | char *profile_rid; |
---|
[5a7af1b] | 135 | |
---|
| 136 | /* Mostly used for sending the ADL command; since MSNP13 the client |
---|
| 137 | is responsible for downloading the contact list and then sending |
---|
| 138 | it to the MSNP server. */ |
---|
[ca7de3a] | 139 | GTree *domaintree; |
---|
[5a7af1b] | 140 | int adl_todo; |
---|
[b7d3cc34] | 141 | }; |
---|
| 142 | |
---|
| 143 | struct msn_switchboard |
---|
| 144 | { |
---|
[0da65d5] | 145 | struct im_connection *ic; |
---|
[b7d3cc34] | 146 | |
---|
[bae0617] | 147 | /* The following two are also in the handler. TODO: Clean up. */ |
---|
[b7d3cc34] | 148 | int fd; |
---|
| 149 | gint inp; |
---|
| 150 | struct msn_handler_data *handler; |
---|
[9bf2481] | 151 | gint keepalive; |
---|
[b7d3cc34] | 152 | |
---|
| 153 | int trId; |
---|
| 154 | int ready; |
---|
| 155 | |
---|
| 156 | int session; |
---|
| 157 | char *key; |
---|
| 158 | |
---|
| 159 | GSList *msgq; |
---|
| 160 | char *who; |
---|
[0da65d5] | 161 | struct groupchat *chat; |
---|
[b7d3cc34] | 162 | }; |
---|
| 163 | |
---|
| 164 | struct msn_away_state |
---|
| 165 | { |
---|
| 166 | char code[4]; |
---|
| 167 | char name[16]; |
---|
| 168 | }; |
---|
| 169 | |
---|
| 170 | struct msn_status_code |
---|
| 171 | { |
---|
| 172 | int number; |
---|
| 173 | char *text; |
---|
| 174 | int flags; |
---|
| 175 | }; |
---|
| 176 | |
---|
| 177 | struct msn_message |
---|
| 178 | { |
---|
| 179 | char *who; |
---|
| 180 | char *text; |
---|
| 181 | }; |
---|
| 182 | |
---|
[70ac477] | 183 | struct msn_groupadd |
---|
| 184 | { |
---|
| 185 | char *who; |
---|
| 186 | char *group; |
---|
| 187 | }; |
---|
| 188 | |
---|
[7f34ce2] | 189 | typedef enum |
---|
| 190 | { |
---|
[ca7de3a] | 191 | MSN_BUDDY_FL = 1, /* Warning: FL,AL,BL *must* be 1,2,4. */ |
---|
[7f34ce2] | 192 | MSN_BUDDY_AL = 2, |
---|
| 193 | MSN_BUDDY_BL = 4, |
---|
| 194 | MSN_BUDDY_RL = 8, |
---|
| 195 | MSN_BUDDY_PL = 16, |
---|
[5a7af1b] | 196 | MSN_BUDDY_ADL_SYNCED = 256, |
---|
[7f34ce2] | 197 | } msn_buddy_flags_t; |
---|
| 198 | |
---|
| 199 | struct msn_buddy_data |
---|
| 200 | { |
---|
| 201 | char *cid; |
---|
| 202 | msn_buddy_flags_t flags; |
---|
| 203 | }; |
---|
| 204 | |
---|
[ff27648] | 205 | struct msn_group |
---|
| 206 | { |
---|
| 207 | char *name; |
---|
| 208 | char *id; |
---|
| 209 | }; |
---|
| 210 | |
---|
[b7d3cc34] | 211 | /* Bitfield values for msn_status_code.flags */ |
---|
| 212 | #define STATUS_FATAL 1 |
---|
| 213 | #define STATUS_SB_FATAL 2 |
---|
[3b9390b] | 214 | #define STATUS_SB_IM_SPARE 4 /* Make one-to-one conversation switchboard available again, invite failed. */ |
---|
| 215 | #define STATUS_SB_CHAT_SPARE 8 /* Same, but also for groupchats (not used yet). */ |
---|
[b7d3cc34] | 216 | |
---|
[c6ca3ee] | 217 | extern int msn_chat_id; |
---|
[0196c47] | 218 | extern const struct msn_away_state msn_away_state_list[]; |
---|
| 219 | extern const struct msn_status_code msn_status_code_list[]; |
---|
[b7d3cc34] | 220 | |
---|
| 221 | /* Keep a list of all the active connections. We need these lists because |
---|
| 222 | "connected" callbacks might be called when the connection they belong too |
---|
| 223 | is down already (for example, when an impatient user disabled the |
---|
| 224 | connection), the callback should check whether it's still listed here |
---|
| 225 | before doing *anything* else. */ |
---|
[c6ca3ee] | 226 | extern GSList *msn_connections; |
---|
| 227 | extern GSList *msn_switchboards; |
---|
[b7d3cc34] | 228 | |
---|
| 229 | /* ns.c */ |
---|
[bc676ac] | 230 | int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ) G_GNUC_PRINTF( 3, 4 ); |
---|
[bae0617] | 231 | gboolean msn_ns_connect( struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port ); |
---|
| 232 | void msn_ns_close( struct msn_handler_data *handler ); |
---|
[660cb00] | 233 | void msn_auth_got_passport_token( struct im_connection *ic, const char *token, const char *error ); |
---|
[ca7de3a] | 234 | void msn_auth_got_contact_list( struct im_connection *ic ); |
---|
[80175a1] | 235 | int msn_ns_finish_login( struct im_connection *ic ); |
---|
[bc676ac] | 236 | int msn_ns_sendmessage( struct im_connection *ic, struct bee_user *bu, const char *text ); |
---|
| 237 | void msn_ns_oim_send_queue( struct im_connection *ic, GSList **msgq ); |
---|
[b7d3cc34] | 238 | |
---|
| 239 | /* msn_util.c */ |
---|
[0da65d5] | 240 | int msn_logged_in( struct im_connection *ic ); |
---|
[193dc74] | 241 | int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group ); |
---|
| 242 | int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group ); |
---|
[e5854a8] | 243 | void msn_buddy_ask( bee_user_t *bu ); |
---|
[b7d3cc34] | 244 | char **msn_linesplit( char *line ); |
---|
| 245 | int msn_handler( struct msn_handler_data *h ); |
---|
[46dca11] | 246 | void msn_msgq_purge( struct im_connection *ic, GSList **list ); |
---|
[21029d0] | 247 | char *msn_p11_challenge( char *challenge ); |
---|
[ca7de3a] | 248 | gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ ); |
---|
[ff27648] | 249 | struct msn_group *msn_group_by_name( struct im_connection *ic, const char *name ); |
---|
| 250 | struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id ); |
---|
[e0e1546] | 251 | int msn_ns_set_display_name( struct im_connection *ic, const char *value ); |
---|
[b7d3cc34] | 252 | |
---|
| 253 | /* tables.c */ |
---|
[0196c47] | 254 | const struct msn_away_state *msn_away_state_by_number( int number ); |
---|
| 255 | const struct msn_away_state *msn_away_state_by_code( char *code ); |
---|
| 256 | const struct msn_away_state *msn_away_state_by_name( char *name ); |
---|
| 257 | const struct msn_status_code *msn_status_by_number( int number ); |
---|
[b7d3cc34] | 258 | |
---|
| 259 | /* sb.c */ |
---|
[bc676ac] | 260 | int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ) G_GNUC_PRINTF( 2, 3 );; |
---|
[0da65d5] | 261 | struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ); |
---|
| 262 | struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ); |
---|
| 263 | struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ); |
---|
| 264 | struct msn_switchboard *msn_sb_spare( struct im_connection *ic ); |
---|
[b7d3cc34] | 265 | int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ); |
---|
[0da65d5] | 266 | struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ); |
---|
[b7d3cc34] | 267 | void msn_sb_destroy( struct msn_switchboard *sb ); |
---|
[ba9edaa] | 268 | gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); |
---|
[a830512] | 269 | int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ); |
---|
[bb839e8] | 270 | void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial ); |
---|
| 271 | void msn_sb_stop_keepalives( struct msn_switchboard *sb ); |
---|
[a830512] | 272 | |
---|
| 273 | #endif //_MSN_H |
---|