~ubuntu-branches/ubuntu/vivid/quassel/vivid-updates

« back to all changes in this revision

Viewing changes to src/core/core.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Michael Marley
  • Date: 2015-02-19 07:42:04 UTC
  • mfrom: (1.1.59)
  • Revision ID: package-import@ubuntu.com-20150219074204-vu1qv4i0devi2j2t
Tags: 0.12~beta1-0ubuntu1
[ Michael Marley ]
* New upstream kf5 based beta release
  - Drop patches debian/patches/CVE-2014-8483.patch,
    upstream_qca-qt5-cmake.patch and upstream_qca-qt5-code.patch
  - Add kf5 build-deps
  - Adjust install paths
* Fix upstart job to avoid race conditions on restart

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2005-2014 by the Quassel Project                        *
 
2
 *   Copyright (C) 2005-2015 by the Quassel Project                        *
3
3
 *   devel@quassel-irc.org                                                 *
4
4
 *                                                                         *
5
5
 *   This program is free software; you can redistribute it and/or modify  *
222
222
    foreach(CoreAuthHandler *handler, _connectingClients) {
223
223
        handler->deleteLater(); // disconnect non authed clients
224
224
    }
225
 
    qDeleteAll(sessions);
 
225
    qDeleteAll(_sessions);
226
226
    qDeleteAll(_storageBackends);
227
227
}
228
228
 
234
234
    CoreSettings s;
235
235
    QVariantMap state;
236
236
    QVariantList activeSessions;
237
 
    foreach(UserId user, instance()->sessions.keys()) activeSessions << QVariant::fromValue<UserId>(user);
 
237
    foreach(UserId user, instance()->_sessions.keys())
 
238
        activeSessions << QVariant::fromValue<UserId>(user);
238
239
    state["CoreStateVersion"] = 1;
239
240
    state["ActiveSessions"] = activeSessions;
240
241
    s.setCoreState(state);
247
248
        // qWarning() << qPrintable(tr("Cannot restore a state for an unconfigured core!"));
248
249
        return;
249
250
    }
250
 
    if (instance()->sessions.count()) {
 
251
    if (instance()->_sessions.count()) {
251
252
        qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
252
253
        return;
253
254
    }
265
266
        quInfo() << "Restoring previous core state...";
266
267
        foreach(QVariant v, activeSessions) {
267
268
            UserId user = v.value<UserId>();
268
 
            instance()->createSession(user, true);
 
269
            instance()->sessionForUser(user, true);
269
270
        }
270
271
    }
271
272
}
577
578
    handler->deleteLater();
578
579
 
579
580
    // Find or create session for validated user
580
 
    SessionThread *session;
581
 
    if (sessions.contains(uid)) {
582
 
        session = sessions[uid];
583
 
    }
584
 
    else {
585
 
        session = createSession(uid);
586
 
        if (!session) {
587
 
            qWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(peer->description());
588
 
            peer->close();
589
 
            peer->deleteLater();
590
 
            return;
591
 
        }
592
 
    }
 
581
    sessionForUser(uid);
593
582
 
594
583
    // as we are currently handling an event triggered by incoming data on this socket
595
584
    // it is unsafe to directly move the socket to the client thread.
610
599
void Core::addClientHelper(RemotePeer *peer, UserId uid)
611
600
{
612
601
    // Find or create session for validated user
613
 
    if (!sessions.contains(uid)) {
614
 
        qWarning() << qPrintable(tr("Could not find a session for client:")) << qPrintable(peer->description());
615
 
        peer->close();
616
 
        peer->deleteLater();
617
 
        return;
618
 
    }
619
 
 
620
 
    SessionThread *session = sessions[uid];
 
602
    SessionThread *session = sessionForUser(uid);
621
603
    session->addClient(peer);
622
604
}
623
605
 
643
625
    clientPeer->setPeer(corePeer);
644
626
 
645
627
    // Find or create session for validated user
646
 
    SessionThread *sessionThread;
647
 
    if (sessions.contains(uid))
648
 
        sessionThread = sessions[uid];
649
 
    else
650
 
        sessionThread = createSession(uid);
651
 
 
 
628
    SessionThread *sessionThread = sessionForUser(uid);
652
629
    sessionThread->addClient(corePeer);
653
630
}
654
631
 
655
632
 
656
 
SessionThread *Core::createSession(UserId uid, bool restore)
 
633
SessionThread *Core::sessionForUser(UserId uid, bool restore)
657
634
{
658
 
    if (sessions.contains(uid)) {
659
 
        qWarning() << "Calling createSession() when a session for the user already exists!";
660
 
        return 0;
661
 
    }
662
 
    SessionThread *sess = new SessionThread(uid, restore, this);
663
 
    sessions[uid] = sess;
664
 
    sess->start();
665
 
    return sess;
 
635
    if (_sessions.contains(uid))
 
636
        return _sessions[uid];
 
637
 
 
638
    SessionThread *session = new SessionThread(uid, restore, this);
 
639
    _sessions[uid] = session;
 
640
    session->start();
 
641
    connect(session, SIGNAL(passwordChangeRequested(UserId, QString)), _storage, SLOT(updateUser(UserId, QString)));
 
642
    return session;
666
643
}
667
644
 
668
645