// called at the end of client initialization // void NOTICES::init_rss() { rss_feeds.init(); if (log_flags.notice_debug) { msg_printf(0, MSG_INFO, "read %d total notices", (int)notices.size()); } // sort by decreasing arrival time, then assign seqnos // sort(notices.begin(), notices.end(), cmp); size_t n = notices.size(); for (unsigned int i=0; i<n; i++) { notices[i].seqno = (int)(n - i); } }
// write archive file for the given RSS feed // (or, if NULL, non-RSS notices) // void NOTICES::write_archive(RSS_FEED* rfp) { char path[MAXPATHLEN]; if (rfp) { rfp->archive_file_name(path); } else { safe_strcpy(path, NOTICES_DIR"/archive.xml"); } FILE* f = fopen(path, "w"); if (!f) return; MIOFILE fout; fout.init_file(f); fout.printf("<notices>\n"); if (!f) return; for (unsigned int i=0; i<notices.size(); i++) { NOTICE& n = notices[i]; if (rfp) { if (strcmp(rfp->url, n.feed_url)) continue; } else { if (strlen(n.feed_url)) continue; } n.write(fout, false); } fout.printf("</notices>\n"); fclose(f); }
// called at the start of client initialization // void NOTICES::init() { #if 0 read_archive_file(NOTICES_DIR"/archive.xml", NULL); if (log_flags.notice_debug) { msg_printf(0, MSG_INFO, "read %d BOINC notices", (int)notices.size()); } write_archive(NULL); #endif }
// write notices newer than seqno as XML (for GUI RPC). // Write them in order of increasing seqno // void NOTICES::write(int seqno, GUI_RPC_CONN& grc, bool public_only) { size_t i; MIOFILE mf; if (!net_status.need_physical_connection) { remove_notices(NULL, REMOVE_NETWORK_MSG); } if (log_flags.notice_debug) { msg_printf(0, MSG_INFO, "NOTICES::write: seqno %d, refresh %s, %d notices", seqno, grc.get_notice_refresh()?"true":"false", (int)notices.size() ); } grc.mfout.printf("<notices>\n"); if (grc.get_notice_refresh()) { grc.clear_notice_refresh(); NOTICE n; n.seqno = -1; seqno = -1; i = notices.size(); n.write(grc.mfout, true); if (log_flags.notice_debug) { msg_printf(0, MSG_INFO, "NOTICES::write: sending -1 seqno notice"); } } else { for (i=0; i<notices.size(); i++) { NOTICE& n = notices[i]; if (n.seqno <= seqno) break; } } for (; i>0; i--) { NOTICE& n = notices[i-1]; if (public_only && n.is_private) continue; if (log_flags.notice_debug) { msg_printf(0, MSG_INFO, "NOTICES::write: sending notice %d", n.seqno); } n.write(grc.mfout, true); } grc.mfout.printf("</notices>\n"); }