Qt4 Google Contacts APIs

July 24, 2009 | Filed Under Qt4 | No Comments

Just pushed at GitHub the first draft of the Qt4 Google Contacts Service…

Contacts APIs allows client applications to view and update Contacts content in the form of Google Data API feeds. Your client application can request a list of a user’s contacts, edit or delete content in an existing contact.

// Setup Contact
THGoogleContact *contact = new THGoogleContact;
contact->setFullName("John Doe");

THGoogleIm *im = new THGoogleIm;
im->setRel(THGoogleIm::relWork());
im->setAddress("john.doe@aim.com");
im->setProtocol(THGoogleIm::protocolAim());
contact->addImAddress(im);

THGoogleEmail *email = new THGoogleEmail;
email->setAddress("john.doe@mail.com");
email->setRel(THGoogleEmail::relWork());
contact->addEmailAddress(email);

// Insert Contact
THGoogleContactsService *gContacts = new THGoogleContactsService;
gContacts->setAuthToken(...);
gContacts->insertContact(contact);


Take a look at contacttest.cpp for a more complete usage example.

Qt4 Google Services: Translator, Spell Checker and more…

June 6, 2009 | Filed Under Qt4 | No Comments

Last month I’ve made a simple wrapper for Google Authentication, Today I’ve written other 4 classes to wrap the Google’s Translator, Language Detector, Suggestions and the Spell Checker Services.

Translator Example

QEventLoop l;
THGoogleTranslator gTranslator;
connect(&gTranslator, SIGNAL(finished(bool)), &l, SLOT(quit()));
gTranslator.setDestinationLanguage("en");
gTranslator.translate("Ciao");
l.exec();

qDebug() << gTranslator.translatedText(); // Maybe "Hello"
qDebug() << gTranslator.detectedSourceLanguage(); // Maybe "it"

Suggest Example

QEventLoop l;
THGoogleSuggest gSuggest;
connect(&gSuggest, SIGNAL(finished(bool)), &l, SLOT(quit()));
gSuggest.suggest("Qt Softw");
l.exec();

qDebug() << gSuggest.suggestions();
// ("qt software", "qt software download", "qt software gpl exception", ...)

Spell Checker Example

QEventLoop l;
THGoogleSpellChecker gSpellChecker;
connect(&gSpellChecker, SIGNAL(finished(bool)), &l, SLOT(quit()));
gSpellChecker.spellCheck("Gogl Spll");
l.exec();

// "Gogl" ("Google", "Gogol", "Gog", "Goal", "Gog's")
// "Spll" ("Spell", "Sp ll", "Sp-ll", "Spill", "Sell")
foreach (QString original, gSpellChecker.keys())
    qDebug() << original << gSpellChecker.suggestions(original);

Language Detector Example

QEventLoop l;
THGoogleDetectLanguage gDetectLang;
connect(&gDetectLang, SIGNAL(finished(bool)), &l, SLOT(quit()));
gDetectLang.detectLanguage("Ciao");
l.exec();

qDebug() << "Query" << gDetectLang.query();
qDebug() << "Language" << gDetectLang.language(); // Maybe "it"
qDebug() << "Is Reliable" << gDetectLang.isReliable();
qDebug() << "Confidence" << gDetectLang.confidence();

You can find the source at GitHub (Git WebView) or you can download the source code Here: Qt4 Google Services Take 2 Source Code.

Qt4 Google Authentication

May 1, 2009 | Filed Under Qt4 | 1 Comment

Today, I’m looking at Google services, Contacts, Maps, Search… to use all this service in your app you need to get The Authentication Token (see the Google Auth For Installed Apps page). So, I’ve implemented a simple class to do this.

QEventLoop q;
THGoogleAuth gAuth("MYNAME@gmail.com");
QObject::connect(&gAuth, SIGNAL(authenticated()), &q, SLOT(quit()));
gAuth.login(THGoogleAuth::Contacts, "MYPASSWORD");
q.exec();

if (gAuth.error() == THGoogleAuth::NoError) {
    qDebug() << "SID" << gAuth.sid();
    qDebug() << "LSID" << gAuth.lsid();
    qDebug() << "AUTH" << gAuth.auth();
} else {
    qDebug() << gAuth.errorString();
}

The Source Code is Available Here: Qt4 Google Auth Source Code.