[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; |
---|
[b7d3cc34] | 125 | |
---|
[4aa8a04] | 126 | GSList *msgq, *grpq, *soapq; |
---|
[b7d3cc34] | 127 | GSList *switchboards; |
---|
[59f527b6] | 128 | int sb_failures; |
---|
| 129 | time_t first_sb_failure; |
---|
[bc736cfa] | 130 | |
---|
[59f527b6] | 131 | const struct msn_away_state *away_state; |
---|
[ff27648] | 132 | GSList *groups; |
---|
[76c89dc7] | 133 | char *profile_rid; |
---|
[5a7af1b] | 134 | |
---|
| 135 | /* Mostly used for sending the ADL command; since MSNP13 the client |
---|
| 136 | is responsible for downloading the contact list and then sending |
---|
| 137 | it to the MSNP server. */ |
---|
[ca7de3a] | 138 | GTree *domaintree; |
---|
[5a7af1b] | 139 | int adl_todo; |
---|
[b7d3cc34] | 140 | }; |
---|
| 141 | |
---|
| 142 | struct msn_switchboard |
---|
| 143 | { |
---|
[0da65d5] | 144 | struct im_connection *ic; |
---|
[b7d3cc34] | 145 | |
---|
[bae0617] | 146 | /* The following two are also in the handler. TODO: Clean up. */ |
---|
[b7d3cc34] | 147 | int fd; |
---|
| 148 | gint inp; |
---|
| 149 | struct msn_handler_data *handler; |
---|
[9bf2481] | 150 | gint keepalive; |
---|
[b7d3cc34] | 151 | |
---|
| 152 | int trId; |
---|
| 153 | int ready; |
---|
| 154 | |
---|
| 155 | int session; |
---|
| 156 | char *key; |
---|
| 157 | |
---|
| 158 | GSList *msgq; |
---|
| 159 | char *who; |
---|
[0da65d5] | 160 | struct groupchat *chat; |
---|
[b7d3cc34] | 161 | }; |
---|
| 162 | |
---|
| 163 | struct msn_away_state |
---|
| 164 | { |
---|
| 165 | char code[4]; |
---|
| 166 | char name[16]; |
---|
| 167 | }; |
---|
| 168 | |
---|
| 169 | struct msn_status_code |
---|
| 170 | { |
---|
| 171 | int number; |
---|
| 172 | char *text; |
---|
| 173 | int flags; |
---|
| 174 | }; |
---|
| 175 | |
---|
| 176 | struct msn_message |
---|
| 177 | { |
---|
| 178 | char *who; |
---|
| 179 | char *text; |
---|
| 180 | }; |
---|
| 181 | |
---|
[70ac477] | 182 | struct msn_groupadd |
---|
| 183 | { |
---|
| 184 | char *who; |
---|
| 185 | char *group; |
---|
| 186 | }; |
---|
| 187 | |
---|
[7f34ce2] | 188 | typedef enum |
---|
| 189 | { |
---|
[ca7de3a] | 190 | MSN_BUDDY_FL = 1, /* Warning: FL,AL,BL *must* be 1,2,4. */ |
---|
[7f34ce2] | 191 | MSN_BUDDY_AL = 2, |
---|
| 192 | MSN_BUDDY_BL = 4, |
---|
| 193 | MSN_BUDDY_RL = 8, |
---|
| 194 | MSN_BUDDY_PL = 16, |
---|
[5a7af1b] | 195 | MSN_BUDDY_ADL_SYNCED = 256, |
---|
[7f34ce2] | 196 | } msn_buddy_flags_t; |
---|
| 197 | |
---|
| 198 | struct msn_buddy_data |
---|
| 199 | { |
---|
| 200 | char *cid; |
---|
| 201 | msn_buddy_flags_t flags; |
---|
| 202 | }; |
---|
| 203 | |
---|
[ff27648] | 204 | struct msn_group |
---|
| 205 | { |
---|
| 206 | char *name; |
---|
| 207 | char *id; |
---|
| 208 | }; |
---|
| 209 | |
---|
[b7d3cc34] | 210 | /* Bitfield values for msn_status_code.flags */ |
---|
| 211 | #define STATUS_FATAL 1 |
---|
| 212 | #define STATUS_SB_FATAL 2 |
---|
[3b9390b] | 213 | #define STATUS_SB_IM_SPARE 4 /* Make one-to-one conversation switchboard available again, invite failed. */ |
---|
| 214 | #define STATUS_SB_CHAT_SPARE 8 /* Same, but also for groupchats (not used yet). */ |
---|
[b7d3cc34] | 215 | |
---|
[c6ca3ee] | 216 | extern int msn_chat_id; |
---|
[0196c47] | 217 | extern const struct msn_away_state msn_away_state_list[]; |
---|
| 218 | extern const struct msn_status_code msn_status_code_list[]; |
---|
[b7d3cc34] | 219 | |
---|
| 220 | /* Keep a list of all the active connections. We need these lists because |
---|
| 221 | "connected" callbacks might be called when the connection they belong too |
---|
| 222 | is down already (for example, when an impatient user disabled the |
---|
| 223 | connection), the callback should check whether it's still listed here |
---|
| 224 | before doing *anything* else. */ |
---|
[c6ca3ee] | 225 | extern GSList *msn_connections; |
---|
| 226 | extern GSList *msn_switchboards; |
---|
[b7d3cc34] | 227 | |
---|
| 228 | /* ns.c */ |
---|
[bc676ac] | 229 | int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ) G_GNUC_PRINTF( 3, 4 ); |
---|
[bae0617] | 230 | gboolean msn_ns_connect( struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port ); |
---|
| 231 | void msn_ns_close( struct msn_handler_data *handler ); |
---|
[660cb00] | 232 | void msn_auth_got_passport_token( struct im_connection *ic, const char *token, const char *error ); |
---|
[ca7de3a] | 233 | void msn_auth_got_contact_list( struct im_connection *ic ); |
---|
[80175a1] | 234 | int msn_ns_finish_login( struct im_connection *ic ); |
---|
[bc676ac] | 235 | int msn_ns_sendmessage( struct im_connection *ic, struct bee_user *bu, const char *text ); |
---|
| 236 | void msn_ns_oim_send_queue( struct im_connection *ic, GSList **msgq ); |
---|
[b7d3cc34] | 237 | |
---|
| 238 | /* msn_util.c */ |
---|
[0da65d5] | 239 | int msn_logged_in( struct im_connection *ic ); |
---|
[193dc74] | 240 | int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group ); |
---|
| 241 | int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group ); |
---|
[e5854a8] | 242 | void msn_buddy_ask( bee_user_t *bu ); |
---|
[b7d3cc34] | 243 | char **msn_linesplit( char *line ); |
---|
| 244 | int msn_handler( struct msn_handler_data *h ); |
---|
[46dca11] | 245 | void msn_msgq_purge( struct im_connection *ic, GSList **list ); |
---|
[21029d0] | 246 | char *msn_p11_challenge( char *challenge ); |
---|
[ca7de3a] | 247 | gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ ); |
---|
[ff27648] | 248 | struct msn_group *msn_group_by_name( struct im_connection *ic, const char *name ); |
---|
| 249 | struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id ); |
---|
[e0e1546] | 250 | int msn_ns_set_display_name( struct im_connection *ic, const char *value ); |
---|
[b7d3cc34] | 251 | |
---|
| 252 | /* tables.c */ |
---|
[0196c47] | 253 | const struct msn_away_state *msn_away_state_by_number( int number ); |
---|
| 254 | const struct msn_away_state *msn_away_state_by_code( char *code ); |
---|
| 255 | const struct msn_away_state *msn_away_state_by_name( char *name ); |
---|
| 256 | const struct msn_status_code *msn_status_by_number( int number ); |
---|
[b7d3cc34] | 257 | |
---|
| 258 | /* sb.c */ |
---|
[bc676ac] | 259 | int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ) G_GNUC_PRINTF( 2, 3 );; |
---|
[0da65d5] | 260 | struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ); |
---|
| 261 | struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ); |
---|
| 262 | struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ); |
---|
| 263 | struct msn_switchboard *msn_sb_spare( struct im_connection *ic ); |
---|
[b7d3cc34] | 264 | int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ); |
---|
[0da65d5] | 265 | struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ); |
---|
[b7d3cc34] | 266 | void msn_sb_destroy( struct msn_switchboard *sb ); |
---|
[ba9edaa] | 267 | gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); |
---|
[a830512] | 268 | int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ); |
---|
[bb839e8] | 269 | void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial ); |
---|
| 270 | void msn_sb_stop_keepalives( struct msn_switchboard *sb ); |
---|
[a830512] | 271 | |
---|
| 272 | #endif //_MSN_H |
---|