~vish/ubuntu/maverick/pidgin/bug25979

« back to all changes in this revision

Viewing changes to libpurple/protocols/msn/directconn.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-10-09 19:40:26 UTC
  • mfrom: (1.4.1 upstream) (46.1.10 karmic)
  • Revision ID: james.westby@ubuntu.com-20091009194026-wbqqh0bsbz19nx5q
Tags: 1:2.6.2-1ubuntu7
* Don't stick the buddy list window to all desktops as some
  window managers have trouble to properly unstick it (LP: #346840)
  - debian/patches/11_buddy_list_really_show.patch
* Always use default tray icon size on KDE (LP: #209440)
  - debian/patches/62_tray_icon_size_kde.patch
* Use scrollbars in the preferences dialog if the screen height is
  below 700 px instead of 600 px
  - debian/patches/60_1024x600_gtkprefs.c.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
 
202
202
        g_free(buffer);
203
203
 
204
 
#if 0
205
 
        /* Let's write the length of the data. */
206
 
        ret = write(directconn->fd, &len, sizeof(len));
207
 
 
208
 
        /* Let's write the data. */
209
 
        ret = write(directconn->fd, data, len);
210
 
 
211
 
        char *str;
212
 
        str = g_strdup_printf("/home/revo/msntest/w%.4d.bin", directconn->c);
213
 
 
214
 
        FILE *tf = g_fopen(str, "w");
215
 
        fwrite(&len, 1, sizeof(len), tf);
216
 
        fwrite(data, 1, len, tf);
217
 
        fclose(tf);
218
 
 
219
 
        g_free(str);
220
 
#endif
221
 
 
222
204
        directconn->c++;
223
205
 
224
206
        return ret;
265
247
}
266
248
 
267
249
static void
268
 
msn_directconn_process_msg(MsnDirectConn *directconn, MsnMessage *msg)
269
 
{
270
 
        purple_debug_info("msn", "directconn: process_msg\n");
271
 
 
272
 
        msn_slplink_process_msg(directconn->slplink, msg);
273
 
}
274
 
 
275
 
static void
276
250
read_cb(gpointer data, gint source, PurpleInputCondition cond)
277
251
{
278
252
        MsnDirectConn* directconn;
285
259
        directconn = data;
286
260
 
287
261
        /* Let's read the length of the data. */
 
262
#error This code is broken.  See the note below.
 
263
        /*
 
264
         * TODO: This has problems!  First of all, sizeof(body_len) will be
 
265
         *       different on 32bit systems and on 64bit systems (4 bytes
 
266
         *       vs. 8 bytes).
 
267
         *       Secondly, we're reading from a TCP stream.  There is no
 
268
         *       guarantee that we have received the number of bytes we're
 
269
         *       trying to read.  We need to read into a buffer.  If read
 
270
         *       returns <0 then we need to check errno.  If errno is EAGAIN
 
271
         *       then don't destroy anything, just exit and wait for more
 
272
         *       data.  See every other function in libpurple that does this
 
273
         *       correctly for an example.
 
274
         */
288
275
        len = read(directconn->fd, &body_len, sizeof(body_len));
289
276
 
290
277
        if (len <= 0)
341
328
                MsnMessage *msg;
342
329
 
343
330
#ifdef DEBUG_DC
344
 
                str = g_strdup_printf("/home/revo/msntest/r%.4d.bin", directconn->c);
 
331
                str = g_strdup_printf("%s/msntest/r%.4d.bin", g_get_home_dir(), directconn->c);
345
332
 
346
333
                FILE *tf = g_fopen(str, "w");
347
334
                fwrite(body, 1, len, tf);
355
342
                msg = msn_message_new_msnslp();
356
343
                msn_message_parse_slp_body(msg, body, body_len);
357
344
 
358
 
                msn_directconn_process_msg(directconn, msg);
 
345
                purple_debug_info("msn", "directconn: process_msg\n");
 
346
                msn_slplink_process_msg(directconn->slplink, msg);
359
347
        }
360
348
        else
361
349
        {
369
357
 
370
358
                msn_directconn_destroy(directconn);
371
359
        }
 
360
 
 
361
        g_free(body);
372
362
}
373
363
 
374
364
static void