[libgdata/offline-testing] youtube: Add a CHANNEL_REQUIRED error code



commit 7c0fa6d59e8044b9421b3e7dbac1da5abd24ae27
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Jul 8 15:34:24 2013 +0100

    youtube: Add a CHANNEL_REQUIRED error code
    
    This is returned for operations which require the currently authenticated
    Google Account to have an associated YouTube channel, but it doesn’t.
    
    This adds the following API:
     • GDATA_YOUTUBE_SERVICE_ERROR_CHANNEL_REQUIRED

 gdata/services/youtube/gdata-youtube-service.c |   21 +++++++++++++++++----
 gdata/services/youtube/gdata-youtube-service.h |    6 +++++-
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/gdata/services/youtube/gdata-youtube-service.c b/gdata/services/youtube/gdata-youtube-service.c
index 2e57984..15c7afb 100644
--- a/gdata/services/youtube/gdata-youtube-service.c
+++ b/gdata/services/youtube/gdata-youtube-service.c
@@ -450,10 +450,23 @@ parse_error_response (GDataService *self, GDataOperationType operation_type, gui
                /* Create an error message, but only for the first error */
                if (error == NULL || *error == NULL) {
                        /* See 
http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Error_responses */
-                       if (xmlStrcmp (domain, (xmlChar*) "yt:service") == 0 && xmlStrcmp (code, (xmlChar*) 
"disabled_in_maintenance_mode") == 0) {
-                               /* Service disabled */
-                               g_set_error (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_UNAVAILABLE,
-                                            _("This service is not available at the moment."));
+                       if (xmlStrcmp (domain, (xmlChar*) "yt:service") == 0) {
+                               if (xmlStrcmp (code, (xmlChar*) "disabled_in_maintenance_mode") == 0) {
+                                       /* Service disabled */
+                                       g_set_error (error, GDATA_SERVICE_ERROR, 
GDATA_SERVICE_ERROR_UNAVAILABLE,
+                                                    _("This service is not available at the moment."));
+                               } else if (xmlStrcmp (code, (xmlChar*) "youtube_signup_required") == 0) {
+                                       /* Tried to authenticate with a Google Account which hasn't yet had a 
YouTube channel created for it. */
+                                       g_set_error (error, GDATA_YOUTUBE_SERVICE_ERROR, 
GDATA_YOUTUBE_SERVICE_ERROR_CHANNEL_REQUIRED,
+                                                    /* Translators: the parameter is a URI. */
+                                                    _("Your Google Account must be associated with a YouTube 
channel to do this. Visit %s to create one."),
+                                                    "https://www.youtube.com/create_channel";);
+                               } else {
+                                       /* Protocol error */
+                                       g_set_error (error, GDATA_SERVICE_ERROR, 
GDATA_SERVICE_ERROR_PROTOCOL_ERROR,
+                                                    _("Unknown error code \"%s\" in domain \"%s\" received 
with location \"%s\"."),
+                                                    code, domain, location);
+                               }
                        } else if (xmlStrcmp (domain, (xmlChar*) "yt:authentication") == 0) {
                                /* Authentication problem */
                                g_set_error (error, GDATA_SERVICE_ERROR, 
GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
diff --git a/gdata/services/youtube/gdata-youtube-service.h b/gdata/services/youtube/gdata-youtube-service.h
index 4a4f534..fb9c22f 100644
--- a/gdata/services/youtube/gdata-youtube-service.h
+++ b/gdata/services/youtube/gdata-youtube-service.h
@@ -65,12 +65,16 @@ typedef enum {
  * GDataYouTubeServiceError:
  * @GDATA_YOUTUBE_SERVICE_ERROR_API_QUOTA_EXCEEDED: the API request quota for this developer account has 
been exceeded
  * @GDATA_YOUTUBE_SERVICE_ERROR_ENTRY_QUOTA_EXCEEDED: the entry (e.g. video) quota for this user account has 
been exceeded
+ * @GDATA_YOUTUBE_SERVICE_ERROR_CHANNEL_REQUIRED: the currently authenticated user doesn't have a YouTube 
channel, but the current action requires one;
+ * if this error is received, inform the user that they need a YouTube channel, and provide a link to
+ * <ulink type="http" 
url="https://www.youtube.com/create_channel";>https://www.youtube.com/create_channel</ulink>
  *
  * Error codes for #GDataYouTubeService operations.
  **/
 typedef enum {
        GDATA_YOUTUBE_SERVICE_ERROR_API_QUOTA_EXCEEDED,
-       GDATA_YOUTUBE_SERVICE_ERROR_ENTRY_QUOTA_EXCEEDED
+       GDATA_YOUTUBE_SERVICE_ERROR_ENTRY_QUOTA_EXCEEDED,
+       GDATA_YOUTUBE_SERVICE_ERROR_CHANNEL_REQUIRED,
 } GDataYouTubeServiceError;
 
 #define GDATA_TYPE_YOUTUBE_SERVICE             (gdata_youtube_service_get_type ())


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