Exemplo n.º 1
0
// we're considering adding a notice n.
// If there's already an identical message n2
//     return false (don't add n)
// If there's a message n2 with same title and text,
//      and n is significantly newer than n2,
//      delete n2
//
// Also remove notices older than 30 days
//
bool NOTICES::remove_dups(NOTICE& n) {
    deque<NOTICE>::iterator i = notices.begin();
    bool removed_something = false;
    bool retval = true;
    double min_time = gstate.now - 30*86400;
    while (i != notices.end()) {
        NOTICE& n2 = *i;
        if (n2.arrival_time < min_time
            || (n2.create_time && n2.create_time < min_time)
        ) {
            i = notices.erase(i);
            removed_something = true;
#if 0
        // this check prevents news item edits from showing; skip it
        } else if (same_guid(n, n2)) {
            n2.keep = true;
            return false;
#endif
        } else if (same_text(n, n2)) {
            int min_diff = 0;

            // show a given scheduler notice at most once a week
            //
            if (!strcmp(n.category, "scheduler")) {
                min_diff = 7*86400;
            }

            if (n.create_time > n2.create_time + min_diff) {
                i = notices.erase(i);
                removed_something = true;
            } else {
                n2.keep = true;
                retval = false;
                ++i;
            }
        } else {
            ++i;
        }
    }
#ifndef SIM
    if (removed_something) {
        gstate.gui_rpcs.set_notice_refresh();
    }
#endif
    return retval;
}
Exemplo n.º 2
0
// Remove "need network access" notices
//
void NOTICES::remove_network_msg() {
    deque<NOTICE>::iterator i = notices.begin();
    while (i != notices.end()) {
        NOTICE& n = *i;
        if (!strcmp(n.description.c_str(), NEED_NETWORK_MSG)) {
            i = notices.erase(i);
#ifndef SIM
            gstate.gui_rpcs.set_notice_refresh();
#endif
            if (log_flags.notice_debug) {
                msg_printf(0, MSG_INFO, "REMOVING NETWORK MESSAGE");
            }
        } else {
            ++i;
        }
    }
}
Exemplo n.º 3
0
void NOTICES::unkeep(const char* url) {
    deque<NOTICE>::iterator i = notices.begin();
    bool removed_something = false;
    while (i != notices.end()) {
        NOTICE& n = *i;
        if (!strcmp(url, n.feed_url) && !n.keep) {
            i = notices.erase(i);
            removed_something = true;
        } else {
            i++;
        }
    }
#ifndef SIM
    if (removed_something) {
        gstate.gui_rpcs.set_notice_refresh();
    }
#endif
}
Exemplo n.º 4
0
// Remove scheduler notices from the given project.
// This is called if we did an RPC to the project requesting work,
// and no notices were returned.
//
void NOTICES::remove_scheduler_notices(PROJECT* p) {
    deque<NOTICE>::iterator i = notices.begin();
    while (i != notices.end()) {
        NOTICE& n = *i;
        if (!strcmp(n.project_name, p->get_project_name())
            && !strcmp(n.category, "scheduler")
        ) {
            i = notices.erase(i);
#ifndef SIM
            gstate.gui_rpcs.set_notice_refresh();
#endif
            if (log_flags.notice_debug) {
                msg_printf(0, MSG_INFO, "REMOVING PROJECT MESSAGE");
            }
        } else {
            ++i;
        }
    }
}
Exemplo n.º 5
0
// Remove outdated notices
//
void NOTICES::remove_notices(PROJECT* p, int which) {
    deque<NOTICE>::iterator i = notices.begin();
    while (i != notices.end()) {
        NOTICE& n = *i;
        if (p && strcmp(n.project_name, p->get_project_name())) {
            ++i;
            continue;
        }
        bool remove = false;
        switch (which) {
        case REMOVE_NETWORK_MSG:
            remove = !strcmp(n.description.c_str(), NEED_NETWORK_MSG);
            break;
        case REMOVE_SCHEDULER_MSG:
            remove = !strcmp(n.category, "scheduler");
            break;
        case REMOVE_NO_WORK_MSG:
            remove = !strcmp(n.description.c_str(), NO_WORK_MSG);
            break;
        case REMOVE_CONFIG_MSG:
            remove = (strstr(n.description.c_str(), "cc_config.xml") != NULL);
            break;
        case REMOVE_APP_INFO_MSG:
            remove = (strstr(n.description.c_str(), "app_info.xml") != NULL);
            break;
        case REMOVE_APP_CONFIG_MSG:
            remove = (strstr(n.description.c_str(), "app_config.xml") != NULL);
            break;
        }
        if (remove) {
            i = notices.erase(i);
#ifndef SIM
            gstate.gui_rpcs.set_notice_refresh();
#endif
            if (log_flags.notice_debug) {
                msg_printf(p, MSG_INFO, "Removing notices of type %d", which);
            }
        } else {
            ++i;
        }
    }
}