~ubuntu-branches/ubuntu/oneiric/libinfinity/oneiric

« back to all changes in this revision

Viewing changes to test/inf-test-browser.c

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Kern
  • Date: 2011-04-03 15:50:33 UTC
  • mfrom: (1.2.4 upstream) (1.4.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110403155033-eqntz262lxzt0d8s
Tags: 0.5.0-2
* Fix infinoted postinst and prerm.  (Closes: #620687)
* Updated debian/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* libinfinity - a GObject-based infinote implementation
2
 
 * Copyright (C) 2007, 2008, 2009 Armin Burgmeier <armin@arbur.net>
 
2
 * Copyright (C) 2007-2011 Armin Burgmeier <armin@arbur.net>
3
3
 *
4
4
 * This library is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU Lesser General Public
24
24
#include <libinfinity/common/inf-ip-address.h>
25
25
#include <libinfinity/common/inf-standalone-io.h>
26
26
#include <libinfinity/common/inf-io.h>
 
27
#include <libinfinity/common/inf-protocol.h>
27
28
 
28
29
#include <string.h>
29
30
 
32
33
  InfStandaloneIo* io;
33
34
  InfXmppConnection* conn;
34
35
  InfcBrowser* browser;
 
36
#ifndef G_OS_WIN32
35
37
  int input_fd;
 
38
#endif
36
39
 
37
40
  InfcBrowserIter cwd;
38
41
};
226
229
 
227
230
  if(io & INF_IO_INCOMING)
228
231
  {
229
 
    fgets(buffer, sizeof(buffer), stdin);
230
 
    if(strlen(buffer) != sizeof(buffer) || buffer[sizeof(buffer)-2] == '\n')
 
232
    if(fgets(buffer, sizeof(buffer), stdin) == NULL)
 
233
    {
 
234
      inf_standalone_io_loop_quit(test->io);
 
235
    }
 
236
    else if(strlen(buffer) != sizeof(buffer) ||
 
237
            buffer[sizeof(buffer)-2] == '\n')
231
238
    {
232
239
      buffer[strlen(buffer)-1] = '\0';
233
240
 
276
283
  {
277
284
    printf("Connection established\n");
278
285
 
279
 
    inf_io_watch(
 
286
#ifndef G_OS_WIN32
 
287
    inf_io_add_watch(
280
288
      INF_IO(test->io),
281
289
      &test->input_fd,
282
290
      INF_IO_INCOMING | INF_IO_ERROR,
284
292
      test,
285
293
      NULL
286
294
    );
 
295
#endif
287
296
 
288
297
    /* Explore root node */
289
298
    infc_browser_iter_get_root(test->browser, &test->cwd);
292
301
 
293
302
  if(infc_browser_get_status(test->browser) == INFC_BROWSER_DISCONNECTED)
294
303
  {
295
 
    inf_standalone_io_loop_quit(test->io);
 
304
    if(inf_standalone_io_loop_running(test->io))
 
305
      inf_standalone_io_loop_quit(test->io);
296
306
  }
297
307
}
298
308
 
309
319
  g_type_init();
310
320
 
311
321
  test.io = inf_standalone_io_new();
 
322
#ifndef G_OS_WIN32
312
323
  test.input_fd = STDIN_FILENO;
313
 
 
 
324
#endif
314
325
  address = inf_ip_address_new_loopback4();
315
326
 
316
327
  error = NULL;
317
328
  tcp_conn =
318
 
    inf_tcp_connection_new_and_open(INF_IO(test.io), address, 6523, &error);
 
329
    inf_tcp_connection_new_and_open(INF_IO(test.io), address, inf_protocol_get_default_port(), &error);
319
330
 
320
331
  inf_ip_address_free(address);
321
332