//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_systemmonitor_propogatenewvalues
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_systemmonitor_propogatenewvalues()
{
	//Declare variables
	agent *currentagent;

	//Reset all values to unknown
	for (int i = 0; i < SYSTEMMONITOR_NUMTYPES; i++)
	{
		agenttype_systemmonitor_previous_values[i] = agenttype_systemmonitor_values[i];
		agenttype_systemmonitor_values[i] = -1.0;
	}

	//Go through every agent
	listnode *currentnode;
	dolist(currentnode, agenttype_systemmonitor_agents)
	{
		//Get the agent
		currentagent = (agent *) currentnode->value;

		//Get the monitor type
		int monitor_type = ((agenttype_systemmonitor_details *) (currentagent->agentdetails))->monitor_type;

		//Calculate a new value for this type
		agenttype_systemmonitor_updatevalue(monitor_type);

		//Tell the agent to update itself if the value has changed
		if (agenttype_systemmonitor_previous_values[monitor_type] != agenttype_systemmonitor_values[monitor_type])
		{
			control_notify(currentagent->controlptr, NOTIFY_NEEDUPDATE, NULL);
		}
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_networkmonitor_propogatenewvalues
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_networkmonitor_propogatenewvalues()
{
	//Declare variables
	agent *currentagent;
	
	//Reset all values to unknown
	for (int i = 0; i < AGENTTYPE_NETWORKMONITOR_NUMINTERFACES; i++)
	{
		for (int j = 0; j < 3; j++){
			agenttype_networkmonitor_previous_values[i][j] = agenttype_networkmonitor_values[i][j];
			agenttype_networkmonitor_values[i][j] = -1.0;
		}
	}

	listnode *currentnode;
	//Go through every agent
	dolist(currentnode, agenttype_networkmonitor_agents)
	{
		//Get the agent
		currentagent = (agent *) currentnode->value;

		//Get the monitor type
		int monitor_interface_number = ((agenttype_networkmonitor_details *) (currentagent->agentdetails))->monitor_interface_number;

		//Calculate a new value for this type
		agenttype_networkmonitor_updatevalue(monitor_interface_number);

		//Tell the agent to update itself if the value has changed
		if (agenttype_networkmonitor_previous_values[monitor_interface_number][0] != agenttype_networkmonitor_values[monitor_interface_number][0])
		{
			control_notify(currentagent->controlptr, NOTIFY_NEEDUPDATE, NULL);
		}
	}
예제 #3
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_bitmap_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int agenttype_bitmap_message(agent *a, int tokencount, char *tokens[])
{
	//Get the agent details
	agenttype_bitmap_details *details = (agenttype_bitmap_details *) a->agentdetails;
	if (details->is_icon && !stricmp("Size", tokens[5]) && config_set_int(tokens[6], &details->width, 1, 256))
	{
		details->height = details->width;
		control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
		return 0;
	}
	else if (details->filename && !stricmp("Scale", tokens[5]) && config_set_int(tokens[6], &details->scale, 1, 500))
	{
		control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
		return 0;
	}
	else if (!stricmp("Source", tokens[5]))
	{
		//Try to set the source
		char *parameterstring = new_string(tokens[6]);
		int setsource = agenttype_bitmaporicon_setsource(a, parameterstring);
		free_string(&parameterstring);
		if (setsource == 0) control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
		return 0;
	}

	int i;
	if ( (!stricmp("VAlign", tokens[5])) && (-1 != (i = get_string_index(tokens[6], image_valigns))) )
	{
		details->valign = i;
		control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
		return 0;
	}
	else if (!stricmp("HAlign", tokens[5]) && (-1 != (i = get_string_index(tokens[6], image_haligns))) )
	{
		details->halign = i;
		control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
		return 0;
	}



	return 1;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_networkmonitor_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int agenttype_networkmonitor_message(agent *a, int tokencount, char *tokens[])
{
	agenttype_networkmonitor_details *details = (agenttype_networkmonitor_details *) a->agentdetails;
	          
	if (!stricmp("MonitorType", tokens[5]) && config_set_int(tokens[6],&details->monitor_types, 0,2)){
		control_notify(a->controlptr,NOTIFY_NEEDUPDATE,NULL);
	}
	//No errors
	return 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_diskspacemonitor_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int agenttype_diskspacemonitor_message(agent *a, int tokencount, char *tokens[])
{
	agenttype_diskspacemonitor_details *details = (agenttype_diskspacemonitor_details *) a->agentdetails;
	if (!strcmp("MonitoringPath",tokens[5]) && config_set_str(tokens[6],&details->path)){
		details->value=-1.0;
		agenttype_diskspacemonitor_updatevalue(details);
		control_notify(a->controlptr,NOTIFY_NEEDUPDATE,NULL);
	}
	
	return 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_compoundtext_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int agenttype_compoundtext_message(agent *a, int tokencount, char *tokens[])
{
	if (!stricmp("Formatting", tokens[5]))
	{
		agenttype_compoundtext_details *details = (agenttype_compoundtext_details *) a->agentdetails;
		free_string(&details->text);
		if (*tokens[6]) details->text = new_string(tokens[6]);
		control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
		return 0;
	}

	return 1;
}
	dolist(currentnode, agenttype_diskspacemonitor_agents)
	{
		currentagent = (agent *) currentnode->value;
		details = (agenttype_diskspacemonitor_details *)currentagent->agentdetails;
		
		//Calculate a new value for this type
		agenttype_diskspacemonitor_updatevalue(details);

		//Tell the agent to update itself if the value has changed

		if (details->previous_value != details->value)
		{
			control_notify(currentagent->controlptr, NOTIFY_NEEDUPDATE, NULL);
		}
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_systemmonitor_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_systemmonitor_notify(agent *a, int notifytype, void *messagedata)
{
	//Get the agent details
	agenttype_systemmonitor_details *details = (agenttype_systemmonitor_details *) a->agentdetails;

	switch(notifytype)
	{
		case NOTIFY_CHANGE:
			control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
			break;

		case NOTIFY_SAVE_AGENT:
			//Write existance
			config_write(config_get_control_setagent_c(a->controlptr, a->agentaction, a->agenttypeptr->agenttypename, agenttype_systemmonitor_types[details->monitor_type]));
			break;
	}
}
예제 #9
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_graph_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int agenttype_graph_message(agent *a, int tokencount, char *tokens[])
{
	if (!stricmp("GraphType", tokens[5]))
	{
		agenttype_graph_details *details = (agenttype_graph_details *) a->agentdetails;
		int charttype = -1;
		for (int  i = 0; i < AGENTTYPE_GRAPH_CHARTTYPECOUNT; i++)
		{
			if (!stricmp(tokens[6], agenttype_graph_charttypes[i])) charttype = i;
		}
		if (charttype == -1) return 1;
		details->charttype = charttype;
		control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
		return 0;
	}

	return 1;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_networkmonitor_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_networkmonitor_notify(agent *a, int notifytype, void *messagedata)
{
	//Get the agent details
	agenttype_networkmonitor_details *details = (agenttype_networkmonitor_details *) a->agentdetails;

	switch(notifytype)
	{
		case NOTIFY_CHANGE:
			control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
			break;

		case NOTIFY_SAVE_AGENT:
			//Write existance
			config_write(config_get_control_setagent_c(a->controlptr, a->agentaction, a->agenttypeptr->agenttypename, agenttype_networkmonitor_interface_numbers[details->monitor_interface_number]));
			config_write(config_get_control_setagentprop_i(a->controlptr,a->agentaction, "MonitorType",&details->monitor_types));
			break;
	}
}
//##################################################
//agenttype_mixer_recieverevent
//##################################################
LRESULT CALLBACK agenttype_mixer_recieverevent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if (msg == MM_MIXM_CONTROL_CHANGE)
	{
		//When there's a volume change or something
		agent *a = (agent *) GetProp(hwnd, "mixagtptr");
		if (a)
		{
			AgentType_Mixer_XP * details = static_cast<AgentType_Mixer_XP *>(a->agentdetails);
			//If this is the right control
			//if (details->control == (ULONG) lParam)
			if (details->m_control == lParam)
			{
				control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
			}
		}
	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_systeminfo_propogatenewvalues
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_systeminfo_propogatenewvalues()
{
	//Declare variables
	agent *currentagent;

	//Go through every agent
	listnode *currentnode;
	dolist(currentnode, agenttype_systeminfo_agents)
	{
		//Get the agent
		currentagent = (agent *) currentnode->value;

		//Get the monitor type
		int monitor_type = ((agenttype_systeminfo_details *) (currentagent->agentdetails))->monitor_type;

		//Calculate a new value for this type
		
		agenttype_systeminfo_updatevalue(monitor_type);
		control_notify(currentagent->controlptr, NOTIFY_NEEDUPDATE, NULL);
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_diskspacemonitor_create
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int agenttype_diskspacemonitor_create(agent *a, char *parameterstring)
{


	if (0 == * parameterstring)
		return 2; // no param, no agent

	//Find the monitor type
	int monitor_type = DISKSPACEMONITOR_TYPE_NONE;
	for (int i = 1; i < DISKSPACEMONITOR_NUMTYPES; i++)
	{
		if (_stricmp(agenttype_diskspacemonitor_types[i], parameterstring) == 0)
		{
			monitor_type = i;
			break;
		}
	}

	//If we didn't find a correct monitor type
	if (monitor_type == DISKSPACEMONITOR_TYPE_NONE)
	{
		//On an error
		if (!plugin_suppresserrors)
		{
			char buffer[1000];
			sprintf(buffer,	"There was an error setting the Disk Space Monitor agent:\n\nType \"%s\" is not a valid type.", parameterstring);
			BBMessageBox(NULL, buffer, szAppName, MB_OK|MB_SYSTEMMODAL);
		}
		return 1;
	}

	//Is this the first?
	bool first = (agenttype_diskspacemonitor_agents->first == NULL ? true : false);

	//Create the details
	agenttype_diskspacemonitor_details *details = new agenttype_diskspacemonitor_details;
	details->monitor_type = monitor_type;
	details->value=-1.0;
	details->previous_value = 0;
	details->path=NULL;
	strcpy(details->str_value,"");
	
	//Create a unique string to assign to this (just a number from a counter)
	char identifierstring[64];
	sprintf(identifierstring, "%ul", agenttype_diskspacemonitor_counter);
	details->internal_identifier = new_string(identifierstring);

	//Set the details
	a->agentdetails = (void *)details;
	agenttype_diskspacemonitor_updatevalue(details);
	control_notify(a->controlptr,NOTIFY_NEEDUPDATE,NULL);
	
	//Add this to our internal tracking list
	agent *oldagent; //Unused, but we have to pass it
	list_add(agenttype_diskspacemonitor_agents, details->internal_identifier, (void *) a, (void **) &oldagent);

	//Increment the counter
	agenttype_diskspacemonitor_counter++;

	if (!agenttype_diskspacemonitor_hastimer)
	{
		SetTimer(agenttype_diskspacemonitor_window, 0, 10000, agenttype_diskspacemonitor_timercall);
		agenttype_diskspacemonitor_hastimer = true;
	}

	//No errors
	return 0;
}
예제 #14
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_graph_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_graph_notify(agent *a, int notifytype, void *messagedata)
{
	//Get the agent details
	agenttype_graph_details *details = (agenttype_graph_details *) a->agentdetails;
	styledrawinfo *di;
	HPEN hpen;
	HGDIOBJ oldobj;
	int offset_left;
	int width;
	int offset_top;
	int offset_bottom;
	int height;
	int currenty;
	int xoffset;
	double *currentvalue;
	double finalvalue;

	switch (notifytype)
	{
	case NOTIFY_TIMER:

		//Get the current value
		currentvalue = (double *) agent_getdata(details->agents[AGENTTYPE_GRAPH_AGENT_VALUE], DATAFETCH_VALUE_SCALE);
		finalvalue = (currentvalue == NULL || *currentvalue < 0.0 || *currentvalue > 1.0 ? 0.0 : *currentvalue);

		//Store this value in the value history
		details->historyindex++;
		if (details->historyindex == AGENTTYPE_GRAPH_HISTORYLENGTH) details->historyindex = 0;
		details->valuehistory[details->historyindex] = finalvalue;

		//Notify the control it is time to redraw
		control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);

		break;

	case NOTIFY_DRAW:

		//Get set up for drawing the graph
		di = (styledrawinfo *) messagedata;
		hpen = CreatePen(PS_SOLID, 1, style_get_text_color(STYLETYPE_TOOLBAR));
		oldobj = SelectObject(di->buffer, hpen);

		//Prepare some variables for convenience
		offset_left = di->rect.left + 2;
		width = di->rect.right - di->rect.left - 4;
		offset_top = di->rect.top + 2;
		offset_bottom = di->rect.bottom - 2;
		height = di->rect.bottom - di->rect.top - 4;

		//Make sure we have a large enough area
		if (width > 2 && height > 2)
		{
			//Draw the graph
			int currenthistoryindex = details->historyindex;

			if (details->charttype == AGENTTYPE_GRAPH_CHARTTYPE_FILL)
			{
				for (int currentx = width; currentx >= offset_left; currentx--)
				{
					currenty = offset_bottom - (height*details->valuehistory[currenthistoryindex]);
					MoveToEx(di->buffer, currentx, offset_bottom, NULL);
					LineTo(di->buffer, currentx, currenty);
					currenthistoryindex--;
					if (currenthistoryindex < 0) currenthistoryindex = AGENTTYPE_GRAPH_HISTORYLENGTH - 1;
				}
			}
			else if (details->charttype == AGENTTYPE_GRAPH_CHARTTYPE_LINE)
			{
				currenty = offset_bottom - (height*details->valuehistory[currenthistoryindex]);
				for (int currentx = width; currentx >= offset_left; currentx--)
				{
					MoveToEx(di->buffer, currentx, currenty, NULL);
					currenty = offset_bottom - (height*details->valuehistory[currenthistoryindex]);
					LineTo(di->buffer, currentx-1, currenty);
					currenthistoryindex--;
					if (currenthistoryindex < 0) currenthistoryindex = AGENTTYPE_GRAPH_HISTORYLENGTH - 1;
				}
			}
		}

		//Cleanup
		SelectObject(di->buffer, oldobj);
		DeleteObject(hpen);

		break;

	case NOTIFY_SAVE_AGENT:
		//Write existance
		config_write(config_get_control_setagent_c(a->controlptr, a->agentaction, a->agenttypeptr->agenttypename, agenttype_graph_charttypes[details->charttype]));

		//Save all child agents, if necessary
		for (int i = 0; i < AGENTTYPE_GRAPH_AGENTCOUNT; i++) agent_notify(details->agents[i], NOTIFY_SAVE_AGENT, NULL);

		break;
	}
}