Revision 1853 trunk/plugins/jsonrpc/jsonrpc_events.c
| jsonrpc_events.c (revision 1853) | ||
|---|---|---|
| 302 | 302 | 
                  }  | 
              
| 303 | 303 | 
                   | 
              
| 304 | 304 | 
                  static void  | 
              
| 305 | 
                  file_state_changed (NGPlugin *plugin_data, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, gpointer data)  | 
              |
| 305 | 
                  file_state_changed (NGPlugin *plugin_data, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining, gpointer data)  | 
              |
| 306 | 306 | 
                  {
                 | 
              
| 307 | 307 | 
                  struct json_object *event = json_object_new_object();  | 
              
| 308 | 
                  int i_file_size_remaining = 0;  | 
              |
| 309 | 
                  int i_total_size = 0;  | 
              |
| 310 | 
                  int i_total_size_remaining = 0;  | 
              |
| 308 | 311 | 
                   | 
              
| 312 | 
                      if (file_size_remaining) {
                 | 
              |
| 313 | 
                  i_file_size_remaining = max(1, file_size_remaining / 1024);  | 
              |
| 314 | 
                  }  | 
              |
| 315 | 
                      if (total_size != 0) {
                 | 
              |
| 316 | 
                  i_total_size = max(1, total_size / 1024);  | 
              |
| 317 | 
                  }  | 
              |
| 318 | 
                      if (total_size_remaining != 0) {
                 | 
              |
| 319 | 
                  i_total_size_remaining = max(1, total_size_remaining / 1024);  | 
              |
| 320 | 
                  }  | 
              |
| 321 | 
                   | 
              |
| 309 | 322 | 
                  json_object_object_add(event, "collection_name", json_object_new_string((char*) collection_name));  | 
              
| 310 | 323 | 
                  json_object_object_add(event, "subject", json_object_new_string((char*) subject));  | 
              
| 311 | 324 | 
                  json_object_object_add(event, "real_filename", json_object_new_string((char*) (real_filename ? real_filename : "")));  | 
              
| 312 | 325 | 
                  json_object_object_add(event, "old_state", json_object_new_int(old_state));  | 
              
| 313 | 326 | 
                  json_object_object_add(event, "new_state", json_object_new_int(new_state));  | 
              
| 327 | 
                  json_object_object_add(event, "file_size_remaining", json_object_new_int(i_file_size_remaining));  | 
              |
| 328 | 
                  json_object_object_add(event, "total_size", json_object_new_int(i_total_size));  | 
              |
| 329 | 
                  json_object_object_add(event, "total_size_remaining", json_object_new_int(i_total_size_remaining));  | 
              |
| 314 | 330 | 
                   | 
              
| 315 | 331 | 
                      emit_event("file_state_changed", event);
                 | 
              
| 316 | 332 | 
                   | 
              
Also available in: Unified diff
NNTPGrab

