Index: src/cheese-fileutil.c =================================================================== --- src/cheese-fileutil.c (revision 997) +++ src/cheese-fileutil.c (working copy) @@ -79,6 +79,12 @@ } gchar * +cheese_fileutil_get_path_before_224 (CheeseFileUtil *fileutil) +{ + return g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2", "cheese", "media", NULL); +} + +gchar * cheese_fileutil_get_log_path (CheeseFileUtil *fileutil) { CheeseFileUtilPrivate *priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil); @@ -177,41 +183,37 @@ CheeseFileUtilPrivate *priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil); CheeseGConf *gconf; - gchar *v_path, *p_path; gconf = cheese_gconf_new (); - /* get the path from gconf, xdg or hardcoded */ - g_object_get (gconf, "gconf_prop_video_path", &v_path, NULL); + g_object_get (gconf, "gconf_prop_video_path", &priv->video_path, NULL); + g_object_get (gconf, "gconf_prop_photo_path", &priv->photo_path, NULL); - if (!v_path || strcmp (v_path, "") == 0) + /* get the video path from gconf, xdg or hardcoded */ + if (!priv->video_path || strcmp (priv->video_path, "") == 0) { /* get xdg */ - v_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS), "Webcam", NULL); - if (strcmp (v_path, "") == 0) + priv->video_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS), "Webcam", NULL); + if (strcmp (priv->video_path, "") == 0) { /* get "~/.gnome2/cheese/media" */ - - v_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2", "cheese", "media", NULL); + priv->video_path = cheese_fileutil_get_path_before_224 (fileutil); } } - priv->video_path = v_path; - /* get the path from gconf, xdg or hardcoded */ - g_object_get (gconf, "gconf_prop_photo_path", &p_path, NULL); - - if (!p_path || strcmp (p_path, "") == 0) + /* get the photo path from gconf, xdg or hardcoded */ + if (!priv->photo_path || strcmp (priv->photo_path, "") == 0) { /* get xdg */ - p_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), "Webcam", NULL); - if (strcmp (p_path, "") == 0) + priv->photo_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), "Webcam", NULL); + if (strcmp (priv->photo_path, "") == 0) { /* get "~/.gnome2/cheese/media" */ - p_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2", "cheese", "media", NULL); + priv->photo_path = cheese_fileutil_get_path_before_224 (fileutil); } } - priv->photo_path = p_path; + /* FIXME: use the xdg log path */ priv->log_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2", "cheese", NULL); g_object_unref (gconf); Index: src/cheese-fileutil.h =================================================================== --- src/cheese-fileutil.h (revision 997) +++ src/cheese-fileutil.h (working copy) @@ -58,6 +58,7 @@ gchar *cheese_fileutil_get_video_path (CheeseFileUtil *fileutil); gchar *cheese_fileutil_get_photo_path (CheeseFileUtil *fileutil); +gchar *cheese_fileutil_get_path_before_224 (CheeseFileUtil *fileutil); gchar *cheese_fileutil_get_log_path (CheeseFileUtil *fileutil); gchar *cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMode mode); Index: src/cheese.c =================================================================== --- src/cheese.c (revision 998) +++ src/cheese.c (working copy) @@ -49,7 +49,6 @@ CheeseFileUtil *fileutil = cheese_fileutil_new (); - if (fp == NULL) { path = cheese_fileutil_get_log_path (fileutil); @@ -85,6 +84,75 @@ fprintf (stdout, "%s", string); } +void +cheese_handle_files_from_before_224 (void) +{ + CheeseFileUtil *fileutil = cheese_fileutil_new (); + gchar *photo_path = cheese_fileutil_get_photo_path (fileutil); + gchar *video_path = cheese_fileutil_get_video_path (fileutil); + gchar *path_from_before_224 = cheese_fileutil_get_path_before_224 (fileutil); + GDir *dir_from_before_224; + gchar *source_filename, *target_filename; + const char *name; + GFile *source, *target; + + if (g_file_test (path_from_before_224, G_FILE_TEST_IS_DIR) && + (g_strcmp0 (video_path, path_from_before_224) != 0) && + (g_strcmp0 (photo_path, path_from_before_224) != 0)) + { + dir_from_before_224 = g_dir_open (path_from_before_224, 0, NULL); + + while ((name = g_dir_read_name (dir_from_before_224))) + { + /* the filenames from before 2.24 have different namings than the > 2.24 + * files (0042.jpg/ogg vs. 2008-09-09-015555.jpg/ogv) so we just copy and + * rename the ogg files to ogv + */ + if (g_str_has_suffix (name, VIDEO_NAME_SUFFIX)) + { + target_filename = g_build_filename (video_path, name, NULL); + } + else if (g_str_has_suffix (name, ".ogg")) + { + gchar *filename = g_strdup (name); + gchar *extension = g_strrstr (filename, ".ogg"); + extension[3] = 'v'; + target_filename = g_build_filename (video_path, filename, NULL); + g_free (filename); + } + else if (g_str_has_suffix (name, PHOTO_NAME_SUFFIX)) + { + target_filename = g_build_filename (photo_path, name, NULL); + } + else + { + continue; + } + + source_filename = g_build_filename (path_from_before_224, name, NULL); + source = g_file_new_for_path (source_filename); + target = g_file_new_for_path (target_filename); + printf ("copying %s to %s\n", source_filename, target_filename); + g_file_move (source, target, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); + g_free (source_filename); + g_free (target_filename); + g_object_unref (source); + g_object_unref (target); + } + + g_dir_close (dir_from_before_224); + + target = g_file_new_for_path (path_from_before_224); + g_file_delete (target, NULL, NULL); + g_object_unref (target); + + } + g_free (video_path); + g_free (photo_path); + g_free (path_from_before_224); + //g_object_unref (fileutil); +} + int main (int argc, char **argv) { @@ -133,6 +201,7 @@ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), APPNAME_DATA_DIR G_DIR_SEPARATOR_S "icons"); + cheese_handle_files_from_before_224 (); cheese_window_init (CheeseOptions.hal_device_id, dbus_server); gdk_threads_enter ();