Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.h

    r951aefd r5ebff60  
    3232#define NUDGE_MESSAGE "\r\r\rSHAKE THAT THING\r\r\r"
    3333#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
     34#define SB_KEEPALIVE_MESSAGE "\r\r\rDONT HANG UP ON ME!\r\r\r"
    3435
    3536#ifdef DEBUG_MSN
     
    5960#define MSNP11_PROD_KEY "C1BX{V4W}Q3*10SM"
    6061#define MSNP11_PROD_ID  "PROD0120PW!CCV9@"
    61 #define MSNP_VER        "MSNP21"
     62#define MSNP_VER        "MSNP18"
    6263#define MSNP_BUILD      "14.0.8117.416"
    6364
     
    6768#define MSN_CAP2        0x0000
    6869
    69 #define MSN_BASE_HEADERS \
    70         "Routing: 1.0\r\n" \
    71         "To: 1:%s\r\n" \
    72         "From: 1:%s;epid={%s}\r\n" \
    73         "\r\n" \
    74         "Reliability: 1.0\r\n" \
     70#define MSN_MESSAGE_HEADERS "MIME-Version: 1.0\r\n" \
     71        "Content-Type: text/plain; charset=UTF-8\r\n" \
     72        "User-Agent: BitlBee " BITLBEE_VERSION "\r\n" \
     73        "X-MMS-IM-Format: FN=MS%20Shell%20Dlg; EF=; CO=0; CS=0; PF=0\r\n" \
    7574        "\r\n"
    76 
    77 #define MSN_MESSAGE_HEADERS MSN_BASE_HEADERS \
    78         "Messaging: 2.0\r\n" \
    79         "Message-Type: Text\r\n" \
    80         "Content-Length: %zd\r\n" \
    81         "Content-Type: text/plain; charset=UTF-8\r\n" \
    82         "X-MMS-IM-Format: FN=Segoe%%20UI; EF=; CO=0; CS=0; PF=0\r\n" \
    83         "\r\n" \
    84         "%s"
    85 
    86 #define MSN_PUT_HEADERS MSN_BASE_HEADERS \
    87         "Publication: 1.0\r\n" \
    88         "Uri: %s\r\n" \
    89         "Content-Type: %s\r\n" \
    90         "Content-Length: %zd\r\n" \
    91         "\r\n" \
    92         "%s"
    93 
    94 #define MSN_PUT_USER_BODY \
    95         "<user>" \
    96         "<s n=\"PE\"><UserTileLocation></UserTileLocation><FriendlyName>%s</FriendlyName><PSM>%s</PSM><DDP></DDP>" \
    97         "<Scene></Scene><ASN></ASN><ColorScheme>-3</ColorScheme><BDG></BDG><RUM>%s</RUM><RUL></RUL><RLT>0</RLT>" \
    98         "<RID></RID><SUL></SUL><MachineGuid>%s</MachineGuid></s>" \
    99         "<s n=\"IM\"><Status>%s</Status><CurrentMedia></CurrentMedia></s>" \
    100         "<sep n=\"PD\"><ClientType>1</ClientType><EpName>%s</EpName><Idle>%s</Idle><State>%s</State></sep>" \
    101         "<sep n=\"PE\"><VER>BitlBee:" BITLBEE_VERSION "</VER><TYP>1</TYP><Capabilities>%d:%d</Capabilities></sep>" \
    102         "<sep n=\"IM\"><Capabilities>%d:%d</Capabilities></sep>" \
    103         "</user>"
    10475
    10576#define MSN_TYPING_HEADERS "MIME-Version: 1.0\r\n" \
     
    11384        "ID: 1\r\n" \
    11485        "\r\n"
     86
     87#define MSN_SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \
     88        "Content-Type: text/x-ping\r\n" \
     89        "\r\n\r\n"
    11590
    11691#define PROFILE_URL "http://members.msn.com/"
     
    12499} msn_flags_t;
    125100
    126 struct msn_gw {
    127         char *last_host;
    128         int port;
    129         gboolean ssl;
    130 
    131         char *session_id;
    132 
    133         GByteArray *in;
    134         GByteArray *out;
    135 
    136         int poll_timeout;
    137 
    138         b_event_handler callback;
    139 
    140         struct im_connection *ic;
    141         struct msn_data *md;
    142 
    143         gboolean open;
    144         gboolean waiting;
    145         gboolean polling;
    146 };
    147 
    148 struct msn_data {
     101struct msn_handler_data {
    149102        int fd, inpa;
    150103        int rxlen;
     
    154107        char *cmd_text;
    155108
     109        /* Either ic or sb */
     110        gpointer data;
     111
     112        int (*exec_command) (struct msn_handler_data *handler, char **cmd, int count);
     113        int (*exec_message) (struct msn_handler_data *handler, char *msg, int msglen, char **cmd, int count);
     114};
     115
     116struct msn_data {
    156117        struct im_connection *ic;
    157118
     119        struct msn_handler_data ns[1];
    158120        msn_flags_t flags;
    159121
     
    164126
    165127        GSList *msgq, *grpq, *soapq;
     128        GSList *switchboards;
     129        int sb_failures;
     130        time_t first_sb_failure;
    166131
    167132        const struct msn_away_state *away_state;
     
    174139        GTree *domaintree;
    175140        int adl_todo;
    176 
    177         gboolean is_http;
    178         struct msn_gw *gw;
     141};
     142
     143struct msn_switchboard {
     144        struct im_connection *ic;
     145
     146        /* The following two are also in the handler. TODO: Clean up. */
     147        int fd;
     148        gint inp;
     149        struct msn_handler_data *handler;
     150        gint keepalive;
     151
     152        int trId;
     153        int ready;
     154
     155        int session;
     156        char *key;
     157
     158        GSList *msgq;
     159        char *who;
     160        struct groupchat *chat;
    179161};
    180162
     
    223205#define STATUS_FATAL            1
    224206#define STATUS_SB_FATAL         2
     207#define STATUS_SB_IM_SPARE      4       /* Make one-to-one conversation switchboard available again, invite failed. */
     208#define STATUS_SB_CHAT_SPARE    8       /* Same, but also for groupchats (not used yet). */
    225209
    226210extern int msn_chat_id;
     
    234218   before doing *anything* else. */
    235219extern GSList *msn_connections;
     220extern GSList *msn_switchboards;
    236221
    237222/* ns.c */
    238223int msn_ns_write(struct im_connection *ic, int fd, const char *fmt, ...) G_GNUC_PRINTF(3, 4);
    239 gboolean msn_ns_connect(struct im_connection *ic, const char *host, int port);
    240 void msn_ns_close(struct msn_data *handler);
     224gboolean msn_ns_connect(struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port);
     225void msn_ns_close(struct msn_handler_data *handler);
    241226void msn_auth_got_passport_token(struct im_connection *ic, const char *token, const char *error);
    242227void msn_auth_got_contact_list(struct im_connection *ic);
    243228int msn_ns_finish_login(struct im_connection *ic);
    244229int msn_ns_sendmessage(struct im_connection *ic, struct bee_user *bu, const char *text);
    245 int msn_ns_command(struct msn_data *md, char **cmd, int num_parts);
    246 int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts);
     230void msn_ns_oim_send_queue(struct im_connection *ic, GSList **msgq);
    247231
    248232/* msn_util.c */
     
    251235int msn_buddy_list_remove(struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group);
    252236void msn_buddy_ask(bee_user_t *bu);
    253 void msn_queue_feed(struct msn_data *h, char *bytes, int st);
    254 int msn_handler(struct msn_data *h);
     237char **msn_linesplit(char *line);
     238int msn_handler(struct msn_handler_data *h);
     239void msn_msgq_purge(struct im_connection *ic, GSList **list);
    255240char *msn_p11_challenge(char *challenge);
    256241gint msn_domaintree_cmp(gconstpointer a_, gconstpointer b_);
     
    266251const struct msn_status_code *msn_status_by_number(int number);
    267252
    268 /* gw.c */
    269 struct msn_gw *msn_gw_new(struct im_connection *ic);
    270 void msn_gw_free(struct msn_gw *gw);
    271 void msn_gw_open(struct msn_gw *gw);
    272 ssize_t msn_gw_read(struct msn_gw *gw, char **buf);
    273 void msn_gw_write(struct msn_gw *gw, char *buf, size_t len);
     253/* sb.c */
     254int msn_sb_write(struct msn_switchboard *sb, const char *fmt, ...) G_GNUC_PRINTF(2, 3);;
     255struct msn_switchboard *msn_sb_create(struct im_connection *ic, char *host, int port, char *key, int session);
     256struct msn_switchboard *msn_sb_by_handle(struct im_connection *ic, const char *handle);
     257struct msn_switchboard *msn_sb_by_chat(struct groupchat *c);
     258struct msn_switchboard *msn_sb_spare(struct im_connection *ic);
     259int msn_sb_sendmessage(struct msn_switchboard *sb, char *text);
     260struct groupchat *msn_sb_to_chat(struct msn_switchboard *sb);
     261void msn_sb_destroy(struct msn_switchboard *sb);
     262gboolean msn_sb_connected(gpointer data, gint source, b_input_condition cond);
     263int msn_sb_write_msg(struct im_connection *ic, struct msn_message *m);
     264void msn_sb_start_keepalives(struct msn_switchboard *sb, gboolean initial);
     265void msn_sb_stop_keepalives(struct msn_switchboard *sb);
    274266
    275267#endif //_MSN_H
Note: See TracChangeset for help on using the changeset viewer.