[frogr] Renamed FspLocation to FspDataLocation.



commit 709f9f90bf41cc44ba2a75d235fd4b252609a511
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Sun Aug 14 19:20:36 2011 +0200

    Renamed FspLocation to FspDataLocation.
    
    Also implemented the fsp_data_new, fsp_data_copy and fsp_data_free
    functions, and updated callers, allocations and frees as well.

 src/flicksoup/fsp-data.c    |   22 +++++++++++++++++++++-
 src/flicksoup/fsp-data.h    |   20 +++++++++++++-------
 src/flicksoup/fsp-session.c |    2 +-
 src/flicksoup/fsp-session.h |    2 +-
 src/frogr-controller.c      |    4 ++--
 src/frogr-picture-loader.c  |   15 +++++++--------
 src/frogr-picture.c         |    9 +++++----
 src/frogr-picture.h         |    4 ++--
 8 files changed, 52 insertions(+), 26 deletions(-)
---
diff --git a/src/flicksoup/fsp-data.c b/src/flicksoup/fsp-data.c
index d6742d5..aea0414 100644
--- a/src/flicksoup/fsp-data.c
+++ b/src/flicksoup/fsp-data.c
@@ -99,6 +99,13 @@ fsp_data_new                            (FspDataType type)
       new_data->group.n_photos = -1;
       break;
 
+    case FSP_LOCATION:
+      new_data->location.latitude = 0.0;
+      new_data->location.longitude = 0.0;
+      new_data->location.accuracy = 16;
+      new_data->location.context = FSP_LOCATION_CONTEXT_UNKNOWN;
+      break;
+
     default:
       break;
     }
@@ -174,6 +181,13 @@ fsp_data_copy                           (const FspData *data)
       new_data->group.n_photos = data->group.n_photos;
       break;
 
+    case FSP_LOCATION:
+      new_data->location.latitude = data->location.latitude;
+      new_data->location.longitude = data->location.longitude;
+      new_data->location.accuracy = data->location.accuracy;
+      new_data->location.context = data->location.context;
+      break;
+
     default:
       break;
     }
@@ -184,7 +198,9 @@ fsp_data_copy                           (const FspData *data)
 void
 fsp_data_free                           (FspData *data)
 {
-  g_return_if_fail (data != NULL);
+  /* Do nothing if passed NULL */
+  if (data == NULL)
+    return;
 
   switch (data->type)
     {
@@ -224,6 +240,10 @@ fsp_data_free                           (FspData *data)
       g_free (data->group.name);
       break;
 
+    case FSP_LOCATION:
+      /* Nothing to do here (no memory allocated) */
+      break;
+
     default:
       break;
     }
diff --git a/src/flicksoup/fsp-data.h b/src/flicksoup/fsp-data.h
index ad2fd15..bbf9873 100644
--- a/src/flicksoup/fsp-data.h
+++ b/src/flicksoup/fsp-data.h
@@ -32,12 +32,14 @@ G_BEGIN_DECLS
 #define FSP_DATA_PHOTO_INFO(data)    ((FspDataPhotoInfo*) data)
 #define FSP_DATA_PHOTO_SET(data)     ((FspDataPhotoSet*) data)
 #define FSP_DATA_GROUP(data)         ((FspDataGroup*) data)
+#define FSP_DATA_LOCATION(data)      ((FspDataLocation*) data)
 
 typedef struct _FspDataAuthToken    FspDataAuthToken;
 typedef struct _FspDataUploadStatus FspDataUploadStatus;
 typedef struct _FspDataPhotoInfo    FspDataPhotoInfo;
 typedef struct _FspDataPhotoSet     FspDataPhotoSet;
 typedef struct _FspDataGroup        FspDataGroup;
+typedef struct _FspDataLocation     FspDataLocation;
 
 typedef union  _FspData	    FspData;
 
@@ -49,6 +51,7 @@ typedef enum
   FSP_PHOTO_INFO    = 2,
   FSP_PHOTO_SET     = 3,
   FSP_GROUP         = 4,
+  FSP_LOCATION      = 5,
   FSP_DATA_LAST
 } FspDataType;
 
@@ -101,13 +104,6 @@ typedef enum {
   FSP_LOCATION_CONTEXT_OUTDOORS   = 2
 } FspLocationContext;
 
-typedef struct {
-    gdouble latitude;
-    gdouble longitude;
-    unsigned char accuracy;
-    FspLocationContext context;
-} FspLocation;
-
 typedef enum {
   FSP_ROTATION_NONE = 0,
   FSP_ROTATION_90   = 90,
@@ -197,6 +193,15 @@ struct _FspDataGroup
   gint             n_photos;
 };
 
+struct _FspDataLocation {
+  FspDataType        type;
+  gdouble            latitude;
+  gdouble            longitude;
+  gushort            accuracy;
+  FspLocationContext context;
+};
+
+
 union _FspData
 {
   FspDataType         type;
@@ -205,6 +210,7 @@ union _FspData
   FspDataPhotoInfo    photo_info;
   FspDataPhotoSet     photo_set;
   FspDataGroup        group;
+  FspDataLocation     location;
 };
 
 GType
diff --git a/src/flicksoup/fsp-session.c b/src/flicksoup/fsp-session.c
index d51af16..beab2eb 100644
--- a/src/flicksoup/fsp-session.c
+++ b/src/flicksoup/fsp-session.c
@@ -2190,7 +2190,7 @@ fsp_session_set_license_finish          (FspSession    *self,
 void
 fsp_session_set_location_async           (FspSession          *self,
                                           const gchar         *photo_id,
-                                          FspLocation         *location,
+                                          FspDataLocation     *location,
                                           GCancellable        *cancellable,
                                           GAsyncReadyCallback  callback,
                                           gpointer             data)
diff --git a/src/flicksoup/fsp-session.h b/src/flicksoup/fsp-session.h
index 4fc86d8..7bcba04 100644
--- a/src/flicksoup/fsp-session.h
+++ b/src/flicksoup/fsp-session.h
@@ -244,7 +244,7 @@ fsp_session_set_license_finish          (FspSession    *self,
 void
 fsp_session_set_location_async           (FspSession          *self,
                                           const gchar         *photo_id,
-                                          FspLocation         *location,
+                                          FspDataLocation     *location,
                                           GCancellable        *cancellable,
                                           GAsyncReadyCallback  callback,
                                           gpointer             data);
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index e5962d7..6108f3d 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -721,7 +721,7 @@ _set_location_on_idle (gpointer data)
   FrogrController *controller = NULL;
   FrogrControllerPrivate *priv = NULL;
   FrogrPicture *picture = NULL;
-  FspLocation *location;
+  FspDataLocation *location;
 
   up_st = (upload_picture_st*) data;
   controller = up_st->controller;
@@ -1095,7 +1095,7 @@ _notify_setting_location (FrogrController *self,
 {
   FrogrControllerPrivate *priv = NULL;
   const gchar *picture_title = NULL;
-  FspLocation *location;
+  FspDataLocation *location;
   gchar *debug_msg = NULL;
 
   priv = FROGR_CONTROLLER_GET_PRIVATE (self);
diff --git a/src/frogr-picture-loader.c b/src/frogr-picture-loader.c
index 1824a6d..b9c7016 100644
--- a/src/frogr-picture-loader.c
+++ b/src/frogr-picture-loader.c
@@ -64,7 +64,7 @@ struct _FrogrPictureLoaderPrivate
   FspLicense license;
   FspSafetyLevel safety_level;
   FspContentType content_type;
-  FspLocation *location;
+  FspDataLocation *location;
 
   FrogrPictureLoadedCallback picture_loaded_cb;
   FrogrPicturesLoadedCallback pictures_loaded_cb;
@@ -246,10 +246,9 @@ get_gps_coordinate (ExifData *exif,
   return FALSE;
 }
 
-FspLocation *get_location_from_exif (ExifData *exif_data)
+FspDataLocation *get_location_from_exif (ExifData *exif_data)
 {
-    ExifEntry *exif_entry;
-    FspLocation *location;
+    FspDataLocation *location;
     gdouble coordinate;
     gboolean found;
 
@@ -260,14 +259,14 @@ FspLocation *get_location_from_exif (ExifData *exif_data)
     if (!found)
       return NULL;
 
-    location = g_new0 (FspLocation, 1);
+    location = FSP_DATA_LOCATION (fsp_data_new (FSP_LOCATION));
     location->latitude = coordinate;
 
     found = get_gps_coordinate (exif_data, EXIF_TAG_GPS_LONGITUDE,
                                 EXIF_TAG_GPS_LONGITUDE_REF, &location->longitude);
     if (!found)
       {
-        g_free (location);
+        fsp_data_free (FSP_DATA (location));
         return NULL;
       }
 
@@ -371,7 +370,7 @@ _load_next_picture_cb (GObject *object,
           exif_data = exif_loader_get_data (exif_loader);
           if (exif_data)
             {
-              FspLocation *location;
+              FspDataLocation *location;
 
               exif_entry = exif_data_get_entry (exif_data, EXIF_TAG_DATE_TIME);
               if (exif_entry)
@@ -488,7 +487,7 @@ _frogr_picture_loader_finalize (GObject* object)
   /* Free */
   g_slist_foreach (priv->file_uris, (GFunc)g_free, NULL);
   g_slist_free (priv->file_uris);
-  g_free (priv->location);
+  fsp_data_free (FSP_DATA (priv->location));
 
   G_OBJECT_CLASS (frogr_picture_loader_parent_class)->finalize(object);
 }
diff --git a/src/frogr-picture.c b/src/frogr-picture.c
index 83820ee..bc39ba3 100644
--- a/src/frogr-picture.c
+++ b/src/frogr-picture.c
@@ -53,7 +53,7 @@ struct _FrogrPicturePrivate
   FspSafetyLevel safety_level;
   FspContentType content_type;
   FspLicense license;
-  FspLocation *location;
+  FspDataLocation *location;
   gboolean show_in_search;
 
   GdkPixbuf *pixbuf;
@@ -349,7 +349,7 @@ _frogr_picture_finalize (GObject* object)
   g_slist_free (priv->tags_list);
 
   /* free structs */
-  g_free (priv->location);
+  fsp_data_free (FSP_DATA (priv->location));
 
   /* call super class */
   G_OBJECT_CLASS (frogr_picture_parent_class)->finalize(object);
@@ -848,7 +848,7 @@ frogr_picture_set_license (FrogrPicture *self, FspLicense license)
   priv->license = license;
 }
 
-FspLocation *
+FspDataLocation *
 frogr_picture_get_location (FrogrPicture *self)
 {
   FrogrPicturePrivate *priv = NULL;
@@ -860,13 +860,14 @@ frogr_picture_get_location (FrogrPicture *self)
 }
 
 void
-frogr_picture_set_location (FrogrPicture *self, FspLocation *location)
+frogr_picture_set_location (FrogrPicture *self, FspDataLocation *location)
 {
   FrogrPicturePrivate *priv = NULL;
 
   g_return_if_fail(FROGR_IS_PICTURE(self));
 
   priv = FROGR_PICTURE_GET_PRIVATE (self);
+  fsp_data_free (FSP_DATA (location));
   priv->location = location;
 }
 
diff --git a/src/frogr-picture.h b/src/frogr-picture.h
index 6003c59..d1aadd5 100644
--- a/src/frogr-picture.h
+++ b/src/frogr-picture.h
@@ -105,8 +105,8 @@ void frogr_picture_set_content_type (FrogrPicture *self,
                                      FspContentType content_type);
 FspLicense frogr_picture_get_license (FrogrPicture *self);
 void frogr_picture_set_license (FrogrPicture *self, FspLicense license);
-FspLocation *frogr_picture_get_location (FrogrPicture *self);
-void frogr_picture_set_location (FrogrPicture *self, FspLocation *location);
+FspDataLocation *frogr_picture_get_location (FrogrPicture *self);
+void frogr_picture_set_location (FrogrPicture *self, FspDataLocation *location);
 
 gboolean frogr_picture_show_in_search (FrogrPicture *self);
 void frogr_picture_set_show_in_search (FrogrPicture *self,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]