/* * Copyright (C) 2004 Morten Fjord-Larsen * Copyright (C) 2005 Kouji TAKAO * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #if ENABLE_BONOBO #include #include #endif #include "gpass/error.h" #include "gpass/configuration.h" #include "application.h" #if ENABLE_BONOBO static void new_instance (BonoboAppClient *app_client, int argc, char *argv[]) { g_message("new-instance"); } static void unique_app (int *argcp, char *argv[]) { BonoboApplication *app; BonoboAppClient *client = NULL; gchar *serverinfo; Bonobo_RegistrationResult rv; bonobo_init(argcp, argv); app = bonobo_application_new("GNOME_Password_Manager"); g_assert(app != NULL); serverinfo = bonobo_application_create_serverinfo(app, NULL); g_assert(serverinfo != NULL); rv = bonobo_application_register_unique(app, serverinfo, &client); g_free(serverinfo); bonobo_object_unref(app); if (rv == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE) { g_message(_("One instance of Password Manager is already running.")); //g_assert(client != NULL); //bonobo_app_client_new_instance(client, *argcp, argv, NULL); bonobo_object_unref(client); exit(1); } else { g_signal_connect(app, "new-instance", G_CALLBACK(new_instance), NULL); } } #endif #if 0 static gboolean on_save_yourself(GnomeClient *client, gint phase, GnomeSaveStyle arg2, gboolean arg3, GnomeInteractStyle arg4, gboolean arg5, gpointer user_data) { GPassController *controller = (GPassController *) GPASS_CONTROLLER(user_data); if (gpass_window_save(controller->window) != NULL) { return FALSE; } return TRUE; } #endif int main(int argc, char *argv[]) { GPassApplication *app; GnomeProgram *gnome_program; GnomeClient *gnome_client; gboolean result; GError *error = NULL; #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(PACKAGE); #endif #if ENABLE_BONOBO unique_app(&argc, argv); #endif gnome_program = gnome_program_init(PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_POPT_TABLE, NULL, GNOME_PARAM_NONE); glade_gnome_init(); g_set_application_name(_("Password Manager")); gnome_client = gnome_master_client(); gnome_client_set_restart_style(gnome_client, GNOME_RESTART_IF_RUNNING); gnome_client_set_restart_command(gnome_client, argc, argv); { GPassConfiguration *config = gpass_configuration_instance(); g_object_set(config, "gconf_client", gconf_client_get_default(), NULL); } app = g_object_new(GPASS_TYPE_APPLICATION, NULL); app->view_factory = GPASS_VIEW_FACTORY(g_object_new(GPASS_TYPE_VIEW_FACTORY, NULL)); error = gpass_application_welcome(app, &result); if (error != NULL || !result) { goto end; } error = gpass_application_run(app, &result); end: g_object_unref(app->view_factory); g_object_unref(app); if (error != NULL) { gpass_error_show_and_exit(error); } gpass_configuration_finalize(); #if 0 g_signal_connect(gnome_client, "save-yourself", G_CALLBACK(on_save_yourself), user_data); #endif return 0; }