Author: post
Date: 2012-08-25 12:35:48 +0200 (Sat, 25 Aug 2012)
New Revision: 4269
Modified:
trunk/librawstudio/rs-profile-camera.c
trunk/librawstudio/rs-profile-camera.h
trunk/librawstudio/rs-profile-factory.c
trunk/librawstudio/rs-profile-factory.h
trunk/plugins/meta-tiff/tiff-meta.c
trunk/src/rs-photo.c
Log:
Make DCP profile retrival (and fallback) part of the profile factory to avoid
different implementations. Usage is simpler - give make+model and you will
receive a list of profiles, including profiles found via fallback.
Modified: trunk/librawstudio/rs-profile-camera.c
===================================================================
--- trunk/librawstudio/rs-profile-camera.c 2012-08-25 10:16:19 UTC (rev
4268)
+++ trunk/librawstudio/rs-profile-camera.c 2012-08-25 10:35:48 UTC (rev
4269)
@@ -23,8 +23,8 @@
#include <libxml/xmlwriter.h>
#include "rs-utils.h"
-const gchar *
-rs_profile_camera_find(gchar *make, gchar *model)
+gchar *
+rs_profile_camera_find(const gchar *make, const gchar *model)
{
static gchar *last_make = NULL;
static gchar *last_model = NULL;
@@ -95,7 +95,7 @@
{
xmlFree(xml_make);
xmlFree(xml_model);
- const gchar *unique_id
= g_strdup((gchar *) xml_unique_id);
+ gchar *unique_id =
g_strdup((gchar *) xml_unique_id);
xmlFree(xml_unique_id);
xmlFree(doc);
last_id =
g_strdup(unique_id);
Modified: trunk/librawstudio/rs-profile-camera.h
===================================================================
--- trunk/librawstudio/rs-profile-camera.h 2012-08-25 10:16:19 UTC (rev
4268)
+++ trunk/librawstudio/rs-profile-camera.h 2012-08-25 10:35:48 UTC (rev
4269)
@@ -26,6 +26,7 @@
const gchar *unique_id;
} rs_profile_camera;
-const gchar * rs_profile_camera_find(gchar *make, gchar *model);
+/* The returned gchar* must be freed by the caller */
+gchar * rs_profile_camera_find(const gchar *make, const gchar *model);
#endif /* RS_PROFILE_CAMERA_H */
Modified: trunk/librawstudio/rs-profile-factory.c
===================================================================
--- trunk/librawstudio/rs-profile-factory.c 2012-08-25 10:16:19 UTC (rev
4268)
+++ trunk/librawstudio/rs-profile-factory.c 2012-08-25 10:35:48 UTC (rev
4269)
@@ -22,6 +22,7 @@
#include "rs-profile-factory-model.h"
#include "config.h"
#include "rs-utils.h"
+#include "rs-profile-camera.h"
#define PROFILE_FACTORY_DEFAULT_SEARCH_PATH PACKAGE_DATA_DIR G_DIR_SEPARATOR_S
PACKAGE G_DIR_SEPARATOR_S "profiles" G_DIR_SEPARATOR_S
@@ -309,10 +310,31 @@
}
GSList *
-rs_profile_factory_find_from_model(RSProfileFactory *factory, const gchar *id)
+rs_profile_factory_find_from_model(RSProfileFactory *factory, const gchar
*make, const gchar *model)
{
g_assert(RS_IS_PROFILE_FACTORY(factory));
- return rs_profile_factory_find_from_column(factory, id,
FACTORY_MODEL_COLUMN_MODEL);
+ if (!model)
+ return NULL;
+
+ gchar* unique_id = NULL;
+
+ if (make && model)
+ unique_id = g_strdup(rs_profile_camera_find(make, model));
+
+ if (!unique_id)
+ unique_id = g_strdup(model);
+
+ GSList *profiles = rs_profile_factory_find_from_column(factory,
unique_id, FACTORY_MODEL_COLUMN_MODEL);
+
+ if (g_slist_length(profiles) == 0 && NULL != make)
+ {
+ /* Try combining make+model */
+ g_free(unique_id);
+ unique_id = g_strjoin(" ", make, model, NULL);
+ profiles = rs_profile_factory_find_from_column(factory,
unique_id, FACTORY_MODEL_COLUMN_MODEL);
+ }
+ g_free(unique_id);
+ return profiles;
}
Modified: trunk/librawstudio/rs-profile-factory.h
===================================================================
--- trunk/librawstudio/rs-profile-factory.h 2012-08-25 10:16:19 UTC (rev
4268)
+++ trunk/librawstudio/rs-profile-factory.h 2012-08-25 10:35:48 UTC (rev
4269)
@@ -69,7 +69,7 @@
RSIccProfile *rs_profile_factory_find_icc_from_filename(RSProfileFactory
*factory, const gchar *path);
-GSList *rs_profile_factory_find_from_model(RSProfileFactory *factory, const
gchar *id);
+GSList *rs_profile_factory_find_from_model(RSProfileFactory *factory, const
gchar *make, const gchar *model);
void rs_profile_factory_set_embedded_profile(RSProfileFactory *factory, const
RSIccProfile *profile);
Modified: trunk/plugins/meta-tiff/tiff-meta.c
===================================================================
--- trunk/plugins/meta-tiff/tiff-meta.c 2012-08-25 10:16:19 UTC (rev 4268)
+++ trunk/plugins/meta-tiff/tiff-meta.c 2012-08-25 10:35:48 UTC (rev 4269)
@@ -1990,23 +1990,18 @@
g_object_set(finput, "filename", service, NULL);
/* Find a dcp profile */
- const gchar* camera_id = rs_profile_camera_find(meta->make_ascii,
meta->model_ascii);
RSDcpFile *dcp = NULL;
- if (camera_id)
+ RSProfileFactory *factory = rs_profile_factory_new_default();
+ GSList *all_profiles = rs_profile_factory_find_from_model(factory,
meta->make_ascii, meta->model_ascii);
+ if (g_slist_length(all_profiles) > 0)
{
- RSProfileFactory *factory = rs_profile_factory_new_default();
- GSList *all_profiles =
rs_profile_factory_find_from_model(factory, camera_id);
- if (g_slist_length(all_profiles) > 0)
- {
- GSList *profiles_i = all_profiles;
- do {
- if (profiles_i->data &&
RS_IS_DCP_FILE(profiles_i->data))
- dcp = RS_DCP_FILE(profiles_i->data);
- profiles_i = profiles_i->next;
- } while (NULL == dcp && profiles_i);
-
- g_slist_free(all_profiles);
- }
+ GSList *profiles_i = all_profiles;
+ do {
+ if (profiles_i->data &&
RS_IS_DCP_FILE(profiles_i->data))
+ dcp = RS_DCP_FILE(profiles_i->data);
+ profiles_i = profiles_i->next;
+ } while (NULL == dcp && profiles_i);
+ g_slist_free(all_profiles);
}
if (NULL != dcp)
Modified: trunk/src/rs-photo.c
===================================================================
--- trunk/src/rs-photo.c 2012-08-25 10:16:19 UTC (rev 4268)
+++ trunk/src/rs-photo.c 2012-08-25 10:35:48 UTC (rev 4269)
@@ -23,7 +23,6 @@
#include "rs-cache.h"
#include "rs-camera-db.h"
#include "rs-profile-factory.h"
-#include "rs-profile-camera.h"
static void rs_photo_class_init (RS_PHOTOClass *klass);
@@ -822,16 +821,7 @@
if (!photo->dcp && !photo->icc && !photo->embedded_profile &&
photo->metadata && photo->metadata->model_ascii)
{
RSProfileFactory *factory =
rs_profile_factory_new_default();
- const gchar* unique_id = NULL;
-
- if (photo->metadata->make_ascii)
- unique_id =
rs_profile_camera_find(photo->metadata->make_ascii,
photo->metadata->model_ascii);
-
- if (!unique_id)
- unique_id =
g_strdup(photo->metadata->model_ascii);
-
- GSList *profiles =
rs_profile_factory_find_from_model(factory, unique_id);
-
+ GSList *profiles =
rs_profile_factory_find_from_model(factory, photo->metadata->make_ascii,
photo->metadata->model_ascii);
/* Select alphabetically first profile */
if (g_slist_length(profiles) > 0)
{
@@ -849,7 +839,6 @@
} while (i != NULL);
g_slist_free(profiles);
}
- g_free((void*)unique_id);
}
}
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit