Beispiel #1
0
QVariant CookieModel::data(const QModelIndex &index, int role) const
{
    if (index.row() < 0 || index.row() >= m_cookies.size())
        return QVariant();

    switch (role) {
    case Qt::DisplayRole:
    case Qt::EditRole: {
        QNetworkCookie cookie = m_cookies.at(index.row());
        switch (index.column()) {
        case 0:
            return cookie.domain();
        case 1:
            return cookie.name();
        case 2:
            return cookie.path();
        case 3:
            return cookie.isSecure() ? tr("true") : tr("false");
        case 4:
            return cookie.isSessionCookie() ? tr("Session cookie") : cookie.expirationDate().toString();
        case 5:
            return cookie.value();
        }
    }
    case Qt::FontRole: {
        QFont font;
        font.setPointSize(10);
        return font;
    }
    }

    return QVariant();
}
Beispiel #2
0
CookieDialog::CookieDialog(const QNetworkCookie &cookie, QWidget *parent): QDialog(parent)
{
    setupUi(this);
    m_nameLineEdit->setText(cookie.name());
    m_domainLineEdit->setText(cookie.domain());
    m_valueLineEdit->setText(cookie.value());
    m_pathLineEdit->setText(cookie.path());
    m_dateEdit->setDate(cookie.expirationDate().date());
    m_isSecureComboBox->addItem(cookie.isSecure() ? tr("yes") : tr("no"));
    m_isHttpOnlyComboBox->addItem(cookie.isHttpOnly() ? tr("yes") : tr("no"));
    m_addButton->setVisible(false);
    m_cancelButton->setText(tr("Close"));
}
void ShibLoginDialog::onNewCookieCreated(const QUrl& url, const QNetworkCookie& cookie)
{
    QString name = cookie.name();
    if (url.host() == url_.host() && name == kSeahubShibCookieName) {
        QString value = cookie.value();

        Account account = parseAccount(value);
        if (seafApplet->accountManager()->saveAccount(account) < 0) {
            seafApplet->warningBox(tr("Failed to save current account"), this);
            reject();
        } else {
            accept();
        }
    }
}
void ShibLoginDialog::onNewCookieCreated(const QUrl& url, const QNetworkCookie& cookie)
{
    if (cookie_seen_) {
        return;
    }
    QString name = cookie.name();
    QString value = cookie.value();
    if (url.host() == url_.host() && name == kSeahubShibCookieName) {
        Account account = parseAccount(value);
        if (!account.isValid()) {
            qWarning("wrong account information from server");
            return;
        }
        cookie_seen_ = true;
        if (seafApplet->accountManager()->saveAccount(account) < 0) {
            seafApplet->warningBox(tr("Failed to save current account"), this);
            reject();
        } else {
            accept();
        }
    }
}
Beispiel #5
0
void CookieJar::saveCookies()
{
    QString fName = m_appPath;
    fName += "cookies";
    QSettings cnFile(fName, QSettings::IniFormat);
    cnFile.clear();

    cnFile.setValue("login", m_sVkLogin);

    QList<QNetworkCookie> cookies = allCookies();
    cnFile.beginWriteArray("cookies");
    for(int i=0; i<cookies.size(); i++) {
        QNetworkCookie cook = cookies.at(i);

        cnFile.setArrayIndex(i);

        cnFile.setValue("name", cook.name());
        cnFile.setValue("value", cook.value());
        cnFile.setValue("domain", cook.domain());
        cnFile.setValue("path", cook.path());
    }
    cnFile.endArray();
}