示例#1
0
/**
 * @brief Reports the visited websites to the central services.
 * @return True if success
 */
bool CentralServiceReporter::reportBrowsingHistory()
{
    QVariantList history;
    IDatabaseSettings *settings = m_proxyConnection->databaseSettings(this);

    IDatabaseSelectQuery *query = m_proxyConnection->databaseSelect("pages", this);
    QString lastReport = settings->value("last_central_service_report", "");
    IDatabaseSelectQueryWhereGroup *joinOn = query->join("user_visits_pages")->whereGroup(IDatabaseSelectQuery::And);
    joinOn->where("user_visits_pages.page_id", "pages.id", IDatabaseSelectQuery::Equal, false);
    if (lastReport != "")
        joinOn->where("user_visits_pages.date_created", lastReport, IDatabaseSelectQuery::GreaterThan);
    query->select("pages.id, pages.absolute_uri, user_visits_pages.date_created");
    query->limit(500);

    QString currentDate = QDateTime::currentDateTime().toString(Qt::ISODate);

    while (query->next()) {
        QVariantMap item;
        item.insert("cache_id", query->value("id").toUInt());
        item.insert("absolute_uri", query->value("absolute_uri").toString());
        item.insert("accessed_at", query->value("date_created").toString());
        history.append(item);
    }
    if (!history.count())
        return true;

    if (sendHistory(history)) {
        settings->setValue("last_central_service_report", currentDate);
        return true;
    }
    m_proxyConnection->message("Central Service Report: Failed to report browsing hitory to the service");
    return false;
}
示例#2
0
文件: Client.cpp 项目: 4ukuta/core
void Client::onHistoryFull()
{
  if (isOnline() && isAuthentificated())
  {
    sendHistory();
    getTagsRequest();
  }
}
示例#3
0
文件: Client.cpp 项目: 4ukuta/core
void Client::stopTrack()
{
  if (m_timer->isActive())
  {
    m_timer->stop();
    m_additionalTimer->start(m_history->getHistoryLimit()*m_trackInterval*1000);
  }
  if (isOnline() && isAuthentificated() && !m_history->isEmpty()) sendHistory();
}
示例#4
0
文件: Client.cpp 项目: 4ukuta/core
void Client::onNetworkEvent(bool state)
{
  if (state) sendHistory();
}
示例#5
0
文件: Client.cpp 项目: 4ukuta/core
void Client::onGoOffEvent()
{
  sendHistory();
}