~ubuntu-branches/ubuntu/natty/fso-abyss/natty

« back to all changes in this revision

Viewing changes to src/main.vala

  • Committer: Bazaar Package Importer
  • Author(s): Heiko Stuebner
  • Date: 2010-06-09 21:26:20 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100609212620-fpzi8ql8qwr9tqar
Tags: 0.9.0+git20100310-1
* New upstream snapshot
* Fixes compilation with newer vala versions (Closes: #574302)
* Update standards to 3.8.4
* Install default configs matching the current library scheme

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * main.vala
3
3
 *
4
 
 * Authored by Michael 'Mickey' Lauer <mlauer@vanille-media.de>
 
4
 * (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
19
19
 *
20
20
 */
21
21
 
22
 
//===========================================================================
23
 
using GLib;
24
22
using CONST;
25
23
 
 
24
//===========================================================================
26
25
Server server;
27
26
MainLoop loop;
 
27
FsoFramework.Logger logger;
28
28
 
29
29
//===========================================================================
30
30
public static void SIGINT_handler( int signum )
31
31
{
32
 
    debug( "SIGINT handler called" );
33
32
    Posix.signal( signum, null ); // restore original signal handler
 
33
    logger.info( "received signal -%d, exiting.".printf( signum ) );
34
34
    if ( server != null )
35
35
    {
36
36
        try
39
39
        }
40
40
        catch ( Error e )
41
41
        {
42
 
            warning( "Oops: %s", e.message );
 
42
            logger.error( @"Oops: $(e.message)" );
43
43
        }
44
44
        loop.quit();
45
45
    }
46
46
}
47
47
 
48
48
//===========================================================================
49
 
public static void LOG_handler( string? log_domain, LogLevelFlags log_levels, string message )
50
 
{
51
 
    var t = TimeVal();
52
 
    stdout.printf( "%s: %s\n", t.to_iso8601(), message );
53
 
}
54
 
 
55
 
//===========================================================================
56
49
void main()
57
50
{
58
 
    Environment.set_prgname( "fso-abyss" );
59
 
    loop = new MainLoop( null, false );
 
51
    var bin = FsoFramework.Utility.programName();
 
52
    logger = FsoFramework.theLogger;
 
53
    logger.info( "%s starting up...".printf( bin ) );
 
54
    loop = new MainLoop();
60
55
 
61
56
    try
62
57
    {
68
63
 
69
64
        if ( request_name_result == DBus.RequestNameReply.PRIMARY_OWNER )
70
65
        {
71
 
            Log.set_handler( null, LogLevelFlags.LEVEL_DEBUG, LOG_handler );
72
66
            Posix.signal( Posix.SIGINT, SIGINT_handler );
73
 
 
74
67
            server = new Server();
75
68
            conn.register_object( MUXER_OBJ_PATH, server );
76
 
            debug( "=> mainloop" );
77
69
            loop.run();
78
 
            debug( "<= mainloop" );
79
70
            server = null;
80
71
        }
81
72
        else
82
73
        {
83
 
            error( "Can't register bus name. Service already started?\n" );
 
74
            logger.error( "Can't register bus name. Service already started?\n" );
84
75
        }
85
 
    } catch (Error e) {
86
 
        error( "Oops: %s", e.message );
 
76
    }
 
77
    catch (Error e)
 
78
    {
 
79
        logger.error( @"Oops: $(e.message)" );
87
80
    }
88
81
}
89
82