Removed console noise and fixed itemmodel a little
[squawker.git] / twittersocket.cpp
blobc1bd2f6d7cdcc53466a4e5e7d9103d99d072c8a4
1 #include <QDebug>
3 #include "twittersocket.h"
5 TwitterSocket::TwitterSocket(QString user, QString pass, QObject *parent) : QHttp(parent)
7 setHost("twitter.com");
8 setUser(user, pass);
9 QObject::connect( this, SIGNAL( done(bool) ), this, SLOT(done( bool) ) );
12 void TwitterSocket::accountValid()
14 get(QLatin1String("/statuses/friends_timeline.xml"));
17 void TwitterSocket::update(QString message)
19 QHttpRequestHeader header("POST", "/statuses/update.xml");
20 header.setValue("Host", "twitter.com");
22 // Twitterrific manages to get its name on the page using the source
23 // tag, but it doesn't seem to work for us :/
24 const QString msg("source=Squawker&status="+message);
25 request(header, msg.toAscii());
28 void TwitterSocket::timeline()
30 get(QLatin1String("/statuses/friends_timeline.xml"));
33 void TwitterSocket::done( bool error)
35 QString results = readAll();
37 // Hack to work around bug in Qt4.2 basic auth. Fixed in 4.3
38 // (It doesn't report an error when incorrect credentials are supplied)
39 if ( results == "Could not authenticate you")
40 emit result(true, QLatin1String("Authentication denied"), NULL );
41 else
42 emit result(error, errorString(), results);
44 deleteLater();