Example #1
0
// Sends abort from lister to locking process
void lister_send_abort(Lister *lister)
{
	// Do we have a known locker?
	if (lister->locker_ipc)
	{
		// Send abort command
		if ((IPC_SafeCommand(lister->locker_ipc,IPC_ABORT,0,lister,0,0,&GUI->function_list))!=(ULONG)-1)
		{
			// Also signal control C to break MatchFirst/MatchNext
			if (lister->locker_ipc->proc)
			{
				Signal((struct Task *)lister->locker_ipc->proc,(SIGBREAKF_CTRL_C|IPCSIG_QUIT));
			}
		}
	}

	// Set abort flag
	lister->flags|=LISTERF_ABORTED;

	// Custom lister handler?
	if (lister->cur_buffer->buf_CustomHandler[0])
	{
		char port_name[40];

		// Abort trap installed?
		if (FindFunctionTrap("abort",lister->cur_buffer->buf_CustomHandler,port_name))
		{
			// Send abort message
			rexx_handler_msg(
				port_name,
				lister->cur_buffer,
				0,
				HA_String,0,"abort",
				HA_Value,1,lister,
				TAG_END);
		}
	}
}
Example #2
0
// Notify people we're quitting
BOOL quit_notify(void)
{
	APTR trap;
	char port[40];

	// Lock trap list
	trap=LockTrapList();

	// Look for quit traps
	while ((trap=FindTrapEntry(trap,"quit",port)))
	{
		// Send abort message
		rexx_handler_msg(port,0,0,HA_String,0,"quit",TAG_END);
	}

	// Unlock trap list
	UnlockTrapList();

	// Broadcast notify message
	SendNotifyMsg(DN_OPUS_QUIT,GUI->dopus_copy,0,0,GUI->rexx_port_name,0);

	return 1;
}
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;
}
Example #4
0
UWORD lister_listerpopup(Lister *lister,UWORD code)
{
	short a,num=0;
	UWORD res;
	PopUpHandle *menu;
	PopUpItem *item;
	PopUpExt *ext;

	// Allocate menu handle
	if (!(menu=PopUpNewHandle((ULONG)lister,lister->backdrop_info->callback,&locale)))
		return (UWORD)-1;

	// Build default lister popup
	for (a=0;lister_popup_data[a];a+=2)
	{
		if (lister_popup_data[a]==(UWORD)-1)
			PopUpSeparator(menu);
		else
		if ((item=PopUpNewItem(menu,lister_popup_data[a],lister_popup_data[a+1],0)))
		{
			// Kludge for 'lock position'
			if (item->id==MENU_LISTER_LOCK_POS)
				item->flags|=POPUPF_CHECKIT|((lister->flags&LISTERF_LOCK_POS)?POPUPF_CHECKED:0);
		}
	}

	// Clear 'separator' flag
	menu->ph_Flags&=~POPHF_SEP;

	// Lock extension list
	lock_listlock(&GUI->popupext_list,FALSE);

	// Go through list
	for (ext=(PopUpExt *)GUI->popupext_list.list.lh_Head;
		ext->pe_Node.ln_Succ;
		ext=(PopUpExt *)ext->pe_Node.ln_Succ)
	{
		// Lister?
		if (ext->pe_Type==POPUP_LISTER2)
		{
			// Check custom handler
			if (!(ext->pe_Flags&POPUPEXTF_HANDLER) ||
				strcmp(ext->pe_Command,lister->cur_buffer->buf_CustomHandler)==0)
			{
				// Add a separator if needed
				if (!(menu->ph_Flags&POPHF_SEP))
					PopUpSeparator(menu);

				// Allocate item
				if ((item=PopUpNewItem(
					menu,
					(ULONG)ext->pe_Menu,
					MENU_EXTENSION+num,
					POPUPF_STRING)))
				{
					// Set data pointer
					item->data=ext;
					++num;
				}
			}
		}
	}

	// Do popup menu
	item=0;
	if ((res=DoPopUpMenu(lister->window,&menu->ph_Menu,&item,code))!=(UWORD)-1 &&
		res>=MENU_EXTENSION)
	{
		// Got valid pointer?
		if (item && item->data)
		{
			PopUpExt *ext=(PopUpExt *)item->data;

			// Custom handler in lister?
			if (strcmp(lister->cur_buffer->buf_CustomHandler,ext->pe_Command)==0)
			{
				// Send message
				rexx_handler_msg(
					0,
					lister->cur_buffer,
					RXMF_WARN,
					HA_String,0,ext->pe_Menu,
					HA_Value,1,lister,
					TAG_END);
			}

			// Normal extension
			else
			{
				// Call popup function
				popup_run_func(item->data,0,0,lister);
			}

			// Clear result code
			res=(UWORD)-1;
		}
	}

	// Unlock extension list
	unlock_listlock(&GUI->popupext_list);

	// Free menu data
	PopUpFreeHandle(menu);
	return res;
}
Example #5
0
// Send a message for an AppThing
BOOL rexx_send_appmsg(RexxAppThing *app,short type,struct AppMessage *msg)
{
	char buf[40];
	char *files=0,*entry=0;
	ULONG lister=0;
	BOOL ret;

	// Snapshot?
	if (type==REXXAPPCMD_SNAPSHOT)
	{
		struct AppSnapshotMsg *sm;

		// Get snapshot pointer
		sm=(struct AppSnapshotMsg *)msg;

		// Unsnapshot?
		if (sm->flags&APPSNAPF_UNSNAPSHOT) type=REXXAPPCMD_UNSNAPSHOT;

		// Snapshot
		else
		{
			// Build coordinate string
			lsprintf(buf,"%ld,%ld",sm->position_x,sm->position_y);
			entry=buf;
		}
	}

	// Menu?
	else
	if (type==REXXAPPCMD_MENU)
	{
		struct AppSnapshotMsg *sm;

		// Get message pointer
		sm=(struct AppSnapshotMsg *)msg;

		// ID string
		lsprintf(buf,"%ld",sm->id);
		entry=buf;

		// Help?
		if (sm->flags&APPSNAPF_HELP) type=REXXAPPCMD_MENUHELP;
	}

	// Something with files?
	else
	if (msg && msg->am_NumArgs>0)
	{
		// Build string of files
		if ((files=rexx_build_filestring((DOpusAppMessage *)msg,&lister,(app->flags&RATF_QUOTES)?CUSTF_WANT_QUOTES:0)))
			entry=files;
	}

	// Send message
	ret=rexx_handler_msg(
		app->port_name,
		0,
		(type!=REXXAPPCMD_QUIT)?RXMF_WARN:0,
		HA_String,0,app_commands[type],
		HA_Value,1,app->id,
		HA_String,2,entry,
		HA_Value,3,lister,
		HA_String,4,"icon",
		TAG_END);

	// Free files string
	FreeVec(files);

	return ret;
}