[frogr] Store the max allowed size for a picture in FrogrAccount.



commit 5d49c94bd83315ca5795ac6c35241964f3190342
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Sun Aug 14 17:39:13 2011 +0200

    Store the max allowed size for a picture in FrogrAccount.

 src/frogr-account.c    |   40 ++++++++++++++++++++++++++++++++++++++++
 src/frogr-account.h    |    5 +++++
 src/frogr-controller.c |    1 +
 3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/src/frogr-account.c b/src/frogr-account.c
index feccbaf..d2b0d4d 100644
--- a/src/frogr-account.c
+++ b/src/frogr-account.c
@@ -44,6 +44,7 @@ struct _FrogrAccountPrivate
   /* Following properties won't be persistent */
   gulong remaining_bandwidth;
   gulong max_bandwidth;
+  gulong max_filesize;
   gboolean is_pro;
 };
 
@@ -59,6 +60,7 @@ enum {
   PROP_IS_ACTIVE,
   PROP_REMAINING_BANDWIDTH,
   PROP_MAX_BANDWIDTH,
+  PROP_MAX_FILESIZE,
   PROP_IS_PRO
 };
 
@@ -107,6 +109,10 @@ _frogr_account_set_property (GObject      *object,
       frogr_account_set_max_bandwidth (self, g_value_get_ulong (value));
       break;
 
+    case PROP_MAX_FILESIZE:
+      frogr_account_set_max_filesize (self, g_value_get_ulong (value));
+      break;
+
     case PROP_IS_PRO:
       frogr_account_set_is_pro (self, g_value_get_boolean (value));
       break;
@@ -158,6 +164,10 @@ _frogr_account_get_property (GObject    *object,
       g_value_set_ulong (value, priv->max_bandwidth);
       break;
 
+    case PROP_MAX_FILESIZE:
+      g_value_set_ulong (value, priv->max_filesize);
+      break;
+
     case PROP_IS_PRO:
       g_value_set_boolean (value, priv->is_pro);
       break;
@@ -249,6 +259,13 @@ frogr_account_class_init (FrogrAccountClass *klass)
                               G_PARAM_READWRITE);
   g_object_class_install_property (obj_class, PROP_MAX_BANDWIDTH, pspec);
 
+  pspec = g_param_spec_ulong ("max-filesize",
+                              "max-filesize",
+                              "Max allowed filesize in KB",
+                              0, G_MAXULONG, G_MAXULONG,
+                              G_PARAM_READWRITE);
+  g_object_class_install_property (obj_class, PROP_MAX_FILESIZE, pspec);
+
   pspec = g_param_spec_boolean ("is-pro",
                                 "is-pro",
                                 "Whether the user has a Pro account or not",
@@ -271,6 +288,7 @@ frogr_account_init (FrogrAccount *self)
   priv->is_active = FALSE;
   priv->remaining_bandwidth = G_MAXULONG;
   priv->max_bandwidth = G_MAXULONG;
+  priv->max_filesize = G_MAXULONG;
   priv->is_pro = FALSE;
 }
 
@@ -472,6 +490,28 @@ frogr_account_set_max_bandwidth (FrogrAccount *self, gulong max_bandwidth)
   priv->max_bandwidth = max_bandwidth;
 }
 
+gulong frogr_account_get_max_filesize (FrogrAccount *self)
+{
+  FrogrAccountPrivate *priv = NULL;
+
+  g_return_val_if_fail (FROGR_IS_ACCOUNT (self), G_MAXULONG);
+
+  priv = FROGR_ACCOUNT_GET_PRIVATE (self);
+  return priv->max_filesize;
+}
+
+void frogr_account_set_max_filesize (FrogrAccount *self,
+                                     gulong max_filesize)
+{
+  FrogrAccountPrivate *priv = NULL;
+
+  g_return_if_fail (FROGR_IS_ACCOUNT (self));
+
+  priv = FROGR_ACCOUNT_GET_PRIVATE (self);
+  priv->max_filesize = max_filesize;
+}
+
+
 gboolean
 frogr_account_is_pro (FrogrAccount *self)
 {
diff --git a/src/frogr-account.h b/src/frogr-account.h
index 57eddd6..f91f072 100644
--- a/src/frogr-account.h
+++ b/src/frogr-account.h
@@ -96,6 +96,11 @@ gulong frogr_account_get_max_bandwidth (FrogrAccount *self);
 void frogr_account_set_max_bandwidth (FrogrAccount *self,
                                       gulong max_bandwidth);
 
+gulong frogr_account_get_max_filesize (FrogrAccount *self);
+
+void frogr_account_set_max_filesize (FrogrAccount *self,
+                                     gulong max_filesize);
+
 gboolean frogr_account_is_pro (FrogrAccount *self);
 
 void frogr_account_set_is_pro (FrogrAccount *self, gboolean is_pro);
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index f5297d5..7546eff 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -1480,6 +1480,7 @@ _fetch_account_extra_info_cb (GObject *object, GAsyncResult *res, gpointer data)
       frogr_account_set_remaining_bandwidth (priv->account,
                                              upload_status->bw_remaining_kb);
       frogr_account_set_max_bandwidth (priv->account, upload_status->bw_max_kb);
+      frogr_account_set_max_filesize (priv->account, upload_status->fs_max_kb);
       frogr_account_set_is_pro (priv->account, upload_status->pro_user);
 
       if (old_remaining_bw != upload_status->bw_remaining_kb



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