Ejemplo n.º 1
0
Archivo: menu.c Proyecto: ysei/NetSurf
static void ami_menu_item_arexx_execute(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
	char *temp;
	struct gui_window_2 *gwin;
	GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);

	if(AslRequestTags(filereq,
						ASLFR_Window, gwin->win,
						ASLFR_SleepWindow, TRUE,
						ASLFR_TitleText, messages_get("NetSurf"),
						ASLFR_Screen, scrn,
						ASLFR_DoSaveMode, FALSE,
						ASLFR_InitialDrawer, nsoption_charp(arexx_dir),
						ASLFR_InitialPattern, "#?.nsrx",
						TAG_DONE))
	{
		if(temp = AllocVecTagList(1024, NULL))
		{
			strlcpy(temp, filereq->fr_Drawer, 1024);
			AddPart(temp, filereq->fr_File, 1024);
			ami_arexx_execute(temp);
			FreeVec(temp);
		}
	}
}
Ejemplo n.º 2
0
static char *VSID_BrowseFile(char *select_text, char *pattern)
{
    struct FileRequester *request;

    request = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest, ASL_Hail, select_text, (struct TagItem *)TAG_DONE);

    if (AslRequestTags(request, ASLFR_Window, vsid_window,
                                ASLFR_InitialDrawer, "PROGDIR:",
                                ASLFR_InitialPattern, pattern,
                                ASLFR_PositiveText, select_text,
                                (struct TagItem *)TAG_DONE)) {
        fname[0] = 0;
        strcat(fname,request->rf_Dir);
        if (fname[strlen(fname) - 1] != (UBYTE)58) {
            strcat(fname, "/");
        }
        strcat(fname, request->rf_File);
        if (fname[strlen(fname) - 1] != (UBYTE)58 && fname[strlen(fname) - 1] != '/') {
            if (request) {
                FreeAslRequest(request);
            }
            return fname;
        }
    }
    if (request) {
        FreeAslRequest(request);
    }

    return NULL;
}
Ejemplo n.º 3
0
nserror
gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
{
	char fname[1024];
	STRPTR openurlstring,linkname;
	struct DiskObject *dobj = NULL;

	linkname = ASPrintf("Link_to_%s",FilePart(nsurl_access(url)));

	if(AslRequestTags(savereq,
		ASLFR_Window, g->shared->win,
		ASLFR_SleepWindow, TRUE,
		ASLFR_TitleText,messages_get("NetSurf"),
		ASLFR_Screen,scrn,
		ASLFR_InitialFile,linkname,
		TAG_DONE))
	{
		strlcpy(fname, savereq->fr_Drawer, 1024);
		AddPart(fname,savereq->fr_File,1024);

		ami_set_pointer(g->shared, GUI_POINTER_WAIT, false);

		if(ami_download_check_overwrite(fname, g->shared->win, 0))
		{
			BPTR fh;

			if((fh = FOpen(fname,MODE_NEWFILE,0)))
			{
				/* \todo Should be URLOpen on OS4.1 */
				openurlstring = ASPrintf("openurl \"%s\"\n",nsurl_access(url));
				FWrite(fh,openurlstring,1,strlen(openurlstring));
				FClose(fh);
				FreeVec(openurlstring);
				SetComment(fname, nsurl_access(url));

				dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,"url",
									ICONGETA_GetDefaultType,WBPROJECT,
									TAG_DONE);		

				dobj->do_DefaultTool = "IconX";

				PutIconTags(fname,dobj,
							ICONPUTA_NotifyWorkbench,TRUE,
							TAG_DONE);

				FreeDiskObject(dobj);
			}
			FreeVec(linkname);
		}
		ami_reset_pointer(g->shared);
	}
	return NSERROR_OK;
}
Ejemplo n.º 4
0
long ScreenMode(void)
{

	if((AslBase = OpenLibrary("asl.library", 0)) != NULL)
	{

		struct ScreenModeRequester *sm;

		if((sm = AllocAslRequest(ASL_ScreenModeRequest,NULL)))
		{
		#ifdef DEBUG
		Printf("sm %08lx\n", sm);
		#endif
			if(AslRequestTags(sm,
					ASLSM_DoDepth, TRUE,
					ASLSM_DoWidth, TRUE,
					ASLSM_DoHeight, TRUE,
					ASLSM_MinDepth, 8,
					ASLSM_MaxDepth, 32,
					ASLSM_MinWidth, 640,
					ASLSM_MinHeight,480,
					ASLSM_MaxWidth, 1920,
					ASLSM_MaxHeight,1080,
					TAG_DONE))
			{

					sprintf(cvar, "%d",  sm->sm_DisplayWidth);
				set(obj->STR_width, MUIA_String_Contents, cvar);
					sprintf(cvar, "%d",  sm->sm_DisplayHeight);
				set(obj->STR_height, MUIA_String_Contents, cvar);
					sprintf(cvar, "%d",  sm->sm_DisplayDepth);
				set(obj->STR_depth, MUIA_String_Contents, cvar);
				
				int depth = sm->sm_DisplayDepth;
				if (depth == 8)
					set(obj->CH_fullscreen, MUIA_Selected, TRUE);
				else if ((depth > 8) && (depth < 16))
					set(obj->STR_depth, MUIA_String_Contents, "16");
				else if (depth> 16) 
					set(obj->STR_depth, MUIA_String_Contents, "32");	
			}

			FreeAslRequest(sm);
		}
		
	if (AslBase)
		CloseLibrary(AslBase);
	}

	return 0;
}
Ejemplo n.º 5
0
STRPTR AslFile( STRPTR TitleText, STRPTR InitialPattern )
{
	struct Library * AslBase;
	STRPTR name = NULL;
	
	ENTER();
	
	if((AslBase = OpenLibrary("asl.library", 0)))
	{
		struct FileRequester *freq;
		
		if((freq = AllocAslRequestTags(ASL_FileRequest, TAG_DONE)))
		{
			if(AslRequestTags(freq,
				ASLFR_TitleText, (ULONG)TitleText,
				ASLFR_InitialDrawer, (ULONG)GetString(AslFilePath,"PROGDIR:"),
				ASLFR_RejectIcons, TRUE,
				InitialPattern != NULL ? ASLFR_DoPatterns:TAG_IGNORE, TRUE,
				InitialPattern != NULL ? ASLFR_InitialPattern:TAG_IGNORE, (ULONG)InitialPattern,
				TAG_DONE))
			{
				ULONG namelen;
				
				namelen = strlen(freq->fr_File) + strlen(freq->fr_Drawer) + 32;
				
				if((name = AllocVec(namelen + 1, MEMF_PUBLIC | MEMF_CLEAR)))
				{
					AddPart(name, freq->fr_Drawer, namelen);
					AddPart(name, freq->fr_File, namelen);
					
					set( AslFilePath, MUIA_String_Contents,(ULONG)freq->fr_Drawer);
				}
			}
			
			FreeAslRequest(freq);
		}
		else ShowError("Cannot alloc AslRequest!");
		
		CloseLibrary( AslBase );
	}
	else ShowError("Cannot open %s","asl.library");
	
	DBG_STRING(name);
	
	return name;
}
Ejemplo n.º 6
0
// Ask for font name
void font_ask_name(font_data *data)
{
	char file[40],path[256],*fileptr;

	// Copy path
	strcpy(path,data->font_name);

	// Split filename
	if ((fileptr=FilePart(path)))
	{
		strcpy(file,fileptr);
		*fileptr=0;
	}
	else file[0]=0;

	// Empty path?
	if (!path[0]) strcpy(path,"fonts:");

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

	// Display requester
	if (AslRequestTags(((WindowData *)data->window->UserData)->request,
		ASLFR_Window,data->window,
		ASLFR_TitleText,GetString(&data->locale,MSG_FONT_SELECT),
		ASLFR_InitialFile,file,
		ASLFR_InitialDrawer,path,
		ASLFR_IntuiMsgFunc,&data->refresh_hook,
		TAG_END))
	{
		// Get pathname
		strcpy(path,((WindowData *)data->window->UserData)->request->fr_Drawer);
		AddPart(path,((WindowData *)data->window->UserData)->request->fr_File,256);

		// Get font name
		font_get_name(data,path);

		// Get new font
		font_get_font(data);
		font_show_font(data,FALSE);
	}

	// Unbusy window
	else ClearWindowBusy(data->window);
}
Ejemplo n.º 7
0
Att_List *import_sites(struct window_params *wp,short gadgetid)
{
struct display_globals *dg;
char path[256];
Att_List *sitelist=NULL;

if	(!wp)
	return(NULL);

dg=wp->wp_dg;

// Make window busy
SetWindowBusy(wp->wp_win);

if	(gadgetid==MENU_FTP_IMPORT_AMFTP)
	strcpy(path,".AmFTPProfiles");
else
	strcpy(path,"DOpus5:System/");

// Display file requester
if	(AslRequestTags(DATA(wp->wp_win)->request,
	ASLFR_Window,wp->wp_win,
	ASLFR_TitleText,GetString(locale,MSG_FTP_IMPORT_SITES),
	ASLFR_InitialFile,  (gadgetid==MENU_FTP_IMPORT_AMFTP)? path:"",
	ASLFR_InitialDrawer,(gadgetid==MENU_FTP_IMPORT_AMFTP)? ""  :path,
	ASLFR_Flags1,FRF_PRIVATEIDCMP,
	TAG_END))
	{
	// Get new path
	strcpy(path,DATA(wp->wp_win)->request->fr_Drawer);
	AddPart(path,DATA(wp->wp_win)->request->fr_File,256);

	if	(gadgetid==MENU_FTP_IMPORT)
		sitelist=do_import_sites(dg->dg_og,path);
	else if	(gadgetid==MENU_FTP_IMPORT_AMFTP)
		sitelist=do_import_amftp(dg,path);

	}


// Make window unbusy
ClearWindowBusy(wp->wp_win);

return(sitelist);
}
Ejemplo n.º 8
0
 /* menu hook functions */
HOOKF(void, ami_history_global_menu_item_project_export, APTR, window, struct IntuiMessage *)
{
	char fname[1024];
	struct ami_corewindow *ami_cw;
	GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);

	if(AslRequestTags(savereq,
		ASLFR_Window, ami_cw->win,
		ASLFR_SleepWindow, TRUE,
		ASLFR_TitleText, messages_get("NetSurf"),
		ASLFR_Screen, scrn,
		ASLFR_InitialFile, "history.html",
		TAG_DONE)) {
			strlcpy(fname, savereq->fr_Drawer, 1024);
			AddPart(fname, savereq->fr_File, 1024);
			ami_update_pointer(ami_cw->win, GUI_POINTER_WAIT);
			global_history_export(fname, NULL);
			ami_update_pointer(ami_cw->win, GUI_POINTER_DEFAULT);
	}
}
Ejemplo n.º 9
0
void ami_file_save_req(int type, struct gui_window_2 *gwin,
		struct hlcache_handle *object)
{
	char *fname = AllocVecTags(1024, NULL);

	if(AslRequestTags(savereq,
			ASLFR_Window, gwin->win,
			ASLFR_SleepWindow, TRUE,
			ASLFR_TitleText, messages_get("NetSurf"),
			ASLFR_Screen, scrn,
			ASLFR_InitialFile, object ? FilePart(nsurl_access(hlcache_handle_get_url(object))) : "",
			TAG_DONE))
	{
		strlcpy(fname, savereq->fr_Drawer, 1024);
		AddPart(fname, savereq->fr_File, 1024);

		ami_file_save(type, fname, gwin->win, object, gwin->bw->window->favicon, gwin->bw);
	}

	if(fname) FreeVec(fname);
}
Ejemplo n.º 10
0
void ami_file_open(struct gui_window_2 *gwin)
{
	char *temp, *temp2;
	nsurl *url;

	if(AslRequestTags(filereq,
			ASLFR_TitleText, messages_get("NetSurf"),
			ASLFR_Window, gwin->win,
			ASLFR_SleepWindow, TRUE,
			ASLFR_Screen, scrn,
			ASLFR_DoSaveMode, FALSE,
			ASLFR_RejectIcons, TRUE,
			ASLFR_FilterFunc, &aslhookfunc,
			TAG_DONE))
	{
		if(temp = AllocVecTagList(1024, NULL))
		{
			strlcpy(temp, filereq->fr_Drawer, 1024);
			AddPart(temp, filereq->fr_File, 1024);
			temp2 = path_to_url(temp);

			if (nsurl_create(temp2, &url) != NSERROR_OK) {
				warn_user("NoMemory", 0);
			} else {
				browser_window_navigate(gwin->bw,
					url,
					NULL,
					BW_NAVIGATE_HISTORY,
					NULL,
					NULL,
					NULL);
				nsurl_unref(url);
			}

			free(temp2);
			FreeVec(temp);
		}
	}
}
Ejemplo n.º 11
0
static BOOL do_filereq(struct Window *win,char *path,int title,ULONG flags)
{
BOOL ok;

char *ptr=0;
char file[40];

if	(!win)
	return(FALSE);

// Invalid path?
if	(!path[0])
	strcpy(path,"DOpus5:System/");

// Get filename
else if	((ptr=FilePart(path)))
	{
	strcpy(file,ptr);
	*ptr=0;
	ptr=file;
	}

// Display file requester
if	((ok=AslRequestTags(DATA(win)->request,
		ASLFR_Window,win,
		ASLFR_TitleText,GetString(locale,title),
		ASLFR_InitialFile,(ptr)?ptr:"",
		ASLFR_InitialDrawer,path,
		ASLFR_Flags1,FRF_PRIVATEIDCMP | flags,
		TAG_END)))
	{
	// Get new path
	strcpy(path,DATA(win)->request->fr_Drawer);
	AddPart(path,DATA(win)->request->fr_File,256);
	}

return(ok);

}
Ejemplo n.º 12
0
SDL_bool filerequester( struct machine *oric, char *title, char *path, char *fname, int type )
{
  char *pat, ppat[16*2+2];
  BOOL dosavemode = FALSE;
  
  switch( type )
  {
    case FR_DISKSAVE:
      dosavemode = TRUE;
    case FR_DISKLOAD:
      pat = "#?.dsk";
      break;
    
    case FR_TAPESAVETAP:
      dosavemode = TRUE;
      pat = "#?.tap";
      break;

    case FR_TAPESAVEORT:
      dosavemode = TRUE;
      pat = "#?.ort";
      break;

    case FR_TAPELOAD:
      pat = "#?.(tap|ort|wav)";
      break;
    
    case FR_ROMS:
      pat = "#?.rom";
      break;

    case FR_SNAPSHOTSAVE:
      dosavemode = TRUE;
    case FR_SNAPSHOTLOAD:
      pat = "#?.sna";
      break;
      
    case FR_KEYMAPPINGSAVE:
    	dosavemode = TRUE;
    case FR_KEYMAPPINGLOAD:
    	pat = "#?.kma";
        break;
 
    default:
      pat = NULL;
      break;
  }
  
  if( pat ) ParsePatternNoCase( (CONST_STRPTR)pat, (UBYTE *)ppat, 16*2+2 );
  
  if( !AslRequestTags( req,
         ASLFR_TitleText,     title,
         ASLFR_InitialDrawer, path,
         ASLFR_InitialFile,   fname,
         ASLFR_DoPatterns,    pat != NULL,
         ASLFR_RejectIcons,   TRUE,
         ASLFR_DoSaveMode,    dosavemode,
         pat ? ASLFR_AcceptPattern : TAG_IGNORE, ppat,
         pat ? ASLFR_InitialPattern : TAG_IGNORE, pat,
         TAG_DONE ) )
    return SDL_FALSE;
  
  strncpy( path,  (const char *)req->fr_Drawer, 4096 ); path[4095] = 0;
  strncpy( fname, (const char *)req->fr_File,   512  ); fname[511] = 0;
  
  return SDL_TRUE;
}
Ejemplo n.º 13
0
Archivo: ami-gui.c Proyecto: rzr/PUAE
static void do_file_dialog (unsigned int type)
{
    struct FileRequester *FileRequest;
    struct Window *win;

    char buf[80];
    char path[512];

    const char *req_prompt;
    const char *req_pattern = 0;
    const char *req_lastdir;
    int         req_do_save = FALSE;

#ifdef __amigaos4__
    int release_asl = 0;
#endif

    if (type >= FILEDIALOG_MAX)
        return;

    if (!AslBase) {
        AslBase = OpenLibrary ("asl.library", 36);
        if (!AslBase) {
            write_log ("Can't open asl.library v36.\n");
            return;
        } else {
#ifdef __amigaos4__
            IAsl = (struct AslIFace *) GetInterface ((struct Library *)AslBase, "main", 1, NULL);
            if (!IAsl) {
                CloseLibrary (AslBase);
                AslBase = 0;
                write_log ("Can't get asl.library interface\n");
            }
#endif
        }
#ifdef __amigaos4__
    } else {
        IAsl->Obtain ();
        release_asl = 1;
#endif
    }

    FileRequest = AllocAslRequest (ASL_FileRequest, NULL);
    if (!FileRequest) {
        write_log ("Unable to allocate file requester.\n");
        return;
    }

    /* Find this task's default window */
    win = ((struct Process *) FindTask (NULL))->pr_WindowPtr;
    if (win == (struct Window *)-1)
        win = 0;

    /*
     * Prepare requester.
     */
    switch (type) {

    default: /* to stop GCC complaining */
    case FILEDIALOG_INSERT_DF0:
    case FILEDIALOG_INSERT_DF1:
    case FILEDIALOG_INSERT_DF2:
    case FILEDIALOG_INSERT_DF3:
        sprintf (buf, "Select image to insert in drive DF%d:", FILEDIALOG_DRIVE(type));
        req_prompt = buf;
        req_pattern = "(#?.(ad(f|z)|dms|ipf|zip)#?|df?|?)";
        req_lastdir = get_last_floppy_dir ();
        break;

    case FILEDIALOG_SAVE_STATE:
        req_prompt = "Select file to save emulator state to";
        req_pattern = "#?.uss";
        req_lastdir = get_last_savestate_dir ();
        req_do_save = TRUE;
        break;

    case FILEDIALOG_LOAD_STATE:
        req_prompt = "Select saved state file to load";
        req_pattern = "#?.uss";
        req_lastdir = get_last_savestate_dir ();
        break;
    }

    /*
     * Do the file request.
     */
    if (AslRequestTags (FileRequest,
                        ASLFR_TitleText,      req_prompt,
                        ASLFR_InitialDrawer,  req_lastdir,
                        ASLFR_InitialPattern, req_pattern,
                        ASLFR_DoPatterns,     req_pattern != 0,
                        ASLFR_DoSaveMode,     req_do_save,
                        ASLFR_RejectIcons,    TRUE,
                        ASLFR_Window,         win,
                        TAG_DONE)) {

        /*
         * User selected a file.
         *
         * Construct file path to selected image.
         */
        strcpy (path, FileRequest->fr_Drawer);
        if (strlen (path) && !(path[strlen (path) - 1] == ':' || path[strlen (path) - 1] == '/'))
            strcat (path, "/");
        strcat (path, FileRequest->fr_File);

        /*
         * Process selected file.
         */
        switch (type) {

        default: /* to stop GCC complaining */
        case FILEDIALOG_INSERT_DF0:
        case FILEDIALOG_INSERT_DF1:
        case FILEDIALOG_INSERT_DF2:
        case FILEDIALOG_INSERT_DF3:
            set_last_savestate_dir (FileRequest->fr_Drawer);
            strcpy (changed_prefs.df[FILEDIALOG_DRIVE(type)], path);
            break;

        case FILEDIALOG_SAVE_STATE:
            set_last_savestate_dir (FileRequest->fr_Drawer);
            savestate_initsave (path, 1, 0);
            save_state (path, "Description");
            break;

        case FILEDIALOG_LOAD_STATE:
            set_last_savestate_dir (FileRequest->fr_Drawer);
            savestate_initsave (path, 1, 0);
            savestate_state = STATE_DORESTORE;
            write_log ("Restoring state from '%s'...\n", path);
            break;
        }
    }

    FreeAslRequest (FileRequest);

#ifdef __amigaos4__
    if (release_asl)
        IAsl->Release ();
#endif

    return;
}
void _env_select_icon_font(
	config_env_data *data,
	char *name,
	UBYTE *size,
	UBYTE *fpen,
	UBYTE *bpen,
	UBYTE *mode,
	short bufsize)
{
	short initial_fpen,initial_bpen;
	char *mode_list[6];

	// No requester?
	if (!data->icon_font_req) return;

	// Fill out mode list array
	mode_list[0]=GetString(locale,MSG_FONT_DRAWMODE);
	mode_list[1]=GetString(locale,MSG_FONT_TEXT);
	mode_list[2]=GetString(locale,MSG_FONT_FIELD_TEXT);
	mode_list[3]=GetString(locale,MSG_FONT_SHADOW);
	mode_list[4]=GetString(locale,MSG_FONT_OUTLINE);
	mode_list[5]=0;

	// Fix initial pens
	initial_fpen=*fpen;
	initial_bpen=*bpen;
	if (initial_fpen>=4 && initial_fpen<252 && data->palette_table)
		initial_fpen=data->palette_table[initial_fpen-4];
	if (initial_bpen>=4 && initial_bpen<252 && data->palette_table)
		initial_bpen=data->palette_table[initial_bpen-4];

	// Make window busy
	SetWindowBusy(data->window);

	// Show font requester
	if (AslRequestTags(data->icon_font_req,
			ASLFO_Window,data->window,
			ASLFO_TitleText,GetString(locale,MSG_SELECT_FONT),
			ASLFO_InitialName,name,
			ASLFO_InitialSize,(ULONG)*size,
			ASLFO_InitialFrontPen,initial_fpen,
			ASLFO_InitialBackPen,initial_bpen,
			ASLFO_InitialDrawMode,(ULONG)*mode,
			ASLFO_Flags,FOF_PRIVATEIDCMP|FOF_DOFRONTPEN|FOF_DOBACKPEN|FOF_DODRAWMODE,
			ASLFO_MaxFrontPen,data->font_pen_count,
			ASLFO_MaxBackPen,data->font_pen_count,
			ASLFO_FrontPens,data->font_pen_table,
			ASLFO_BackPens,data->font_pen_table,
			ASLFO_ModeList,mode_list,
			TAG_END))
	{
		// Store name and size
		stccpy(name,data->icon_font_req->fo_Attr.ta_Name,bufsize);
		*size=data->icon_font_req->fo_Attr.ta_YSize;

		// Store colours
		*fpen=_env_map_font_colour(data,data->icon_font_req->fo_FrontPen);
		*bpen=_env_map_font_colour(data,data->icon_font_req->fo_BackPen);
		*mode=data->icon_font_req->fo_DrawMode;
	}

	// Make window unbusy
	ClearWindowBusy(data->window);
}
Ejemplo n.º 15
0
static struct gui_download_window *gui_download_window_create(download_context *ctx,
		struct gui_window *gui)
{
	const char *url = nsurl_access(download_context_get_url(ctx));
	unsigned long total_size = download_context_get_total_length(ctx);
	struct gui_download_window *dw;
	char *dl_filename = ami_utf8_easy(download_context_get_filename(ctx));
	APTR va[3];

	dw = ami_misc_allocvec_clear(sizeof(struct gui_download_window), 0);

	if(gui && (!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url)))
	{
		strcpy(dw->fname, dw->dln->filename);
		free(dw->dln->node.ln_Name);
		dw->dln->node.ln_Name = NULL;
	}
	else
	{
		if(AslRequestTags(savereq,
			ASLFR_Window, gui->shared->win,
			ASLFR_SleepWindow, TRUE,
			ASLFR_TitleText, messages_get("NetSurf"),
			ASLFR_Screen, scrn,
			ASLFR_InitialFile, dl_filename,
			TAG_DONE))
		{
			strlcpy(dw->fname, savereq->fr_Drawer, 1024);
			AddPart((STRPTR)&dw->fname,savereq->fr_File,1024);
			if(!ami_download_check_overwrite(dw->fname, gui->shared->win, total_size))
			{
				FreeVec(dw);
				return NULL;
			}
		}
		else
		{
			FreeVec(dw);
			return NULL;
		}
	}

	if(dl_filename) ami_utf8_free(dl_filename);
	dw->size = total_size;
	dw->downloaded = 0;
	if(gui) dw->bw = gui->bw;
	dw->url = url;

	va[0] = (APTR)dw->downloaded;
	va[1] = (APTR)dw->size;
	va[2] = 0;

	if(!(dw->fh = FOpen((STRPTR)&dw->fname,MODE_NEWFILE,0)))
	{
		FreeVec(dw);
		return NULL;
	}

	dw->objects[OID_MAIN] = WindowObj,
      	    WA_ScreenTitle, ami_gui_get_screen_title(),
           	WA_Title, dw->url,
           	WA_Activate, TRUE,
           	WA_DepthGadget, TRUE,
           	WA_DragBar, TRUE,
           	WA_CloseGadget, FALSE,
           	WA_SizeGadget, TRUE,
			WA_PubScreen,scrn,
			WINDOW_SharedPort,sport,
			WINDOW_UserData,dw,
			WINDOW_IconifyGadget, FALSE,
			WINDOW_LockHeight,TRUE,
         	WINDOW_Position, WPOS_CENTERSCREEN,
           	WINDOW_ParentGroup, dw->objects[GID_MAIN] = LayoutVObj,
				LAYOUT_AddChild, dw->objects[GID_STATUS] = FuelGaugeObj,
					GA_ID,GID_STATUS,
					GA_Text,messages_get("amiDownload"),
					FUELGAUGE_Min,0,
					FUELGAUGE_Max,total_size,
					FUELGAUGE_Level,0,
					FUELGAUGE_Ticks,11,
					FUELGAUGE_ShortTicks,TRUE,
					FUELGAUGE_VarArgs,va,
					FUELGAUGE_Percent,FALSE,
					FUELGAUGE_Justification,FGJ_CENTER,
				FuelGaugeEnd,
				CHILD_NominalSize,TRUE,
				CHILD_WeightedHeight,0,
				LAYOUT_AddChild, dw->objects[GID_CANCEL] = ButtonObj,
					GA_ID,GID_CANCEL,
					GA_RelVerify,TRUE,
					GA_Text,messages_get("Abort"),
					GA_TabCycle,TRUE,
				ButtonEnd,
			EndGroup,
		EndWindow;

	dw->win = (struct Window *)RA_OpenWindow(dw->objects[OID_MAIN]);
	dw->ctx = ctx;

	dw->node = AddObject(window_list,AMINS_DLWINDOW);
	dw->node->objstruct = dw;

	downloads_in_progress++;

	return dw;
}
Ejemplo n.º 16
0
ULONG __asm __saveds intAHIsub_Start(
    register __d0 ULONG Flags,
    register __a2 struct AHIAudioCtrlDrv *AudioCtrl )
{
  AHIsub_Stop(Flags, AudioCtrl);

  if(Flags & AHISF_PLAY)
  {
    ULONG savebufferlength;

    if(!(dd->fs_MixBuffer = AllocVec(AudioCtrl->ahiac_BuffSize, MEMF_ANY)))
      return AHIE_NOMEM;

    dd->fs_SaveBufferSize = AudioCtrl->ahiac_MaxBuffSamples;

    // S16 has two buffers (L/R) instead
    if((AudioCtrl->ahiac_Flags & AHIACF_STEREO) && dd->fs_Format != FORMAT_S16)
    {
      dd->fs_SaveBufferSize <<=1;
    }

    if(dd->fs_SaveBufferSize < SAVEBUFFERSIZE)
    {
      dd->fs_SaveBufferSize = SAVEBUFFERSIZE;
    }

    savebufferlength = dd->fs_SaveBufferSize;


    switch(dd->fs_Format)
    {
      case FORMAT_8SVX:
        break;

      case FORMAT_AIFF:
        savebufferlength <<= 1;
        break;

      case FORMAT_AIFC:
        savebufferlength <<= 1;
        break;

      case FORMAT_S16:
        savebufferlength <<= 1;
        break;

      default:
        break;
    }


    if(!(dd->fs_SaveBuffer = AllocVec(savebufferlength, MEMF_ANY)))
    {
      return AHIE_NOMEM;
    }

    if ((AudioCtrl->ahiac_Flags & AHIACF_STEREO) && dd->fs_Format == FORMAT_S16)
    {
      if(!(dd->fs_SaveBuffer2 = AllocVec(savebufferlength, MEMF_ANY)))
      {
        return AHIE_NOMEM;
      }
    }

    if(AslRequestTags(dd->fs_FileReq,TAG_DONE))
    {

      Forbid();

      if(dd->fs_SlaveTask = CreateNewProcTags(
          NP_Entry,     SlaveEntry,
          NP_Name,      _LibName,
          NP_Priority,  -1,               // It's a number cruncher...
          NP_StackSize, 10000,
          TAG_DONE))
      {
        dd->fs_SlaveTask->pr_Task.tc_UserData = AudioCtrl;
      }

      Permit();

      if(dd->fs_SlaveTask)
      {
        Wait(1L<<dd->fs_MasterSignal);  // Wait for slave to come alive
        if(dd->fs_SlaveTask == NULL)    // Is slave alive or dead?
        {
          return AHIE_UNKNOWN;
        }
      }
      else
      {
        return AHIE_NOMEM;
      }
    }
    else
    {
      if(IoErr())
      {
        return AHIE_NOMEM;    //error occured
      }
      else
      {
        return AHIE_ABORTED;  //requester cancelled
      }
    }
  }

  if(Flags & AHISF_RECORD)
  {
    if(!(dd->fs_RecBuffer = AllocVec(RECBUFFERSIZE*4,MEMF_ANY)))
    {
      return AHIE_NOMEM;
    }

    if(AslRequestTags(dd->fs_RecFileReq,TAG_DONE))
    {
      Delay(TICKS_PER_SECOND);         // Wait for window to close etc...

      Forbid();

      if(dd->fs_RecSlaveTask = CreateNewProcTags(
          NP_Entry,     RecSlaveEntry,
          NP_Name,      _LibName,
          NP_Priority,  1,               // Make it steady...
          TAG_DONE))
      {
        dd->fs_RecSlaveTask->pr_Task.tc_UserData = AudioCtrl;
      }

      Permit();

      if(dd->fs_RecSlaveTask)
      {
        Wait(1L<<dd->fs_RecMasterSignal);  // Wait for slave to come alive
        if(dd->fs_RecSlaveTask == NULL)    // Is slave alive or dead?
        {
          return AHIE_UNKNOWN;
        }
      }
      else
      {
        return AHIE_NOMEM;
      }
    }
    else
    {
      if(IoErr())
      {
        return AHIE_NOMEM;    //error occured
      }
      else
      {
        return AHIE_ABORTED;  //requester cancelled
      }
    }
  }

  return AHIE_OK;
}
Ejemplo n.º 17
0
/**
 * REQUESTFILE ARexx command
 *
 * @param rxmsg the message defining the ARexx context
 * @param args the command's arguments
 */
static void arexx_requestfile(struct RexxMsg *rxmsg, STRPTR args)
{
	APTR arg_handle;

	struct	{
		STRPTR stem;
		STRPTR drawer;
		STRPTR file;
		STRPTR pattern;
		STRPTR title;
		STRPTR positive;
		STRPTR negative;
		STRPTR acceptpattern;
		STRPTR rejectpattern;
		ULONG savemode;
		ULONG multiselect;
		ULONG drawersonly;
		ULONG noicons;
	} requestfile_arg;
	memset(&requestfile_arg,0,sizeof(requestfile_arg));

	if ((arg_handle = ParseTemplate("STEM/K,DRAWER,FILE/K,PATTERN/K,TITLE/K,POSITIVE/K,NEGATIVE/K,ACCEPTPATTERN/K,REJECTPATTERN/K,SAVEMODE/S,MULTISELECT/S,DRAWERSONLY/S,NOICONS/S",args,&requestfile_arg)))
	{
		struct FileRequester *filereq = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL);
		if (filereq)
		{
			UBYTE *acceptpattern = NULL,*rejectpattern = NULL;
			int stem_len;
			char *stem_buf;
			char num_buf[32];

			if (requestfile_arg.stem)
			{
				stem_len = strlen(requestfile_arg.stem);
				if ((stem_buf = (char *)malloc(stem_len+20)))
				{
					strcpy(stem_buf,requestfile_arg.stem);
				} else stem_len = 0;
			} else
			{
				stem_buf = 0;
				stem_len = 0;
			}


			if (requestfile_arg.acceptpattern)
			{
				int len = strlen(requestfile_arg.acceptpattern)*2+3;
				if ((acceptpattern = (UBYTE*)AllocVec(len,0)))
					ParsePatternNoCase(requestfile_arg.acceptpattern,(STRPTR)acceptpattern,len);
			}

			if (requestfile_arg.rejectpattern)
			{
				int len = strlen(requestfile_arg.rejectpattern)*2+3;
				if ((rejectpattern = (UBYTE*)AllocVec(len,0)))
					ParsePatternNoCase(requestfile_arg.rejectpattern,(STRPTR)rejectpattern,len);
			}

			if (AslRequestTags(filereq,
						ASLFR_Screen, main_get_screen(),
						requestfile_arg.title?ASLFR_TitleText:TAG_IGNORE, requestfile_arg.title,
						requestfile_arg.positive?ASLFR_PositiveText:TAG_IGNORE, requestfile_arg.positive,
						requestfile_arg.negative?ASLFR_NegativeText:TAG_IGNORE, requestfile_arg.negative,
						requestfile_arg.drawer?ASLFR_InitialDrawer:TAG_IGNORE, requestfile_arg.drawer,
						requestfile_arg.file?ASLFR_InitialFile:TAG_IGNORE, requestfile_arg.file,
						requestfile_arg.pattern?ASLFR_InitialPattern:TAG_IGNORE, requestfile_arg.pattern,
						rejectpattern?ASLFR_RejectPattern:TAG_IGNORE, rejectpattern,
						acceptpattern?ASLFR_AcceptPattern:TAG_IGNORE, acceptpattern,
						ASLFR_RejectIcons, requestfile_arg.noicons,
						ASLFR_DrawersOnly, requestfile_arg.drawersonly,
						ASLFR_DoMultiSelect, requestfile_arg.multiselect,
						ASLFR_DoSaveMode, requestfile_arg.savemode,
						requestfile_arg.pattern?ASLFR_DoPatterns:TAG_IGNORE, TRUE,
						TAG_DONE))
			{
				int i;
				char *name;
				STRPTR dirname;
				BPTR dirlock;

				if (stem_buf)
				{
					strcpy(&stem_buf[stem_len],"PATH.COUNT");
					sprintf(num_buf,"%ld",filereq->fr_NumArgs);
					MySetRexxVarFromMsg(stem_buf,num_buf,rxmsg);

					for (i=0;i<filereq->fr_NumArgs;i++)
					{
						sprintf(&stem_buf[stem_len],"PATH.%d",i);
						if ((dirname = NameOfLock(filereq->fr_ArgList[i].wa_Lock)))
						{
							if ((name = mycombinepath(dirname,filereq->fr_ArgList[i].wa_Name)))
							{
								MySetRexxVarFromMsg(stem_buf,name,rxmsg);
								free(name);
							} else MySetRexxVarFromMsg(stem_buf,"",rxmsg);
							FreeVec(dirname);
						} else MySetRexxVarFromMsg(stem_buf,"",rxmsg);
					}

					strcpy(&stem_buf[stem_len],"FILE");
					MySetRexxVarFromMsg(stem_buf,filereq->fr_File,rxmsg);

					strcpy(&stem_buf[stem_len],"DRAWER");
					MySetRexxVarFromMsg(stem_buf,filereq->fr_Drawer,rxmsg);

					strcpy(&stem_buf[stem_len],"PATTERN");
					MySetRexxVarFromMsg(stem_buf,filereq->fr_Pattern,rxmsg);
				}

				if ((dirlock = Lock(filereq->fr_Drawer,ACCESS_READ)))
				{
					if ((dirname = NameOfLock(dirlock)))
					{
						if ((name = mycombinepath(dirname,filereq->fr_File)))
						{
							arexx_set_result(rxmsg,name);
							free(name);
						}
						FreeVec(dirname);
					}
					UnLock(dirlock);
				}
			} else
			{
				if (stem_buf)
				{
					strcpy(&stem_buf[stem_len],"PATH.COUNT");
					MySetRexxVarFromMsg(stem_buf,"0",rxmsg);
				}
				arexx_set_result(rxmsg,"");
			}
		}
		FreeTemplate(arg_handle);
	}
}