Exemplo n.º 1
0
void restore_SYSTEM_VTE_CJK_WIDTH_STR()
{
#ifdef DETAIL
	g_debug("! Launch restore_SYSTEM_VTE_CJK_WIDTH_STR()");
#endif
	extern gchar *SYSTEM_VTE_CJK_WIDTH_STR;
	if (SYSTEM_VTE_CJK_WIDTH_STR)
		g_setenv("VTE_CJK_WIDTH", SYSTEM_VTE_CJK_WIDTH_STR, TRUE);
	else
		g_unsetenv("VTE_CJK_WIDTH");
}
Exemplo n.º 2
0
/**
 * 
 * Determine and set Grisbi locale as follows (in order of priority):
 * - Value of HKCU\SOFTWARE\GRISBI\LANG
 * - Value of %LANG% (LANG con content a LOCALE definition or a LCID value)
 * - Default user value
 * 
 * @return Does the function change the application context LANG value
 * @retval TRUE a value have set to LANG
 * @retval FALSE LANG has not been modified for any reason.
 * 
*/
gboolean win32_set_locale() 
{ /* {{{ */
    gchar* gzLocale = NULL;
    BOOL    bFound           = FALSE;
    
    // ---------------------------------------------------------------------
    // Grisbi language has been configured through the specific application
    // ---------------------------------------------------------------------
    // 1 - look into HKCU/SOFTWARE/GRISBI/LANG
    gzLocale = win32_strdup_registry(HKEY_CURRENT_USER,"SOFTWARE\\GRISBI","LANG",REG_SZ);
    bFound   = (BOOL)(gzLocale && (*gzLocale));
    
    // ---------------------------------------------------------------------
    // Try to find language setting using the LANG environment variable
    // ---------------------------------------------------------------------
    if(!bFound)
    {
		g_unsetenv("LANG");
        gzLocale = g_getenv("LANG");
        bFound   = (BOOL)(gzLocale && (*gzLocale));
        if (bFound)
        {
            // LANG can contain the Windows LCID instead of the LC_LOCALE value, in this case we need to convert it
            // LANG can the LCID given in decimal
            // LANG can the LCID given is hexadecimal
            // When LANG is the LCID its size is 3 or 4 and start with a digit
            // In other case we suppose LANG to be a valid LC_LOCALE value
            int len = strlen(gzLocale);
            if ( (len==3||len==4)&&(g_ascii_isdigit(*gzLocale))) 
            {
                    gzLocale = win32_lcid_to_lang(atoi(gzLocale));
                    bFound   = (BOOL)(gzLocale && (*gzLocale));
            }
        }
    
    }
    // ---------------------------------------------------------------------
    // Last change: retrieve current Windows value
    // ---------------------------------------------------------------------
    if ( (!bFound) || (!gzLocale) || ( (gzLocale) && (!(*gzLocale)) ) )
    {
        gzLocale = win32_lcid_to_lang(GetUserDefaultLCID());
    }

    if ((gzLocale)&&(*gzLocale))
    {
        bFound = TRUE;
        g_setenv("LANG",gzLocale,TRUE);
        g_free(gzLocale);
        gzLocale = NULL;
    }
    return bFound;
} /* }}} */
Exemplo n.º 3
0
static void
teardown_plugins_dir(void)
{
  if (plugins_dir_env) {
    g_setenv("GRN_PLUGINS_DIR", plugins_dir_env, TRUE);
  } else {
    g_unsetenv("GRN_PLUGINS_DIR");
  }
  grn_plugin_init_from_env();
  g_free(plugins_dir_env);
  g_free(plugins_dir);
}
Exemplo n.º 4
0
void __restore_layers_path(const gchar *old_value)
{
    if (old_value == NULL) {
        g_unsetenv(LAYER_LAYERS_PATH_ENV_VAR);
    } else {
        g_setenv(LAYER_LAYERS_PATH_ENV_VAR, old_value, TRUE);
    }
    g_free(current_dir);
    g_free(layerpath1);
    g_free(layerpath2);
    current_dir = NULL;
}
Exemplo n.º 5
0
static void
test_x11_autolaunch (void)
{
  if (g_test_subprocess ())
    {
      g_unsetenv ("DISPLAY");
      g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
      g_unsetenv ("XDG_RUNTIME_DIR");
      set_up_mock_dbus_launch ();

      print_address ();

      tear_down_mock_dbus_launch ();
      return;
    }

  g_test_trap_subprocess (NULL, 0, 0);
  g_test_trap_assert_stderr_unmatched ("?*");
  g_test_trap_assert_stdout ("hello:this=address-is-from-the,mock=dbus-launch\n");
  g_test_trap_assert_passed ();
}
Exemplo n.º 6
0
static void
setup (TestCase *tc,
       gconstpointer data)
{
  GPtrArray *ptr = g_ptr_array_new ();
  const TestFixture *fix = data;
  const gchar *old_val = g_getenv ("XDG_CONFIG_DIRS");
  gint i;
  struct group *gr = NULL;

  g_setenv ("XDG_CONFIG_DIRS", config_dir, TRUE);
  tc->cert_dir = g_build_filename (config_dir, "cockpit", "ws-certs.d", NULL);

  /* make sure we start clean */
  delete_all(tc);

  if (fix->readonly_dir)
    {
      g_assert (g_mkdir_with_parents (tc->cert_dir, 0755) == 0);
      g_assert (g_chmod (tc->cert_dir, 0555) == 0);
    }

  g_ptr_array_add (ptr, "certificate");
  if (fix->ensure)
    {
      cockpit_expect_info ("Generating temporary certificate*");
      cockpit_expect_info ("Error generating temporary dummy cert using sscg, falling back to openssl*");
      g_ptr_array_add (ptr, "--ensure");
    }
  g_ptr_array_add (ptr, "--user");
  g_ptr_array_add (ptr, (gchar *) g_get_user_name ());

  gr = getgrnam (g_get_user_name ());
  if (gr != NULL)
    {
      g_ptr_array_add (ptr, "--group");
      g_ptr_array_add (ptr, (gchar *) g_get_user_name ());
    }

  for (i = 0; fix->files[i] != NULL; i++)
    g_ptr_array_add (ptr, (gchar *) fix->files[i]);

  if (fix->expected_message)
    cockpit_expect_message (fix->expected_message);

  tc->ret = cockpit_remotectl_certificate (ptr->len, (gchar **) ptr->pdata);

  g_ptr_array_free (ptr, TRUE);
  if (old_val)
    g_setenv ("XDG_CONFIG_DIRS", old_val, TRUE);
  else
    g_unsetenv ("XDG_CONFIG_DIRS");
}
Exemplo n.º 7
0
void test_remove_env()
{
    g_unsetenv("LAYERAPI_TEST");
    g_setenv("LAYERAPI_TEST", "foo:bar:plop", TRUE);
    field_remove_env("LAYERAPI_TEST", "foobar", FALSE, FALSE);
    g_assert_cmpstr(g_getenv("LAYERAPI_TEST"), ==, "foo:bar:plop");
    field_remove_env("LAYERAPI_TEST", "bar", FALSE, FALSE);
    g_assert_cmpstr(g_getenv("LAYERAPI_TEST"), ==, "foo:plop");
    field_remove_env("LAYERAPI_TEST", "p*", TRUE, FALSE);
    g_assert_cmpstr(g_getenv("LAYERAPI_TEST"), ==, "foo");
    field_remove_env("LAYERAPI_TEST", "*", TRUE, FALSE);
    g_assert_cmpstr(g_getenv("LAYERAPI_TEST"), ==, "");
}
Exemplo n.º 8
0
static void
test_xdg_runtime (void)
{
  if (g_test_subprocess ())
    {
      g_unsetenv ("DISPLAY");
      g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
      set_up_mock_xdg_runtime_dir ();
      set_up_mock_dbus_launch ();

      print_address ();

      tear_down_mock_dbus_launch ();
      tear_down_mock_xdg_runtime_dir ();
      return;
    }

  g_test_trap_subprocess (NULL, 0, 0);
  g_test_trap_assert_stderr_unmatched ("?*");
  g_test_trap_assert_stdout ("unix:path=/tmp/gdbus%2Cunix%2Ctest.*/bus\n");
  g_test_trap_assert_passed ();
}
Exemplo n.º 9
0
void set_env(const gchar *variable, const gchar *value, gboolean overwrite)
{
#ifdef DETAIL
	g_debug("! Launch set_env() with variable = %s, value = %s, overwrite = %d", variable, value, overwrite);
#endif
#ifdef DEFENSIVE
	if ((variable==NULL) || (variable[0]=='\0')) return;
#endif
	if (value)
		g_setenv(variable, value, overwrite);
	else
		g_unsetenv(variable);
}
Exemplo n.º 10
0
void syl_init(void)
{
#ifdef G_OS_WIN32
	gchar *newpath;
	const gchar *lang_env;

	/* disable locale variable such as "LANG=1041" */

#define DISABLE_DIGIT_LOCALE(envstr)			\
{							\
	lang_env = g_getenv(envstr);			\
	if (lang_env && g_ascii_isdigit(lang_env[0]))	\
		g_unsetenv(envstr);			\
}

	DISABLE_DIGIT_LOCALE("LC_ALL");
	DISABLE_DIGIT_LOCALE("LANG");
	DISABLE_DIGIT_LOCALE("LC_CTYPE");
	DISABLE_DIGIT_LOCALE("LC_MESSAGES");

#undef DISABLE_DIGIT_LOCALE

	g_unsetenv("LANGUAGE");
#endif /* G_OS_WIN32 */

#ifdef HAVE_LOCALE_H
	setlocale(LC_ALL, "");
#endif

	set_startup_dir();

#ifdef G_OS_WIN32
	/* include startup directory into %PATH% for GSpawn */
	newpath = g_strconcat(get_startup_dir(), ";", g_getenv("PATH"), NULL);
	g_setenv("PATH", newpath, TRUE);
	g_free(newpath);
#endif

#ifdef ENABLE_NLS
	syl_init_gettext(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
#endif

	sock_init();

#ifdef G_OS_UNIX
	/* ignore SIGPIPE signal for preventing sudden death of program */
	signal(SIGPIPE, SIG_IGN);
#endif
}
Exemplo n.º 11
0
int
main (int   argc,
      char *argv[])
{
  g_test_init (&argc, &argv, NULL);

  /* Unset variables that would make libproxy try to use gconf or ksettings */
  g_unsetenv ("GNOME_DESKTOP_SESSION_ID");
  g_unsetenv ("DESKTOP_SESSION");
  g_unsetenv ("KDE_FULL_SESSION");

  /* Use the just-built libproxy module */
  g_setenv ("GIO_EXTRA_MODULES", TOP_BUILDDIR "/proxy/libproxy/.libs", TRUE);

  g_test_add_vtable ("/proxy/libproxy/uri", 0, NULL,
		     reset_proxy_settings, test_proxy_uri, NULL);
  g_test_add_vtable ("/proxy/libproxy/socks", 0, NULL,
		     reset_proxy_settings, test_proxy_socks, NULL);
  g_test_add_vtable ("/proxy/libproxy/ignore", 0, NULL,
		     reset_proxy_settings, test_proxy_ignore, NULL);

  return g_test_run();
}
Exemplo n.º 12
0
/* If possible, we want to localize a language in itself.
 * If it fails, fallback to the currently selected language, then to system lang.
 * Only fallback to C (en_US) as a last resort.
 */
static void
gimp_language_store_self_l10n (GimpLanguageStore *store,
                               const gchar       *lang,
                               const gchar       *code)
{
  if (lang && *lang && code && *code)
    {
      const gchar *semicolon;

      /* English does not need localization. */
      if (g_strcmp0 (code, "en") != 0)
        {
          gchar *current_lang = g_strdup (g_getenv ("LANGUAGE"));
          gchar *temp_lang;

          if (current_lang)
            temp_lang = g_strdup_printf ("%s:%s:%s", code, current_lang, setlocale (LC_ALL, NULL));
          else
            temp_lang = g_strdup (code);

          /* Temporarily change the localization language. */
          g_setenv ("LANGUAGE", temp_lang, TRUE);
          setlocale (LC_ALL, "");
          lang = dgettext ("iso_639", lang);
          if (current_lang)
            g_setenv ("LANGUAGE", current_lang, TRUE);
          else
            g_unsetenv("LANGUAGE");
          setlocale (LC_ALL, "");

          g_free (current_lang);
          g_free (temp_lang);
        }

      /*  there might be several language names; use the first one  */
      semicolon = strchr (lang, ';');

      if (semicolon)
        {
          gchar *first = g_strndup (lang, semicolon - lang);

          gimp_language_store_add (store, first, code);
          g_free (first);
        }
      else
        {
          gimp_language_store_add (store, lang, code);
        }
    }
}
Exemplo n.º 13
0
int
main(int argc, char* argv[]) {
	GtkWidget *win;
	GtkCssProvider *cssprovider;
	GdkScreen *screen;
	GError *error;

	/* Disable global menus */
	g_unsetenv ("UBUNTU_MENUPROXY");
	gtk_init(&argc, &argv);
	ido_init ();
	screen = gdk_screen_get_default();
	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW (win), -1, 28);
	g_signal_connect(win, "realize", G_CALLBACK(on_realize), NULL);
	g_signal_connect(screen, "monitors-changed", G_CALLBACK(on_screen_change), win);
	g_signal_connect(screen, "size-changed", G_CALLBACK(on_screen_change), win);

	cssprovider = gtk_css_provider_new ();
	gtk_css_provider_load_from_data(cssprovider,
			"GtkMenuBar {\n"
			"    -GtkMenuBar-internal-padding: 0;\n"
			"    -GtkMenuBar-shadow-type: none;\n"
			"}\n"
			"GtkWidget {\n"
			"    -GtkWidget-focus-line-width: 0;\n"
			"    -GtkWidget-focus-padding: 0;\n"
			"}\n", -1, NULL);

	gtk_style_context_add_provider_for_screen(screen,
		GTK_STYLE_PROVIDER (cssprovider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

	GtkWidget* menubar = gtk_menu_bar_new();

	load_indicator_files (INDICATOR_DIR, menubar);
	IndicatorObject * io = indicator_object_new_from_file("/usr/lib/indicators3/7/libapplication.so");
	load_indicator(io, menubar);

	GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
	gtk_container_add(GTK_CONTAINER(win), hbox);
	gtk_box_pack_end(GTK_BOX(hbox), menubar, FALSE, FALSE, 0);
	g_signal_connect_after(menubar, "draw", G_CALLBACK(on_draw), NULL);
	g_signal_connect(win, "draw", G_CALLBACK(on_draw), NULL);
	gtk_widget_show_all(win);
	gdk_window_process_updates(gtk_widget_get_window(win), TRUE);
	gtk_widget_set_app_paintable(win, TRUE);
	gtk_main();
	return 0;
}
Exemplo n.º 14
0
Arquivo: gdk.c Projeto: 3v1n0/gtk
void
gdk_pre_parse (void)
{
  const char *rendering_mode;
  const gchar *gl_string;

  gdk_initialized = TRUE;

  /* We set the fallback program class here, rather than lazily in
   * gdk_get_program_class, since we don't want -name to override it.
   */
  gdk_progclass = g_strdup (g_get_prgname ());
  if (gdk_progclass && gdk_progclass[0])
    gdk_progclass[0] = g_ascii_toupper (gdk_progclass[0]);
  
#ifdef G_ENABLE_DEBUG
  {
    gchar *debug_string = getenv("GDK_DEBUG");
    if (debug_string != NULL)
      _gdk_debug_flags = g_parse_debug_string (debug_string,
                                              (GDebugKey *) gdk_debug_keys,
                                              G_N_ELEMENTS (gdk_debug_keys));
  }
#endif  /* G_ENABLE_DEBUG */

  gl_string = getenv("GDK_GL");
  if (gl_string != NULL)
    _gdk_gl_flags = g_parse_debug_string (gl_string,
                                          (GDebugKey *) gdk_gl_keys,
                                          G_N_ELEMENTS (gdk_gl_keys));

  if (getenv ("GDK_NATIVE_WINDOWS"))
    {
      g_warning ("The GDK_NATIVE_WINDOWS environment variable is not supported in GTK3.\n"
                 "See the documentation for gdk_window_ensure_native() on how to get native windows.");
      g_unsetenv ("GDK_NATIVE_WINDOWS");
    }

  rendering_mode = g_getenv ("GDK_RENDERING");
  if (rendering_mode)
    {
      if (g_str_equal (rendering_mode, "similar"))
        _gdk_rendering_mode = GDK_RENDERING_MODE_SIMILAR;
      else if (g_str_equal (rendering_mode, "image"))
        _gdk_rendering_mode = GDK_RENDERING_MODE_IMAGE;
      else if (g_str_equal (rendering_mode, "recording"))
        _gdk_rendering_mode = GDK_RENDERING_MODE_RECORDING;
    }
}
Exemplo n.º 15
0
void
cut_teardown (void)
{
    if (stdout_string)
        g_free(stdout_string);
    if (stderr_string)
        g_free(stderr_string);

    if (lang) {
        g_setenv("LANG", lang, TRUE);
        g_free(lang);
    } else {
        g_unsetenv("LANG");
    }
}
Exemplo n.º 16
0
static void set_locale(const char *ui_lang, const char *old_env)
{
  if(ui_lang && *ui_lang)
  {
    // TODO: Also set LANG
    g_setenv("LANGUAGE", ui_lang, TRUE);
    gtk_disable_setlocale();
  }
  else if(old_env && *old_env)
    g_setenv("LANGUAGE", old_env, TRUE);
  else
    g_unsetenv("LANGUAGE");

  setlocale(LC_ALL, "");
}
Exemplo n.º 17
0
int
main (int    argc,
      char **argv)
{
  GError *error = NULL;
  g_autofree const char *old_env = NULL;
  int ret;

  setlocale (LC_ALL, "");

  g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, message_handler, NULL);

  g_set_prgname (argv[0]);

  /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
  old_env = g_strdup (g_getenv ("GIO_USE_VFS"));
  g_setenv ("GIO_USE_VFS", "local", TRUE);
  g_vfs_get_default ();
  if (old_env)
    g_setenv ("GIO_USE_VFS", old_env, TRUE);
  else
    g_unsetenv ("GIO_USE_VFS");

  if (argc >= 4 && strcmp (argv[1], "complete") == 0)
    return complete (argc, argv);

  flatpak_migrate_from_xdg_app ();

  ret = flatpak_run (argc, argv, &error);
  if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
    flatpak_usage (commands, TRUE);

  if (error != NULL)
    {
      int is_tty = isatty (1);
      const char *prefix = "";
      const char *suffix = "";
      if (is_tty)
        {
          prefix = "\x1b[31m\x1b[1m"; /* red, bold */
          suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */
        }
      g_printerr ("%serror: %s%s\n", prefix, suffix, error->message);
      g_error_free (error);
    }

  return ret;
}
Exemplo n.º 18
0
static gchar* 
askpass_command (const gchar *cmd, const gchar *arg)
{
    const gchar* env;
    gchar *t, *ret;
    int fd;
        
    /* Try an open the connection with bastile */
    if (!bastile_link) {
        env = g_getenv ("BASTILE_SSH_ASKPASS_FD");
        if (env == NULL)
            return NULL;
        g_unsetenv ("BASTILE_SSH_ASKPASS_FD");
        
        fd = strtol (env, &t, 10);
        if (*t) {
            g_warning ("fd received from bastile was not valid: %s", env);
            return NULL;
        }
        
        bastile_link = fdopen (fd, "r+b");
        if (!bastile_link) {
            g_warning ("couldn't open fd %d: %s", fd, strerror (errno));
            return NULL;
        }
        
        setvbuf(bastile_link, 0, _IONBF, 0);
    }
    
    /* Request a setting be sent */
    fprintf (bastile_link, "%s %s\n", cmd, arg ? arg : "");
    fflush (bastile_link);
    
    /* Read the setting */
    t = g_new0 (gchar, 512);
    ret = fgets (t, 512, bastile_link);
    
    /* Make sure it worked */
    if (ferror (bastile_link)) {
        g_warning ("error reading from bastile");
        fclose (bastile_link);
        bastile_link = NULL;
        g_free (t);
        return NULL;
    }
    
    return t;
}
Exemplo n.º 19
0
static inline void _get_current_time (time_t epoch, GldiModuleInstance *myApplet)
{
	if (myConfig.cLocation != NULL)
	{
		g_setenv ("TZ", myConfig.cLocation, TRUE);
		tzset ();
	}
	localtime_r (&epoch, &myData.currentTime);
	if (myConfig.cLocation != NULL)
	{
		if (myData.cSystemLocation != NULL)
			g_setenv ("TZ", myData.cSystemLocation, TRUE);
		else
			g_unsetenv ("TZ");
	}
}
Exemplo n.º 20
0
void
teardown (void)
{
  if (original_language)
    g_setenv ("LANGUAGE", original_language, TRUE);
  else
    g_unsetenv ("LANGUAGE");
  if (original_locale)
    {
      setlocale (LC_ALL, original_locale);
      g_free(original_locale);
    }
  if (keyfile)
    g_key_file_free (keyfile);
  g_log_set_default_handler (default_log_func, NULL);
}
Exemplo n.º 21
0
int
main(int argc, char* argv[]) {
	GtkWidget *win;
	GtkCssProvider *cssprovider;

	/* Disable global menus */
	g_unsetenv ("UBUNTU_MENUPROXY");
	gtk_init(&argc, &argv);
	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect(win, "realize", G_CALLBACK(on_realize), NULL);

	cssprovider = gtk_css_provider_new ();
	gtk_css_provider_load_from_data(cssprovider,
			"GtkMenuBar {\n"
			"    -GtkMenuBar-internal-padding: 0;\n"
			"    -GtkMenuBar-shadow-type: none;\n"
			"}\n"
			"GtkWidget {\n"
			"    -GtkWidget-focus-line-width: 0;\n"
			"    -GtkWidget-focus-padding: 0;\n"
			"}\n"
			".menuitem {\n"
			"    padding: 0px 0px 0px 0px;\n"
			"}\n", -1, NULL);

	gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
		GTK_STYLE_PROVIDER (cssprovider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

	GtkWidget* menubar = gtk_menu_bar_new();
	gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar), GTK_PACK_DIRECTION_RTL);
	int i;
	for(i = 0; indicators[i]; i++) {
		if (!load_module(indicators[i], menubar)) {
			g_error("Unable to load module");
		}
	}
	GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
	gtk_container_add(GTK_CONTAINER(win), hbox);
	gtk_box_pack_end(GTK_BOX(hbox), menubar, FALSE, FALSE, 0);
	g_signal_connect_after(menubar, "draw", G_CALLBACK(on_draw), NULL);
	g_signal_connect(win, "draw", G_CALLBACK(on_draw), NULL);
	gtk_widget_show_all(win);
	gdk_window_process_updates(gtk_widget_get_window(win), TRUE);
	gtk_widget_set_app_paintable(win, TRUE);
	gtk_main();
	return 0;
}
int
main (int   argc,
      char *argv[])
{
  GError *error;
  gint ret;

  g_type_init ();
  g_thread_init (NULL);
  g_test_init (&argc, &argv, NULL);

  /* all the tests rely on a shared main loop */
  loop = g_main_loop_new (NULL, FALSE);

  /* all the tests use a session bus with a well-known address that we can bring up and down
   * using session_bus_up() and session_bus_down().
   */
  g_unsetenv ("DISPLAY");
  g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_bus_get_temporary_address (), TRUE);

  session_bus_up ();

  /* TODO: wait a bit for the bus to come up.. ideally session_bus_up() won't return
   * until one can connect to the bus but that's not how things work right now
   */
  usleep (500 * 1000);

  /* this is safe; testserver will exit once the bus goes away */
  g_assert (g_spawn_command_line_async (SRCDIR "/gdbus-testserver.py", NULL));

  /* wait for the service to come up */
  usleep (500 * 1000);

  /* Create the connection in the main thread */
  error = NULL;
  c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
  g_assert_no_error (error);
  g_assert (c != NULL);

  g_test_add_func ("/gdbus/connection-loss", test_connection_loss);

  ret = g_test_run();

  g_object_unref (c);

  return ret;
}
int
main (int argc, char *argv[])
{
  GisDriver *driver;
  int status;
  GOptionContext *context;

  GOptionEntry entries[] = {
    { "existing-user", 0, 0, G_OPTION_ARG_NONE, &force_existing_user_mode,
      _("Force existing user mode"), NULL },
    { NULL }
  };

  g_unsetenv ("GIO_USE_VFS");

  context = g_option_context_new (_("- GNOME initial setup"));
  g_option_context_add_main_entries (context, entries, NULL);

  g_option_context_parse (context, &argc, &argv, NULL);

  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

#ifdef HAVE_CHEESE
  cheese_gtk_init (NULL, NULL);
#endif

  gtk_init (&argc, &argv);

#if HAVE_CLUTTER
  if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) {
    g_critical ("Clutter-GTK init failed");
    exit (1);
  }
#endif

  gis_ensure_login_keyring ();

  driver = gis_driver_new (get_mode ());
  g_signal_connect (driver, "rebuild-pages", G_CALLBACK (rebuild_pages_cb), NULL);
  status = g_application_run (G_APPLICATION (driver), argc, argv);

  g_object_unref (driver);
  g_option_context_free (context);
  return status;
}
Exemplo n.º 24
0
static void
do_accept_language_test (void)
{
	const char *orig_language;

	debug_printf (1, "\nAutomatic Accept-Language processing\n");

	orig_language = g_getenv ("LANGUAGE");
	do_one_accept_language_test ("C", "en");
	do_one_accept_language_test ("fr_FR", "fr-fr, fr;q=0.9");
	do_one_accept_language_test ("fr_FR:de:en_US", "fr-fr, fr;q=0.9, de;q=0.8, en-us;q=0.7, en;q=0.6");

	if (orig_language)
		g_setenv ("LANGUAGE", orig_language, TRUE);
	else
		g_unsetenv ("LANGUAGE");
}
Exemplo n.º 25
0
static void *
get_func (const char *func_name)
{
  static void *handle = NULL;
  void *func;
  char *error;

  if (G_UNLIKELY (g_once_init_enter (&handle)))
    {
      void *_handle;

      _handle = dlopen("libgobject-2.0.so.0", RTLD_LAZY);

      if (_handle == NULL)
        g_error ("Failed to open libgobject-2.0.so.0: %s", dlerror ());

      /* set up signal handlers */
      signal (SIGUSR1, _sig_usr1_handler);
      signal (SIGUSR2, _sig_usr2_handler);

      /* set up objects map */
      gobject_list_state.objects = g_hash_table_new (NULL, NULL);
      gobject_list_state.added = g_hash_table_new (NULL, NULL);
      gobject_list_state.removed = g_hash_table_new_full (NULL, NULL, NULL, g_free);

      /* Set up exit handler */
      atexit (_exiting);

      /* Prevent propagation to child processes. */
      if (g_getenv ("GOBJECT_PROPAGATE_LD_PRELOAD") == NULL)
        {
          g_unsetenv ("LD_PRELOAD");
        }

      g_once_init_leave (&handle, _handle);
    }

  func = dlsym (handle, func_name);

  if ((error = dlerror ()) != NULL)
    g_error ("Failed to find symbol: %s", error);

  G_UNLOCK (gobject_list);

  return func;
}
Exemplo n.º 26
0
static void test_govirt_https_ca(void)
{
    OvirtProxy *proxy;
    OvirtApi *api;
    GError *error = NULL;
    GovirtMockHttpd *httpd;

    httpd = govirt_mock_httpd_new(GOVIRT_HTTPS_PORT);
    govirt_mock_httpd_add_request(httpd, "GET", "/ovirt-engine/api", "<api></api>");
    govirt_mock_httpd_start(httpd);

    g_setenv("GOVIRT_NO_SSL_STRICT", "1", TRUE);
    g_test_expect_message("libgovirt", G_LOG_LEVEL_WARNING,
                          "Disabling strict checking of SSL certificates");
    g_test_expect_message("libgovirt", G_LOG_LEVEL_CRITICAL,
                          "ovirt_proxy_set_api_from_xml: assertion 'vms != NULL' failed");
    proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT));
    api = ovirt_proxy_fetch_api(proxy, &error);
    g_test_assert_expected_messages();
    g_assert_nonnull(api);
    g_assert_no_error(error);
    g_object_unref(proxy);
    g_unsetenv("GOVIRT_NO_SSL_STRICT");

    g_test_expect_message("libgovirt", G_LOG_LEVEL_WARNING,
                          "Error while getting collection: Unacceptable TLS certificate");
    proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT));
    api = ovirt_proxy_fetch_api(proxy, &error);
    g_test_assert_expected_messages();
    g_assert_null(api);
    g_assert_error(error, REST_PROXY_ERROR, REST_PROXY_ERROR_SSL);
    g_assert_cmpstr(error->message, ==, "Unacceptable TLS certificate");
    g_clear_error(&error);

    g_test_expect_message("libgovirt", G_LOG_LEVEL_CRITICAL,
                          "ovirt_proxy_set_api_from_xml: assertion 'vms != NULL' failed");
    ovirt_proxy_set_mock_ca(proxy);
    api = ovirt_proxy_fetch_api(proxy, &error);
    g_test_assert_expected_messages();
    g_assert_nonnull(api);
    g_assert_no_error(error);
    g_clear_object(&proxy);

    govirt_mock_httpd_stop(httpd);
}
Exemplo n.º 27
0
static void
cb_child_setup (gpointer user)
{
	const char *lcvars[] = {
		"LC_ALL",
		"LC_MESSAGES",
		"LC_CTYPE",
		"LC_NUMERIC"
	};
	unsigned ui;

	g_unsetenv ("LANG");
	for (ui = 0; ui < G_N_ELEMENTS (lcvars); ui++) {
		const char *v = lcvars[ui];
		if (g_getenv (v))
			g_setenv (v, "C", TRUE);
	}
}
static Suite *
souphttpsrc_suite (void)
{
  TCase *tc_chain, *tc_internet;
  Suite *s;

  /* we don't support exceptions from the proxy, so just unset the environment
   * variable - in case it's set in the test environment it would otherwise
   * prevent us from connecting to localhost (like jenkins.qa.ubuntu.com) */
  g_unsetenv ("http_proxy");

  s = suite_create ("souphttpsrc");
  tc_chain = tcase_create ("general");
  tc_internet = tcase_create ("internet");

  suite_add_tcase (s, tc_chain);
  if (run_server (&http_port, &https_port)) {
    atexit (stop_server);
    tcase_add_test (tc_chain, test_first_buffer_has_offset);
    tcase_add_test (tc_chain, test_redirect_yes);
    tcase_add_test (tc_chain, test_redirect_no);
    tcase_add_test (tc_chain, test_not_found);
    tcase_add_test (tc_chain, test_forbidden);
    tcase_add_test (tc_chain, test_cookies);
    tcase_add_test (tc_chain, test_good_user_basic_auth);
    tcase_add_test (tc_chain, test_bad_user_basic_auth);
    tcase_add_test (tc_chain, test_bad_password_basic_auth);
    tcase_add_test (tc_chain, test_good_user_digest_auth);
    tcase_add_test (tc_chain, test_bad_user_digest_auth);
    tcase_add_test (tc_chain, test_bad_password_digest_auth);

    if (ssl_server != NULL)
      tcase_add_test (tc_chain, test_https);
  } else {
    g_print ("Skipping 12 souphttpsrc tests, couldn't start or connect to "
        "local http server\n");
  }

  suite_add_tcase (s, tc_internet);
  tcase_set_timeout (tc_internet, 250);
  tcase_add_test (tc_internet, test_icy_stream);

  return s;
}
Exemplo n.º 29
0
static void test_expand_evn(void)
{
    /* set environment var for testing expansion */
    g_setenv("VIMB_VAR", "value", true);

    check_expand("$VIMB_VAR", "value");
    check_expand("$VIMB_VAR", "value");
    check_expand("$VIMB_VAR$VIMB_VAR", "valuevalue");
    check_expand("${VIMB_VAR}", "value");
    check_expand("my$VIMB_VAR", "myvalue");
    check_expand("'$VIMB_VAR'", "'value'");
    check_expand("${VIMB_VAR}s ", "values ");

    g_unsetenv("UNKNOWN");

    check_expand("$UNKNOWN", "");
    check_expand("${UNKNOWN}", "");
    check_expand("'$UNKNOWN'", "''");
}
Exemplo n.º 30
0
/* data is here so we can use this as a callback for IPC */
static int
timezone_get_time(const char *timezone, struct tm *tm, double *diff, void *data)
{
    time_t now;
    struct tm *tm_tmp;
#ifdef PRIVATE_TZLIB
    struct state *tzinfo = timezone_load(timezone);

    if(!tzinfo)
        return -1;

    time(&now);
    localsub(&now, 0, tm, tzinfo);
    free(tzinfo);
#else
    const gchar *old_tz;

    /* Store the current TZ value. */
    old_tz = g_getenv("TZ");

    g_setenv("TZ", timezone, TRUE);

    time(&now);
    tm_tmp = localtime(&now);
    *tm = *tm_tmp;              /* Must copy, localtime uses local buffer */

    /* Reset the old TZ value. */
    if (old_tz == NULL)
        g_unsetenv("TZ");
    else
        g_setenv("TZ", old_tz, TRUE);
#endif

    /* Calculate user's localtime, and compare. If same, no output */
    tm_tmp = localtime(&now);

    if (tm_tmp->tm_hour == tm->tm_hour && tm_tmp->tm_min == tm->tm_min)
        return 1;

    *diff = timezone_calc_difference(tm, tm_tmp);
    return 0;
}