coreConnectionInfo.clear();
netsToSync.clear();
- channelsToSync.clear();
- usersToSync.clear();
blockSize = 0;
//restartPhaseNull();
}
// create buffers
// FIXME: get rid of this crap
QVariantList bufferinfos = sessionState["BufferInfos"].toList();
- foreach(QVariant vinfo, bufferinfos) Client::buffer(vinfo.value<BufferInfo>()); // create Buffers and BufferItems
+ foreach(QVariant vinfo, bufferinfos)
+ Client::buffer(vinfo.value<BufferInfo>()); // create Buffers and BufferItems
QVariantList networkids = sessionState["NetworkIds"].toList();
- // prepare sync progress thingys... FIXME: Care about removal of networks
+ // prepare sync progress thingys...
+ // FIXME: Care about removal of networks
numNetsToSync = networkids.count();
- numChannelsToSync = 0; //sessionState["IrcChannelCount"].toUInt();
- numUsersToSync = 0; // sessionState["IrcUserCount"].toUInt(); qDebug() << numUsersToSync;
emit networksProgress(0, numNetsToSync);
- emit channelsProgress(0, numChannelsToSync);
- emit ircUsersProgress(0, numUsersToSync);
// create network objects
foreach(QVariant networkid, networkids) {
Network *net = new Network(netid, Client::instance());
netsToSync.insert(net);
connect(net, SIGNAL(initDone()), this, SLOT(networkInitDone()));
- connect(net, SIGNAL(ircUserInitDone(IrcUser *)), this, SLOT(ircUserInitDone(IrcUser *)));
- connect(net, SIGNAL(ircUserAdded(IrcUser *)), this, SLOT(ircUserAdded(IrcUser *)));
- connect(net, SIGNAL(ircUserRemoved(QObject *)), this, SLOT(ircUserRemoved(QObject *)));
- connect(net, SIGNAL(ircChannelInitDone(IrcChannel *)), this, SLOT(ircChannelInitDone(IrcChannel *)));
- connect(net, SIGNAL(ircChannelAdded(IrcChannel *)), this, SLOT(ircChannelAdded(IrcChannel *)));
- connect(net, SIGNAL(ircChannelRemoved(QObject *)), this, SLOT(ircChannelRemoved(QObject *)));
Client::addNetwork(net);
}
checkSyncState();
checkSyncState();
}
-void ClientSyncer::ircChannelInitDone(IrcChannel *chan) {
- channelsToSync.remove(chan);
- emit channelsProgress(numChannelsToSync - channelsToSync.count(), numChannelsToSync);
- checkSyncState();
-}
-
-void ClientSyncer::ircChannelAdded(IrcChannel *chan) {
- if(!chan->isInitialized()) {
- channelsToSync.insert(chan);
- numChannelsToSync++;
- emit channelsProgress(numChannelsToSync - channelsToSync.count(), numChannelsToSync);
- checkSyncState();
- }
-}
-
-void ClientSyncer::ircChannelRemoved(QObject *chan) {
- if(channelsToSync.contains(chan)) {
- numChannelsToSync--;
- channelsToSync.remove(chan);
- emit channelsProgress(numChannelsToSync - channelsToSync.count(), numChannelsToSync);
- checkSyncState();
- }
-}
-
-void ClientSyncer::ircUserInitDone(IrcUser *user) {
- usersToSync.remove(user);
- emit ircUsersProgress(numUsersToSync - usersToSync.count(), numUsersToSync);
- checkSyncState();
-}
-
-void ClientSyncer::ircUserAdded(IrcUser *user) {
- if(!user->isInitialized()) {
- usersToSync.insert(user);
- numUsersToSync++;
- emit ircUsersProgress(numUsersToSync - usersToSync.count(), numUsersToSync);
- checkSyncState();
- }
-}
-
-void ClientSyncer::ircUserRemoved(QObject *user) {
- if(usersToSync.contains(user)) {
- numUsersToSync--;
- usersToSync.remove(user);
- emit ircUsersProgress(numUsersToSync - usersToSync.count(), numUsersToSync);
- checkSyncState();
- }
-}
-
void ClientSyncer::checkSyncState() {
- // if(usersToSync.count() + channelsToSync.count() + netsToSync.count() == 0) {
if(netsToSync.isEmpty()) {
- // done syncing!
- /*
- qDebug() << "done";
- foreach(Network *net, _networks.values()) {
- //disconnect(net, 0, this, SLOT(networkInitDone()));
- //disconnect(net, 0, this, SLOT(ircUserInitDone(IrcUser *)));
- //disconnect(net, 0, this, SLOT(ircUserAdded(IrcUser *)));
- //disconnect(net, 0, this, SLOT(ircUserRemoved(QObject *)));
- //disconnect(net, 0, this, SLOT(ircChannelInitDone(IrcChannel *)));
- //disconnect(net, 0, this, SLOT(ircChannelAdded(IrcChannel *)));
- //disconnect(net, 0, this, SLOT(ircChannelRemoved(QObject *)));
- qDebug() << "disconnecting";
- disconnect(net, SIGNAL(initDone()), this, SLOT(networkInitDone()));
- disconnect(net, SIGNAL(ircUserInitDone(IrcUser *)), this, SLOT(ircUserInitDone(IrcUser *)));
- disconnect(net, SIGNAL(ircUserAdded(IrcUser *)), this, SLOT(ircUserAdded(IrcUser *)));
- disconnect(net, SIGNAL(ircUserRemoved(QObject *)), this, SLOT(ircUserRemoved(QObject *)));
- disconnect(net, SIGNAL(ircChannelInitDone(IrcChannel *)), this, SLOT(ircChannelInitDone(IrcChannel *)));
- disconnect(net, SIGNAL(ircChannelAdded(IrcChannel *)), this, SLOT(ircChannelAdded(IrcChannel *)));
- disconnect(net, SIGNAL(ircChannelRemoved(QObject *)), this, SLOT(ircChannelRemoved(QObject *)));
- }
- */
-
Client::instance()->setSyncedToCore();
emit syncFinished();
- //emit connected();
- //emit connectionStateChanged(true);
-
}
}
class ClientSyncer : public QObject {
Q_OBJECT
- public:
- ClientSyncer(QObject *parent = 0);
- ~ClientSyncer();
-
- signals:
- void recvPartialItem(quint32 avail, quint32 size);
- void connectionError(const QString &errorMsg);
- void connectionMsg(const QString &msg);
- void sessionProgress(quint32 part, quint32 total);
- void networksProgress(quint32 part, quint32 total);
- void channelsProgress(quint32 part, quint32 total);
- void ircUsersProgress(quint32 part, quint32 total);
- void socketStateChanged(QAbstractSocket::SocketState);
- void socketDisconnected();
-
- void startLogin();
- void loginFailed(const QString &error);
- void loginSuccess();
- void syncFinished();
- void startCoreSetup(const QVariantList &);
- void coreSetupSuccess();
- void coreSetupFailed(const QString &error);
-
- void encrypted(bool);
-
- public slots:
- void connectToCore(const QVariantMap &);
- void loginToCore(const QString &user, const QString &passwd);
- void disconnectFromCore();
-
- private slots:
- void coreSocketError(QAbstractSocket::SocketError);
- void coreHasData();
- void coreSocketConnected();
- void coreSocketDisconnected();
-
- void clientInitAck(const QVariantMap &msg);
-
+public:
+ ClientSyncer(QObject *parent = 0);
+ ~ClientSyncer();
+
+signals:
+ void recvPartialItem(quint32 avail, quint32 size);
+ void connectionError(const QString &errorMsg);
+ void connectionMsg(const QString &msg);
+ void sessionProgress(quint32 part, quint32 total);
+ void networksProgress(quint32 part, quint32 total);
+ void socketStateChanged(QAbstractSocket::SocketState);
+ void socketDisconnected();
+
+ void startLogin();
+ void loginFailed(const QString &error);
+ void loginSuccess();
+ void syncFinished();
+ void startCoreSetup(const QVariantList &);
+ void coreSetupSuccess();
+ void coreSetupFailed(const QString &error);
+
+ void encrypted(bool);
+
+public slots:
+ void connectToCore(const QVariantMap &);
+ void loginToCore(const QString &user, const QString &passwd);
+ void disconnectFromCore();
+
+private slots:
+ void coreSocketError(QAbstractSocket::SocketError);
+ void coreHasData();
+ void coreSocketConnected();
+ void coreSocketDisconnected();
+
+ void clientInitAck(const QVariantMap &msg);
+
// for sync progress
- void networkInitDone();
- void ircUserAdded(IrcUser *);
- void ircUserRemoved(QObject *);
- void ircUserInitDone(IrcUser *);
- void ircChannelAdded(IrcChannel *);
- void ircChannelRemoved(QObject *);
- void ircChannelInitDone(IrcChannel *);
- void checkSyncState();
-
- void syncToCore(const QVariantMap &sessionState);
- void sessionStateReceived(const QVariantMap &state);
-
- void doCoreSetup(const QVariant &setupData);
+ void networkInitDone();
+ void checkSyncState();
+
+ void syncToCore(const QVariantMap &sessionState);
+ void sessionStateReceived(const QVariantMap &state);
+
+ void doCoreSetup(const QVariant &setupData);
#ifndef QT_NO_OPENSSL
void sslErrors(const QList<QSslError> &errors);
#endif
- private:
- QPointer<QIODevice> socket;
- quint32 blockSize;
- QVariantMap coreConnectionInfo;
-
- QSet<QObject *> netsToSync, channelsToSync, usersToSync;
- int numNetsToSync, numChannelsToSync, numUsersToSync;
-
+private:
+ QPointer<QIODevice> socket;
+ quint32 blockSize;
+ QVariantMap coreConnectionInfo;
+
+ QSet<QObject *> netsToSync;
+ int numNetsToSync;
};
#endif
connect(clientSyncer, SIGNAL(startCoreSetup(const QVariantList &)), this, SLOT(startCoreConfig(const QVariantList &)));
connect(clientSyncer, SIGNAL(sessionProgress(quint32, quint32)), this, SLOT(coreSessionProgress(quint32, quint32)));
connect(clientSyncer, SIGNAL(networksProgress(quint32, quint32)), this, SLOT(coreNetworksProgress(quint32, quint32)));
- connect(clientSyncer, SIGNAL(channelsProgress(quint32, quint32)), this, SLOT(coreChannelsProgress(quint32, quint32)));
- connect(clientSyncer, SIGNAL(ircUsersProgress(quint32, quint32)), this, SLOT(coreIrcUsersProgress(quint32, quint32)));
connect(clientSyncer, SIGNAL(syncFinished()), this, SLOT(syncFinished()));
connect(ui.user, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates()));
ui.sessionProgress->setValue(0);
ui.networksProgress->setRange(0, 1);
ui.networksProgress->setValue(0);
- ui.channelsProgress->setRange(0, 1);
- ui.channelsProgress->setValue(0);
- ui.ircUsersProgress->setRange(0, 1);
- ui.ircUsersProgress->setValue(0);
ui.stackedWidget->setCurrentWidget(ui.syncPage);
// clean up old page
}
}
-void CoreConnectDlg::coreChannelsProgress(quint32 val, quint32 max) {
- if(max == 0) {
- ui.channelsProgress->setFormat("0/0");
- ui.channelsProgress->setRange(0, 1);
- ui.channelsProgress->setValue(1);
- } else {
- ui.channelsProgress->setFormat("%v/%m");
- ui.channelsProgress->setRange(0, max);
- ui.channelsProgress->setValue(val);
- }
-}
-
-void CoreConnectDlg::coreIrcUsersProgress(quint32 val, quint32 max) {
- if(max == 0) {
- ui.ircUsersProgress->setFormat("0/0");
- ui.ircUsersProgress->setRange(0, 1);
- ui.ircUsersProgress->setValue(1);
- } else {
- if(val % 100) return;
- ui.ircUsersProgress->setFormat("%v/%m");
- ui.ircUsersProgress->setRange(0, max);
- ui.ircUsersProgress->setValue(val);
- }
-}
-
void CoreConnectDlg::syncFinished() {
if(!wizard) accept();
else {
void coreSessionProgress(quint32, quint32);
void coreNetworksProgress(quint32, quint32);
- void coreChannelsProgress(quint32, quint32);
- void coreIrcUsersProgress(quint32, quint32);
private:
Ui::CoreConnectDlg ui;
<rect>
<x>0</x>
<y>0</y>
- <width>519</width>
- <height>325</height>
+ <width>563</width>
+ <height>356</height>
</rect>
</property>
<property name="sizePolicy" >
</sizepolicy>
</property>
<property name="currentIndex" >
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="accountPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>511</width>
- <height>317</height>
+ <width>539</width>
+ <height>331</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<rect>
<x>0</x>
<y>0</y>
- <width>511</width>
- <height>317</height>
+ <width>539</width>
+ <height>332</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<rect>
<x>0</x>
<y>0</y>
- <width>485</width>
- <height>147</height>
+ <width>501</width>
+ <height>145</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<rect>
<x>0</x>
<y>0</y>
- <width>511</width>
- <height>317</height>
+ <width>539</width>
+ <height>332</height>
</rect>
</property>
<layout class="QVBoxLayout" >
</property>
</widget>
</item>
- <item row="2" column="0" >
- <widget class="QLabel" name="label_4" >
- <property name="text" >
- <string>Channel states:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="QProgressBar" name="channelsProgress" >
- <property name="maximum" >
- <number>1</number>
- </property>
- <property name="value" >
- <number>0</number>
- </property>
- <property name="format" >
- <string>0/0</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="QLabel" name="label_5" >
- <property name="text" >
- <string>User states:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1" >
- <widget class="QProgressBar" name="ircUsersProgress" >
- <property name="minimum" >
- <number>0</number>
- </property>
- <property name="maximum" >
- <number>1</number>
- </property>
- <property name="value" >
- <number>0</number>
- </property>
- <property name="format" >
- <string>0/0</string>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>