File: cs_notice.h

package info (click to toggle)
boinc 8.0.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 106,832 kB
  • sloc: cpp: 167,537; php: 111,699; pascal: 56,262; ansic: 49,284; xml: 18,762; python: 7,938; javascript: 6,538; sh: 5,719; makefile: 2,183; java: 2,041; objc: 1,867; perl: 1,843; sql: 830; lisp: 47; csh: 30
file content (154 lines) | stat: -rw-r--r-- 4,600 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// 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/>.

#ifndef BOINC_CS_NOTICE_H
#define BOINC_CS_NOTICE_H

// Code related to "notices", which come from
// 1) RSS feeds specified by projects and account managers
// 2) Scheduler replies (high-priority messages)
// 3) the client (MSG_USER_ALERT messages)
//
// Classes:
//
// NOTICE represents a notice of any the above types.
// Attributes include an "arrival time"; for RSS items, this is the time it
// arrived at the client, not the create time.
//
// NOTICES represents the set of all current notices.
// 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.
// The client polls each feed periodically.
//
// The last successful reply from each feed is cached on disk.
//
// Two projects may request the same feed.
// So each PROJECT has its own list of feeds.
// There's also a merged list "rss_feeds" where seqno is stored.
//
// files:
// notices/feeds.xml                feed list
// notices/feeds_PROJ_URL.xml       list of project feeds
// notices/RSS_URL.xml              result of last fetch for a feed
// notices/archive_RSS_URL.xml      archive for a feed

#include <deque>
#include <vector>

#include "miofile.h"

#include "gui_http.h"
#include "client_types.h"
#include "gui_rpc_server.h"

#include "notice.h"

struct NOTICES {
    std::deque<NOTICE> notices;
        // stored newest (i.e. highest seqno) message first
    void write(int seqno, GUI_RPC_CONN&, bool public_only);
    bool append(NOTICE&);
    void init();
    void init_rss();
    int read_archive_file(const char* file, struct RSS_FEED*);
    void write_archive(struct RSS_FEED*);
    bool remove_dups(NOTICE&);
    void remove_notices(PROJECT*, int which);
    void clear_keep();
        // 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.
    void unkeep(const char* url);
        // called after parsing an RSS feed,
        // to remove notices that weren't in the feed.
    void clear() {
        notices.clear();
    }
};

// args to remove_notices()
#define REMOVE_NETWORK_MSG      0
    // "need network access" notice
#define REMOVE_SCHEDULER_MSG    1
    // msgs from scheduler
#define REMOVE_CONFIG_MSG       3
    // notices about cc_config.xml
#define REMOVE_APP_INFO_MSG     4
    // notices about project/app_info.xml
#define REMOVE_APP_CONFIG_MSG   5
    // notices about project/app_config.xml

extern NOTICES notices;

struct RSS_FEED {
    char url[256];
    char url_base[256];
    char project_name[256];
    double poll_interval;
    double next_poll_time;
    bool found;
        // temp used in garbage collection

    int fetch_start();
    int fetch_complete();

    void write(MIOFILE&);
    int parse_desc(XML_PARSER&);
    int parse_items(XML_PARSER&, int&);
    void feed_file_name(char*, int);
    void archive_file_name(char*, int);
    int read_archive_file();
    void delete_files();
};

struct RSS_FEED_OP: public GUI_HTTP_OP {
    int error_num;
    bool canceled;

    RSS_FEED_OP();
    virtual ~RSS_FEED_OP(){}
    virtual void handle_reply(int http_op_retval);
    bool poll();
};

extern RSS_FEED_OP rss_feed_op;

struct RSS_FEEDS {
    std::vector<RSS_FEED> feeds;
    void init();
    void trigger_fetch(struct PROJ_AM*);
    void update_feed_list();
    RSS_FEED* lookup_url(char*);
    void update_proj_am(PROJ_AM*);
    void write_feed_list();
    void clear() {
        feeds.clear();
    }
};

extern RSS_FEEDS rss_feeds;

int parse_rss_feed_descs(XML_PARSER&, std::vector<RSS_FEED>&);
void handle_sr_feeds(std::vector<RSS_FEED>&, struct PROJ_AM*);
    // process the feeds in a scheduler reply

void delete_project_notice_files(PROJECT*);

#endif