From 217da241b2be352b9f420c531c6a3deb0944e968 Mon Sep 17 00:00:00 2001 From: Jesper Thomschutz Date: Mon, 2 Apr 2007 13:53:02 +0200 Subject: [PATCH] Project born. So far nothing works really :) --- README | 10 ++++++++ main.cpp | 14 +++++++++++ squawker.pro | 14 +++++++++++ twittersocket.cpp | 42 ++++++++++++++++++++++++++++++++ twittersocket.h | 26 ++++++++++++++++++++ w_connect.cpp | 29 +++++++++++++++++++++++ w_connect.h | 25 ++++++++++++++++++++ w_connect.ui | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ w_timeline.cpp | 10 ++++++++ w_timeline.h | 19 +++++++++++++++ w_timeline.ui | 49 ++++++++++++++++++++++++++++++++++++++ 11 files changed, 309 insertions(+) create mode 100644 README create mode 100644 main.cpp create mode 100644 squawker.pro create mode 100644 twittersocket.cpp create mode 100644 twittersocket.h create mode 100644 w_connect.cpp create mode 100644 w_connect.h create mode 100644 w_connect.ui create mode 100644 w_timeline.cpp create mode 100644 w_timeline.h create mode 100644 w_timeline.ui diff --git a/README b/README new file mode 100644 index 0000000..f8e2e68 --- /dev/null +++ b/README @@ -0,0 +1,10 @@ +Licence: GPLv2 +Jesper Thomschutz, evilhax0r@gmail.com + +A cross-platform twitter.com client for Linux, Mac, and Windows. + +Written using C++ and Qt 4. + +Enjoy! + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..74ebd6b --- /dev/null +++ b/main.cpp @@ -0,0 +1,14 @@ +#include +#include + +#include "w_connect.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + w_Connect *connectWindow = new w_Connect(); + connectWindow->show(); + + return app.exec(); +} diff --git a/squawker.pro b/squawker.pro new file mode 100644 index 0000000..8009ae9 --- /dev/null +++ b/squawker.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Sun Apr 1 00:36:57 2007 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +QT += network + +# Input +HEADERS += w_connect.h w_timeline.h twittersocket.h +FORMS += w_connect.ui w_timeline.ui +SOURCES += main.cpp w_connect.cpp w_timeline.cpp twittersocket.cpp diff --git a/twittersocket.cpp b/twittersocket.cpp new file mode 100644 index 0000000..9c607da --- /dev/null +++ b/twittersocket.cpp @@ -0,0 +1,42 @@ +#include + +#include "twittersocket.h" + +TwitterSocket::TwitterSocket(QObject *parent) : QHttp(parent) +{ + qDebug("Constructed socket."); + setHost("twitter.com"); +} + +bool TwitterSocket::accountValid(QString user, QString pass) +{ + QObject::connect( this, SIGNAL( done( bool) ), this, SLOT( done( bool) ) ); + qDebug() << "Trying to connect with: " << user << " and " << pass; + + setUser(user, pass); + get("/statuses/friends.xml"); + return true; +} + +void TwitterSocket::done( bool error) +{ + // Hack to work around bug in Qt4.2 basic auth. Fixed in 4.3 + // (It doesn't report an error when incorrect credentials are supplied) + if (readAll() == "Could't authenticate you") + emit result(true, QLatin1String("Authentication denied")); + else + emit result(error, errorString()); +} + + +/* + QHttpRequestHeader header("POST", "/statuses/update.xml"); + header.setValue("Host", "twitter.com"); + header.setValue("User-Agent", "Squawker"); + + QHttp *http = new QHttp(); + http->setHost("twitter.com"); + http->setUser("squawker","test123"); + http->request(header, "source=Squawker&status=Walking da turkey, again..."); +*/ + diff --git a/twittersocket.h b/twittersocket.h new file mode 100644 index 0000000..9614c3b --- /dev/null +++ b/twittersocket.h @@ -0,0 +1,26 @@ +#ifndef W_TWITTERSOCKET_H +#define W_TWITTERSOCKET_H + +#include + +class TwitterSocket : public QHttp +{ + Q_OBJECT + +public: + TwitterSocket(QObject *parent=0); + + bool accountValid(QString user, QString pass); + +signals: + void result( bool error, QString errorString); + +private: + QHttp *http; + +private slots: + void done( bool error); +}; + + +#endif diff --git a/w_connect.cpp b/w_connect.cpp new file mode 100644 index 0000000..7895060 --- /dev/null +++ b/w_connect.cpp @@ -0,0 +1,29 @@ +#include + +#include "w_connect.h" +#include "twittersocket.h" + +w_Connect::w_Connect(QWidget *parent) +{ + setupUi(this); + + le_user->setFocus(); + + QObject::connect( pb_connect, SIGNAL( clicked() ), this, SLOT( connect() ) ); +} + +void w_Connect::connect() +{ + pb_connect->setEnabled(false); + TwitterSocket *twittersocket = new TwitterSocket(); + + QObject::connect( twittersocket, SIGNAL( result( bool, QString) ), this, SLOT( status( bool, QString) ) ); + twittersocket->accountValid( le_user->text(), le_password->text()); + + pb_connect->setEnabled(true); +} + +void w_Connect::status( bool error, QString errorString ) +{ + qDebug() << "error:" << error << " and " << errorString; +} diff --git a/w_connect.h b/w_connect.h new file mode 100644 index 0000000..96dd7c6 --- /dev/null +++ b/w_connect.h @@ -0,0 +1,25 @@ +#ifndef W_CONNECT_H +#define W_CONNECT_H + +#include "ui_w_connect.h" +#include "twittersocket.h" + +class w_Connect : public QDialog, private Ui::w_connect +{ + Q_OBJECT + +public: + w_Connect(QWidget *parent = 0); + + +public slots: + void connect(); + +private slots: + void status( bool error, QString errorString); +private: + TwitterSocket twittersocket(); +}; + + +#endif diff --git a/w_connect.ui b/w_connect.ui new file mode 100644 index 0000000..f2db805 --- /dev/null +++ b/w_connect.ui @@ -0,0 +1,71 @@ + + w_connect + + + + 0 + 0 + 266 + 149 + + + + Connect + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + QLineEdit::Password + + + + + + + + + + Password + + + + + + + User + + + + + + + + + Connect + + + + + + + le_user + le_password + + + + diff --git a/w_timeline.cpp b/w_timeline.cpp new file mode 100644 index 0000000..6d9d3c3 --- /dev/null +++ b/w_timeline.cpp @@ -0,0 +1,10 @@ +#include + +#include "w_timeline.h" + +w_Timeline::w_Timeline(QWidget *parent) +{ + setupUi(this); + //Set focus on the message line edit + le_message->setFocus(); +} diff --git a/w_timeline.h b/w_timeline.h new file mode 100644 index 0000000..567199d --- /dev/null +++ b/w_timeline.h @@ -0,0 +1,19 @@ +#ifndef W_TIMELINE_H +#define W_TIMELINE_H + +#include "ui_w_timeline.h" + + +class w_Timeline : public QWidget, private Ui::w_timeline +{ + Q_OBJECT + +public: + w_Timeline(QWidget *parent = 0); + + +public slots: +}; + + +#endif diff --git a/w_timeline.ui b/w_timeline.ui new file mode 100644 index 0000000..8e65f63 --- /dev/null +++ b/w_timeline.ui @@ -0,0 +1,49 @@ + + w_timeline + + + + 0 + 0 + 400 + 453 + + + + Timeline + + + + 9 + + + 6 + + + + + + + + 0 + + + 6 + + + + + + + + Squawk! + + + + + + + + + + -- 2.11.4.GIT