struct _KatzeNet
{
GObject parent_instance;
-
- guint cache_size;
};
struct _KatzeNetClass
G_OBJECT_CLASS (katze_net_parent_class)->finalize (object);
}
-static KatzeNet*
-katze_net_new (void)
-{
- static KatzeNet* net = NULL;
-
- if (!net)
- {
- net = g_object_new (KATZE_TYPE_NET, NULL);
- /* Since this is a "singleton", keep an extra reference */
- g_object_ref (net);
- }
- else
- g_object_ref (net);
-
- return net;
-}
-
typedef struct
{
KatzeNetStatusCb status_cb;
const gchar* uri,
const gchar* subfolder)
{
- gchar* cache_path;
gchar* checksum;
gchar* extension;
gchar* cached_filename;
gchar* cached_path;
- net = katze_net_new ();
-
- if (subfolder)
- cache_path = g_build_filename (midori_paths_get_cache_dir (), subfolder, NULL);
- else
- cache_path = midori_paths_get_cache_dir ();
- katze_mkdir_with_parents (cache_path, 0700);
checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
-
extension = g_strrstr (uri, ".");
cached_filename = g_strdup_printf ("%s%s", checksum,
extension ? extension : "");
g_free (checksum);
- cached_path = g_build_filename (cache_path, cached_filename, NULL);
- g_free (cached_filename);
+
if (subfolder)
+ {
+ gchar* cache_path = g_build_filename (midori_paths_get_cache_dir (), subfolder, NULL);
+ katze_mkdir_with_parents (cache_path, 0700);
+ cached_path = g_build_filename (cache_path, cached_filename, NULL);
g_free (cache_path);
+ }
+ else
+ cached_path = g_build_filename (midori_paths_get_cache_dir (), cached_filename, NULL);
+
+ g_free (cached_filename);
return cached_path;
}