Example #1
0
// Run the update module
void startup_run_update()
{
    struct Library *ModuleBase;
#ifdef __amigaos4__
    struct ModuleIFace *IModule;
#endif

    // Try and get update.module
#ifdef __amigaos4__
    if (OpenLibIFace("dopus5:modules/update.module", (APTR)&ModuleBase, (APTR)&IModule, LIB_VERSION))
#else
    if ((ModuleBase=OpenLibrary("dopus5:modules/update.module",0)))
#endif
    {
        // Launch update function
        Module_Entry(0,0,0,0,0,0);

        // Expunge library
        Module_Expunge();

        // Close library
#ifdef __amigaos4__
        DropInterface((struct Interface *)IModule);
#endif
        CloseLibrary(ModuleBase);
    }
}
void config_env_test_sound(config_env_data *data)
{
	struct Library *ModuleBase;
	BOOL ok=0;

	// Busy the window
	SetWindowBusy(data->window);

	// Open play.module
	if (ModuleBase=OpenLibrary("dopus5:modules/play.module",0))
	{
		short num;
		Cfg_SoundEntry *sound;

		// Get selection
		if ((num=GetGadgetValue(data->option_list,GAD_SETTINGS_SOUNDLIST))>-1 &&
			(sound=(Cfg_SoundEntry *)Att_FindNode((Att_List *)&data->sound_list,num)) &&
			sound->dse_Sound[0])
		{
			struct Node node;
			struct List list;

			// Build file list
			NewList(&list);
			node.ln_Name=sound->dse_Sound;
			AddTail(&list,&node);

			// Play the sound
			Module_Entry(
				&list,
				data->window->WScreen,
				data->ipc,
				data->main_ipc,
				(ULONG)data->window,
				sound->dse_Volume<<8);
			ok=1;
		}

		// Close module
		CloseLibrary(ModuleBase);
	}

	// Unbusy the window
	ClearWindowBusy(data->window);
	if (!ok) DisplayBeep(data->window->WScreen);
}
Example #3
0
// Show about requester
void show_about(struct Screen *screen,IPCData *ipc)
{
	char buf[80],*buffer;
	struct Library *ModuleBase;
	Att_List *list;
	Att_Node *node;

	// Create list of text
	if (!(list=Att_NewList(0)))
		return;

	// Build lines
	lsprintf(buf,"%s %ld.%ld %s",dopus_name,5,version_num,version_string);
	Att_NewNode(list,buf,2,0);
	Att_NewNode(list,about_1,2,0);
	Att_NewNode(list,about_2,2,0);

	// Name of the translator
	Att_NewNode(list,GetString(&locale,MSG_TRANSLATION_BY_YOUR_NAME),3,0);

	// Registered?
	if (GUI->rego.name[0] &&
		GUI->rego.serial_number[0] &&
		atoi(GUI->rego.serial_number)!=(ULONG)GUI->backdrop)
	{
		Att_NewNode(list,GetString(&locale,MSG_REGISTERED_TO),1,0);
		Att_NewNode(list,"",1,0);
		Att_NewNode(list,GUI->rego.name,1,0);
		if (GUI->rego.company[0]) Att_NewNode(list,GUI->rego.company,1,0);
		if (GUI->rego.address1[0]) Att_NewNode(list,GUI->rego.address1,1,0);
		if (GUI->rego.address2[0]) Att_NewNode(list,GUI->rego.address2,1,0);
		if (GUI->rego.address3[0]) Att_NewNode(list,GUI->rego.address3,1,0);
		Att_NewNode(list,"",1,0);
		strcpy(buf,GetString(&locale,MSG_SERIAL_NUMBER));
		strcat(buf,GUI->rego.serial_number);
		Att_NewNode(list,buf,0,0);
	}

	// Unregistered
	else
	{
		Att_NewNode(list,"",1,0);
		Att_NewNode(list,GetString(&locale,MSG_UNREGISTERED),1,0);
		Att_NewNode(list,"",0,0);
	}

	// Try for external about library
	if ((ModuleBase=OpenLibrary("dopus5:modules/about.module",0)))
	{
		short ret;

		// Show about
		ret=Module_Entry((struct List *)list,screen,ipc,&main_ipc,0,0);
		CloseLibrary(ModuleBase);

		// If it displayed ok, return
		if (ret)
		{
			Att_RemList(list,0);
			return;
		}
	}

	// Allocate buffer
	if (buffer=AllocVec(512,0))
	{
		// Clear buffer
		buffer[0]=0;

		// Build about text
		for (node=(Att_Node *)list->list.lh_Head;
			node->node.ln_Succ;
			node=(Att_Node *)node->node.ln_Succ)
		{
			// Skip?
			if (node->data==3) continue;

			// Add to string
			strcat(buffer,node->node.ln_Name);
			if (node->data>0)
			{
				strcat(buffer,(node->data==2)?"\n\n":"\n");
			}
		}

		// Display about text
		super_request_args(
			screen,
			buffer,
			SRF_SCREEN_PARENT|SRF_IPC,
			ipc,
			GetString(&locale,MSG_OKAY),0);

		// Free buffer
		FreeVec(buffer);
	}

	// Free list
	Att_RemList(list,0);
}
function_internal_command(
	CommandList *command,
	char *args,
	FunctionHandle *handle,
	InstructionParsed *instruction)
{
	short ret=1;
	Lister *lister;
	DirBuffer *cust_buffer=0;
	Lister *source_lister=0,*dest_lister=0;
	char custom_port[40];
	PathNode *source_n=0,*dest_n=0;

	// Clear instruction flags
	if (handle) handle->instruction_flags=0;

	// Valid command?
	if (!command || !command->name) return 1;

	// Initialise custom port
	custom_port[0]=0;

	// Got a handle?
	if (handle)
	{
		// Get source and dest nodes
		source_n=function_path_current(&handle->source_paths);
		dest_n=function_path_current(&handle->dest_paths);

		// Get current source lister
		if (lister=function_lister_current(&handle->source_paths))
		{
			// Custom handler installed?
			if (lister->cur_buffer->buf_CustomHandler[0])
			{
				// If there's a NEW flag, we won't be using this lister
				if (instruction && !instruction->new_arg)
				{
					// Look for trap handler
					if (FindFunctionTrap(command->name,lister->cur_buffer->buf_CustomHandler,custom_port))
					{
						source_lister=lister;
						dest_lister=function_lister_current(&handle->dest_paths);
						cust_buffer=lister->cur_buffer;
					}
				}
			}
		}

		// If no custom handler, try destination
		if (!cust_buffer &&
			(command->flags&FUNCF_NEED_DEST) &&
			(lister=function_lister_current(&handle->dest_paths)))
		{
			// Custom handler installed?
			if (lister->cur_buffer->buf_CustomHandler[0])
			{
				// Look for trap handler
				if (FindFunctionTrap(command->name,lister->cur_buffer->buf_CustomHandler,custom_port))
				{
					source_lister=function_lister_current(&handle->source_paths);
					dest_lister=lister;
					cust_buffer=lister->cur_buffer;
				}
			}
		}
	}

	// Custom handler?
	if (cust_buffer)
	{
		char *files=0;
		ULONG flags;

		// Need files?
		if (command->flags&FUNCF_NEED_ENTRIES)
		{
			// Build file string
			files=function_build_file_string(
				handle,
				cust_buffer->cust_flags&CUSTF_WANT_QUOTES);
		}

		// Get flags
		flags=RXMF_WARN;
		if (cust_buffer->cust_flags&CUSTF_SYNCTRAPS) flags|=RXMF_SYNC;

		// Send command message
		ret=rexx_handler_msg(
			custom_port,
			cust_buffer,
			flags,
			HA_String,0,command->name,
			HA_Value,1,source_lister,
			HA_String,2,files,
			HA_Value,3,dest_lister,
			HA_String,4,(source_n)?source_n->path:0,
			HA_String,5,args,
			HA_String,7,(dest_n)?dest_n->path:0,
			HA_Value,8,(flags&RXMF_SYNC)?handle:0,
			TAG_END);

		// Free file string
		FreeVec(files);
		return ret;
	}

	// External command?
	if (command->flags&FUNCF_EXTERNAL_FUNCTION)
	{
		struct Library *ModuleBase;
		char *work_buf=0,*buffer;

		// Need to allocate buffer?
		if (!handle)
		{
			work_buf=AllocVec(512,MEMF_CLEAR);
			buffer=work_buf;
		}
		else buffer=handle->work_buffer;

		// No buffer?
		if (!buffer || strcmp(command->stuff.module_name,"!")==0)
		{
		}

		// User command?
		else
		if (strnicmp(command->stuff.module_name,"dopus5:commands/",16)==0)
		{
			// Shouldn't be able to get here!
		}

		// Rexx script?
		else
		if (sufcmp(command->stuff.module_name,".dopus5"))
		{
			// Get rexx function to run
			lsprintf(buffer,
				"dopus5:modules/%s %s %s %ld %ld %s",
				command->stuff.module_name,
				GUI->rexx_port_name,
				command->name,
				(source_n)?source_n->lister:0,
				(dest_n)?dest_n->lister:0,
				args);

			// Run rexx thing
			rexx_send_command(buffer,TRUE);
		}

		// Open module
		else
		if (ModuleBase=OpenModule(command->stuff.module_name))
		{
			// Copy arguments
			strcpy(buffer,args);

			// Add a newline
			if (*buffer) strcat(buffer,"\n");

			// Call module
			ret=Module_Entry(
				(command->flags&FUNCF_NO_ARGS)?0:(struct List *)buffer,
				GUI->screen_pointer,
				(handle)?handle->ipc:0,
				&main_ipc,
				command->function,
				(ULONG)function_external_hook);

			// Close module
			CloseLibrary(ModuleBase);
		}

		// Free buffer
		FreeVec(work_buf);
	}

	// Valid code?
	else
	if (command->stuff.code)
		ret=(int)((int (*)())(command->stuff.code)(command,handle,args,instruction));

	return ret;
}