Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.h

    r5ebff60 r951aefd  
    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"
    3534
    3635#ifdef DEBUG_MSN
     
    6059#define MSNP11_PROD_KEY "C1BX{V4W}Q3*10SM"
    6160#define MSNP11_PROD_ID  "PROD0120PW!CCV9@"
    62 #define MSNP_VER        "MSNP18"
     61#define MSNP_VER        "MSNP21"
    6362#define MSNP_BUILD      "14.0.8117.416"
    6463
     
    6867#define MSN_CAP2        0x0000
    6968
    70 #define MSN_MESSAGE_HEADERS "MIME-Version: 1.0\r\n" \
     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" \
     75        "\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" \
    7181        "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" \
    74         "\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>"
    75104
    76105#define MSN_TYPING_HEADERS "MIME-Version: 1.0\r\n" \
     
    84113        "ID: 1\r\n" \
    85114        "\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"
    90115
    91116#define PROFILE_URL "http://members.msn.com/"
     
    99124} msn_flags_t;
    100125
    101 struct msn_handler_data {
     126struct 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
     148struct msn_data {
    102149        int fd, inpa;
    103150        int rxlen;
     
    107154        char *cmd_text;
    108155
    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 
    116 struct msn_data {
    117156        struct im_connection *ic;
    118157
    119         struct msn_handler_data ns[1];
    120158        msn_flags_t flags;
    121159
     
    126164
    127165        GSList *msgq, *grpq, *soapq;
    128         GSList *switchboards;
    129         int sb_failures;
    130         time_t first_sb_failure;
    131166
    132167        const struct msn_away_state *away_state;
     
    139174        GTree *domaintree;
    140175        int adl_todo;
    141 };
    142 
    143 struct 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;
     176
     177        gboolean is_http;
     178        struct msn_gw *gw;
    161179};
    162180
     
    205223#define STATUS_FATAL            1
    206224#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). */
    209225
    210226extern int msn_chat_id;
     
    218234   before doing *anything* else. */
    219235extern GSList *msn_connections;
    220 extern GSList *msn_switchboards;
    221236
    222237/* ns.c */
    223238int msn_ns_write(struct im_connection *ic, int fd, const char *fmt, ...) G_GNUC_PRINTF(3, 4);
    224 gboolean msn_ns_connect(struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port);
    225 void msn_ns_close(struct msn_handler_data *handler);
     239gboolean msn_ns_connect(struct im_connection *ic, const char *host, int port);
     240void msn_ns_close(struct msn_data *handler);
    226241void msn_auth_got_passport_token(struct im_connection *ic, const char *token, const char *error);
    227242void msn_auth_got_contact_list(struct im_connection *ic);
    228243int msn_ns_finish_login(struct im_connection *ic);
    229244int msn_ns_sendmessage(struct im_connection *ic, struct bee_user *bu, const char *text);
    230 void msn_ns_oim_send_queue(struct im_connection *ic, GSList **msgq);
     245int msn_ns_command(struct msn_data *md, char **cmd, int num_parts);
     246int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts);
    231247
    232248/* msn_util.c */
     
    235251int msn_buddy_list_remove(struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group);
    236252void msn_buddy_ask(bee_user_t *bu);
    237 char **msn_linesplit(char *line);
    238 int msn_handler(struct msn_handler_data *h);
    239 void msn_msgq_purge(struct im_connection *ic, GSList **list);
     253void msn_queue_feed(struct msn_data *h, char *bytes, int st);
     254int msn_handler(struct msn_data *h);
    240255char *msn_p11_challenge(char *challenge);
    241256gint msn_domaintree_cmp(gconstpointer a_, gconstpointer b_);
     
    251266const struct msn_status_code *msn_status_by_number(int number);
    252267
    253 /* sb.c */
    254 int msn_sb_write(struct msn_switchboard *sb, const char *fmt, ...) G_GNUC_PRINTF(2, 3);;
    255 struct msn_switchboard *msn_sb_create(struct im_connection *ic, char *host, int port, char *key, int session);
    256 struct msn_switchboard *msn_sb_by_handle(struct im_connection *ic, const char *handle);
    257 struct msn_switchboard *msn_sb_by_chat(struct groupchat *c);
    258 struct msn_switchboard *msn_sb_spare(struct im_connection *ic);
    259 int msn_sb_sendmessage(struct msn_switchboard *sb, char *text);
    260 struct groupchat *msn_sb_to_chat(struct msn_switchboard *sb);
    261 void msn_sb_destroy(struct msn_switchboard *sb);
    262 gboolean msn_sb_connected(gpointer data, gint source, b_input_condition cond);
    263 int msn_sb_write_msg(struct im_connection *ic, struct msn_message *m);
    264 void msn_sb_start_keepalives(struct msn_switchboard *sb, gboolean initial);
    265 void msn_sb_stop_keepalives(struct msn_switchboard *sb);
     268/* gw.c */
     269struct msn_gw *msn_gw_new(struct im_connection *ic);
     270void msn_gw_free(struct msn_gw *gw);
     271void msn_gw_open(struct msn_gw *gw);
     272ssize_t msn_gw_read(struct msn_gw *gw, char **buf);
     273void msn_gw_write(struct msn_gw *gw, char *buf, size_t len);
    266274
    267275#endif //_MSN_H
Note: See TracChangeset for help on using the changeset viewer.