Пример #1
0
Server::Server(CreateUserLookupFn *createUserLookup, QObject *parent)
  : QObject(parent)
{
  group = new User_Group(createUserLookup, this);
  connect(group, SIGNAL(userAuthenticated()),
          this, SLOT(userAuthenticated()));
  connect(group, SIGNAL(userDisconnected()),
          this, SLOT(userDisconnected()));

  connect(&listener, SIGNAL(newConnection()),
          this, SLOT(acceptNewConnection()));

  sessionUpdateTimer.setSingleShot(true);
  connect(&sessionUpdateTimer, SIGNAL(timeout()),
          this, SLOT(updateNextSession()));
}
KOVirtCredGreeter::KOVirtCredGreeter(KGreeterPluginHandler *handler,
                                   QWidget *parent,
                                   const QString &fixedEntity,
                                   Function func, Context ctx) :
    QObject(),
    KGreeterPlugin(handler)
{
    Q_UNUSED(parent);
    Q_UNUSED(fixedEntity);
    Q_UNUSED(func);
    Q_UNUSED(ctx);

    parent = new QWidget(parent);
    parent->setObjectName("welcome");
    widgetList << parent;

    QBoxLayout *grid = new QBoxLayout(QBoxLayout::LeftToRight, parent);
    m_titleLabel = new QLabel(i18n("oVirt Automatic Login System"), parent);
    grid->addWidget(m_titleLabel, 0, Qt::AlignHCenter);    

    m_Credentials = new OVirtCred(KDM_OVIRTCRED_SERVER_DBUS_NAME, KDM_OVIRTCRED_SERVER_DBUS_PATH,
        QDBusConnection::systemBus(), 0);
        
    QObject::connect(m_Credentials, SIGNAL(UserAuthenticated(QString)),
        this, SLOT(userAuthenticated(QString)));
}
void GoogleDocumentService::handleNetworkData(QNetworkReply *networkReply)
{
    if (!networkReply->error()) {
        if (!loggedin) {
            QString text(networkReply->readAll());
            text = text.right(text.length() - text.indexOf("Auth=") - 5);
            authToken = QString("GoogleLogin auth=") + text.left(text.indexOf("\n"));
            if(authToken.length() > 20) {
                if(!haveDocAuthToken) {
                    docAuthToken = authToken;
                    haveDocAuthToken = true;
                    qDebug() << "Received Doc token = " << docAuthToken;
                    clientLogin(this->username, this->password);
                    return;
                }
                spreadAuthToken = authToken;
                authToken = "";
                loggedin = true;
                qDebug() << "Received Spreadsheet token = " << spreadAuthToken;
                listDocuments();
                emit userAuthenticated(loggedin, "");
            }
        }
        else if (waitingForDoc) {
            QByteArray data = networkReply->readAll();
            QFile file(QDir::tempPath() + QLatin1Char('/') + documentList->currentDocument());
            file.open(QIODevice::ReadWrite);
            file.write(data);
            file.close();
            qDebug() << "Received Document!!!!! " << file.fileName();
            emit receivedDocument(file.fileName());
            waitingForDoc = false;
            showDocumentListWindow(false);
        }
        else {
            QByteArray bytAry = networkReply->readAll();
//            qDebug() << bytAry;

//            xmlInput.setData(networkReply->readAll());
            xmlInput.setData(bytAry);
            qDebug() << "Part received.........";
            if (newInformation) {
                emit progressUpdate("Parsing document list...");
                newInformation = xmlReader.parse(&xmlInput, true);
                qDebug() << "New Information = " << newInformation;
//                newInformation = false;
                getDocument();
            }
        }
    } else {
        QString errorString(networkReply->readAll());
        qDebug() << "Error occurred !!!!  " << errorString;
        errorString = errorString.right(errorString.length() - errorString.indexOf("Error=") - 6);
        if (!loggedin) {
            emit userAuthenticated(loggedin, errorString);
        } else {
            QMessageBox msgBox(QMessageBox::Information, i18n("Online Document Services"),
                               "Error occurred !!!!  " + errorString);
            msgBox.exec();
        }
    }
}