]> git.wh0rd.org Git - tt-rss.git/commitdiff
report runtime info in counter callbacks
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 23 May 2006 08:59:00 +0000 (09:59 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 23 May 2006 08:59:00 +0000 (09:59 +0100)
backend-rpc.php
functions.js
functions.php
tt-rss.js

index 1e98aa125bcd2be4d96b5a370820a7542a1ed387..6387b1e53a460d84ef4f9aafa7f818abf4280ace 100644 (file)
                if ($subop == "getLabelCounters") {
                        $aid = $_GET["aid"];            
                        print "<rpc-reply>";
+                       print "<counters>";
                        getLabelCounters($link);
                        if ($aid) {
                                getFeedCounter($link, $aid);
                        }
+                       print "</counters>";
                        print "</rpc-reply>";
                }
 
                if ($subop == "getFeedCounters") {
                        print "<rpc-reply>";
+                       print "<counters>";
                        getFeedCounters($link);
+                       print "</counters>";
                        print "</rpc-reply>";
                }
 
                if ($subop == "getAllCounters") {
                        print "<rpc-reply>";
+                       print "<counters>";
                        getAllCounters($link);
+                       print "</counters>";
+                       print_runtime_info($link);
                        print "</rpc-reply>";
                }
 
                                update_rss_feed($link, $feed_url, $feed_id);
                        }
 
-                       print "<rpc-reply>";
+                       print "<rpc-reply>";    
+                       print "<counters>";
                        getFeedCounter($link, $feed_id);
+                       print "</counters>";
                        print "</rpc-reply>";
                        
                        return;
 
                        print "<rpc-reply>";
 
+                       print "<counters>";
+
                        if ($global_unread_caller != $global_unread) {
 
                                $omode = $_GET["omode"];
 
                        getGlobalCounters($link, $global_unread);
 
+                       print "</counters>";
+
+                       print_runtime_info($link);
+
                        print "</rpc-reply>";
 
                }
                                }
                        }
                        print "<rpc-reply>";
+                       print "<counters>";
                        getAllCounters($link);
+                       print "</counters>";
+                       print_runtime_info($link);
                        print "</rpc-reply>";
                }
 
                                }
                        }
                        print "<rpc-reply>";
+                       print "<counters>";
                        getAllCounters($link);
+                       print "</counters>";
+                       print_runtime_info($link);
                        print "</rpc-reply>";
                }
 
                        if (sanity_check($link)) {
                                print "<error error-code=\"0\"/>";
                                print_init_params($link);
+                               print_runtime_info($link);
                        }
                        print "</rpc-reply>";
                }               
index 35579364047fa149fc88c2f1c2d530bf49a32fa1..e58a9703653bbe8e4c1d6800a822cf58fe81458a 100644 (file)
@@ -470,6 +470,11 @@ function parse_counters(reply, scheduled_call) {
                var f_document = getFeedsContext().document;
                var title_obj = getMainContext();
 
+               if (reply.firstChild && reply.firstChild.firstChild) {
+                       debug("<b>wrong element passed to parse_counters, adjusting.</b>");
+                       reply = reply.firstChild;
+               }
+
                debug("F_DOC: " + f_document + ", T_OBJ: " + title_obj);
 
                for (var l = 0; l < reply.childNodes.length; l++) {
@@ -565,7 +570,9 @@ function all_counters_callback() {
 
                        var reply = xmlhttp_rpc.responseXML.firstChild;
 
-                       parse_counters(reply);
+                       var counters = reply.firstChild;
+
+                       parse_counters(counters);
        
                } catch (e) {
                        exception_error("all_counters_callback", e);
index 5ec8d45f464a3662ac23baa3b98fdee044907959..fbce56b5ed9e4cb3e4fc3eb8968f956425ca3df5 100644 (file)
 
                print "</init-params>";
        }
+
+       function print_runtime_info($link) {
+               print "<runtime-info>";
+               print "<param key=\"daemon_is_running\" value=\"".
+                       sprintf("%d", file_is_locked("update_daemon.lock")) . "\"/>";
+               print "</runtime-info>";
+       }
 ?>
index 55c813b7f70750ecc9428d439e8912c7cbdd0fd5..7157d3292ef8f03ca625816d53e4922b49f12adf 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -70,8 +70,10 @@ function refetch_callback() {
                        if (error_code && error_code != 0) {
                                return fatalError(error_code, reply.getAttribute("error-msg"));
                        }
+
+                       var counters = reply.firstChild;
        
-                       parse_counters(reply, true);
+                       parse_counters(counters, true);
 
                        debug("refetch_callback: done");