コード例 #1
0
ファイル: xml.c プロジェクト: toxicgumbo/MegaTunix
void load_gauge(GtkWidget *dash, xmlNode *node)
{
	xmlNode *cur_node = NULL;
	GtkWidget *gauge = NULL;
	gchar * filename = NULL;
	gint width = 0;
	gint height = 0;
	gint x_offset = 0;
	gint y_offset = 0;
	gchar *xml_name = NULL;
	gchar *datasource = NULL;
	if (!node->children)
	{
		printf("ERROR, load_gauge, xml node is empty!!\n");
		return;
	}
	cur_node = node->children;
	while (cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_strcasecmp((gchar *)cur_node->name,"width") == 0)
				generic_xml_gint_import(cur_node,&width);
			if (g_strcasecmp((gchar *)cur_node->name,"height") == 0)
				generic_xml_gint_import(cur_node,&height);
			if (g_strcasecmp((gchar *)cur_node->name,"x_offset") == 0)
				generic_xml_gint_import(cur_node,&x_offset);
			if (g_strcasecmp((gchar *)cur_node->name,"y_offset") == 0)
				generic_xml_gint_import(cur_node,&y_offset);
			if (g_strcasecmp((gchar *)cur_node->name,"gauge_xml_name") == 0)
				generic_xml_gchar_import(cur_node,&xml_name);
			if (g_strcasecmp((gchar *)cur_node->name,"datasource") == 0)
				generic_xml_gchar_import(cur_node,&datasource);
		}
		cur_node = cur_node->next;

	}
	if (xml_name && datasource)
	{
		gauge = mtx_gauge_face_new();
		gtk_fixed_put(GTK_FIXED(dash),gauge,x_offset,y_offset);
		xml_name = g_strdelimit(xml_name,"\\",'/');
		filename = get_file(g_build_filename(PSEP,GAUGES_DATA_DIR,xml_name,NULL),NULL);
		mtx_gauge_face_import_xml(MTX_GAUGE_FACE(gauge),filename);
		gtk_widget_set_usize(gauge,width,height);
		g_free(filename);
		OBJ_SET_FULL((gauge),"datasource",g_strdup(datasource),g_free);
		/* Cheat to get property window created... */


		create_preview_list(NULL,NULL);
		update_properties(gauge,GAUGE_ADD);
		g_free(xml_name);
		g_free(datasource);
		gtk_widget_show_all(dash);
	}

}
コード例 #2
0
ファイル: xmlcomm.c プロジェクト: BMWPower/MegaTunix
/*!
  \brief loads the command post functions of an XML Command from the XML.
  \param cmd is the pointer to the Command structure
  \param node is the XML node
  */
G_MODULE_EXPORT void load_cmd_post_functions(Command *cmd, xmlNode *node)
{
	xmlNode *cur_node = NULL;
	PostFunction *pf = NULL;

	ENTER();
	if (!node->children)
	{
		MTXDBG(CRITICAL,_("XML node is empty!!\n"));
		EXIT();
		return;
	}

	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"function") == 0)
			{
				pf = g_new0(PostFunction, 1);
				generic_xml_gchar_import(cur_node,&pf->name);
				if (!get_symbol(pf->name,(void **)&pf->function))
					printf(_("Unable to locate Post Function %s within MegaTunix or active plugins\n"),pf->name);
				else
				{
					pf->w_arg = FALSE;
					g_array_append_val(cmd->post_functions,pf);
				}
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"function_w_arg") == 0)
			{
				pf = g_new0(PostFunction, 1);
				generic_xml_gchar_import(cur_node,&pf->name);
				if (!get_symbol(pf->name,(void **)&pf->function_w_arg))
					printf(_("Unable to locate Post Function with argument %s within MegaTunix or active plugins\n"),pf->name);
				else
				{
					pf->w_arg = TRUE;
					g_array_append_val(cmd->post_functions,pf);
				}
			}
		}
		cur_node = cur_node->next;
	}
	EXIT();
	return;
}
コード例 #3
0
ファイル: xmlbase.c プロジェクト: JacobD10/MegaTunix
/*!
  \brief Searches for an Integer starting from an XML node and 
  stores in the dest var
  \param node is the pointer to the XML node
  \param name is the key to find
  \param dest is the pointer to the place to store the read value
  */
gboolean generic_xml_gchar_find(xmlNode *node, const gchar *name, gpointer dest)
{
	xmlNode *cur_node = NULL;
	gboolean found = FALSE;
	g_return_val_if_fail(node,FALSE);
	g_return_val_if_fail(dest,FALSE);
	g_return_val_if_fail(node->children,FALSE);

	ENTER();
	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_ascii_strcasecmp((gchar *)cur_node->name,name) == 0)
			{
				generic_xml_gchar_import(cur_node,dest);
				found = TRUE;
			}
		}
		cur_node = cur_node->next;
	}
	EXIT();
	return found;
}
コード例 #4
0
ファイル: xmlcomm.c プロジェクト: BMWPower/MegaTunix
/*!
  \brief loads the command args of an XML Command from the XML.
  \param cmd is the pointer to the Command structure
  \param node is the XML node
  */
G_MODULE_EXPORT void load_cmd_args(Command *cmd, xmlNode *node)
{
	xmlNode *cur_node = NULL;
	gchar * tmpbuf = NULL;
	PotentialArg *arg = NULL;

	ENTER();
	if (!node->children)
	{
		MTXDBG(CRITICAL,_("XML node is empty!!\n"));
		EXIT();
		return;
	}
	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"arg") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				arg = (PotentialArg *)g_hash_table_lookup((GHashTable *)DATA_GET(global_data,"potential_arguments"),tmpbuf);
				cmd->args = g_array_append_val(cmd->args,arg);
				g_free(tmpbuf);
				tmpbuf = NULL;
			}
		}
		cur_node = cur_node->next;
	}
	EXIT();
	return;
}
コード例 #5
0
ファイル: runtime_text.c プロジェクト: seank/MegaTunix
G_MODULE_EXPORT void load_rtt(xmlNode *node,GtkListStore *store,GtkWidget *parent)
{
	gchar *int_name = NULL;
	gchar *source = NULL;
	Rt_Text *rt_text = NULL;
	GtkTreeIter iter;
	xmlNode *cur_node = NULL;

	if (!node->children)
	{
		printf(_("ERROR, load_potential_args, xml node is empty!!\n"));
		return;
	}
	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_strcasecmp((gchar *)cur_node->name,"internal_name") == 0)
				generic_xml_gchar_import(cur_node,&int_name);
			if (g_strcasecmp((gchar *)cur_node->name,"datasource") == 0)
				generic_xml_gchar_import(cur_node,&source);
		}
		cur_node = cur_node->next;
	}
	if ((int_name) && (source))
		rt_text = create_rtt(int_name,source,TRUE);
	if (rt_text)
	{
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter,
				COL_RTT_OBJECT,(gpointer)rt_text,
				COL_RTT_INT_NAME,rt_text->ctrl_name,
				COL_RTT_DATA,"",
				COL_RTT_LAST,-0.1,-1);	
	}
	if (int_name)
		g_free(int_name);
	if (source)
		g_free(source);
}
コード例 #6
0
ファイル: runtime_sliders.c プロジェクト: bigamil/MegaTunix
/*!
  \brief loads runtime status details from XML, creates the slider and inserts
  it into the hash table
  \param node is the current XML node
  \param hash is the hashtable to stick the resulting RTS structure into
  \param table_num is the table number on this tab
  \param tab_id is the Tab identification enumeration
  */
G_MODULE_EXPORT void load_rts(xmlNode *node, GHashTable *hash, gint table_num, TabIdent tab_id)
{
	gchar *slider_name = NULL;
	gchar *source = NULL;
	gint row = 0;
	gint table = 0;
	Rt_Slider *slider = NULL;
	xmlNode *cur_node = NULL;

	if (!node->children)
	{
		printf(_("ERROR, load_rts, xml node is empty!!\n"));
		return;
	}
	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_strcasecmp((gchar *)cur_node->name,"slider_name") == 0)
				generic_xml_gchar_import(cur_node,&slider_name);
			if (g_strcasecmp((gchar *)cur_node->name,"source") == 0)
				generic_xml_gchar_import(cur_node,&source);
			if (g_strcasecmp((gchar *)cur_node->name,"row") == 0)
				generic_xml_gint_import(cur_node,&row);
			if (g_strcasecmp((gchar *)cur_node->name,"table") == 0)
				generic_xml_gint_import(cur_node,&table);
		}
		cur_node = cur_node->next;
	}
	if ((slider_name) && (source))
		slider = add_slider(slider_name,table,table_num,row,source,tab_id);
	if (slider)
	{
		if (g_hash_table_lookup(hash,slider_name) == NULL)
			g_hash_table_insert(hash,g_strdup(slider_name),(gpointer)slider);
	}
	g_free(slider_name);
	g_free(source);
}
コード例 #7
0
ファイル: runtime_status.c プロジェクト: seank/MegaTunix
G_MODULE_EXPORT void load_status(xmlNode *node,GtkWidget *parent)
{
	gchar *txt = NULL;
	gchar *active_fg = NULL;
	gchar *inactive_fg = NULL;
	gchar *bind_to_list = NULL;
	gchar *source = NULL;
	gint bitval = -1;
	gint bitmask = -1;
	GtkWidget *label = NULL;
	GtkWidget *frame = NULL;
	GdkColor color;
	xmlNode *cur_node = NULL;

	if (!node->children)
	{
		printf(_("ERROR, load_potential_args, xml node is empty!!\n"));
		return;
	}
	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_strcasecmp((gchar *)cur_node->name,"label") == 0)
				generic_xml_gchar_import(cur_node,&txt);
			if (g_strcasecmp((gchar *)cur_node->name,"active_fg") == 0)
				generic_xml_gchar_import(cur_node,&active_fg);
			if (g_strcasecmp((gchar *)cur_node->name,"inactive_fg") == 0)
				generic_xml_gchar_import(cur_node,&inactive_fg);
			if (g_strcasecmp((gchar *)cur_node->name,"source") == 0)
				generic_xml_gchar_import(cur_node,&source);
			if (g_strcasecmp((gchar *)cur_node->name,"bind_to_list") == 0)
				generic_xml_gchar_import(cur_node,&bind_to_list);
			if (g_strcasecmp((gchar *)cur_node->name,"bitval") == 0)
				generic_xml_gint_import(cur_node,&bitval);
			if (g_strcasecmp((gchar *)cur_node->name,"bitmask") == 0)
				generic_xml_gint_import(cur_node,&bitmask);
		}
		cur_node = cur_node->next;
	}
	/* Minimum requirements */
	if ((txt) && (active_fg) && (inactive_fg) && (bind_to_list))
	{
		frame = gtk_frame_new(NULL);
		gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_ETCHED_IN);
		label = gtk_label_new(NULL);
		gtk_label_set_markup(GTK_LABEL(label),_(txt));
		gtk_container_add(GTK_CONTAINER(frame),label);
		gtk_widget_set_sensitive(GTK_WIDGET(label),FALSE);
		gdk_color_parse(active_fg,&color);
		gtk_widget_modify_fg(label,GTK_STATE_NORMAL,&color);
		gdk_color_parse(inactive_fg,&color);
		gtk_widget_modify_fg(label,GTK_STATE_INSENSITIVE,&color);
		g_free(txt);
		g_free(active_fg);
		g_free(inactive_fg);
		/* For controls based on ECU data */
		if ((bitval >= 0) && (bitmask >= 0) && (source))
		{
			OBJ_SET(label,"bitval",GINT_TO_POINTER(bitval));
			OBJ_SET(label,"bitmask",GINT_TO_POINTER(bitmask));
			OBJ_SET_FULL(label,"source",g_strdup(source),g_free);
			g_free(source);
		}
		if (bind_to_list)
		{
			bind_to_lists(label, bind_to_list);
			g_free(bind_to_list);
		}
		gtk_box_pack_start(GTK_BOX(parent),frame,TRUE,TRUE,0);
	}
}
コード例 #8
0
ファイル: gauge-xml.c プロジェクト: bigamil/MegaTunix
void mtx_gauge_gchar_import(MtxGaugeFace *gauge, xmlNode *node, gpointer dest,gboolean api_compat)
{
	generic_xml_gchar_import(node,dest);
}
コード例 #9
0
ファイル: xmlcomm.c プロジェクト: BMWPower/MegaTunix
/*!
  \brief loads the details of an XML Command from the XML.
  \param cmd is the pointer to the Command structure
  \param node is the XML node
  */
G_MODULE_EXPORT void load_cmd_details(Command *cmd, xmlNode *node)
{
	xmlNode *cur_node = NULL;
	gchar *tmpbuf = NULL;

	ENTER();
	if (!node->children)
	{
		MTXDBG(CRITICAL,_("XML node is empty!!\n"));
		EXIT();
		return;
	}
	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"name") == 0)
				generic_xml_gchar_import(cur_node,&cmd->name);
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"desc") == 0)
				generic_xml_gchar_import(cur_node,&cmd->desc);
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"type") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				cmd->type = (CmdType)translate_string(tmpbuf);
				g_free(tmpbuf);
				tmpbuf = NULL;
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"func_call_name") == 0)
			{
				generic_xml_gchar_import(cur_node,&cmd->func_call_name);
				if (!get_symbol(cmd->func_call_name,(void **)&cmd->function))
					printf(_("Unable to locate Function Call %s within MegaTunix or active plugins\n"),cmd->func_call_name);
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"func_call_arg") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				cmd->func_call_arg = translate_string(tmpbuf);
				g_free(tmpbuf);
				tmpbuf = NULL;
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"defer_post_functions") == 0)
				generic_xml_gboolean_import(cur_node,&cmd->defer_post_functions);

			if (g_ascii_strcasecmp((gchar *)cur_node->name,"base") == 0)
				generic_xml_gchar_import(cur_node,&cmd->base);

			if (g_ascii_strcasecmp((gchar *)cur_node->name,"helper_func") == 0)
			{
				generic_xml_gchar_import(cur_node,&cmd->helper_func_name);
				if (!get_symbol(cmd->helper_func_name,(void **)&cmd->helper_function))
					printf(_("Unable to locate Helper Function %s within MegaTunix or active plugins\n"),cmd->helper_func_name);
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"helper_func_arg") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				cmd->helper_func_arg = translate_string(tmpbuf);
				g_free(tmpbuf);
				tmpbuf = NULL;
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"post_functions") == 0)
			{
				load_cmd_post_functions(cmd,cur_node);
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"args") == 0)
				load_cmd_args(cmd,cur_node);
		}
		cur_node = cur_node->next;
	}
	EXIT();
	return;
}
コード例 #10
0
ファイル: xmlcomm.c プロジェクト: BMWPower/MegaTunix
/*!
  \brief loads the details of an XML PotentialArg from the XML.
  \param arg is the pointer to the PotentialArg structure
  \param node is the XML node
  */
G_MODULE_EXPORT void load_arg_details(PotentialArg *arg, xmlNode *node)
{
	xmlNode *cur_node = NULL;
	gchar *tmpbuf = NULL;

	ENTER();
	if (!node->children)
	{
		MTXDBG(CRITICAL,_("XML node is empty!!\n"));
		EXIT();
		return;
	}
	cur_node = node->children;
	while (cur_node->next)
	{
		if (cur_node->type == XML_ELEMENT_NODE)
		{
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"name") == 0)
				generic_xml_gchar_import(cur_node,&arg->name);
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"desc") == 0)
				generic_xml_gchar_import(cur_node,&arg->desc);
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"internal_name") == 0)
				generic_xml_gchar_import(cur_node,&arg->internal_name);
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"size") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				arg->size = (DataSize)translate_string(tmpbuf);
				g_free(tmpbuf);
				tmpbuf = NULL;
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"type") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				arg->type = (ArgType)translate_string(tmpbuf);
				g_free(tmpbuf);
				tmpbuf = NULL;
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"action") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				arg->action = (Action)translate_string(tmpbuf);
				g_free(tmpbuf);
				tmpbuf = NULL;
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"action_arg") == 0)
				generic_xml_gint_import(cur_node,&arg->action_arg);
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"string") == 0)
			{
				generic_xml_gchar_import(cur_node,&arg->static_string);
				arg->string_len = strlen(arg->static_string);
			}
			if (g_ascii_strcasecmp((gchar *)cur_node->name,"hex_string") == 0)
			{
				generic_xml_gchar_import(cur_node,&tmpbuf);
				parse_hex_string(tmpbuf, arg->static_string, &arg->string_len);
				g_free(tmpbuf);
			}

		}
		cur_node = cur_node->next;
	}
	EXIT();
	return;
}