static void
handle_channels_cb (TpSimpleHandler *handler,
  TpAccount *account,
  TpConnection *connection,
  GList *channels,
  GList *request_satisfied,
  gint64 user_aciton_time,
  TpHandleChannelsContext *handler_context,
  gpointer user_data)
{
  TpChannel *channel = channels->data;
  gchar *path = g_build_filename (
    g_get_user_config_dir (),
    "phoenix",
    "auth",
    NULL);
  GFile *file = g_file_new_for_path (path);
  GFileIOStream *stream;
  GDataInputStream *input = NULL;
  char *password = NULL;
  char *line;

  if (g_list_length (channels) != 1)
    {
      GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
        "Can only handle one channel at a time" };
      tp_handle_channels_context_fail (handler_context,
        &err);
      goto out;
    }

  stream = g_file_open_readwrite (file, NULL, NULL);

  if (stream == NULL)
    {
      GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
        "No authenication data stored" };
      tp_handle_channels_context_fail (handler_context,
        &err);
      goto out;
    }

  input = g_data_input_stream_new (
    g_io_stream_get_input_stream (G_IO_STREAM (stream)));
  while ((line = g_data_input_stream_read_line_utf8 (input, NULL, NULL, NULL))
      != NULL)
    {
      gchar **r = g_strsplit (line, " ", 2);
      if (r[0] == NULL || r[1] == NULL)
        continue;

      if (!tp_strdiff (r[0], tp_account_get_path_suffix (account)))
        {
          password = g_strdup (r[1]);
          printf ("Found password: %s\n", password);
          g_strfreev(r);
          break;
        }
      g_strfreev(r);
    }
  g_object_unref (input);

  if (password == NULL)
    {
      GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
        "No authenication data stored for this account" };
      tp_handle_channels_context_fail (handler_context,
        &err);
      goto out;
    }

  tp_handle_channels_context_accept (handler_context);

  tp_cli_channel_interface_sasl_authentication_connect_to_sasl_status_changed
    (channel, sasl_status_changed_cb, NULL, NULL, NULL, NULL);
  provide_password (channel, password);

out:
  g_free (path);
  g_free (password);
}
Ejemplo n.º 2
0
void
gmameui_init (void)
{
	gchar *filename;
#ifdef ENABLE_JOYSTICK
	gboolean usejoyingui;
#endif
	
#ifdef ENABLE_DEBUG
	GTimer *mytimer;

	mytimer = g_timer_new ();
	g_timer_start (mytimer);
#endif

	/* FIXME TODO Move to mame_options_init () */
	filename = g_build_filename (g_get_user_config_dir (), "gmameui", "options", NULL);
	if (!g_file_test (filename, G_FILE_TEST_IS_DIR)) {
		GMAMEUI_DEBUG ("no options directory creating one");
		g_mkdir (filename, S_IRWXU);
	}
	g_free (filename);

	GMAMEUI_DEBUG (_("Initialising list of possible MAME executable options"));
	xmame_options_init ();
	
	GMAMEUI_DEBUG (_("Initialising MAME executables"));
	main_gui.exec_list = mame_exec_list_new ();
	
	/* Load GUI preferences */
	main_gui.gui_prefs = mame_gui_prefs_new ();

	/* Set the MAME executable list */
	GValueArray *va_exec_paths;
	gchar *mame_executable = NULL;
	guint i;
	g_object_get (main_gui.gui_prefs,
		      "executable-paths", &va_exec_paths,
		      "current-executable", &mame_executable,
		      NULL);
	for (i = 0; i < va_exec_paths->n_values; i++) {
		GMAMEUI_DEBUG (_("Adding executable from preferences file: %s"),
			       g_value_get_string (g_value_array_get_nth (va_exec_paths, i)));
		
		MameExec *exec = mame_exec_new_from_path (g_value_get_string (g_value_array_get_nth (va_exec_paths, i)));
		mame_exec_list_add (main_gui.exec_list, exec);
		
		// FIXME TODO Unref the exec
	}
	g_value_array_free (va_exec_paths);
	
	if (mame_executable) {
		GMAMEUI_DEBUG ("Adding executable that was specified previously as %s", mame_executable);
		mame_exec_list_set_current_executable (main_gui.exec_list,
						       mame_exec_list_get_exec_by_path (main_gui.exec_list, mame_executable));
		g_free (mame_executable);
	} else if (mame_exec_list_size (main_gui.exec_list) > 0) {
		/* Only set a default executable if there are available ones to choose from */
		GMAMEUI_DEBUG ("Adding default executable in position 0");
		mame_exec_list_set_current_executable (main_gui.exec_list,
						       mame_exec_list_nth (main_gui.exec_list, 0));
	}

#ifdef ENABLE_DEBUG
g_message (_("Time to initialise: %.02f seconds"), g_timer_elapsed (mytimer, NULL));
#endif

	/* Create a new audit object */
	gui_prefs.audit = gmameui_audit_new ();

	/* Create a new IO Handler object */
	gui_prefs.io_handler = gmameui_io_handler_new ();

	/* Create a new romset fix list */
	gui_prefs.fixes = gmameui_romfix_list_new ();
	
	/* Initialise the gamelist */
	gui_prefs.gl = mame_gamelist_new ();
#ifdef ENABLE_DEBUG
	g_timer_stop (mytimer);
	g_message (_("Time to initialise GMAMEUI: %.02f seconds"), g_timer_elapsed (mytimer, NULL));
	g_timer_destroy (mytimer);
#endif

#ifdef ENABLE_JOYSTICK
	gchar *joystick_device;
	
	g_object_get (main_gui.gui_prefs,
		      "usejoyingui", &usejoyingui,
		      "joystick-name", &joystick_device,
		      NULL);
	if (usejoyingui) {
		joydata = joystick_new (joystick_device);

		if (joydata)
			g_message (_("Joystick %s found"), joydata->device_name);
		else
			g_message (_("No Joystick found"));
	}
	
	g_free (joystick_device);
#endif
	/* doesn't matter if joystick is enabled or not but easier to handle after */
	joy_focus_on ();

}
Ejemplo n.º 3
0
Preferences* preferences_construct (GType object_type, IBusConfig* config) {
	Preferences * self = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* dictionaries;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	GeeMap* _tmp4_;
	gint _tmp5_ = 0;
	gpointer* _tmp6_ = NULL;
	gchar** _tmp7_;
	gint _tmp7__length1;
	GVariant* _tmp8_;
	GVariant* _tmp9_;
	GeeMap* _tmp10_;
	GVariant* _tmp11_;
	GVariant* _tmp12_;
	GeeMap* _tmp13_;
	GVariant* _tmp14_;
	GVariant* _tmp15_;
	GeeMap* _tmp16_;
	GVariant* _tmp17_;
	GVariant* _tmp18_;
	GeeMap* _tmp19_;
	GVariant* _tmp20_;
	GVariant* _tmp21_;
	GeeMap* _tmp22_;
	GVariant* _tmp23_;
	GVariant* _tmp24_;
	GeeMap* _tmp25_;
	GVariant* _tmp26_;
	GVariant* _tmp27_;
	GeeMap* _tmp28_;
	GVariant* _tmp29_;
	GVariant* _tmp30_;
	GeeMap* _tmp31_;
	GVariant* _tmp32_;
	GVariant* _tmp33_;
	IBusConfig* _tmp34_;
	IBusConfig* _tmp35_;
	IBusConfig* _tmp36_;
	g_return_val_if_fail (config != NULL, NULL);
	self = (Preferences*) g_object_new (object_type, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
	dictionaries = _tmp0_;
	_tmp1_ = g_get_user_config_dir ();
	_tmp2_ = g_strdup_printf ("type=file,file=%s/ibus-skk/user.dict,mode=readwrite", _tmp1_);
	_tmp3_ = _tmp2_;
	gee_abstract_collection_add ((GeeAbstractCollection*) dictionaries, _tmp3_);
	_g_free0 (_tmp3_);
	gee_abstract_collection_add ((GeeAbstractCollection*) dictionaries, "type=file,file=/usr/share/skk/SKK-JISYO.L,mode=readonly");
	gee_abstract_collection_add ((GeeAbstractCollection*) dictionaries, "type=server,host=localhost,port=1178");
	_tmp4_ = self->priv->_default;
	_tmp6_ = gee_abstract_collection_to_array ((GeeAbstractCollection*) dictionaries, &_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp7__length1 = _tmp5_;
	_tmp8_ = g_variant_new_strv (_tmp7_, _tmp5_);
	_tmp9_ = g_variant_ref_sink (_tmp8_);
	gee_map_set (_tmp4_, "dictionaries", _tmp9_);
	_g_variant_unref0 (_tmp9_);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_tmp10_ = self->priv->_default;
	_tmp11_ = g_variant_new_strv (PREFERENCES_AUTO_START_HENKAN_KEYWORDS, G_N_ELEMENTS (PREFERENCES_AUTO_START_HENKAN_KEYWORDS));
	_tmp12_ = g_variant_ref_sink (_tmp11_);
	gee_map_set (_tmp10_, "auto_start_henkan_keywords", _tmp12_);
	_g_variant_unref0 (_tmp12_);
	_tmp13_ = self->priv->_default;
	_tmp14_ = g_variant_new_int32 ((gint32) SKK_PERIOD_STYLE_JA_JA);
	_tmp15_ = g_variant_ref_sink (_tmp14_);
	gee_map_set (_tmp13_, "period_style", _tmp15_);
	_g_variant_unref0 (_tmp15_);
	_tmp16_ = self->priv->_default;
	_tmp17_ = g_variant_new_int32 ((gint32) 7);
	_tmp18_ = g_variant_ref_sink (_tmp17_);
	gee_map_set (_tmp16_, "page_size", _tmp18_);
	_g_variant_unref0 (_tmp18_);
	_tmp19_ = self->priv->_default;
	_tmp20_ = g_variant_new_int32 ((gint32) 4);
	_tmp21_ = g_variant_ref_sink (_tmp20_);
	gee_map_set (_tmp19_, "pagination_start", _tmp21_);
	_g_variant_unref0 (_tmp21_);
	_tmp22_ = self->priv->_default;
	_tmp23_ = g_variant_new_boolean (TRUE);
	_tmp24_ = g_variant_ref_sink (_tmp23_);
	gee_map_set (_tmp22_, "show_annotation", _tmp24_);
	_g_variant_unref0 (_tmp24_);
	_tmp25_ = self->priv->_default;
	_tmp26_ = g_variant_new_int32 ((gint32) SKK_INPUT_MODE_HIRAGANA);
	_tmp27_ = g_variant_ref_sink (_tmp26_);
	gee_map_set (_tmp25_, "initial_input_mode", _tmp27_);
	_g_variant_unref0 (_tmp27_);
	_tmp28_ = self->priv->_default;
	_tmp29_ = g_variant_new_boolean (FALSE);
	_tmp30_ = g_variant_ref_sink (_tmp29_);
	gee_map_set (_tmp28_, "egg_like_newline", _tmp30_);
	_g_variant_unref0 (_tmp30_);
	_tmp31_ = self->priv->_default;
	_tmp32_ = g_variant_new_string ("default");
	_tmp33_ = g_variant_ref_sink (_tmp32_);
	gee_map_set (_tmp31_, "typing_rule", _tmp33_);
	_g_variant_unref0 (_tmp33_);
	_tmp34_ = config;
	_tmp35_ = _g_object_ref0 (_tmp34_);
	_g_object_unref0 (self->priv->config);
	self->priv->config = _tmp35_;
	preferences_load (self);
	_tmp36_ = config;
	g_signal_connect_object (_tmp36_, "value-changed", (GCallback) _preferences_value_changed_cb_ibus_config_value_changed, self, 0);
	_g_object_unref0 (dictionaries);
	return self;
}
Ejemplo n.º 4
0
void save_app_config(GKeyFile* key, const char* name)
{
    char* path = g_build_filename(g_get_user_config_dir(), name, NULL);
    save_key_file(key, path);
    g_free(path);
}
Ejemplo n.º 5
0
static char* panel_launcher_get_personal_path(void)
{
		return g_build_filename(g_get_user_config_dir(), "mate", "panel2.d", "default", "launchers", NULL);
}
Ejemplo n.º 6
0
static gchar *config_file_name(void)
{
  return g_strdup_printf("%s/%s", g_get_user_config_dir(), "etherape");
}