Coder Social home page Coder Social logo

gtasks's Introduction

GTasks - A C++/Qt API client for Google Tasks

GTasks is a C++/library that allows you to interact with the Google Tasks API. Before using GTasks, please make sure that you are familiar with the Google Tasks API.

Read the documentation of the Google Tasks API: http://code.google.com/apis/tasks/overview.html

Enable the API: https://code.google.com/apis/console

Dependencies

GTasks depends on the following libraries:

Architecture

GTasks is structured into jobs. There is a job for each operation that you can do (list tasks, list tasklists, delete task, etc...), and each job has a result signal that is emitted when the job finishes.

You create a new job instances by using the appropriate method in the GTasks::Service, for example, to delete a task:

QString taskId = "ABCDEFGH1234";
// Assume service is a pointer to a Gtasks::Service instance
gtasksService->deleteTask(taskId).startAndCallback(this, SLOT(onTaskDeleted(GTasks::Error)));

startAndCallback will connect the slot that you provide with the job's result signal, and will start the job. If you're not interested in receiving the job's result signal, you could just call start() instead.

Memory management

GTasks use the copy-on-write idiom for the model classes, and Qt's deleteLater() for the jobs, meaning that you don't have to manually delete any object, except the GTasks::Service instance.

Authentication

You must use the SimpleOAuth library to authenticate your user. Once you have a valid OAuth::Token, just pass it to the GTasks::Service.

See SimpleOauth documentation: https://github.com/gregschlom/SimpleOAuth

Usage

MyClass::setupGTasks()
{		
	m_gtasks = new GTasks::Service(new QNetworkAccessManager(this), this);
	m_gtasks->setApiKey("[YOUR API KEY HERE]");

	// Creates a oauth token from the SimpleOAuth library
	OAuth::Token token;
	token.setType(OAuth::Token::AccessToken);
	token.setConsumerKey("[YOUR OAUTH CONSUMER KEY]");
	token.setConsumerSecret("[YOUR OAUTH CONSUMER SECRET]");
	token.setTokenString("[VALID OAUTH TOKEN STRING]");  // Assuming you have previously
	token.setTokenSecret("[VALID OAUTH TOKEN SECRET]");	 // authenticated the user

	// m_gtasks is ready to process request now
	m_gtasks->setToken(token);
}

/*!
  Retrieves a list of all Tasklists
 */
MyClass::getAllTaskslists
{
	m_gtasks->listTasklists().startAndCallback(this, 
		SLOT(onTasklistsReceived(GTasks::TasklistCollection, GTasks::Error)));
}

/*!
  This slot will be called by GTasks when the tasklists have been retrieved
*/
MyClass::onTasklistsReceived(GTasks::TasklistCollection tasklists, GTasks::Error error))
{
	if (error.code() != QNetworkReply::NoError) {
		// Do some error handling here
		qDebug() << "Error:" << error.code() << error.message();
		return;
	}

	// Display the title and id of each tasklist
	foreach (const GTasks::Tasklist& tasklist, tasklists.items()) {
		qDebug() << "Tasklist:" << tasklist.title() << "id:" << tasklist.id();
	}
}

Contact

GTasks is released under the terms of the MIT license.

For any information, feel free to contact me: Gregory Schlomoff - [email protected]

gtasks's People

Contributors

gregschlom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.