pidgin/quail/quail-redux

777509d81ef2
Parents b57337fa2d7b
Children cf73733ee683
Testing branch on a new event loop system that should be more stable on windows
--- a/.hgignore Fri Aug 30 09:43:23 2013 +0100
+++ b/.hgignore Thu Sep 05 10:31:00 2013 +0100
@@ -14,11 +14,11 @@
*.gz
.*.swp
.todo.*
-Makefile
+Makefile*
gaim
temp*
moc_*
-object_script.Quail
+object_script.Quail*
*.pdb
qrc_*.cpp
*~
--- a/Quail-redux.pro Fri Aug 30 09:43:23 2013 +0100
+++ b/Quail-redux.pro Thu Sep 05 10:31:00 2013 +0100
@@ -4,7 +4,7 @@
TEMPLATE = app
TARGET = Quail
VERSION = $${APP_DISPLAY_VERSION}
-CONFIG = qt warn_on debug
+CONFIG = qt warn_on debug_and_release
DEFINES += APP_NAME=\\\"Quail\\\"
DEFINES += QUAIL_PREFS_ROOT=\\\"/quail\\\"
@@ -118,12 +118,15 @@
LIBS += -L"C:/dev/win32-dev/gtk-2.24.10/lib"
LIBS += -L"C:/dev/pidgin-main/libpurple"
LIBS += -L"C:/Qt/4.8.5/lib"
+ LIBS += -L"/cygdrive/c/Qt/4.8.5/lib"
#RC_FILE = resource.rc
LIBS += -llibpurple -lglib-2.0 -lgmodule-2.0
}
+INCLUDEPATH += $$(LIBPURPLE_ROOT)
+#INCLUDEPATH += $$(QTDIR)
OBJECTS_DIR = obj
MOC_DIR = moc
--- a/src/QuailBuddyList.cpp Fri Aug 30 09:43:23 2013 +0100
+++ b/src/QuailBuddyList.cpp Thu Sep 05 10:31:00 2013 +0100
@@ -543,6 +543,7 @@
setColumnWidth(0, BUDDY_ICON_SIZE);
setColumnWidth(1, this->width() - (BUDDY_ICON_SIZE *4));
setColumnWidth(2, BUDDY_ICON_SIZE);
+ qDebug() << "QQuailBuddyList::resizeEvent.end";
}
void
--- a/src/QuailEventLoop.cpp Fri Aug 30 09:43:23 2013 +0100
+++ b/src/QuailEventLoop.cpp Thu Sep 05 10:31:00 2013 +0100
@@ -21,27 +21,14 @@
*/
#include "QuailEventLoop.h"
#include <QDebug>
-#include <QMap>
-
-typedef struct
-{
- guint handle;
-
- union
- {
- QQuailTimer *timer;
- QQuailInputNotifier *notifier;
- };
-
-} QQuailSourceInfo;
static gboolean qQuailSourceRemove(guint handle);
+static gboolean qQuailTimeoutRemove(guint handle);
-static guint nextSourceId = 0;
-static QMap<guint, QQuailSourceInfo*> m_sources;
+static QuailEventLoop *eventLoop = NULL;
-QQuailTimer::QQuailTimer(guint sourceId, GSourceFunc func, gpointer data)
- : QTimer(), sourceId(sourceId), func(func), userData(data)
+QQuailTimer::QQuailTimer(GSourceFunc func, gpointer data)
+ : QTimer(eventLoop), func(func), userData(data)
{
connect(this, SIGNAL(timeout()),
this, SLOT(update()));
@@ -51,14 +38,20 @@
QQuailTimer::update()
{
if (!func(userData))
- qQuailSourceRemove(sourceId);
+ qQuailTimeoutRemove(sourceId);
+}
+
+void
+QQuailTimer::setHandle(guint newSourceId)
+{
+ sourceId(newSourceId);
}
QQuailInputNotifier::QQuailInputNotifier(int fd,
PurpleInputCondition cond,
PurpleInputFunction func,
gpointer userData)
- : QObject(), func(func), userData(userData), readNotifier(NULL),
+ : QObject(eventLoop), func(func), userData(userData), readNotifier(NULL),
writeNotifier(NULL)
{
//qDebug() << "QQuailInputNotifier::QQuailInputNotifier";
@@ -105,30 +98,80 @@
func(userData, fd, (PurpleInputCondition)cond);
}
+QuailEventLoop::QuailEventLoop(QObject *parent) :
+ QObject(parent)
+{
+ eventLoop = this;
+}
+
+bool QuailEventLoop::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ //TODO: Fill this in
+}
+
+bool QuailEventLoop::hasPendingEvents()
+{
+ return (m_timers.count() + m_sources.count()) > 0;
+}
+
+void QuailEventLoop::registerSocketNotifier(QSocketNotifier *notifier)
+{
+ //qQuailInputAdd
+}
+
+void QuailEventLoop::unregisterSocketNotifier(QSocketNotifier *notifier)
+{
+ //qQuailSourceRemove
+}
+
+void QuailEventLoop::registerTimer(int timerId, int interval, QObject *object)
+{
+ //qQuailTimeoutAdd
+}
+
+bool QuailEventLoop::unregisterTimer(int timerId)
+{
+ qQuailTimeoutRemove(timerId);
+}
+
+bool QuailEventLoop::unregisterTimers(QObject *object)
+{
+ qQuailTimeoutRemove(m_timers.indexOf(object));
+}
+
+QList<QAbstractEventDispatcher::TimerInfo>
+QuailEventLoop::registeredTimers(QObject *object) const
+{
+ Q_UNUSED(object);
+ /* Not implemented, we won't use this. It's only used for
+ transfering QObject from one thread to another. */
+ return QList<QAbstractEventDispatcher::TimerInfo>();
+}
static guint
qQuailTimeoutAdd(guint interval, GSourceFunc func, gpointer data)
{
//qDebug() << "QQuailInputNotifier::qQuailTimeoutAdd";
- QQuailSourceInfo *info = new QQuailSourceInfo;
-
- info->handle = nextSourceId++;
+ QQuailTimer *timer = new QQuailTimer(func, data);
+ eventLoop->m_timers.append(timer);
+ guint handle = eventLoop->m_timers.lastIndexOf(timer);
+ timer->setHandle(handle);
+ timer->start(interval);
- info->timer = new QQuailTimer(info->handle, func, data);
- info->timer->start(interval);
-
- m_sources.insert(info->handle, info);
-
- return info->handle;
+ return handle;
}
static gboolean
qQuailTimeoutRemove(guint handle)
{
//qDebug() << "QQuailInputNotifier::qQuailTimeoutRemove";
- qQuailSourceRemove(handle);
+ QQuailTimer *timer = eventLoop->m_timers.takeAt(handle);
- return 0;
+ if (timer == NULL)
+ return false;
+
+ delete timer;
+ return true;
}
static guint
@@ -138,36 +181,21 @@
gpointer userData)
{
//qDebug() << "QQuailInputNotifier::qQuailInputAdd";
- QQuailSourceInfo *info = new QQuailSourceInfo;
-
- info->handle = nextSourceId++;
-
- info->notifier = new QQuailInputNotifier(fd, cond, func, userData);
-
- m_sources.insert(info->handle, info);
-
- return info->handle;
+ QQuailInputNotifier *notifier = new QQuailInputNotifier(fd, cond, func, userData);
+ eventLoop->m_sources.append(notifier);
+ return eventLoop->m_sources.lastIndexOf(notifier);
}
static gboolean
qQuailSourceRemove(guint handle)
{
//qDebug() << "QQuailInputNotifier::qQuailSourceRemove";
- QQuailSourceInfo *info;
+ QQuailInputNotifier *notifier = eventLoop->m_sources.takeAt(handle);
- info = m_sources.value(handle);
-
- if (info == NULL)
+ if (notifier == NULL)
return false;
- m_sources.remove(handle);
-
- if (info->timer != NULL)
- delete info->timer;
- else if (info->notifier != NULL)
- delete info->notifier;
-
- delete info;
+ delete notifier;
return true;
}
--- a/src/QuailEventLoop.h Fri Aug 30 09:43:23 2013 +0100
+++ b/src/QuailEventLoop.h Thu Sep 05 10:31:00 2013 +0100
@@ -24,6 +24,7 @@
#include <libpurple/eventloop.h>
+#include <QList>
#include <QTimer>
#include <QSocketNotifier>
/* http://harmattan-dev.nokia.com/docs/library/html/qt4/qabstracteventdispatcher.html */
@@ -34,10 +35,11 @@
Q_OBJECT
public:
- QQuailTimer(guint sourceId, GSourceFunc func, gpointer data);
+ QQuailTimer(GSourceFunc func, gpointer data);
private slots:
void update();
+ void setHandle(guint newSourceId);
private:
guint sourceId;
@@ -64,6 +66,35 @@
QSocketNotifier *readNotifier, *writeNotifier;
};
+class QuailEventLoop : QAbstractEventDispatcher
+{
+ Q_OBJECT
+
+public:
+ QuailEventLoop(QObject *parent = 0);
+ bool processEvents(QEventLoop::ProcessEventsFlags flags);
+ bool hasPendingEvents();
+
+ void registerSocketNotifier(QSocketNotifier *notifier);
+ void unregisterSocketNotifier(QSocketNotifier *notifier);
+
+ void registerTimer(int timerId, int interval, QObject *object);
+ bool unregisterTimer(int timerId);
+ bool unregisterTimers(QObject *object);
+ QList<TimerInfo> registeredTimers(QObject *object) const;
+
+ //void wakeUp();
+ //void interrupt();
+ //void flush();
+
+ QList<QQuailInputNotifier*> m_sources;
+ QList<QQuailTimer*> m_timers;
+
+private:
+ //static QMap<guint, QQuailSourceInfo*> m_sources;
+
+};
+
/**
* Returns the Qt event loop UI operations structure.
*
--- a/src/main.cpp Fri Aug 30 09:43:23 2013 +0100
+++ b/src/main.cpp Thu Sep 05 10:31:00 2013 +0100
@@ -19,12 +19,15 @@
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
+
+#include "QuailEventLoop.h"
#include "QuailMainWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
+ QuailEventLoop quailEventLoop;
QApplication a(argc, argv);
QQuailMainWindow w;
w.show();