2009-12-18 21:52:08 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2009 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-12-21 17:49:28 +00:00
|
|
|
#ifndef _CS_NOTICE_
|
|
|
|
#define _CS_NOTICE_
|
|
|
|
|
|
|
|
// Code related to "notices", which come from
|
2010-09-08 18:06:56 +00:00
|
|
|
// 1) RSS feeds specified by projects and account managers
|
2009-12-21 17:49:28 +00:00
|
|
|
// 2) Scheduler replies (high-priority messages)
|
2009-12-23 18:02:40 +00:00
|
|
|
// 3) the client (MSG_USER_ALERT messages)
|
2009-12-21 17:49:28 +00:00
|
|
|
//
|
|
|
|
// Classes:
|
|
|
|
//
|
|
|
|
// NOTICE represents a notice of any the above types.
|
2010-10-18 20:55:03 +00:00
|
|
|
// Attributes include an "arrival time"; for RSS items, this is the time it
|
2009-12-21 17:49:28 +00:00
|
|
|
// arrived at the client, not the create time.
|
|
|
|
//
|
2010-10-18 20:55:03 +00:00
|
|
|
// NOTICES represents the set of all current notices.
|
2009-12-21 17:49:28 +00:00
|
|
|
// Each notice has a unique seqno, which is a total ordering
|
|
|
|
// compatible with increasing arrival time.
|
|
|
|
// GUI RPC allow the enumerating of notices above a given seqno.
|
|
|
|
// Seqnos are not permanent.
|
|
|
|
//
|
|
|
|
// RSS_FEED represents an RSS feed.
|
2009-12-22 23:00:55 +00:00
|
|
|
// The client polls each feed periodically.
|
2009-12-21 17:49:28 +00:00
|
|
|
//
|
2010-10-18 20:55:03 +00:00
|
|
|
// The last successful reply from each feed is cached on disk.
|
2009-12-21 17:49:28 +00:00
|
|
|
//
|
|
|
|
// Two projects may request the same feed.
|
|
|
|
// So each PROJECT has its own list of feeds.
|
2009-12-22 23:00:55 +00:00
|
|
|
// There's also a merged list "rss_feeds" where seqno is stored.
|
2009-12-21 17:49:28 +00:00
|
|
|
//
|
2009-12-22 23:00:55 +00:00
|
|
|
// files:
|
2010-06-16 22:07:19 +00:00
|
|
|
// notices/feeds.xml feed list
|
|
|
|
// notices/feeds_PROJ_URL.xml list of project feeds
|
2010-10-18 20:55:03 +00:00
|
|
|
// notices/RSS_URL.xml result of last fetch for a feed
|
2010-10-19 15:48:33 +00:00
|
|
|
// notices/archive_RSS_URL.xml archive for a feed
|
2009-12-21 17:49:28 +00:00
|
|
|
|
2009-12-18 21:52:08 +00:00
|
|
|
#include <deque>
|
2009-12-21 17:49:28 +00:00
|
|
|
#include <vector>
|
2009-12-18 21:52:08 +00:00
|
|
|
|
|
|
|
#include "miofile.h"
|
2009-12-22 03:56:24 +00:00
|
|
|
|
|
|
|
#include "gui_http.h"
|
2010-09-08 18:06:56 +00:00
|
|
|
#include "client_types.h"
|
2011-02-19 03:32:26 +00:00
|
|
|
#include "gui_rpc_server.h"
|
2009-12-22 03:56:24 +00:00
|
|
|
|
2009-12-18 21:52:08 +00:00
|
|
|
#include "notice.h"
|
|
|
|
|
2009-12-21 17:49:28 +00:00
|
|
|
struct NOTICES {
|
|
|
|
std::deque<NOTICE> notices;
|
2010-03-12 04:42:25 +00:00
|
|
|
// stored newest (i.e. highest seqno) message first
|
2011-09-18 21:06:49 +00:00
|
|
|
void write(int seqno, GUI_RPC_CONN&, bool public_only);
|
2010-06-29 19:33:18 +00:00
|
|
|
bool append(NOTICE&);
|
2009-12-22 23:00:55 +00:00
|
|
|
void init();
|
2010-01-06 21:39:31 +00:00
|
|
|
void init_rss();
|
2010-03-25 23:48:58 +00:00
|
|
|
int read_archive_file(const char* file, struct RSS_FEED*);
|
2010-01-13 05:32:11 +00:00
|
|
|
void write_archive(struct RSS_FEED*);
|
2010-06-29 19:33:18 +00:00
|
|
|
bool remove_dups(NOTICE&);
|
2010-06-18 17:09:18 +00:00
|
|
|
void remove_network_msg();
|
2010-10-17 04:01:36 +00:00
|
|
|
void clear_keep();
|
2011-03-02 19:15:23 +00:00
|
|
|
// prior to parsing an RSS feed, we mark all notices as "don't keep".
|
|
|
|
// We clear this flag if the notice is present in the feed.
|
2010-10-17 04:01:36 +00:00
|
|
|
void unkeep(const char* url);
|
2011-03-02 19:15:23 +00:00
|
|
|
// called after parsing an RSS feed,
|
|
|
|
// to remove notices that weren't in the feed.
|
2011-10-06 01:14:21 +00:00
|
|
|
void clear() {
|
|
|
|
notices.clear();
|
|
|
|
}
|
2009-12-21 17:49:28 +00:00
|
|
|
};
|
2009-12-18 21:52:08 +00:00
|
|
|
|
2009-12-21 17:49:28 +00:00
|
|
|
extern NOTICES notices;
|
2009-12-18 21:52:08 +00:00
|
|
|
|
|
|
|
struct RSS_FEED {
|
|
|
|
char url[256];
|
2010-01-13 05:32:11 +00:00
|
|
|
char url_base[256];
|
2010-03-12 04:42:25 +00:00
|
|
|
char project_name[256];
|
2009-12-21 17:49:28 +00:00
|
|
|
double poll_interval;
|
|
|
|
double next_poll_time;
|
|
|
|
bool found;
|
|
|
|
// temp used in garbage collection
|
2009-12-18 21:52:08 +00:00
|
|
|
|
|
|
|
int fetch_start();
|
|
|
|
int fetch_complete();
|
2009-12-21 17:49:28 +00:00
|
|
|
|
|
|
|
void write(MIOFILE&);
|
|
|
|
int parse_desc(XML_PARSER&);
|
2009-12-23 17:18:13 +00:00
|
|
|
int parse_items(XML_PARSER&, int&);
|
2009-12-21 17:49:28 +00:00
|
|
|
void feed_file_name(char*);
|
2009-12-22 03:56:24 +00:00
|
|
|
void archive_file_name(char*);
|
2009-12-22 23:00:55 +00:00
|
|
|
int read_archive_file();
|
2009-12-22 03:56:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RSS_FEED_OP: public GUI_HTTP_OP {
|
|
|
|
int error_num;
|
|
|
|
RSS_FEED* rfp;
|
|
|
|
|
|
|
|
RSS_FEED_OP();
|
|
|
|
virtual ~RSS_FEED_OP(){}
|
|
|
|
virtual void handle_reply(int http_op_retval);
|
|
|
|
bool poll();
|
2009-12-18 21:52:08 +00:00
|
|
|
};
|
2009-12-21 17:49:28 +00:00
|
|
|
|
2009-12-23 00:58:27 +00:00
|
|
|
extern RSS_FEED_OP rss_feed_op;
|
|
|
|
|
2009-12-22 23:00:55 +00:00
|
|
|
struct RSS_FEEDS {
|
|
|
|
std::vector<RSS_FEED> feeds;
|
|
|
|
void init();
|
2010-09-08 18:06:56 +00:00
|
|
|
void trigger_fetch(struct PROJ_AM*);
|
2010-01-06 21:39:31 +00:00
|
|
|
void update_feed_list();
|
2009-12-22 23:00:55 +00:00
|
|
|
RSS_FEED* lookup_url(char*);
|
2010-09-08 18:06:56 +00:00
|
|
|
void update_proj_am(PROJ_AM*);
|
2009-12-23 00:58:27 +00:00
|
|
|
void write_feed_list();
|
2011-10-06 01:14:21 +00:00
|
|
|
void clear() {
|
|
|
|
feeds.clear();
|
|
|
|
}
|
2009-12-22 23:00:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern RSS_FEEDS rss_feeds;
|
|
|
|
|
2011-09-20 18:49:38 +00:00
|
|
|
int parse_rss_feed_descs(XML_PARSER&, std::vector<RSS_FEED>&);
|
2010-09-08 18:06:56 +00:00
|
|
|
void handle_sr_feeds(std::vector<RSS_FEED>&, struct PROJ_AM*);
|
2009-12-22 03:56:24 +00:00
|
|
|
// process the feeds in a scheduler reply
|
2009-12-21 17:49:28 +00:00
|
|
|
|
2009-12-18 21:52:08 +00:00
|
|
|
#endif
|