~bluetooth/ubuntu/lucid/obexd/lp_559412

« back to all changes in this revision

Viewing changes to client/main.c

  • Committer: Baptiste Mille-Mathias
  • Date: 2010-03-15 19:43:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: baptiste.millemathias@gmail.com-20100315194306-bsoo9qovl1qt0pi2
Tags: 0.22-0ubuntu1
* New upstream release (LP: #539914):
  - Fix file corruption during PUT operation. (LP: #421684]
  - Fix the response of PUT requests for PBAP.
  - Fix blocking while waiting capability script to exit.
  - Fix compilation issues with driver and plugin options.
  - Fix service driver selection when WHO header is informed.
  - Fix issue with PC-Suite WHO header.
  - Fix issue when mime type exists but is unknown.
  - Fix issue when opening file fails during SendFiles.
  - Fix error code response when there is no default vCard.
  - Fix a memory leak when opening a folder for listing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  OBEX Client
4
4
 *
5
 
 *  Copyright (C) 2007-2009  Marcel Holtmann <marcel@holtmann.org>
 
5
 *  Copyright (C) 2007-2010  Marcel Holtmann <marcel@holtmann.org>
6
6
 *
7
7
 *
8
8
 *  This program is free software; you can redistribute it and/or modify
29
29
#include <stdlib.h>
30
30
#include <string.h>
31
31
#include <signal.h>
 
32
#include <syslog.h>
32
33
 
33
34
#include <glib.h>
34
35
#include <gdbus.h>
35
36
 
 
37
#include "logging.h"
36
38
#include "session.h"
37
39
 
38
40
#define CLIENT_SERVICE  "org.openobex.client"
429
431
 
430
432
static GMainLoop *event_loop = NULL;
431
433
 
 
434
static gboolean option_debug = FALSE;
 
435
static gboolean option_stderr = FALSE;
 
436
 
 
437
static GOptionEntry options[] = {
 
438
        { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
 
439
                                "Enable debug information output" },
 
440
        { "stderr", 's', 0, G_OPTION_ARG_NONE, &option_stderr,
 
441
                                "Write log information to stderr" },
 
442
        { NULL },
 
443
};
 
444
 
432
445
static void sig_term(int sig)
433
446
{
434
447
        g_main_loop_quit(event_loop);
436
449
 
437
450
int main(int argc, char *argv[])
438
451
{
 
452
        GOptionContext *context;
439
453
        struct sigaction sa;
440
454
        DBusConnection *conn;
441
 
        DBusError err;
442
 
 
443
 
        dbus_error_init(&err);
444
 
 
445
 
        conn = g_dbus_setup_bus(DBUS_BUS_SESSION, CLIENT_SERVICE, &err);
446
 
        if (conn == NULL) {
447
 
                if (dbus_error_is_set(&err) == TRUE) {
448
 
                        fprintf(stderr, "%s\n", err.message);
449
 
                        dbus_error_free(&err);
450
 
                } else
451
 
                        fprintf(stderr, "Can't register with session bus\n");
 
455
        DBusError derr;
 
456
        GError *gerr = NULL;
 
457
        int log_option;
 
458
 
 
459
        context = g_option_context_new(NULL);
 
460
        g_option_context_add_main_entries(context, options, NULL);
 
461
 
 
462
        g_option_context_parse(context, &argc, &argv, &gerr);
 
463
        if (gerr != NULL) {
 
464
                g_printerr("%s\n", gerr->message);
 
465
                g_error_free(gerr);
 
466
                exit(EXIT_FAILURE);
 
467
        }
 
468
 
 
469
        g_option_context_free(context);
 
470
 
 
471
        dbus_error_init(&derr);
 
472
 
 
473
        conn = g_dbus_setup_bus(DBUS_BUS_SESSION, CLIENT_SERVICE, &derr);
 
474
        if (dbus_error_is_set(&derr) == TRUE) {
 
475
                g_printerr("%s: %s\n", derr.name, derr.message);
 
476
                dbus_error_free(&derr);
452
477
                exit(EXIT_FAILURE);
453
478
        }
454
479
 
455
480
        if (g_dbus_register_interface(conn, CLIENT_PATH, CLIENT_INTERFACE,
456
481
                                                client_methods, NULL, NULL,
457
482
                                                        NULL, NULL) == FALSE) {
458
 
                fprintf(stderr, "Can't register client interface\n");
 
483
                g_printerr("Can't register client interface\n");
459
484
                dbus_connection_unref(conn);
460
485
                exit(EXIT_FAILURE);
461
486
        }
462
487
 
463
488
        event_loop = g_main_loop_new(NULL, FALSE);
464
489
 
 
490
        log_option = LOG_NDELAY | LOG_PID;
 
491
 
 
492
        if (option_stderr == TRUE)
 
493
                log_option |= LOG_PERROR;
 
494
 
 
495
        openlog("obex-client", log_option, LOG_DAEMON);
 
496
 
 
497
        if (option_debug == TRUE) {
 
498
                info("Enabling debug information");
 
499
                enable_debug();
 
500
        }
 
501
 
465
502
        memset(&sa, 0, sizeof(sa));
466
503
        sa.sa_handler = sig_term;
467
504
        sigaction(SIGINT, &sa, NULL);