Beispiel #1
0
static void
render_init (void)
{
	gchar   	**shortlang = NULL;	/* e.g. "de" */
	gchar		**lang = NULL;		/* e.g. "de_AT" */
	gchar		*filename;

	if (langParams)
		render_parameter_free (langParams);

	/* Install default stylesheet if it does not yet exist */
	filename = common_create_config_filename ("liferea.css");
	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
		common_copy_file (PACKAGE_DATA_DIR "/" PACKAGE "/css/user.css", filename);
	g_free(filename);

	/* Prepare localization parameters */
	debug1 (DEBUG_HTML, "XSLT localisation: setlocale(LC_MESSAGES, NULL) reports '%s'", setlocale(LC_MESSAGES, NULL));
	lang = g_strsplit (setlocale (LC_MESSAGES, NULL), "@", 0);
	shortlang = g_strsplit (setlocale (LC_MESSAGES, NULL), "_", 0);

	langParams = render_parameter_new ();
	render_parameter_add (langParams, "lang='%s'", lang[0]);
	render_parameter_add (langParams, "shortlang='%s'", shortlang[0]);
	debug2 (DEBUG_HTML, "XSLT localisation: lang='%s' shortlang='%s'", lang[0], shortlang[0]);

	g_strfreev (shortlang);
	g_strfreev (lang);

	if (!stylesheets)
		stylesheets = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
}
Beispiel #2
0
static gboolean
liferea_shell_save_accels (gpointer data)
{
	gchar *accels_file = NULL;

	accels_file = common_create_config_filename ("accels");
	gtk_accel_map_save (accels_file);
	g_free (accels_file);
	return FALSE;
}
Beispiel #3
0
void
network_init (void)
{
	gchar		*useragent;
	SoupCookieJar	*cookies;
	gchar		*filename;
	SoupLogger	*logger;

	/* Set an appropriate user agent */
	if (g_getenv ("LANG")) {
		/* e.g. "Liferea/1.10.0 (Linux; de_DE; https://lzone.de/liferea/) AppleWebKit (KHTML, like Gecko)" */
		useragent = g_strdup_printf ("Liferea/%s (%s; %s; %s) AppleWebKit (KHTML, like Gecko)", VERSION, OSNAME, g_getenv ("LANG"), HOMEPAGE);
	} else {
		/* e.g. "Liferea/1.10.0 (Linux; https://lzone.de/liferea/) AppleWebKit (KHTML, like Gecko)" */
		useragent = g_strdup_printf ("Liferea/%s (%s; %s) AppleWebKit (KHTML, like Gecko)", VERSION, OSNAME, HOMEPAGE);
	}

	/* Cookies */
	filename = common_create_config_filename ("cookies.txt");
	cookies = soup_cookie_jar_text_new (filename, FALSE);
	g_free (filename);

	/* Initialize libsoup */
	session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
						 SOUP_SESSION_TIMEOUT, 120,
						 SOUP_SESSION_IDLE_TIMEOUT, 30,
						 SOUP_SESSION_ADD_FEATURE, cookies,
	                                         SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
						 NULL);
	session2 = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
						  SOUP_SESSION_TIMEOUT, 120,
						  SOUP_SESSION_IDLE_TIMEOUT, 30,
						  SOUP_SESSION_ADD_FEATURE, cookies,
	                                          SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
						  SOUP_SESSION_PROXY_URI, NULL,
						  SOUP_SESSION_PROXY_RESOLVER, NULL,
						  NULL);

	/* Only 'session' gets proxy, 'session2' is for non-proxy requests */
	network_set_soup_session_proxy (session, network_get_proxy_detect_mode(),
		network_get_proxy_host (),
		network_get_proxy_port (),
		network_get_proxy_username (),
		network_get_proxy_password ());

	g_signal_connect (session, "authenticate", G_CALLBACK (network_authenticate), NULL);

	/* Soup debugging */
	if (debug_level & DEBUG_NET) {
		logger = soup_logger_new (SOUP_LOGGER_LOG_HEADERS, -1);
		soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
	}

	g_free (useragent);
}
Beispiel #4
0
static void
enclosure_mime_types_load (void)
{
	xmlDocPtr	doc;
	xmlNodePtr	cur;
	encTypePtr	etp;
	gchar		*filename;
	
	typesLoaded = TRUE;
	
	filename = common_create_config_filename ("mime.xml");
	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
		doc = xmlParseFile (filename);
		if (!doc) {
			debug0 (DEBUG_CONF, "could not load enclosure type config file!");
		} else {
			cur = xmlDocGetRootElement (doc);
			if (!cur) {
				g_warning ("could not read root element from enclosure type config file!");
			} else {
				while (cur) {
					if (!xmlIsBlankNode (cur)) {
						if (!xmlStrcmp (cur->name, BAD_CAST"types")) {
							cur = cur->xmlChildrenNode;
							while (cur) {
								if ((!xmlStrcmp (cur->name, BAD_CAST"type"))) {
									etp = g_new0 (struct encType, 1);
									etp->mime = (gchar *) xmlGetProp (cur, BAD_CAST"mime");
									etp->extension = (gchar *) xmlGetProp (cur, BAD_CAST"extension");
									etp->cmd = (gchar *) xmlGetProp (cur, BAD_CAST"cmd");
									etp->permanent = TRUE;
									types = g_slist_append (types, etp);
								}
								cur = cur->next;
							}
							break;
						} else {
							g_warning (_("\"%s\" is not a valid enclosure type config file!"), filename);
						}
					}
					cur = cur->next;
				}
			}
Beispiel #5
0
static void
migrate_from_14plus (const gchar *oldBaseDir, nodePtr node)
{
	GFile *sourceDbFile, *targetDbFile;
	gchar *newConfigDir, *newCacheDir, *newDataDir, *oldCacheDir, *filename;

	g_print("Performing %s -> XDG cache migration...\n", oldBaseDir);	
	
	/* 1.) Close already loaded DB */
	db_deinit ();

	/* 2.) Copy all files */
	newCacheDir	= g_build_filename (g_get_user_cache_dir(), "liferea", NULL);
	newConfigDir	= g_build_filename (g_get_user_config_dir(), "liferea", NULL);
	newDataDir	= g_build_filename (g_get_user_data_dir(), "liferea", NULL);
	oldCacheDir	= g_build_filename (oldBaseDir, "cache", NULL);

	migrate_copy_dir (oldBaseDir, newConfigDir, "");
	migrate_copy_dir (oldCacheDir, newCacheDir, G_DIR_SEPARATOR_S "favicons");
	migrate_copy_dir (oldCacheDir, newCacheDir, G_DIR_SEPARATOR_S "plugins");	

	/* 3.) Move DB to from new config dir to cache dir instead (this is
	       caused by the batch copy in step 2.) */
	sourceDbFile = g_file_new_for_path (g_build_filename (newConfigDir, "liferea.db", NULL));
	targetDbFile = g_file_new_for_path (g_build_filename (newDataDir, "liferea.db", NULL));
	g_file_move (sourceDbFile, targetDbFile, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL);
	g_object_unref (sourceDbFile);
	g_object_unref (targetDbFile);
	
	/* 3.) And reopen the copied DB */
	db_init ();

	/* 4.) Migrate file feed list into DB */
	filename = common_create_config_filename ("feedlist.opml");

	if (!import_OPML_feedlist (filename, node, FALSE, TRUE))
		g_error ("Fatal: Feed list migration failed!");

	g_free (filename);
	g_free (newConfigDir);
	g_free (newCacheDir);
	g_free (oldCacheDir);
}
Beispiel #6
0
static void
liferea_shell_restore_state (const gchar *overrideWindowState)
{
	gchar		*toolbar_style, *accels_file;
	gint		last_vpane_pos, last_hpane_pos, last_wpane_pos;
	gint		resultState;
	
	debug0 (DEBUG_GUI, "Setting toolbar style");
	
	toolbar_style = conf_get_toolbar_style ();	
	liferea_shell_set_toolbar_style (toolbar_style);
	g_free (toolbar_style);

	debug0 (DEBUG_GUI, "Loading accelerators");
	
	accels_file = common_create_config_filename ("accels");
	gtk_accel_map_load (accels_file);
	g_free (accels_file);	

	debug0 (DEBUG_GUI, "Restoring window position");
	
	liferea_shell_restore_position ();

	debug0 (DEBUG_GUI, "Loading pane proportions");
		
	conf_get_int_value (LAST_VPANE_POS, &last_vpane_pos);
	if (last_vpane_pos)
		gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("leftpane")), last_vpane_pos);
	conf_get_int_value (LAST_HPANE_POS, &last_hpane_pos);
	if (last_hpane_pos)
		gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("normalViewPane")), last_hpane_pos);
	conf_get_int_value (LAST_WPANE_POS, &last_wpane_pos);
	if (last_wpane_pos)
		gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("wideViewPane")), last_wpane_pos);

	/* Apply horrible window state parameter logic:
	   -> overrideWindowState provides optional command line flags passed by
	      user or the session manager (prio 1)
	   -> lastState provides last shutdown preference (prio 2)
	 */

	/* Initialize with last saved state */
	conf_get_int_value (LAST_WINDOW_STATE, &resultState);

	/* Override with command line options */
	if (!g_strcmp0 (overrideWindowState, "hidden"))
		resultState = MAINWINDOW_HIDDEN;
	if (!g_strcmp0 (overrideWindowState, "shown"))
		resultState = MAINWINDOW_SHOWN;

	/* And set the window to the resulting state */
	switch (resultState) {
		case MAINWINDOW_HIDDEN:
			debug0 (DEBUG_GUI, "Restoring window state 'hidden (to tray)'");
			/* Realize needed so that the window structure can be
			   accessed... otherwise we get a GTK warning when window is
			   shown by clicking on notification icon or when theme
			   colors are fetched. */
			gtk_widget_realize (GTK_WIDGET (shell->priv->window));
			gtk_widget_hide (GTK_WIDGET (shell->priv->window));
			break;
		case MAINWINDOW_SHOWN:
		default:
			/* Safe default is always to show window */
			debug0 (DEBUG_GUI, "Restoring window state 'shown'");
			gtk_widget_show (GTK_WIDGET (shell->priv->window));
	}
}
Beispiel #7
0
static gchar *
default_source_source_get_feedlist (nodePtr node)
{
	return common_create_config_filename ("feedlist.opml");
}