Enlightenment CVS committal Author : nasa01 Project : e_modules Module : monitor
Dir : e_modules/monitor Modified Files: e_mod_config.c e_mod_main.c e_mod_main.h Log Message: Fixing small bug, adding couple of sensors =================================================================== RCS file: /cvsroot/enlightenment/e_modules/monitor/e_mod_config.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_mod_config.c 24 Dec 2005 02:31:46 -0000 1.3 +++ e_mod_config.c 28 Dec 2005 16:47:12 -0000 1.4 @@ -117,7 +117,7 @@ static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, void *data) { - Evas_Object *o, *of, *ob, *ob1, *ob2, *ob3, *ob4, *ot; + Evas_Object *o, *of, *ob, *ob1, *ob2, *ob3, *ob4, *ob5, *ob6, *ob7,*ot; E_Radio_Group *rg; CFData *cfdata; cfdata = data; @@ -140,6 +140,12 @@ e_widget_framelist_object_append(of, ob3); ob4 = e_widget_check_add(evas, _("WLAN"), &(mon->conf->wlan)); e_widget_framelist_object_append(of, ob4); + ob5 = e_widget_check_add(evas, _("Hostname"), &(mon->conf->hostname)); + e_widget_framelist_object_append(of, ob5); + ob6 = e_widget_check_add(evas, _("Uptime"), &(mon->conf->uptime)); + e_widget_framelist_object_append(of, ob6); + ob7 = e_widget_check_add(evas, _("time"), &(mon->conf->time)); + e_widget_framelist_object_append(of, ob7); e_widget_list_object_append(o, of, 1, 1, 0.5); of = e_widget_framelist_add(evas, _("Monitor"), 0); =================================================================== RCS file: /cvsroot/enlightenment/e_modules/monitor/e_mod_main.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e_mod_main.c 24 Dec 2005 02:31:46 -0000 1.4 +++ e_mod_main.c 28 Dec 2005 16:47:12 -0000 1.5 @@ -1,4 +1,10 @@ #include "e_mod_main.h" +#include <sys/utsname.h> +#include <stdio.h> +#include <linux/unistd.h> /* for _syscallX macros/related stuff */ +#include <linux/kernel.h> /* for struct sysinfo */ + + /* module private routines */ @@ -23,6 +29,7 @@ static void _monitor_wlan_link_text_update_callcack(Flow_Chart *chart, void *data); static void _monitor_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi); static void _add_sensor(Monitor_Face *face, Evas_Object *o, int VerHor); +static int _date_cb_check(void *data); static int _monitor_count; static int num_sensors; @@ -180,16 +187,22 @@ E_CONFIG_VAL(D, T, net, INT); E_CONFIG_VAL(D, T, wlan, INT); E_CONFIG_VAL(D, T, Horz, INT); + E_CONFIG_VAL(D, T, hostname, INT); + E_CONFIG_VAL(D, T, uptime, INT); + E_CONFIG_VAL(D, T, time, INT); monitor->conf = e_config_domain_load("module.monitor", conf_edd); if (!monitor->conf) { monitor->conf = E_NEW(Config, 1); - monitor->conf->cpu = 1; - monitor->conf->mem = 1; - monitor->conf->net = 1; - monitor->conf->wlan = 1; + monitor->conf->cpu = 0; + monitor->conf->mem = 0; + monitor->conf->net = 0; + monitor->conf->wlan = 0; monitor->conf->Horz = 0; + monitor->conf->hostname = 1; + monitor->conf->uptime = 1; + monitor->conf->time = 0; } _monitor_config_menu_new(monitor); @@ -223,7 +236,7 @@ else { face->conf = cl->data; - if (face->conf->config_version != MONITOR_CONFIG_VERSION) + /* if (face->conf->config_version != MONITOR_CONFIG_VERSION) { face->conf = E_NEW(Config_Face, 1); face->conf = _monitor_face_config_init(face->conf); @@ -231,7 +244,7 @@ _("Configuration data needed upgrading. Your old configuration\n" "has been removed. Please reset your setting for the monitor\n" "module. Sorry for the inconvenience.\n")); - } + } */ cl = cl->next; } @@ -305,7 +318,17 @@ { Monitor_Face *face; Evas_Object *o; + struct utsname u_buf; + char u_date_time[256]; + struct sysinfo s_info; + sysinfo (&s_info); + + long minute = 60; + long hour = minute * 60; + long day = hour * 24; + double megabyte = 1024 * 1024; + uname (&u_buf); /* * Configuration cannot be used yet as the face config * is not initialized. Everything will be updated after @@ -337,6 +360,19 @@ e_table_homogenous_set(o, 1); edje_object_part_swallow(face->monitor_object, "items", face->table_object); evas_object_show(o); + + /*setup hostname sensor*/ + if (config->hostname) + { + face->hostname = edje_object_add(con->bg_evas); + edje_object_file_set(face->hostname, PACKAGE_DATA_DIR"/monitor.edj", "monitor/host"); + _add_sensor(face,face->hostname,config->Horz); + edje_object_part_text_set(face->hostname,"sysname",u_buf.sysname); + edje_object_part_text_set(face->hostname,"release",u_buf.release); + edje_object_part_text_set(face->hostname,"version",u_buf.version); + edje_object_part_text_set(face->hostname,"machine",u_buf.machine); + //edje_object_part_text_set(face->hostname,"node",u_buf.node); + } /* setup cpu */ if (config->cpu) @@ -348,7 +384,7 @@ /* add cpu chart */ chart_con = chart_container_new(con->bg_evas,0,0,0,0); flow_chart_cpu = flow_chart_new(); - flow_chart_color_set(flow_chart_cpu, 33, 100, 220, 255); + flow_chart_color_set(flow_chart_cpu, 33, 100, 220, 125); flow_chart_get_value_function_set(flow_chart_cpu, cpu_usage_get); flow_chart_update_rate_set(flow_chart_cpu, tmp_cpu_interval); chart_container_chart_add(chart_con, flow_chart_cpu); @@ -366,7 +402,7 @@ /* add mem charts */ chart_con = chart_container_new(con->bg_evas,0,0,0,0); flow_chart_mem_real = flow_chart_new(); - flow_chart_color_set(flow_chart_mem_real, 213, 91, 91, 255); + flow_chart_color_set(flow_chart_mem_real, 213, 91, 91, 125); flow_chart_get_value_function_set(flow_chart_mem_real, mem_real_usage_get); flow_chart_update_rate_set(flow_chart_mem_real, tmp_mem_interval); chart_container_chart_add(chart_con, flow_chart_mem_real); @@ -374,7 +410,7 @@ flow_chart_callback_set(flow_chart_mem_real, _monitor_mem_real_text_update_callback, face); flow_chart_mem_swap = flow_chart_new(); - flow_chart_color_set(flow_chart_mem_swap, 51, 181, 69, 255); + flow_chart_color_set(flow_chart_mem_swap, 51, 181, 69, 125); flow_chart_get_value_function_set(flow_chart_mem_swap, mem_swap_usage_get); flow_chart_update_rate_set(flow_chart_mem_swap, tmp_mem_interval); flow_chart_alignment_set(flow_chart_mem_swap, 0); @@ -391,7 +427,7 @@ /* add net charts */ chart_con = chart_container_new(con->bg_evas,0,0,0,0); flow_chart_net_in = flow_chart_new(); - flow_chart_color_set(flow_chart_net_in, 213, 91, 91, 255); + flow_chart_color_set(flow_chart_net_in, 213, 91, 91, 125); flow_chart_get_value_function_set(flow_chart_net_in, net_in_usage_get); flow_chart_update_rate_set(flow_chart_net_in, tmp_net_interval); chart_container_chart_add(chart_con, flow_chart_net_in); @@ -399,7 +435,7 @@ flow_chart_callback_set(flow_chart_net_in, _monitor_net_in_text_update_callcack, face); flow_chart_net_out = flow_chart_new(); - flow_chart_color_set(flow_chart_net_out, 51, 181, 69, 255); + flow_chart_color_set(flow_chart_net_out, 51, 181, 69, 125); flow_chart_get_value_function_set(flow_chart_net_out, net_out_usage_get); flow_chart_update_rate_set(flow_chart_net_out, tmp_net_interval); flow_chart_alignment_set(flow_chart_net_out, 0); @@ -417,13 +453,39 @@ /* add wlan charts */ chart_con = chart_container_new(con->bg_evas,0,0,0,0); flow_chart_wlan_link = flow_chart_new(); - flow_chart_color_set(flow_chart_wlan_link, 33, 100, 220, 255); + flow_chart_color_set(flow_chart_wlan_link, 33, 100, 220, 125); flow_chart_get_value_function_set(flow_chart_wlan_link, wlan_link_get); flow_chart_update_rate_set(flow_chart_wlan_link, tmp_wlan_interval); chart_container_chart_add(chart_con, flow_chart_wlan_link); face->chart_wlan = chart_con; flow_chart_callback_set(flow_chart_wlan_link, _monitor_wlan_link_text_update_callcack, face); } + if (config->uptime) + { + face->uptime = edje_object_add(con->bg_evas); + edje_object_file_set(face->uptime, PACKAGE_DATA_DIR"/monitor.edj", "monitor/uptime"); + _add_sensor(face, face->uptime,config->Horz); + sprintf (u_date_time,"uptime: %ld days, %ld:%02ld:%02ld\n", + s_info.uptime / day, (s_info.uptime % day) / hour, + (s_info.uptime % hour) / minute, s_info.uptime % minute); + edje_object_part_text_set(face->uptime,"uptime",u_date_time); + face->date_check_timer = ecore_timer_add(1, _date_cb_check,face); + } + if (config->time) + { + time_t now; + struct tm date; + time(&now); + char curr_time[12]; + + date = *localtime(&now); + face->time = edje_object_add(con->bg_evas); + edje_object_file_set(face->time, PACKAGE_DATA_DIR"/monitor.edj", "monitor/time"); + _add_sensor(face, face->time,config->Horz); + sprintf (curr_time,"%02d:%02d:%02d",date.tm_hour,date.tm_min,date.tm_sec); + edje_object_part_text_set(face->time,"time",curr_time); + } + face->monitor_cover_obj = evas_object_rectangle_add(face->con->bg_evas); evas_object_color_set(face->monitor_cover_obj, 255,255,255,0); @@ -558,11 +620,15 @@ { e_object_unref(E_OBJECT(face->con)); e_object_del(E_OBJECT(face->gmc)); + ecore_timer_del(face->date_check_timer); evas_object_del(face->cpu); evas_object_del(face->mem); evas_object_del(face->net); evas_object_del(face->wlan); + evas_object_del(face->hostname); + evas_object_del(face->uptime); + evas_object_del(face->time); chart_container_del(face->chart_cpu); chart_container_del(face->chart_mem); @@ -597,28 +663,20 @@ evas_object_resize(face->monitor_object, w, h); evas_object_move(face->monitor_cover_obj, x, y); evas_object_resize(face->monitor_cover_obj, w, h); - + if (face->cpu) evas_object_geometry_get(face->cpu, &x, &y, &w, &h); - //evas_object_move(face->cpu_ev_obj, x, y); - //evas_object_resize(face->cpu_ev_obj, w, h); if (face->cpu) chart_container_move(face->chart_cpu, x+2,y+2); if (face->cpu) chart_container_resize(face->chart_cpu, w-4,h-4); if (face->mem) evas_object_geometry_get(face->mem, &x, &y, &w, &h); - //evas_object_move(face->mem_ev_obj, x, y); - //evas_object_resize(face->mem_ev_obj, w, h); if (face->mem) chart_container_move(face->chart_mem, x+2,y+2); if (face->mem) chart_container_resize(face->chart_mem, w-4,h-4); if (face->net) evas_object_geometry_get(face->net, &x, &y, &w, &h); - //evas_object_move(face->net_ev_obj, x, y); - //evas_object_resize(face->net_ev_obj, w, h); if (face->net) chart_container_move(face->chart_net, x+2,y+2); if (face->net) chart_container_resize(face->chart_net, w-4,h-4); if (face->wlan) evas_object_geometry_get(face->wlan, &x, &y, &w, &h); - //evas_object_move(face->wlan_ev_obj, x, y); - //evas_object_resize(face->wlan_ev_obj, w, h); if (face->wlan) chart_container_move(face->chart_wlan, x+2,y+2); if (face->wlan) chart_container_resize(face->chart_wlan, w-4,h-4); @@ -753,8 +811,17 @@ void rebuild_monitor(Monitor_Face *face) { + struct utsname u_buf; + uname (&u_buf); + + struct sysinfo s_info; + sysinfo (&s_info); + + long minute = 60; + long hour = minute * 60; + long day = hour * 24; + double megabyte = 1024 * 1024; -printf ("string values... %s\n", face->conf->net_interface); Chart_Container *chart_con; Monitor *mon; Monitor_Face *f; @@ -771,6 +838,12 @@ face->net = NULL; if (face->wlan) evas_object_del(face->wlan); face->wlan = NULL; + if (face->hostname) evas_object_del(face->hostname); + face->hostname = NULL; + if (face->uptime) evas_object_del(face->uptime); + face->uptime = NULL; + if (face->time) evas_object_del(face->uptime); + face->time = NULL; if (face->chart_cpu) chart_container_del(face->chart_cpu); face->chart_cpu = NULL; @@ -801,6 +874,18 @@ e_table_homogenous_set(o, 1); edje_object_part_swallow(face->monitor_object, "items", face->table_object); evas_object_show(o); + /*setup hostname */ + if (face->mon->conf->hostname) + { + face->hostname = edje_object_add(face->con->bg_evas); + edje_object_file_set(face->hostname, PACKAGE_DATA_DIR"/monitor.edj", "monitor/host"); + _add_sensor(face,face->hostname,face->mon->conf->Horz); + edje_object_part_text_set(face->hostname,"sysname",u_buf.sysname); + edje_object_part_text_set(face->hostname,"release",u_buf.release); + edje_object_part_text_set(face->hostname,"version",u_buf.version); + edje_object_part_text_set(face->hostname,"machine",u_buf.machine); + //edje_object_part_text_set(face->hostname,"node",u_buf.node); + } /* setup cpu */ if (face->mon->conf->cpu) @@ -812,7 +897,7 @@ /* add cpu chart */ chart_con = chart_container_new(face->con->bg_evas,0,0,0,0); flow_chart_cpu = flow_chart_new(); - flow_chart_color_set(flow_chart_cpu, 33, 100, 220, 255); + flow_chart_color_set(flow_chart_cpu, 33, 100, 220, 125); flow_chart_get_value_function_set(flow_chart_cpu, cpu_usage_get); flow_chart_update_rate_set(flow_chart_cpu, face->conf->cpu_interval); chart_container_chart_add(chart_con, flow_chart_cpu); @@ -830,7 +915,7 @@ /* add mem charts */ chart_con = chart_container_new(face->con->bg_evas,0,0,0,0); flow_chart_mem_real = flow_chart_new(); - flow_chart_color_set(flow_chart_mem_real, 213, 91, 91, 255); + flow_chart_color_set(flow_chart_mem_real, 213, 91, 91, 125); flow_chart_get_value_function_set(flow_chart_mem_real, mem_real_usage_get); flow_chart_update_rate_set(flow_chart_mem_real, face->conf->mem_interval); chart_container_chart_add(chart_con, flow_chart_mem_real); @@ -838,7 +923,7 @@ flow_chart_callback_set(flow_chart_mem_real, _monitor_mem_real_text_update_callback, face); flow_chart_mem_swap = flow_chart_new(); - flow_chart_color_set(flow_chart_mem_swap, 51, 181, 69, 255); + flow_chart_color_set(flow_chart_mem_swap, 51, 181, 69, 125); flow_chart_get_value_function_set(flow_chart_mem_swap, mem_swap_usage_get); flow_chart_update_rate_set(flow_chart_mem_swap, face->conf->mem_interval); flow_chart_alignment_set(flow_chart_mem_swap, 0); @@ -863,7 +948,7 @@ flow_chart_callback_set(flow_chart_net_in, _monitor_net_in_text_update_callcack, face); flow_chart_net_out = flow_chart_new(); - flow_chart_color_set(flow_chart_net_out, 51, 181, 69, 255); + flow_chart_color_set(flow_chart_net_out, 51, 181, 69, 125); flow_chart_get_value_function_set(flow_chart_net_out, net_out_usage_get); flow_chart_update_rate_set(flow_chart_net_out, face->conf->net_interval); flow_chart_alignment_set(flow_chart_net_out, 0); @@ -881,13 +966,40 @@ /* add wlan charts */ chart_con = chart_container_new(face->con->bg_evas,0,0,0,0); flow_chart_wlan_link = flow_chart_new(); - flow_chart_color_set(flow_chart_wlan_link, 33, 100, 220, 255); + flow_chart_color_set(flow_chart_wlan_link, 33, 100, 220, 125); flow_chart_get_value_function_set(flow_chart_wlan_link, wlan_link_get); flow_chart_update_rate_set(flow_chart_wlan_link, face->conf->wlan_interval); chart_container_chart_add(chart_con, flow_chart_wlan_link); face->chart_wlan = chart_con; flow_chart_callback_set(flow_chart_wlan_link, _monitor_wlan_link_text_update_callcack, face); } + if (face->mon->conf->uptime) + { + int num_days, num_hours, num_min; + char u_date_time[256]; + face->uptime = edje_object_add(face->con->bg_evas); + edje_object_file_set(face->uptime, PACKAGE_DATA_DIR"/monitor.edj", "monitor/uptime"); + sprintf (u_date_time,"uptime: %ld days, %ld:%02ld:%02ld\n", + s_info.uptime / day, (s_info.uptime % day) / hour, + (s_info.uptime % hour) / minute, s_info.uptime % minute); + edje_object_part_text_set(face->uptime,"uptime",u_date_time); + face->date_check_timer = ecore_timer_add(1, _date_cb_check,face); + _add_sensor(face, face->uptime,face->mon->conf->Horz); + } + if (face->mon->conf->time) + { + time_t now; + struct tm date; + time(&now); + char curr_time[12]; + + date = *localtime(&now); + face->time = edje_object_add(face->con->bg_evas); + edje_object_file_set(face->time, PACKAGE_DATA_DIR"/monitor.edj", "monitor/time"); + _add_sensor(face, face->time,face->mon->conf->Horz); + sprintf (curr_time,"%02d:%02d:%02d",date.tm_hour,date.tm_min,date.tm_sec); + edje_object_part_text_set(face->time,"time",curr_time); + } face->monitor_cover_obj = evas_object_rectangle_add(face->con->bg_evas); evas_object_color_set(face->monitor_cover_obj, 255,255,255,0); @@ -913,3 +1025,35 @@ evas_event_thaw(face->con->bg_evas); } +static int _date_cb_check(void *data) +{ + Monitor_Face *face; + face = data; + +//Update uptime + char u_date_time[256]; + struct sysinfo s_info; + sysinfo (&s_info); + + long minute = 60; + long hour = minute * 60; + long day = hour * 24; + double megabyte = 1024 * 1024; + + sprintf (u_date_time,"uptime: %ld days, %ld:%02ld:%02ld\n", + s_info.uptime / day, (s_info.uptime % day) / hour, + (s_info.uptime % hour) / minute, s_info.uptime % minute); + edje_object_part_text_set(face->uptime,"uptime",u_date_time); + +//Update time + time_t now; + struct tm date; + time(&now); + char curr_time[12]; + + date = *localtime(&now); + sprintf (curr_time,"%02d:%02d:%02d",date.tm_hour,date.tm_min,date.tm_sec); + edje_object_part_text_set(face->time,"time",curr_time); + + return 1; +} \ No newline at end of file =================================================================== RCS file: /cvsroot/enlightenment/e_modules/monitor/e_mod_main.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- e_mod_main.h 27 Dec 2005 21:19:41 -0000 1.5 +++ e_mod_main.h 28 Dec 2005 16:47:12 -0000 1.6 @@ -22,7 +22,10 @@ int mem; int net; int wlan; + int hostname; int Horz; + int uptime; + int time; }; struct _Config_Face @@ -46,7 +49,7 @@ { Evas_List *faces; E_Menu *config_menu; - + Config *conf; }; @@ -55,10 +58,10 @@ Monitor *mon; E_Container *con; E_Menu *menu; - Config_Face *conf; + Config_Face *conf; + Ecore_Timer *date_check_timer; - Evas_Object *cpu, *net, *mem, *wlan; - //Evas_Object *cpu_ev_obj, *net_ev_obj, *mem_ev_obj, *wlan_ev_obj; + Evas_Object *cpu, *net, *mem, *wlan, *hostname, *uptime, *time; Evas_Object *table_object, *monitor_object, *monitor_cover_obj; Chart_Container *chart_cpu, *chart_net, *chart_mem, *chart_wlan; ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs