No more duplicate items, huzzah! (via ugly hack!)
[squawker.git] / twittersocket.cpp
blobfebc01f62c0acae625e13e06698e4189c68b9270
1 #include <QDebug>
3 #include "twittersocket.h"
5 TwitterSocket::TwitterSocket(QString user, QString pass, QObject *parent) : QHttp(parent)
7 qDebug("Constructed socket.");
8 setHost("twitter.com");
9 setUser(user, pass);
10 QObject::connect( this, SIGNAL( done(bool) ), this, SLOT(done( bool) ) );
13 void TwitterSocket::accountValid()
15 get(QLatin1String("/statuses/friends_timeline.xml"));
18 void TwitterSocket::update(QString message)
20 QHttpRequestHeader header("POST", "/statuses/update.xml");
21 header.setValue("Host", "twitter.com");
23 // Twitterrific manages to get its name on the page using the source
24 // tag, but it doesn't seem to work for us :/
25 const QString msg("source=Squawker&status="+message);
26 request(header, msg.toAscii());
29 void TwitterSocket::timeline()
31 get(QLatin1String("/statuses/friends_timeline.xml"));
34 void TwitterSocket::done( bool error)
36 QString results = readAll();
38 // Hack to work around bug in Qt4.2 basic auth. Fixed in 4.3
39 // (It doesn't report an error when incorrect credentials are supplied)
40 if ( results == "Could't authenticate you")
41 emit result(true, QLatin1String("Authentication denied"), NULL );
42 else
43 emit result(error, errorString(), results);
45 deleteLater();