This folder contains an example/template of plug-in implementation for IDA
and a file with the declaration of the interface which is used for interaction between a 
plug-in and IDA.

DMPluginIntf.pas - the interface declaration (DM - download manager);
dmtest_plugin.dpr - the plug-in Delphi project file;
dmtest_pluginImpl.pas - the test plug-in implementation.

	IDA INTERFACE DESCRIPTION (DMPluginIntf.pas)

	The interface provides two basic functions for interaction with IDA:
EventRaised and DoAction, and one function used to show the configuration window 
of your plug-in -- PluginConfigure, which you have to implement by yourself. Implementation 
of other functions is almost the same for all plug-ins and you can take it from the template.

======function DoAction(action: WideString; parameters: WideString): WideString; stdcall;
//execute some actions in IDA

 	action = 'AddingURL' - add a URL for download.
	parameters = '<url>http://www.westbyte.com/plugin</url> <sectionslimit>2</sectionslimit>';
		possible parameter names:
		'url', 'referer', 'description', 'savepath', 'filename', 'user', 'password', 'sectionslimit', 'priority', 'cookies', 'post', 'hidden', 'start', 'mirror1', 'mirror2', 'mirror3', 'mirror4', 'mirror5'
   
	For example: DoAction('AddingURL', '<url>http://www.westbyte.com/plugin</url> <hidden>1</hidden>')
		- adds http://www.westbyte.com/plugin downlolad without opening the Add download window (hidden=1)

     Possible parameter values (format: (action: WideString; parameters: WideString)):
        ('AddingURL', '<url>http://www.westbyte.com/plugin</url> <hidden>1</hidden>') - add a URL for download without opening the Add download window;
        ('GetDownloadInfoByID', IntToStr(ID)) - return info (in XML-format) about a download with a specified ID;
        ('GetMaxSectionsByID', IntToStr(ID)) - return max number of sections which can be opened by a download with a specfied ID;
        ('GetDownloadIDsList', '') - return a list of IDs (space-separated) of all downloads in the download list. Parameter -- state of downloads to return	('GetDownloadIDsList', IntToStr(State));
        	For example: ('GetDownloadIDsList', '3') - return a list of IDs of downloads being downloaded right now(dsDownloading = 3).  
			Possible state parameter values - (dsPause = 0, dsPausing = 1, dsDownloaded = 2, dsDownloading = 3, dsError = 4, dsErroring = 5, dsQueue = 6);

	('GetTempDir', '') - return the path to the directory with temporary files
	('GetPluginDir', '') - return the path to the plug-in directory
	('GetListDir', '') - return the path to the directory where download lists are stored
	('GetProgramDir', '') - return the path to the program directory
	('GetLanguage', '') - return the currently used interface language
	('GetProgramName', '') - return the program name
	('GetCategoriesList', '') - return the category list in stringlist-format
	('GetSpeedsList', '') - return speed list in stringlist-format
	('GetConnectionsList', '') - return the RAS (connection) list in stringlist-format
	('GetLogDir', '') - return the path to the log directory

        ('StartSheduled', '') - start all scheduled downloads;
        ('StopSheduled', '') - stop all scheduled downloads;
        ('StartAll', '') - start all uncompleted downloads;
        ('StopAll', '') - stop all downloads;
        ('StartNode', IntToStr(NodeID)) - start all uncompleted downloads from the specified directory (subcategories are included only if "Show downloads from subcategories" option is enabled);
        ('StopNode', IntToStr(NodeID)) - stop all in the specified directory (subcategories are included only if "Show downloads from subcategories" option is enabled);
        ('StartDownloads', IntToStr(ID)) - start/(enqueue) (a) download(s) with specified ID(s) (if there are several downloads separate IDs with spaces, for example: ('StartDownloads', '21 456 20'));
        ('StopDownloads', IntToStr(ID)) - stop (a) download(s) with specified ID(s) (if there are several downloads separate IDs with spaces, for example: ('StopDownloads', '13 2527'));
        ('ChangeSpeed', IntToStr(SpeedMode)) - change speed;
        ('RunApp', '<app>'+RunStr+'</app>'+'<param>'+RunParamStr+'</param>') - start a program with the specified parameters;
        ('ConnectRAS', '<connection>'+ConnectionName+'</connection><attempts>'+IntToStr(_Task.ConnectionAttempts)+'</attempts><period>'+IntToStr(_Task.ConnectionPeriod)+'</period>') - establish a connection using the specified parameters;
        ('DisconnectRAS', ConnectionName) - disconnect, if the connection is not specified then all active connections are disconnected;
        ('ShutDown', '') - shutdown the computer;
        ('HibernateMode', '') - switch to the sleep mode (hiberanate);
        ('StandByMode', '') - switch to the stand-by mode;
        ('Exit', '') - exit the program
        ('ChangeMaxDownloads', IntToStr(MaxDownloads)) - change the max number of simultaneous downloads;
        ('AddStringToLog', '<id>'+IntToStr(ID)+'</id>'+'<type>'+IntToStr(Type)+'</type>'+'<logstring>Log String</logstring>') - add to the download (indicated by the ID) log a Log String, with Type (0 - Out, 1 - In, 2 - Info (by default), 3 - Error);
        ('ShowDownloadProperties', '<id>'+IntToStr(ID)+'</id>') - show the "Download properties" window of the download indicated by the ID;
        ('ShowDownloadWindow', '<id>'+IntToStr(ID)+'</id>') - show the download window of the download indicated by the ID;

E-mail me at slava@westbyte.com if you need some additional actions.

========function EventRaised(eventType: WideString; eventData: WideString): WideString; stdcall;
//called back from IDA when some event occurs

Events have the following format: (eventType: WideString; eventData: WideString):
	

1. ('plugin_start', '') - the plug-in is enabled;
2. ('plugin_stop', '') - the plug-in is disabled;
3. ('dm_timer_60', '') - occurs every 60 seconds 
3.2. ('dm_timer_10', '') - occurs every 10 seconds  
3.3. ('dm_timer_5', '') - occurs every 5 seconds 
	(to process something every minute);
4. ('dm_download_state', IntToStr(ID)+' '+IntToStr(integer(State))) - 
	occurs when the state of the download indicated by ID is changed.
	State = (dsPause, dsPausing, dsDownloaded, dsDownloading, dsError, dsErroring, dsQueue);
5. ('dm_download_added', IntToStr(ID)) - occurs when a new download added;
6. ('dm_downloadall', '') - occurs after completing all downloads;
7. ('dm_start', '') - occurs after IDA start;
8. ('dm_connect', '') - ocuurs after IDA established connection;
9. ('dm_changelanguage', language) - occurs when interface language is changed

E-mail me at slava@westbyte.com if you need some additional events.

=============procedure PluginConfigure(params: WideString); stdcall;
//called back from IDA; shows the plug-in configuration window

1. ('<language>VALUE</language>') - where VALUE is the name of the currently used interace language.
	For example: ('<language>english</language>')

	You can implement the configuration window for two or more languages. 
	Code example:
	  if (language = 'russian') or (language = 'ukrainian') or (language = 'belarusian') then
	    //Show in Russian
	  else
	    //Show in English
=================================================================================
						()2006 Vyacheslav Viter