1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
* Copyright (C) Ondrej Holy 2020 <oholy@redhat.com>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* GData Client is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GData Client. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* SECTION:gdata-documents-drive
* @short_description: GData documents drive object
* @stability: Stable
* @include: gdata/services/documents/gdata-documents-drive.h
*
* #GDataDocumentsDrive is a subclass of #GDataEntry to represent an arbitrary Google Drive shared drive.
*
* For more details of Google Drive’s GData API, see the [online documentation](https://developers.google.com/drive/v2/web/about-sdk).
*
* Since: 0.18.0
*/
#include <config.h>
#include <glib.h>
#include "gdata-documents-drive.h"
#include "gdata-private.h"
static void gdata_documents_drive_finalize (GObject *object);
static void gdata_documents_drive_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static gboolean parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error);
typedef struct {
gchar *name;
} GDataDocumentsDrivePrivate;
enum {
PROP_NAME = 1,
};
G_DEFINE_TYPE_WITH_CODE (GDataDocumentsDrive, gdata_documents_drive, GDATA_TYPE_ENTRY,
G_ADD_PRIVATE (GDataDocumentsDrive));
static void
gdata_documents_drive_class_init (GDataDocumentsDriveClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
gobject_class->get_property = gdata_documents_drive_get_property;
gobject_class->finalize = gdata_documents_drive_finalize;
parsable_class->parse_json = parse_json;
/**
* GDataDocumentsDrive:name:
*
* The human-readable name of this shared drive.
*
* Since: 0.18.0
*/
g_object_class_install_property (gobject_class, PROP_NAME,
g_param_spec_string ("name",
"Name", "The human-readable name of this shared drive.",
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
static void
gdata_documents_drive_init (GDataDocumentsDrive *self)
{
}
static void
gdata_documents_drive_finalize (GObject *object)
{
GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (GDATA_DOCUMENTS_DRIVE (object));
g_free (priv->name);
G_OBJECT_CLASS (gdata_documents_drive_parent_class)->finalize (object);
}
static void
gdata_documents_drive_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (GDATA_DOCUMENTS_DRIVE (object));
switch (property_id) {
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/**
* gdata_documents_drive_get_name:
* @self: a #GDataDocumentsDrive
*
* Returns the human-readable name of this shared drive.
*
* Return value: (nullable): the drives's human-readable name, or %NULL if not set
*
* Since: 0.18.0
*/
const gchar *
gdata_documents_drive_get_name (GDataDocumentsDrive *self)
{
GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (self);
return priv->name;
}
static gboolean
parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error)
{
GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (GDATA_DOCUMENTS_DRIVE (parsable));
gboolean success = TRUE;
gchar *name = NULL;
/* JSON format: https://developers.google.com/drive/v2/reference/drives */
if (gdata_parser_string_from_json_member (reader, "name", P_DEFAULT, &name, &success, error) == TRUE) {
if (success)
priv->name = name;
return success;
}
return GDATA_PARSABLE_CLASS (gdata_documents_drive_parent_class)->parse_json (parsable, reader, user_data, error);
}
|