~ubuntu-branches/ubuntu/saucy/parole/saucy-proposed

« back to all changes in this revision

Viewing changes to browser-plugin/media-plugin/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Yves-Alexis Perez, Lionel Le Folgoc, Yves-Alexis Perez
  • Date: 2011-04-24 16:09:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110424160919-rpjwaicrdb8f7un2
Tags: 0.2.0.6-1
[ Lionel Le Folgoc ]
* debian/control:
  - drop unneeded build-dep on xulrunner-dev.   closes: #594073
  - suggests a few useful gstreamer0.10 plugins.
  - build-depends on quilt.
* debian/patches:
  - 01_fix-implicit-dso-linking.patch: added, fixes FTBFS with binutils-gold.
  - series: added.                                            closes: #615760
* debian/rules: pass --with quilt to dh.

[ Yves-Alexis Perez ]
* New upstream release.
* Switch to 3.0 (quilt) source format.
* debian/control:
  - update standards version to 3.9.2.
  - drop browser-plugin-parole package.
  - drop quilt build-dep.
  - add build-dep on hardening-includes
  - bump xfce build-deps to 4.8.
* debian/parole.install updated.
* debian/rules:
  - use --fail-missing and manually remove spurious files.
  - drop quilt addon
  - pick build flags from dpkg-buildflags.
  - add -O1, -z,defs and --as-needed to LDFLAGS.
  - add hardening flags to build flags.
  - stop harcoding the shell to bash, it works fine now.      closes: #623830

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * * Copyright (C) 2008-2009 Ali <aliov@xfce.org>
3
 
 *
4
 
 * Licensed under the GNU General Public License Version 2
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#ifdef HAVE_CONFIG_H
22
 
#include <config.h>
23
 
#endif
24
 
 
25
 
#include <stdio.h>
26
 
#include <stdlib.h>
27
 
#include <string.h>
28
 
 
29
 
#include <unistd.h>
30
 
#include <signal.h>
31
 
 
32
 
#include <gtk/gtk.h>
33
 
 
34
 
#include <libxfcegui4/libxfcegui4.h>
35
 
 
36
 
#include <gst/gst.h>
37
 
 
38
 
#include "parole-plugin-player.h"
39
 
 
40
 
#include "dbus/parole-dbus.h"
41
 
 
42
 
static gulong exit_source_id = 0;
43
 
 
44
 
static void G_GNUC_NORETURN
45
 
force_exit (gpointer data)
46
 
{
47
 
    //g_debug ("Forcing exit");
48
 
    exit (0);
49
 
}
50
 
 
51
 
static void
52
 
posix_signal_handler (gint sig, ParolePluginPlayer *player)
53
 
{
54
 
    parole_plugin_player_exit (player);
55
 
    
56
 
    exit_source_id = g_timeout_add_seconds (4, (GSourceFunc) force_exit, NULL);
57
 
}
58
 
 
59
 
int main (int argc, char **argv)
60
 
{
61
 
    ParolePluginPlayer *player;
62
 
    GdkNativeWindow socket_id = 0;
63
 
    gchar *url = NULL;
64
 
    GOptionContext *ctx;
65
 
    GOptionGroup *gst_option_group;
66
 
    GError *error = NULL;
67
 
    gchar *dbus_name;
68
 
    GtkWidget *plug;
69
 
    
70
 
    GOptionEntry option_entries[] = 
71
 
    {
72
 
        { "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, &socket_id, N_("socket"), N_("SOCKET ID") },
73
 
        { "url", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &url, N_("url to play"), N_("URL") },
74
 
        { NULL, },
75
 
    };
76
 
    
77
 
    if ( !g_thread_supported () )
78
 
        g_thread_init (NULL);
79
 
        
80
 
    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
81
 
 
82
 
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
83
 
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
84
 
#endif
85
 
 
86
 
    textdomain (GETTEXT_PACKAGE);
87
 
  
88
 
    gtk_init (&argc, &argv);
89
 
    
90
 
    ctx = g_option_context_new (NULL);
91
 
    
92
 
    gst_option_group = gst_init_get_option_group ();
93
 
    g_option_context_add_main_entries (ctx, option_entries, GETTEXT_PACKAGE);
94
 
    g_option_context_set_translation_domain (ctx, GETTEXT_PACKAGE);
95
 
    g_option_context_add_group (ctx, gst_option_group);
96
 
 
97
 
    g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
98
 
    
99
 
    if ( !g_option_context_parse (ctx, &argc, &argv, &error) ) 
100
 
    {
101
 
        g_print ("%s\n", error->message);
102
 
        g_print ("Type %s --help to list all available command line options", argv[0]);
103
 
        g_error_free (error);
104
 
        g_option_context_free (ctx);
105
 
        return EXIT_FAILURE;
106
 
    }
107
 
    g_option_context_free (ctx);
108
 
    
109
 
    dbus_name = g_strdup_printf ("org.Parole.Media.Plugin%d", socket_id);
110
 
    parole_dbus_register_name (dbus_name);
111
 
    
112
 
    plug = gtk_plug_new (socket_id);
113
 
        
114
 
    player = parole_plugin_player_new (plug, url);
115
 
    gtk_widget_show_all (plug);
116
 
    
117
 
    if ( xfce_posix_signal_handler_init (&error)) 
118
 
    {
119
 
        xfce_posix_signal_handler_set_handler (SIGKILL,
120
 
                                               (XfcePosixSignalHandler) posix_signal_handler,
121
 
                                               player, NULL);
122
 
    } 
123
 
    else 
124
 
    {
125
 
        g_warning ("Unable to set up POSIX signal handlers: %s", error->message);
126
 
        g_error_free (error);
127
 
    }
128
 
 
129
 
    gtk_main ();
130
 
    g_object_unref (player);
131
 
    gtk_widget_destroy (plug);
132
 
    parole_dbus_release_name (dbus_name);
133
 
    g_free (dbus_name);
134
 
 
135
 
    if ( exit_source_id != 0 )
136
 
        g_source_remove (exit_source_id);
137
 
 
138
 
    //g_debug ("Exiting");
139
 
    gst_deinit ();
140
 
 
141
 
    return EXIT_SUCCESS;
142
 
}