/*! \brief Firmware specific function that backs up the ECU to a filename passed \param filename is the filename to backup the ECU to */ G_MODULE_EXPORT void backup_all_ecu_settings(gchar *filename) { ConfigFile *cfgfile; gchar * section = NULL; gchar * tmpbuf = NULL; gint i = 0; gint locID = 0; gint x = 0; gint canID = 0; DataSize size = MTX_U08; /* <<<<< BAD BAD BAD >>>>> */ GString *string = NULL; extern gconstpointer *global_data; Firmware_Details *firmware = NULL; firmware = DATA_GET(global_data,"firmware"); g_return_if_fail(filename); g_return_if_fail(firmware); cfgfile = cfg_open_file(filename); if(!cfgfile) cfgfile = cfg_new(); set_file_api_f(cfgfile,BACKUP_MAJOR_API,BACKUP_MINOR_API); update_logbar_f("tools_view",NULL,g_strdup_printf("%s %s\n",_("Full Backup Commencing to file:\n\t"),filename),FALSE,FALSE,TRUE); cfg_write_string(cfgfile,"Firmware","name",firmware->name); for(i=0;i<firmware->total_pages;i++) { if (firmware->page_params[i]->read_only) continue; string = g_string_sized_new(64); section = g_strdup_printf("page_%i",i); cfg_write_int(cfgfile,section,"num_variables",firmware->page_params[i]->length); for(x=0;x<firmware->page_params[i]->length;x++) { locID = firmware->page_params[i]->phys_ecu_page; g_string_append_printf(string,"%i",freeems_get_ecu_data(canID,locID,x,size)); if (x < (firmware->page_params[i]->length-1)) string = g_string_append(string,","); } cfg_write_string(cfgfile,section,"data",string->str); g_free(section); g_string_free(string,TRUE); } update_logbar_f("tools_view",NULL,_("Full Backup Complete...\n"),FALSE,FALSE,FALSE); cfg_write_file(cfgfile,filename); cfg_free(cfgfile); }
void save_defaults() { ConfigFile *cfgfile; gchar * filename = NULL; gchar * tmpbuf = NULL; filename = g_build_filename(HOME(),"mtx","default","config", NULL); cfgfile = cfg_open_file(filename); if (cfgfile) { tmpbuf = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtk_builder_get_object ((GtkBuilder *)DATA_GET(global_data,"builder"), "filechooser_button"))); if (tmpbuf) cfg_write_string(cfgfile, (gchar *)"MTXLoader", (gchar *)"last_file", tmpbuf); g_free(tmpbuf); cfg_write_file(cfgfile,filename); cfg_free(cfgfile); g_free(filename); } }
void save_config(GtkWidget *widget) { gchar *filename; ConfigFile *cfgfile; gint x; gint y; filename = g_strconcat(g_get_home_dir(), "/.eXtace/config", NULL); cfgfile = cfg_open_file(filename); if (!cfgfile) cfgfile = cfg_new(); cfg_write_int(cfgfile, "Global", "major_ver", _MAJOR_); cfg_write_int(cfgfile, "Global", "minor_ver", _MINOR_); cfg_write_int(cfgfile, "Global", "micro_ver", _MICRO_); if (Color_map.filename) cfg_write_string(cfgfile, "Global", "last_colormap", Color_map.filename); else cfg_write_string(cfgfile, "Global", "last_colormap",g_strconcat(g_get_home_dir(),"/.eXtace/ColorMaps/","Default",NULL)); cfg_write_int(cfgfile, "Global", "mode", mode); cfg_write_int(cfgfile, "Global", "data_source", data_source); cfg_write_int(cfgfile, "Global", "decimation_factor", decimation_factor); cfg_write_int(cfgfile, "Global", "fft_signal_source", fft_signal_source); cfg_write_float(cfgfile, "Global", "scope_zoom", scope_zoom); cfg_write_int(cfgfile, "Global", "refresh_rate", refresh_rate); cfg_write_int(cfgfile, "Global", "landflip", landflip); cfg_write_int(cfgfile, "Global", "spikeflip", spikeflip); cfg_write_boolean(cfgfile, "Global", "outlined", outlined); cfg_write_int(cfgfile, "Global", "sub_mode_3D", sub_mode_3D); cfg_write_int(cfgfile, "Global", "scope_sub_mode", scope_sub_mode); cfg_write_boolean(cfgfile, "Global", "dir_win_present", dir_win_present); cfg_write_int(cfgfile, "Global", "nsamp", nsamp); cfg_write_int(cfgfile, "Global", "window_func", window_func); cfg_write_int(cfgfile, "Global", "win_width", win_width); cfg_write_int(cfgfile, "Global", "axis_type", axis_type); cfg_write_int(cfgfile, "Global", "bands", bands); cfg_write_int(cfgfile, "Global", "lag", lag); cfg_write_float(cfgfile, "Global", "noise_floor", noise_floor); cfg_write_int(cfgfile, "Global", "seg_height", seg_height); cfg_write_int(cfgfile, "Global", "seg_space", seg_space); cfg_write_boolean(cfgfile, "Global", "bar_decay", bar_decay); cfg_write_boolean(cfgfile, "Global", "peak_decay", peak_decay); cfg_write_boolean(cfgfile, "Global", "stabilized", stabilized); cfg_write_boolean(cfgfile, "Global", "show_graticule", show_graticule); cfg_write_int(cfgfile, "Global", "decay_speed", bar_decay_speed); cfg_write_int(cfgfile, "Global", "peak_decay_speed", peak_decay_speed); cfg_write_int(cfgfile, "Global", "peak_hold_time", peak_hold_time); cfg_write_int(cfgfile, "Global", "tape_scroll", tape_scroll); cfg_write_int(cfgfile, "Global", "xdet_scroll", xdet_scroll); cfg_write_int(cfgfile, "Global", "zdet_scroll", zdet_scroll); cfg_write_float(cfgfile, "Global", "xdet_start", xdet_start); cfg_write_float(cfgfile, "Global", "xdet_end", xdet_end); cfg_write_float(cfgfile, "Global", "ydet_start", ydet_start); cfg_write_float(cfgfile, "Global", "ydet_end", ydet_end); cfg_write_float(cfgfile, "Global", "x3d_start", x3d_start); cfg_write_float(cfgfile, "Global", "x3d_end", x3d_end); cfg_write_float(cfgfile, "Global", "y3d_start", y3d_start); cfg_write_float(cfgfile, "Global", "y3d_end", y3d_end); cfg_write_float(cfgfile, "Global", "multiplier", multiplier); cfg_write_int(cfgfile, "Global", "horiz_spec_start", horiz_spec_start); cfg_write_int(cfgfile, "Global", "vert_spec_start", vert_spec_start); cfg_write_int(cfgfile, "Global", "x3d_scroll", x3d_scroll); cfg_write_int(cfgfile, "Global", "z3d_scroll", z3d_scroll); cfg_write_boolean(cfgfile, "Global", "show_leader", show_leader); cfg_write_int(cfgfile, "Global", "scope_sync_source", scope_sync_source); cfg_write_boolean(cfgfile, "Global", "landtilt",landtilt); cfg_write_boolean(cfgfile, "Global", "spiketilt", spiketilt); cfg_write_float(cfgfile, "Global", "low_freq", low_freq); cfg_write_float(cfgfile, "Global", "high_freq", high_freq); cfg_write_int(cfgfile, "Window", "width", width); cfg_write_int(cfgfile, "Window", "height", height+22); gdk_window_get_root_origin(widget->window, &x, &y); cfg_write_int(cfgfile, "Window", "main_x_origin", x); cfg_write_int(cfgfile, "Window", "main_y_origin", y); // cfg_write_boolean(cfgfile, "Window", "grad_win_present", grad_win_present); if (grad_win_present) { gdk_window_get_root_origin((gpointer) grad_win_ptr->window, &x, &y); cfg_write_int(cfgfile, "Window", "grad_x_origin", x); cfg_write_int(cfgfile, "Window", "grad_y_origin", y); } if (dir_win_present) { gdk_window_get_root_origin((gpointer) dir_win_ptr->window, &x, &y); cfg_write_int(cfgfile, "Window", "dir_x_origin", x); cfg_write_int(cfgfile, "Window", "dir_y_origin", y); } cfg_write_file(cfgfile, filename); cfg_free(cfgfile); g_free(filename); }
gboolean lookuptable_change(GtkCellRenderer *renderer, gchar *path, gchar * new_text, gpointer data) { GtkListStore *store = NULL; GtkTreeIter iter; GtkTreeModel *model = data; ConfigFile *cfgfile = NULL; gchar * int_name = NULL; gchar * old = NULL; gchar * new_name = NULL; gchar ** vector = NULL; gboolean restart_tickler = FALSE; extern gint realtime_id; extern GHashTable *lookuptables; extern GAsyncQueue *io_data_queue; extern Firmware_Details *firmware; gint count = 0; LookupTable *lookuptable = NULL; /* Get combo box model so we can set the combo to this new value */ g_object_get(G_OBJECT(renderer),"model",&store,NULL); gtk_tree_model_get_iter_from_string(model,&iter,path); gtk_tree_model_get(model,&iter,INTERNAL_NAME_COL,&int_name,FILENAME_COL,&old,-1); if (g_strcasecmp(old,new_text) == 0) /* If no change, return */ return TRUE; if (g_strcasecmp(new_text,"Personal") == 0) return TRUE; if (g_strcasecmp(new_text,"System") == 0) return TRUE; if (realtime_id) { restart_tickler = TRUE; stop_tickler(RTV_TICKLER); count = 0; while ((g_async_queue_length(io_data_queue) > 0) && (count < 30)) { dbg_func(CRITICAL,g_strdup_printf(__FILE__": LEAVE() draining I/O Queue, current length %i\n",g_async_queue_length(io_data_queue))); while (gtk_events_pending()) gtk_main_iteration(); count++; } } lookuptable = (LookupTable *)g_hash_table_lookup(lookuptables,int_name); if (!lookuptable) printf(_("No lookuptable found! expect a crash!!\n")); g_free(lookuptable->array); /* Free the old one */ g_free(lookuptable->filename); /* Free the old one */ g_free(lookuptable); /* Free the old one */ get_table(int_name,new_text,NULL); /* Load the new one in it's place */ gtk_list_store_set(GTK_LIST_STORE(model),&iter, FILENAME_COL, new_text,-1); if (restart_tickler) start_tickler(RTV_TICKLER); cfgfile = cfg_open_file(firmware->profile_filename); if (!cfgfile) return FALSE; g_hash_table_foreach(lookuptables,update_lt_config,cfgfile); if (g_strrstr(firmware->profile_filename,".MegaTunix")) cfg_write_file(cfgfile, firmware->profile_filename); else { vector = g_strsplit(firmware->profile_filename,PSEP,-1); new_name = g_build_filename(HOME(),".MegaTunix",INTERROGATOR_DATA_DIR,"Profiles",vector[g_strv_length(vector)-1],NULL); g_strfreev(vector); cfg_write_file(cfgfile, new_name); g_free(firmware->profile_filename); firmware->profile_filename=g_strdup(new_name); g_free(new_name); } cfg_free(cfgfile); /*printf("internal name %s, old table %s, new table %s\n",int_name,old,new_text);*/ return TRUE; }
void fbi_write_config(void) { if (fbi_config) cfg_write_file("config", fbi_config); }
//G_MODULE_EXPORT gboolean lookuptable_changed(GtkCellRendererCombo *renderer, gchar *path, gchar * new_text, gpointer data) G_MODULE_EXPORT gboolean lookuptable_changed(GtkCellRendererCombo *renderer, gchar *path, GtkTreeIter *new_iter, gpointer data) { GtkTreeModel *combostore = NULL; GtkTreeIter iter; GtkTreeModel *model = (GtkTreeModel *)data; ConfigFile *cfgfile = NULL; gchar * new_text = NULL; gchar * int_name = NULL; gchar * old = NULL; gchar * new_name = NULL; gchar ** vector = NULL; const gchar * project = NULL; gboolean restart_tickler = FALSE; GAsyncQueue *io_data_queue = NULL; Firmware_Details *firmware = NULL; ENTER(); firmware = (Firmware_Details *)DATA_GET(global_data,"firmware"); io_data_queue = (GAsyncQueue *)DATA_GET(global_data,"io_data_queue"); /* Get combo box model so we can set the combo to this new value */ g_object_get(G_OBJECT(renderer),"model",&combostore,NULL); gtk_tree_model_get(combostore,new_iter,0,&new_text,-1); /* Get combo box model so we can set the combo to this new value */ gtk_tree_model_get_iter_from_string(model,&iter,path); gtk_tree_model_get(model,&iter,INTERNAL_NAME_COL,&int_name,FILENAME_COL,&old,-1); //printf("New text is %s, int name associated %s, filename %s\n",new_text,int_name,old); if (g_ascii_strcasecmp(old,new_text) == 0) /* If no change, return */ { g_free(int_name); g_free(old); EXIT(); return TRUE; } if (g_ascii_strcasecmp(new_text,"Personal") == 0) { g_free(int_name); g_free(old); EXIT(); return TRUE; } if (g_ascii_strcasecmp(new_text,"System") == 0) { g_free(int_name); g_free(old); EXIT(); return TRUE; } if (DATA_GET(global_data,"realtime_id")) { gint count = 0; restart_tickler = TRUE; stop_tickler(RTV_TICKLER); while ((g_async_queue_length(io_data_queue) > 0) && (count < 30)) { MTXDBG(CRITICAL,_("Draining I/O Queue, current length %i\n"),g_async_queue_length(io_data_queue)); count++; } } get_table(int_name,new_text,NULL); /* Load the new one in it's place */ gtk_list_store_set(GTK_LIST_STORE(model),&iter, FILENAME_COL, new_text,-1); if (restart_tickler) start_tickler(RTV_TICKLER); cfgfile = cfg_open_file(firmware->profile_filename); if (!cfgfile) { g_free(int_name); g_free(old); EXIT(); return FALSE; } g_hash_table_foreach((GHashTable *)DATA_GET(global_data,"lookuptables"),update_lt_config,cfgfile); if (g_strrstr(firmware->profile_filename,"mtx")) cfg_write_file(cfgfile, firmware->profile_filename); else { project = (const gchar *)DATA_GET(global_data,"project_name"); vector = g_strsplit(firmware->profile_filename,PSEP,-1); if (!project) project = DEFAULT_PROJECT; new_name = g_build_filename(HOME(),"mtx",project,INTERROGATOR_DATA_DIR,"Profiles",vector[g_strv_length(vector)-2],vector[g_strv_length(vector)-1],NULL); g_strfreev(vector); cfg_write_file(cfgfile, new_name); g_free(firmware->profile_filename); firmware->profile_filename=g_strdup(new_name); g_free(new_name); } cfg_free(cfgfile); /*printf("internal name %s, old table %s, new table %s\n",int_name,old,new_text);*/ g_free(int_name); g_free(old); EXIT(); return TRUE; }