Changeset 3942789c48c5b3f2e56e9f8ebc8c751bb1a72283

User picture

Commiter: gramakri

Author: gramakri

Parent: e327bd3fa4

(2008/10/21 00:21) Over 3 years ago

Show stats

Affected files

Updated main.cpp Download diff

e327bd3fa4a57b224f9a4f250c0aba826f9a84063942789c48c5b3f2e56e9f8ebc8c751bb1a72283
25
    Q_OBJECT
25
    Q_OBJECT
26
public:
26
public:
27
    KeepAlive(const QString &username, const QString &domain, const QString &password, QWidget *parent = 0)
27
    KeepAlive(const QString &username, const QString &domain, const QString &password, QWidget *parent = 0)
28
        : QWebView(parent)
28
        : QWebView(parent), m_autoLogCount(0)
29
    {
29
    {
30
        setAttribute(Qt::WA_QuitOnClose, false);
30
        setAttribute(Qt::WA_QuitOnClose, false);
31
        connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
31
        connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
...
...
51
        QMenu *menu = new QMenu(this);
51
        QMenu *menu = new QMenu(this);
52
        QAction *showAction = menu->addAction("Show browser");
52
        QAction *showAction = menu->addAction("Show browser");
53
        connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
53
        connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
54
        QAction *statsAction = menu->addAction("Show statistics");
55
        connect(statsAction, SIGNAL(triggered()), this, SLOT(showStatistics()));
54
        menu->addSeparator();
56
        menu->addSeparator();
55
        QAction *exitAction = menu->addAction("Exit");
57
        QAction *exitAction = menu->addAction("Exit");
56
        connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
58
        connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
...
...
77
    {
79
    {
78
        qDebug() << "login() " << url();
80
        qDebug() << "login() " << url();
79
        QVariant result = page()->mainFrame()->evaluateJavaScript(m_loginScript);
81
        QVariant result = page()->mainFrame()->evaluateJavaScript(m_loginScript);
82
        qDebug() << result;
80
        if (result.toBool()) { // script's return value seems to be always false
83
        if (result.toBool()) { // script's return value seems to be always false
81
            qDebug() << "login successful";
84
            qDebug() << "login successful";
85
            ++m_autoLogCount;
82
        }
86
        }
83
        m_watchDogTimer->start();
87
        m_watchDogTimer->start();
84
    }
88
    }
...
...
117
        m_loginTimer->start();
121
        m_loginTimer->start();
118
    }
122
    }
119
123
124
    void showStatistics()
125
    {
126
        QMessageBox::information(this, tr("Statistics"), tr("Auto logged in %1 times").arg(m_autoLogCount));
127
    }
128
120
private:
129
private:
121
    QTimer *m_loginTimer, *m_watchDogTimer;
130
    QTimer *m_loginTimer, *m_watchDogTimer;
122
    QString m_loginScript;
131
    QString m_loginScript;
123
    QSystemTrayIcon *m_trayIcon;
132
    QSystemTrayIcon *m_trayIcon;
133
    int m_autoLogCount;
124
};
134
};
125
135
126
int main(int argc, char *argv[])
136
int main(int argc, char *argv[])