From b2376c1656e7cd39bc2a6243189a8a8126370c18 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 13 Feb 2010 17:31:10 +0000 Subject: Proper download notification code, should also open the file if the notification is double-clicked, although it doesn't seem to work. svn path=/trunk/netsurf/; revision=10037 --- amiga/download.c | 31 +++++++++++++++---------------- amiga/download.h | 1 + amiga/gui.c | 19 +++++++++++++++++-- amiga/gui.h | 3 ++- 4 files changed, 35 insertions(+), 19 deletions(-) (limited to 'amiga') diff --git a/amiga/download.c b/amiga/download.c index 90f73b4f0..fde82679d 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -1,5 +1,5 @@ /* - * Copyright 2008,2009 Chris Young + * Copyright 2008-2010 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,6 @@ #include "amiga/options.h" #include "amiga/bitmap.h" #include "amiga/iff_dr2d.h" -#include "amiga/arexx.h" /* temporarily required for notifications */ #include "content/fetch.h" @@ -58,7 +58,6 @@ struct gui_download_window *gui_download_window_create(const char *url, const char *mime_type, struct fetch *fetch, unsigned int total_size, struct gui_window *gui) { - char fname[1024]; struct gui_download_window *dw; APTR va[3]; @@ -68,7 +67,7 @@ struct gui_download_window *gui_download_window_create(const char *url, if((!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url))) { - strcpy(fname,dw->dln->filename); + strcpy(dw->fname, dw->dln->filename); free(dw->dln->node.ln_Name); dw->dln->node.ln_Name = NULL; } @@ -80,8 +79,8 @@ struct gui_download_window *gui_download_window_create(const char *url, ASLFR_InitialFile,FilePart(url), TAG_DONE)) { - strlcpy(&fname,savereq->fr_Drawer,1024); - AddPart((STRPTR)&fname,savereq->fr_File,1024); + strlcpy(&dw->fname,savereq->fr_Drawer,1024); + AddPart((STRPTR)&dw->fname,savereq->fr_File,1024); } else return NULL; } @@ -95,14 +94,12 @@ struct gui_download_window *gui_download_window_create(const char *url, va[1] = (APTR)dw->size; va[2] = 0; - if(!(dw->fh = FOpen((STRPTR)&fname,MODE_NEWFILE,0))) + if(!(dw->fh = FOpen((STRPTR)&dw->fname,MODE_NEWFILE,0))) { FreeVec(dw); return NULL; } - SetComment(fname,url); - dw->objects[OID_MAIN] = WindowObject, WA_ScreenTitle,nsscreentitle, WA_Title, dw->url, @@ -114,7 +111,7 @@ struct gui_download_window *gui_download_window_create(const char *url, WA_CustomScreen,scrn, WINDOW_SharedPort,sport, WINDOW_UserData,dw, - WINDOW_IconifyGadget, TRUE, + WINDOW_IconifyGadget, FALSE, WINDOW_LockHeight,TRUE, WINDOW_Position, WPOS_CENTERSCREEN, WINDOW_ParentGroup, dw->gadgets[GID_MAIN] = VGroupObject, @@ -203,14 +200,16 @@ void gui_download_window_done(struct gui_download_window *dw) if(!dw) return; + SetComment(dw->fname, dw->url); + if(option_download_notify) { - if(sendcmd = ASPrintf("RINGHIO APP=NetSurf SCREEN=FRONT TITLE=NetSurf \"%s downloaded\"",dw->url)) - { - IDoMethod(arexx_obj, AM_EXECUTE, sendcmd, "RINGHIO", - NULL, NULL, NULL, NULL); - FreeVec(sendcmd); - } + Notify(ami_appid, APPNOTIFY_Title, messages_get("amiDownloadComplete"), + APPNOTIFY_PubScreenName, "FRONT", + APPNOTIFY_BackMsg, dw->fname, + APPNOTIFY_CloseOnDC, TRUE, + APPNOTIFY_Text, dw->fname, + TAG_DONE); } bw->download = false; diff --git a/amiga/download.h b/amiga/download.h index 425207e39..6c37853c3 100755 --- a/amiga/download.h +++ b/amiga/download.h @@ -39,6 +39,7 @@ struct gui_download_window { struct browser_window *bw; struct fetch *fetch; char *url; + char fname[1024]; }; int drag_save; diff --git a/amiga/gui.c b/amiga/gui.c index d787f6dcc..b1c23376b 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1,5 +1,5 @@ /* - * Copyright 2008-9 Chris Young + * Copyright 2008-2010 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -81,6 +81,8 @@ #include #include #include +#include +#include #include "amiga/stringview/stringview.h" #include "amiga/stringview/urlhistory.h" @@ -130,7 +132,6 @@ ULONG throbber_width,throbber_height,throbber_frames,throbber_update_interval; BOOL rmbtrapped; BOOL locked_screen = FALSE; BOOL screen_closed = FALSE; -uint32 ami_appid; struct MsgPort *applibport = NULL; ULONG applibsig = 0; @@ -732,6 +733,7 @@ void gui_init2(int argc, char** argv) REGAPP_HasPrefsWindow, TRUE, REGAPP_CanCreateNewDocs, TRUE, REGAPP_UniqueApplication, TRUE, + REGAPP_Description, "Small as a mouse, fast as a cheetah and available for free. NetSurf is a multi-platform web browser.", TAG_DONE); } else @@ -744,6 +746,7 @@ void gui_init2(int argc, char** argv) REGAPP_HasPrefsWindow, TRUE, REGAPP_CanCreateNewDocs, TRUE, REGAPP_UniqueApplication, TRUE, + REGAPP_Description, "Small as a mouse, fast as a cheetah and available for free. NetSurf is a multi-platform web browser.", TAG_DONE); } @@ -1699,6 +1702,18 @@ void ami_handle_applib(void) case APPLIBMT_ForceQuit: ami_quit_netsurf(); break; + + case APPLIBMT_CustomMsg: + { + struct ApplicationCustomMsg *applibcustmsg = applibmsg; + STRPTR tempmsg; + if(tempmsg = ASPrintf("\"%s\"",applibcustmsg->customMsg)) + { + OpenWorkbenchObjectA(tempmsg, NULL); + FreeVec(tempmsg); + } + } + break; } ReplyMsg((struct Message *)applibmsg); } diff --git a/amiga/gui.h b/amiga/gui.h index 6924bc344..b1f512e08 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-9 Chris Young + * Copyright 2008-2010 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -142,4 +142,5 @@ struct MsgPort *sport; bool win_destroyed; struct browser_window *curbw; struct gui_globals browserglob; +uint32 ami_appid; #endif -- cgit v1.2.3