diff --git a/checkin_notes b/checkin_notes
index 88fa596c56..99ba1ffcd4 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -345,3 +345,23 @@ David 12 Jan 2010
AdvancedFrame.cpp
Makefile.am
ViewNotifications* -> ViewNotices*
+
+David 12 Jan 2010
+ - client: small tweak to work fetch:
+ if project has crazy DCF, don't automatically request 1 sec;
+ only request work if there's a shortfall.
+ - intermediate checkin for notices stuff
+
+ client/
+ Makefile.am
+ work_fetch.cpp
+ html/
+ inc/
+ forum_rss.inc
+ notify.inc
+ pm.inc
+ user/
+ notices.php (new)
+ sched
+ handle_request.cpp
+ sched_types.cpp,h
diff --git a/client/Makefile.am b/client/Makefile.am
index d69fc663a1..9f78dc2b91 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -85,6 +85,8 @@ boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD
boinc_clientdir = $(bindir)
switcher_SOURCES = switcher.cpp
+switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib
+switcher_LDADD = $(LIBBOINC)
## since we are using libtool we need some magic to get boinc and boinc_client
## to both be installed properly. The next two rules do that...
diff --git a/client/work_fetch.cpp b/client/work_fetch.cpp
index 48f17feef2..825d80b95c 100644
--- a/client/work_fetch.cpp
+++ b/client/work_fetch.cpp
@@ -332,20 +332,23 @@ PROJECT* RSC_WORK_FETCH::choose_project(int criterion) {
return pbest;
}
-// request this project's share of shortfall and instances
+// request this project's share of shortfall and instances.
+// don't request anything if project is overworked or backed off.
//
void RSC_WORK_FETCH::set_request(PROJECT* p) {
RSC_PROJECT_WORK_FETCH& w = project_state(p);
if (!w.may_have_work) return;
if (w.overworked()) return;
- double dcf = p->duration_correction_factor;
- if (dcf < 0.02 || dcf > 80.0) {
- // if project's DCF is too big or small,
- // its completion time estimates are useless; just ask for 1 second
- //
- req_secs = 1;
- } else {
- req_secs = shortfall * w.fetchable_share;
+ if (shortfall) {
+ double dcf = p->duration_correction_factor;
+ if (dcf < 0.02 || dcf > 80.0) {
+ // if project's DCF is too big or small,
+ // its completion time estimates are useless; just ask for 1 second
+ //
+ req_secs = 1;
+ } else {
+ req_secs = shortfall * w.fetchable_share;
+ }
}
// the number of additional instances needed to have our share
diff --git a/html/inc/forum_rss.inc b/html/inc/forum_rss.inc
index a180d324c9..149f7a67c9 100644
--- a/html/inc/forum_rss.inc
+++ b/html/inc/forum_rss.inc
@@ -22,6 +22,35 @@ require_once("../inc/util.inc");
require_once("../inc/text_transform.inc");
require_once("../project/project.inc");
+function show_forum_rss_item($thread, $userid, $threads_only, $truncate) {
+ $unique_url=URL_BASE."forum_thread.php?id=".$thread->id;
+
+ $clause2 = " and hidden=0 ";
+ if ($userid) $clause2 .= "and user=$userid";
+ if ($threads_only) {
+ $posts = BoincPost::enum("thread=$thread->id $clause2 order by id limit 1");
+ } else {
+ $posts = BoincPost::enum("thread=$thread->id $clause2 order by timestamp desc limit 1");
+ }
+ $post = $posts[0];
+ $post_date = gmdate('D, d M Y H:i:s',$post->timestamp).' GMT';
+ $t = bb2html($post->content, true);
+ if ($truncate) {
+ if (strlen($post->content) > 256) {
+ $t = substr($post->content, 0, 256).". . .";
+ }
+ }
+ $t = htmlspecialchars($t);
+ echo "-
+ ".strip_tags(bb2html($thread->title))."
+ $unique_url
+ $unique_url
+ $t
+ $post_date
+
+ ";
+}
+
function forum_rss($forumid, $userid, $truncate, $threads_only, $ndays) {
$clause = "forum=$forumid ";
@@ -82,32 +111,7 @@ function forum_rss($forumid, $userid, $truncate, $threads_only, $ndays) {
// write news items
//
foreach ($threads as $thread) {
- $unique_url=URL_BASE."forum_thread.php?id=".$thread->id;
-
- $clause2 = " and hidden=0 ";
- if ($userid) $clause2 .= "and user=$userid";
- if ($threads_only) {
- $posts = BoincPost::enum("thread=$thread->id $clause2 order by id limit 1");
- } else {
- $posts = BoincPost::enum("thread=$thread->id $clause2 order by timestamp desc limit 1");
- }
- $post = $posts[0];
- $post_date=gmdate('D, d M Y H:i:s',$post->timestamp).' GMT';
- $t = bb2html($post->content, true);
- if ($truncate) {
- if (strlen($post->content) > 256) {
- $t = substr($post->content, 0, 256).". . .";
- }
- }
- $t = htmlspecialchars($t);
- echo "-
- ".strip_tags(bb2html($thread->title))."
- $unique_url
- $unique_url
- $t
- $post_date
-
- ";
+ show_forum_rss_item($thread, $truncate);
}
echo "
diff --git a/html/inc/notify.inc b/html/inc/notify.inc
index 401d8f52c9..c1a657e6cf 100644
--- a/html/inc/notify.inc
+++ b/html/inc/notify.inc
@@ -26,4 +26,30 @@ function notify_rss_url($user) {
return URL_BASE."notify_rss.php?userid=$user->id&auth=".notify_rss_auth($user);
}
+function show_notify_rss_item($notify) {
+ switch ($notify->type) {
+ case NOTIFY_FRIEND_REQ:
+ friend_req_rss($notify, $title, $msg, $url);
+ break;
+ case NOTIFY_FRIEND_ACCEPT:
+ friend_accept_rss($notify, $title, $msg, $url);
+ break;
+ case NOTIFY_PM:
+ pm_rss($notify, $title, $msg, $url);
+ break;
+ case NOTIFY_SUBSCRIBED_POST:
+ subscribe_rss($notify, $title, $msg, $url);
+ break;
+ }
+
+ $news_date=gmdate('D, d M Y H:i:s',$notify->create_time) . ' GMT';
+ echo "-
+ $title
+ ".htmlentities($url)."
+
+ $news_date
+
+ ";
+}
+
?>
diff --git a/html/inc/pm.inc b/html/inc/pm.inc
index b24d0d3d85..aaab610ba3 100644
--- a/html/inc/pm.inc
+++ b/html/inc/pm.inc
@@ -196,8 +196,8 @@ function pm_email_remind($user) {
function pm_rss($notify, &$title, &$msg, &$url) {
$pm = BoincPrivateMessage::lookup_id($notify->opaque);
$from_user = BoincUser::lookup_id($pm->senderid);
- $title = "New private message";
- $msg = "$from_user->name sent you a private message; subject: $pm->subject";
+ $title = "Private message from $from_user->name: $pm->subject";
+ $msg = "$pm->content";
$url = URL_BASE."pm.php";
}
diff --git a/html/user/notices.php b/html/user/notices.php
new file mode 100644
index 0000000000..f334295a97
--- /dev/null
+++ b/html/user/notices.php
@@ -0,0 +1,103 @@
+.
+
+require_once("../inc/util.inc");
+require_once("../inc/news.inc");
+require_once("../inc/notify.inc");
+require_once("../inc/forum_rss.inc");
+
+function notice_cmp($a, $b) {
+ return $a->time < $b->time;
+}
+
+function notices_rss_start() {
+ $t = gmdate('D, d M Y H:i:s', time())." GMT";
+ header("Expires: $t");
+ header("Last-Modified: $t");
+ header("Content-Type: application/xml");
+ echo "
+
+
+ ".PROJECT." notices
+ ".URL_BASE."
+ Notices
+ $t
+ ";
+}
+
+function notices_rss_end() {
+ echo "
+
+
+ ";
+}
+
+$userid = get_int('userid');
+$auth = get_str('auth');
+$seqno = get_int('auth', true);
+
+$user = BoincUser::lookup_id($userid);
+if (!$user) xml_error();
+//if (notify_rss_auth($user) != $auth) xml_error();
+
+$seqno_clause = $seqno?"and create_time > $seqno":"";
+
+$notifies = BoincNotify::enum("userid = $userid $seqno_clause");
+
+$forum = news_forum();
+if ($forum) {
+ $threads = BoincThread::enum(
+ "forum = $forum->id and hidden=0 $seqno_clause"
+ );
+}
+
+// there may be a better way to do this
+
+$items = array();
+foreach ($notifies as $n) {
+ $i = null;
+ $i->type = 0;
+ $i->time = $n->create_time;
+ $i->val = $n;
+ $items[] = $i;
+}
+
+foreach ($threads as $t) {
+ $i = null;
+ $i->type = 1;
+ $i->time = $t->create_time;
+ $i->val = $t;
+ $items[] = $i;
+}
+
+usort($items, 'notice_cmp');
+
+notices_rss_start();
+foreach ($items as $item) {
+ switch ($item->type) {
+ case 0:
+ show_notify_rss_item($item->val);
+ break;
+ case 1:
+ show_forum_rss_item($item->val, 0, 1, 0);
+ break;
+ }
+}
+notices_rss_end();
+
+?>
diff --git a/html/user/notify_rss.php b/html/user/notify_rss.php
index 7b1049a2e9..9db124ae1c 100644
--- a/html/user/notify_rss.php
+++ b/html/user/notify_rss.php
@@ -66,30 +66,7 @@ echo "
";
foreach ($notifies as $notify) {
- switch ($notify->type) {
- case NOTIFY_FRIEND_REQ:
- friend_req_rss($notify, $title, $msg, $url);
- break;
- case NOTIFY_FRIEND_ACCEPT:
- friend_accept_rss($notify, $title, $msg, $url);
- break;
- case NOTIFY_PM:
- pm_rss($notify, $title, $msg, $url);
- break;
- case NOTIFY_SUBSCRIBED_POST:
- subscribe_rss($notify, $title, $msg, $url);
- break;
- }
-
- $news_date=gmdate('D, d M Y H:i:s',$notify->create_time) . ' GMT';
- $unique_url=URL_BASE."home.php";
- echo "-
- $title
- ".htmlentities($url)."
-
- $news_date
-
- ";
+ show_notify_rss_item($notify);
}
echo "
diff --git a/sched/handle_request.cpp b/sched/handle_request.cpp
index 89234b1fcd..44bc985a1d 100644
--- a/sched/handle_request.cpp
+++ b/sched/handle_request.cpp
@@ -96,12 +96,6 @@ static bool find_host_by_other(DB_USER& user, HOST req_host, DB_HOST& host) {
}
return false;
}
-static void get_weak_auth(USER& user, char* buf) {
- char buf2[256], out[256];
- sprintf(buf2, "%s%s", user.authenticator, user.passwd_hash);
- md5_block((unsigned char*)buf2, strlen(buf2), out);
- sprintf(buf, "%d_%s", user.id, out);
-}
static void send_error_message(const char* msg, int delay) {
g_reply->insert_message(msg, "low");
diff --git a/sched/sched_types.cpp b/sched/sched_types.cpp
index 300da063b3..f7f764fc55 100644
--- a/sched/sched_types.cpp
+++ b/sched/sched_types.cpp
@@ -1194,7 +1194,7 @@ void GUI_URLS::init() {
void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
bool found;
- char userid[256], teamid[256], hostid[256];
+ char userid[256], teamid[256], hostid[256], weak_auth[256], rss_auth[256];
strcpy(buf, "");
if (!text) return;
strcpy(buf, text);
@@ -1208,8 +1208,10 @@ void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
while (remove_element(buf, "", "")) {
continue;
}
-
}
+
+ get_weak_auth(user, weak_auth);
+ get_rss_auth(user, rss_auth);
while (1) {
found = false;
found |= str_replace(buf, "", userid);
@@ -1218,6 +1220,8 @@ void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
found |= str_replace(buf, "", teamid);
found |= str_replace(buf, "", team.name);
found |= str_replace(buf, "", user.authenticator);
+ found |= str_replace(buf, "", weak_auth);
+ found |= str_replace(buf, "", rss_auth);
if (!found) break;
}
}
@@ -1227,4 +1231,18 @@ void PROJECT_FILES::init() {
read_file_malloc(config.project_path("project_files.xml"), text);
}
+void get_weak_auth(USER& user, char* buf) {
+ char buf2[256], out[256];
+ sprintf(buf2, "%s%s", user.authenticator, user.passwd_hash);
+ md5_block((unsigned char*)buf2, strlen(buf2), out);
+ sprintf(buf, "%d_%s", user.id, out);
+}
+
+void get_rss_auth(USER& user, char* buf) {
+ char buf2[256], out[256];
+ sprintf(buf2, "%s%s%s", user.authenticator, user.passwd_hash, "notify_rss");
+ md5_block((unsigned char*)buf2, strlen(buf2), out);
+ sprintf(buf, "%d_%s", user.id, out);
+}
+
const char *BOINC_RCSID_ea659117b3 = "$Id$";
diff --git a/sched/sched_types.h b/sched/sched_types.h
index 66ddfa60d7..088f28e534 100644
--- a/sched/sched_types.h
+++ b/sched/sched_types.h
@@ -469,4 +469,7 @@ static inline void add_no_work_message(char* m) {
g_wreq->add_no_work_message(m);
}
+extern void get_weak_auth(USER&, char*);
+extern void get_rss_auth(USER&, char*);
+
#endif