GCF LOGO VCL LOGO
GCF's GDriveLite component

Classes

class  GCF::GDriveContent::Permission
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::GDriveContent::User
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::GDriveContent::Properties
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::GDriveContent::ImageMediaMetaData
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::GDriveContent::ItemParent
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::GDriveContent::Item
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::GDriveContent::AuthenticatedUser
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::GDriveContent::Child
 
#include <GCF/GDriveContent.h>
More...
 
class  GCF::IGDriveLite
 This interface gives access to all GDriveLite component functionalities.
#include <GCF3/IGDriveLite>
. More...
 
class  GCF::IGDriveLiteAuthenticator
 This is class helps the user to authenticate..
#include <GCF3/IGDriveLiteAuthenticator>
. More...
 
class  GCF::IGDriveLiteContentModel
 This interface provides access to the content-structure of Google Drive
#include <GCF3/IGDriveLiteContentModel>
. More...
 
class  GCF::IGDriveLiteContentSharingModel
 This interface provides access to permissions of a file/folder item
#include <GCF3/IGDriveLiteContentSharingModel>
. More...
 
class  GCF::IGDriveLiteFileDownloader
 An interface to download a file from Google Drive
#include <GCF3/IGDriveLiteFileDownloader>
. More...
 
class  GCF::IGDriveLiteFileDownloaderListModel
 Provides access to all downloaders from this component as a model
#include <GCF3/IGDriveLiteFileDownloaderListModel>
. More...
 
class  GCF::IGDriveLiteFileUploader
 An interface to upload a file into google-drive
#include <GCF3/IGDriveLiteFileUploader>
. More...
 
class  GCF::IGDriveLiteFileUploaderListModel
 Helper class for accessing details of file uploaders as model.
#include <GCF3/IGDriveLiteFileUploaderListModel>
. More...
 

Detailed Description

GDriveLite is an in-built component in GCF that makes it possible to bring Google Drive to your applications. With this component you can

  • Authenticate a Google Account and access its Drive contents
  • Access the content-structure of the drive (through a model)
  • Upload / Download files
  • Share / Unshare files and folders in the drive
  • Star / Unstar files and folders in the drive
  • Trash / Untrash / Permanently Delete files and folders in the drive
  • Rename files and folders
  • Create directories
  • Move files and directories to other directories

GCF comes bundled with two example programs: GDriveLiteGui and GDriveLiteQml. These programs showcase how the component can be used to build a full-fledged drive-aware application using widgets and QML.

Registering your application with Google API Console

To work with Google Drive API, you will need to register your application with Google using its API Console.

Step 1: Visit Google API Console

Open https://code.google.com/apis/console/ in your web-browser.

api-console.png

Click on the "Create Project" button and switch to the "Services" tab.

api-console1.png

From the list of services, switch on (or enable) Drive-API service access.

api-console2.png

In the API-Access tab, create an OAuth Client-ID.

api-console3.png
 
api-console4.png
 
api-console5.png
Note
Make sure that you selected "Installed Application" as application-type; and "Other" as installed application type.
api-console6.png

Upon creation of Client-ID; you will notice a client-id and client-secret string in your API console. Make note of these strings, you will need to use them in your code for using the GDriveLite component.

Loading GDriveLite component in your GCF applications

Once you have the client-id and client-secret, you can load the GDriveLite component in your code as follows

int main(int argc, char **argv)
{
GCF::GuiApplication a(argc, argv);
QList< QPair<QByteArray,QVariant> > props;
props << qMakePair<QByteArray,QVariant>("clientID", "78399023134.apps.googleusercontent.com");
props << qMakePair<QByteArray,QVariant>("clientSecret", "QiA5B6kXo0gNWcn-6UKpggsJ");
GCF::Component *gDriveLite = a.loadComponent("GDrive/GDriveLite", props);
if(!gDriveLite)
return ::error("Could not load GDrive/GDriveLite component");
// ....
}
Note
To load GDriveLite component in your application, you must ensure that GCF's Binary folder is available in PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH.

Authorising GDriveLite to access drive data

The first thing you will need to do is to authorize GDriveLite to access your drive content. For this, you can make use of the GCF::IGDriveLiteAuthenticator interface. The following code-snippet shows you how to do that

GCF::Component *gDriveLite = a.loadComponent("GDrive/GDriveLite", props);
if(!gDriveLite)
return ::error("Could not load GDrive/GDriveLite component");
// Get the central interface of GDriveLite and then fetch the authenticator
// interface from it.
GCF::IGDriveLite *gDriveIface = qobject_cast<GCF::IGDriveLite*>(gDriveLite);
// Show the authentication URL in a web-view.
QWebView webView;
webView.setUrl( auth->authenticationPageUrl() );
webView.show();
// username and password in the login-page. He will then be taken to
// a authorization page, where he should authorize access to your application.
// Upon success - a token is sent back via 'document title' of the HTML
// page.
GCF::Result result = auth->authenticateFromPageTitle( webView.title() );
if(result.isSuccess())
{
// Authorization successful
}
else
{
// Show result.message() as error to user and abort
}
See Also
GCF::IGDriveLite
GCF::IGDriveLiteAuthenticator
GCF::IGDriveLiteContentModel
GCF::IGDriveLiteContentSharingModel
GCF::IGDriveLiteFileDownloader
GCF::IGDriveLiteFileDownloaderListModel
GCF::IGDriveLiteFileUploader
GCF::IGDriveLiteFileUploaderListModel
GDriveLiteGui - Example application for GCF's GDriveLite
GDriveLiteQml - Example application for GCF's GDriveLite