Пример #1
0
// Someone pressed the help key
void help_get_help(short x,short y,unsigned short qual)
{
    struct Window *window=0;
    struct Layer *layer;
    IPCData *ipc=0;

    // Lock screen layer
    LockLayerInfo(&GUI->screen_pointer->LayerInfo);

    // Find which layer the mouse is over
    if ((layer=WhichLayer(&GUI->screen_pointer->LayerInfo,x,y)))
    {
        // Get window pointer
        window=layer->Window;

        // Get window ID
        if (GetWindowID(window)!=WINDOW_UNKNOWN)
        {
            // Forbid to get port
            Forbid();

            // Get port
            if (!(ipc=(IPCData *)GetWindowAppPort(window)))
                Permit();
        }
    }

    // Unlock layer
    UnlockLayerInfo(&GUI->screen_pointer->LayerInfo);

    // Got a port?
    if (ipc)
    {
        ULONG coords;

        // Convert coordinates to window-relative
        x-=window->LeftEdge;
        y-=window->TopEdge;

        // Pack into longword
        coords=((unsigned short)x<<16)|(unsigned short)y;

        // Send help command
        IPC_Command(ipc,IPC_HELP,qual,(APTR)coords,0,0);

        // Enable multitasking now that message has been sent
        Permit();
    }

    // Otherwise, show generic help
    else help_show_help(HELP_MAIN,0);
}
Пример #2
0
// Group handler
void __saveds backdrop_group_handler(void)
{
	IPCData *ipc;
	GroupData *group=0;

	// Do group
	if (ipc=IPC_ProcStartup((ULONG *)&group,backdrop_group_init))
	{
		// Read objects
		SetBusyPointer(group->window);
		backdrop_read_group_objects(group);
		ClearPointer(group->window);

		// Event loop
		FOREVER
		{
			IPCMessage *msg;
			BOOL quit_flag=0;

			// Got an AppWindow?
			if (group->appwindow)
			{
				DOpusAppMessage *amsg;
				BOOL beep=0;

				// AppMessages?
				while (amsg=(DOpusAppMessage *)GetMsg(group->appport))
				{
					short arg;
					char path[256];
					BackdropObject *drop_obj;

					// Lock backdrop list
					lock_listlock(&group->info->objects,1);

					// Set busy pointer
					if (group->window) SetBusyPointer(group->window);

					// Dropped on an object?
					if (drop_obj=backdrop_get_object(group->info,amsg->da_Msg.am_MouseX,amsg->da_Msg.am_MouseY,0))
					{
						USHORT qual;

						// Get qualifiers
						qual=(InputBase)?PeekQualifier():0;
	
						// Is shift/alt down?
						if (qual&(IEQUALIFIER_LSHIFT|IEQUALIFIER_LALT)==(IEQUALIFIER_LSHIFT|IEQUALIFIER_LALT))
						{
							// Get path of first file
							GetWBArgPath(&amsg->da_Msg.am_ArgList[0],path,256);

							// Replace the image
							backdrop_replace_icon_image(group->info,path,drop_obj);
						}

						// Run program with args
						else
						backdrop_object_open(
							group->info,
							drop_obj,
							0,
							0,
							amsg->da_Msg.am_NumArgs,
							amsg->da_Msg.am_ArgList);
					}

					// Otherwise, adding objects to the group
					else
					for (arg=0;arg<amsg->da_Msg.am_NumArgs;arg++)
					{
						// Valid name?
						if (*amsg->da_Msg.am_ArgList[arg].wa_Name)
						{
							short x,y;

							// Get full path name
							GetWBArgPath(&amsg->da_Msg.am_ArgList[arg],path,256);

							// Default to no position
							x=-1;
							y=-1;

							// Dopus app message?
							if (CheckAppMessage(amsg))
							{
								// Get icon position
								x=amsg->da_DragOffset.x+amsg->da_Msg.am_MouseX+amsg->da_DropPos[arg].x;
								y=amsg->da_DragOffset.y+amsg->da_Msg.am_MouseY+amsg->da_DropPos[arg].y;
							}

							// Add group object
							backdrop_group_add_object(group->name,group->info,path,x,y);
						}

						// Otherwise, set beep flag for error
						else
						if (!beep)
						{
							beep=1;
							DisplayBeep(group->window->WScreen);
						}
					}

					// Clear busy pointer
					if (group->window) ClearPointer(group->window);

					// Unlock backdrop list
					unlock_listlock(&group->info->objects);

					// Reply to message
					ReplyMsg((struct Message *)amsg);
				}
			}

			// Icon notification
			if (group->info->notify_req)
			{
				DOpusNotify *notify;

				// Get notify message	
				if (notify=(DOpusNotify *)GetMsg(group->info->notify_port))
					backdrop_check_notify(group->info,notify,0);
			}

			// IPC messages?
			while (msg=(IPCMessage *)GetMsg(ipc->command_port))
			{
				// Look at message
				switch (msg->command)
				{
					// Activate
					case IPC_ACTIVATE:

						// Bring window to front
						if (group->window)
							backdrop_show_group(group);
						break;


					// Quit
					case IPC_QUIT:
						quit_flag=1;
						group->got_quit=1;
						break;


					// Hide
					case IPC_HIDE:
						backdrop_hide_group(group);
						break;


					// Show
					case IPC_SHOW:
						group->screen=(struct Screen *)msg->data;
						backdrop_show_group(group);
						break;


					// Reset (menus)
					case IPC_RESET:

						// Gotta window?
						if (group->window)
						{
							// Reset menus?
							if (msg->flags)
							{
								display_free_menu(group->window);
								display_get_menu(group->window);
							}

							// Fix menus
							display_fix_menu(group->window,WINDOW_GROUP,0);
						}
						break;


					// New font
					case GROUP_NEW_FONT:

						// Get new font
						backdrop_get_font(group->info);

						// Redraw objects
						backdrop_show_objects(group->info,BDSF_CLEAR|BDSF_RESET);
						break;


					// New name
					case GROUP_NEW_NAME:

						// Copy name
						strcpy(group->name,msg->data_free);

						// Update window title
						if (group->window) SetWindowTitles(group->window,group->name,(char *)-1);
						break;


					// Add a new icon
					case GROUP_ADD_ICON:

						// Lock backdrop list
						lock_listlock(&group->info->objects,1);

						// Set busy pointer
						if (group->window) SetBusyPointer(group->window);

						// Add object
						backdrop_group_add_object(group->name,group->info,msg->data_free,-1,-1);

						// Clear busy pointer
						if (group->window) ClearPointer(group->window);

						// Unlock backdrop list
						unlock_listlock(&group->info->objects);
						break;


					// New backfill pattern
					case LISTER_BACKFILL_CHANGE:

						// Window open?
						if (group->window)
						{
							// Install appropriate hook
							InstallLayerHook(
								group->window->WLayer,
								(msg->flags)?&group->pattern.hook:LAYERS_BACKFILL);

							// Redraw window
							erase_window(group->window);

							// Redraw icons
							backdrop_show_objects(group->info,0);
						}
						break;


					// Delete from group
					case GROUP_DELETE:
						SetBusyPointer(group->window);
						backdrop_remove_group_objects(group,(BackdropObject *)msg->data);
						ClearPointer(group->window);
						break;


					// Help
					case IPC_HELP:

						// Show help for group
						help_show_help(HELP_PROGRAM_GROUP,0);
						break;


					// Do a function
					case LISTER_DO_FUNCTION:

						// Arrange icons?
						if (msg->data>=(APTR)MENU_LISTER_ARRANGE_NAME &&
							msg->data<=(APTR)MENU_LISTER_ARRANGE_SIZE)
						{
							// Do cleanup
							backdrop_cleanup(group->info,BSORT_NAME+(((ULONG)msg->data)-MENU_LISTER_ARRANGE_NAME),0);
						}
						break;
				}

				// Reply to message
				IPC_Reply(msg);
			}

			// Is window open?
			if (group->window)
			{
				struct IntuiMessage *imsg;

				// Check timer
				if (CheckTimer(group->timer))
				{
					// Dragging something?
					if (group->info->flags&BDIF_DRAGGING)
					{
						// Check for deadlocks
						if (group->info->last_tick==group->info->tick_count)
						{
							// Stop drag
							backdrop_stop_drag(group->info);
						}

						// Remember tick count
						group->info->last_tick=group->info->tick_count;
					}

					// Re-start timer
					StartTimer(group->timer,0,500000);
				}

				// Window messages
				while (imsg=(struct IntuiMessage *)GetMsg(group->window->UserPort))
				{
					struct IntuiMessage msg_copy;
					struct MenuItem *item;

					// Copy message
					msg_copy=*imsg;

					// Menu verify?
					if (imsg->Class==IDCMP_MENUVERIFY)
					{
						// See if we want to swallow it
						if (!backdrop_test_rmb(group->info,imsg,&msg_copy,TRUE))
						{
							// Did event happen over the window?
							if (imsg->MouseX>=0 &&
								imsg->MouseY>=0 &&
								imsg->MouseX<group->window->Width &&
								imsg->MouseY<group->window->Height &&
								imsg->Qualifier&IEQUALIFIER_RBUTTON)
							{
								// Cancel menu event
								imsg->Code=MENUCANCEL;

								// Change our copy to MOUSEBUTTONS
								msg_copy.Class=IDCMP_MOUSEBUTTONS;
								msg_copy.Code=MENUDOWN;

								// Kludge for MagicMenu
								if (msg_copy.Seconds==0)
									CurrentTime(&msg_copy.Seconds,&msg_copy.Micros);
							}
						}
					}

					// Resize/refresh?
					if (imsg->Class==IDCMP_NEWSIZE ||
						imsg->Class==IDCMP_REFRESHWINDOW)
					{
						// Handle message
						backdrop_idcmp(group->info,imsg,0);

						// Reply to message
						ReplyMsg((struct Message *)imsg);
						continue;
					}

					// Reply to message
					ReplyMsg((struct Message *)imsg);

					// Is it a backdrop message?
					if (backdrop_idcmp(group->info,&msg_copy,0))
						continue;

					// Look at message class
					switch (msg_copy.Class)
					{
						// Window closed
						case IDCMP_CLOSEWINDOW:
							quit_flag=1;
							break;


						// Window is inactive
						case IDCMP_INACTIVEWINDOW:

							// Abort timer if running
							StopTimer(group->timer);
							break;


						// Window is active
						case IDCMP_ACTIVEWINDOW:

							// Start timer if not running
							StartTimer(group->timer,1,0);
							break;


						// Key press
						case IDCMP_RAWKEY:

							// Help?
							if (msg_copy.Code==0x5f &&
								!(msg_copy.Qualifier&VALID_QUALIFIERS))	
							{
								help_get_help(
									msg_copy.MouseX+group->window->LeftEdge,
									msg_copy.MouseY+group->window->TopEdge,
									msg_copy.Qualifier);
							}

							// Close?
							else
							if (msg_copy.Code==0x45 &&
								msg_copy.Qualifier&IEQUAL_ANYSHIFT) quit_flag=1;
							break;


						// Button pressed
						case IDCMP_MOUSEBUTTONS:

							// Right button?
							if (msg_copy.Code==MENUDOWN)
							{
								USHORT res;

								// Do popup menu
								if (group->popup &&
									(res=DoPopUpMenu(group->window,&group->popup->ph_Menu,NULL,MENUDOWN))!=(USHORT)-1)
								{
									// Help?
									if (res&POPUP_HELPFLAG)
									{
										// Get help ID
										res&=~POPUP_HELPFLAG;

										// Do help
										help_menu_help(res,0);
										break;
									}

									// Do the function
									quit_flag=backdrop_group_do_function(group,res,0);
								}
							}
							break;


						// Menu event
						case IDCMP_MENUPICK:
						case IDCMP_MENUHELP:
							{
								struct Menu *oldstrip=group->window->MenuStrip;
								USHORT nextselect;

								// Get item
								nextselect=msg_copy.Code;
								while (item=ItemAddress(group->window->MenuStrip,nextselect))
								{
									// get next
									nextselect=item->NextSelect;

									// Help?
									if (msg_copy.Class==IDCMP_MENUHELP)
									{
										help_menu_help((long)GTMENUITEM_USERDATA(item),0);
										break;
									}

									// Do the function
									quit_flag=backdrop_group_do_function(group,(ULONG)GTMENUITEM_USERDATA(item),item);

									// Check valid next
									if (!nextselect || !group->window || oldstrip!=group->window->MenuStrip)
										break;
								}
							}
							break;
					}
				}
			}

			// Check quit flag
			if (quit_flag) break;

			// Wait for event
			Wait(	1<<ipc->command_port->mp_SigBit|
					1<<group->timer->port->mp_SigBit|
					((group->info->notify_req)?(1<<group->info->notify_port->mp_SigBit):0)|
					((group->window)?(1<<group->window->UserPort->mp_SigBit):0)|
					((group->appwindow)?(1<<group->appport->mp_SigBit):0));
		}

		// Close window
		backdrop_free_group(group);

		// Send goodbye
		IPC_Goodbye(ipc,&main_ipc,0);
	}
Пример #3
0
// Help for a button
void help_button_help(
    Cfg_Button *button,
    Cfg_Function *func,
    unsigned short qual,
    short which,
    char *generic)
{
    Cfg_Function *function;
    Cfg_Instruction *ins;
    char *ptr;
    CommandList *command;
    char *help_node=0;

    // Function supplied?
    if (func) function=func;

    // No function pointer supplied
    else
    {
        // Function number supplied
        if (qual!=0xffff)
        {
            // Right button?
            if (qual&IEQUALIFIER_RBUTTON) which=FTYPE_RIGHT_BUTTON;

            // Middle button?
            else if (qual&IEQUALIFIER_MIDBUTTON ||
                     (qual&IEQUALIFIER_LEFTBUTTON && qual&IEQUAL_ANYSHIFT))
                which=FTYPE_MID_BUTTON;

            // Default function
            else which=button->current;
        }

        // Get function
        if (!(function=button_valid(button,which)) &&
                !(function=button_valid(button,FTYPE_LEFT_BUTTON)))
        {
            // Invalid function
            help_node=generic;
        }
    }

    // Valid function
    if (function)
    {
        // Get first instruction
        ins=(Cfg_Instruction *)function->instructions.mlh_Head;

        // Valid command?
        if (!ins->node.mln_Succ ||
                ins->type!=INST_COMMAND ||
                !(ptr=ins->string) ||
                !(command=function_find_internal(&ptr,0)))
        {
            // Invalid instruction
            help_node=generic;
        }

        // Get command
        else help_node=command->name;
    }

    // Show help on this command
    help_show_help(help_node,0);
}
Пример #4
0
// Menu item help
void help_menu_help(long id,char *generic)
{
    short a;
    char *header=0;
    Cfg_Button *button;
    APTR appitem;

    // Go through menu help table
    for (a=0; menu_help_data[a].name; a++)
    {
        // New header?
        if (menu_help_data[a].id==0) header=menu_help_data[a].name;

        // Match ID?
        else if (menu_help_data[a].id==id)
        {
            char buf[80];

            // Build help string
            if (header)
            {
                strcpy(buf,header);
                strcat(buf," - ");
            }
            else buf[0]=0;
            strcat(buf,menu_help_data[a].name);

            // Show help
            help_show_help(buf,0);
            return;
        }
    }

    // Lock user menu
    GetSemaphore(&GUI->user_menu_lock,SEMF_SHARED,0);

    // Go through menu, look for this function
    for (button=(Cfg_Button *)GUI->user_menu->buttons.lh_Head;
            button->node.ln_Succ;
            button=(Cfg_Button *)button->node.ln_Succ)
    {
        Cfg_ButtonFunction *func;

        // Go through functions
        for (func=(Cfg_ButtonFunction *)button->function_list.mlh_Head;
                func->node.ln_Succ;
                func=(Cfg_ButtonFunction *)func->node.ln_Succ)
        {
            // Match function
            if (func==(Cfg_ButtonFunction *)id)
            {
                // Show help for user menu function
                help_button_help(button,(Cfg_Function *)func,0xffff,func->function.func_type,GENERIC_USER_MENU);
                FreeSemaphore(&GUI->user_menu_lock);
                return;
            }
        }
    }

    // Unlock user menu
    FreeSemaphore(&GUI->user_menu_lock);

    // Lock app list
    appitem=LockAppList();

    // Search appmenu list, see if that's what was hit
    while ((appitem=NextAppEntry(appitem,APP_MENU)))
    {
        // Item we want?
        if (appitem==(APTR)id)
        {
            // Show help for AppItems
            generic=HELP_APPMENUITEM;
            break;
        }
    }

    // Unlock list
    UnlockAppList();

    // Show generic help
    help_show_help(generic,0);
}
Пример #5
0
int configuration_parse_cmdline( config_t *c, int argc, char *argv[] )
{
	int i;

	configuration_define_defaults( c );
	conf = c;

	if ( argc == 1 ) {
		printf("ERROR: not enough arguments.\n\n");
		help_show_help();
		return -1;
	}

	while ( 1 ) {
		int option_index = 0;

		static struct option long_options[] = {\
			{ "inet-port", 1, NULL, 'i' },
			{ "ip", 1, NULL, 'I' },
			{ "dbdriver",1,NULL,'M'},
			{ "dbname",1,NULL,'N'},
			{ "dbuser",1,NULL,'S'},
			{ "dbhost",1,NULL,'H'},
			{ "dbpassword",1,NULL,'P'},
			{ "interactive", 0, NULL, 'o' },
			{ "debug-level",1, NULL, 'd' },
			{ "config-file",1,NULL,'c'},
			{ "unix-domain-socket-cl",0,NULL,'n'},
			{ "key-file",1,NULL,'k'},
			{ "maintenance-timer",1,NULL,'t'},
			{ "maintenance-timer-config",1,NULL,'m'},
			{ "unix-domain-socket",0,NULL,'u'},
			{ "precision",1,NULL,'p'},
			{ "use-db",1,NULL,'D'},
			{ "key-file-clients",1,NULL,'K'},
			{ "query-port",1,NULL,'q'},
			{ "setup",0,NULL,'T'},
			{ 0,0,0,0 }
		};

		i = getopt_long( argc, argv,
			"S:Tnd:i:oc:k:q:t:m:up:U:M:N:H:P:K:I:", long_options, &option_index );

		if ( i == -1 ) break;

		switch (i) {
			case 'I':
				c->smbtad_ip = strdup(optarg);
				break;
			case 'T':
				c->dbsetup = 1;
				break;
			case 'K':
				c->keyfile_clients = strdup( optarg);
				configuration_load_client_key_from_file(c);
				break;
			case 'q':
				c->query_port = atoi(optarg);
				break;
			case 'n':
				c->unix_socket_clients = 1;
				break;
			case 'S':
				c->dbuser = strdup(optarg);
				break;
			case 'M':
				c->dbdriver = strdup(optarg);
				break;
			case 'N':
				c->dbname = strdup(optarg);
				break;
			case 'H':
				c->dbhost = strdup(optarg);
				break;
			case 'P':
				c->dbpassword = strdup(optarg);
				break;
			case 'u':
				c->unix_socket = 1;
				break;
			case 'i':
				c->port = atoi( optarg );
				break;
			case 't':
				strncpy(c->maintenance_timer_str,optarg,199);
				break;
			case 'm':
				strncpy(c->maint_run_time_str,optarg,199);
				break;
			case 'o':
				c->daemon = 0;
				break;
			case 'd':
				c->dbg = atoi( optarg );
				break;
			case 'c':
				c->config_file = strdup( optarg );
				configuration_load_config_file(c);
				break;
			case 'k':
				c->keyfile = strdup( optarg);
				configuration_load_key_from_file(c);
				break;
			case 'b':
				c->dbname = strdup( optarg );
				break;
			case 'p':
				c->precision = atoi(optarg);
				break;
			case 'U':
				c->use_db = atoi(optarg);
				break;
			default	:
				printf("ERROR: unkown option.\n\n");
				help_show_help();
				return -1;
		}
	}
	configuration_check_configuration(c);

return 0;
}