Exemple #1
0
void
rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
{
	RDFFile		f;
	char		*navCenterURL = NULL;

	if ((status < 0) && (urls != NULL))
	{
		/* if unable to read in navcntr.rdf file, create some default views */
		if ((f = (RDFFile) urls->fe_data) != NULL)
		{
			if (strcmp(f->url, gNavCntrUrl) == 0)
			{
				parseNextRDFXMLBlobInt(f, gDefaultNavcntr,
						strlen(gDefaultNavcntr));
			}
		}
	}

	if (urls != NULL)
	{
		if ((f = (RDFFile) urls->fe_data) != NULL)
		{
			htLoadComplete(cx, urls, f->url, status);
		}
	}

	NET_FreeURLStruct (urls);
}
Exemple #2
0
void XFE_ComposeAttachFolderView::processMessageDrop(fe_dnd_Source *source)
{
    XFE_ThreadView *threadView=(XFE_ThreadView*)source->closure;
    XFE_Outliner *outliner=threadView->getOutliner();
    const int *selectedList;
    int numSelected;
    if (outliner->getSelection(&selectedList, &numSelected)) {
        char **items=new char*[numSelected];
        int numItems=0;
        int i;
        
        for (i=0; i<numSelected; i++) {
            MessageKey key=MSG_GetMessageKey(threadView->getPane(),selectedList[i]);
            URL_Struct *messageURL=MSG_ConstructUrlForMessage(threadView->getPane(),key);
            if (messageURL && messageURL->address) {
                XDEBUG(printf("    %d:%s\n",selectedList[i],messageURL->address));
                items[numItems++]=XP_STRDUP(messageURL->address);
            }
            if (messageURL)
                NET_FreeURLStruct(messageURL);
        }
        
        if (numItems>0)
            addAttachments((const char **) items,numItems);
        
        for (i=0; i<numItems; i++)
            XP_FREE(items[i]);
        delete items;
    }
}
Exemple #3
0
int
rdfRetrievalType (RDFFile f)
{
	URL_Struct		*urls;
	char			*url;
	int			type;

	url = f->url;
	if (f->localp)
	{
		urls = NET_CreateURLStruct(url,  NET_CACHE_ONLY_RELOAD);
		if ((urls != NULL) && (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)))
		{
			type = NET_DONT_RELOAD;
		}
		else
		{
			type = NET_DONT_RELOAD;
		}
		if (urls != NULL)	NET_FreeURLStruct(urls);
	}
	else
	{
		type = NET_DONT_RELOAD;
	}
	return(type);
}
Exemple #4
0
void
rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
{
	char		*navCenterURL = NULL;

	if ((status < 0) && (urls != NULL))
	{
		if ((cx != NULL) && (urls->error_msg != NULL))
		{
			FE_Alert(cx, urls->error_msg);
		}

		/* if unable to read in navcntr.rdf file, create some default views */
		
		PREF_CopyCharPref("browser.NavCenter", &navCenterURL);
		if (navCenterURL != NULL)
		{
			if (urls->address != NULL)
			{
				if (!strcmp(urls->address, navCenterURL))
				{
					remoteStoreAdd(gRemoteStore, gNavCenter->RDF_BookmarkFolderCategory,
						gCoreVocab->RDF_parent, gNavCenter->RDF_Top, RDF_RESOURCE_TYPE, 1);
					remoteStoreAdd(gRemoteStore, gNavCenter->RDF_History, gCoreVocab->RDF_parent,
						gNavCenter->RDF_Top, RDF_RESOURCE_TYPE, 1);
					remoteStoreAdd(gRemoteStore, gNavCenter->RDF_LocalFiles, gCoreVocab->RDF_parent,
						gNavCenter->RDF_Top, RDF_RESOURCE_TYPE, 1);
				}
			}
			freeMem(navCenterURL);
		}
	}
	NET_FreeURLStruct (urls);
}
Exemple #5
0
/* exit routine for NET_GetURL */
static void
crawl_get_page_url_exit(URL_Struct *URL_s, int status, MWContext *window_id)
{
#if defined(XP_MAC)
#pragma unused(window_id)
#endif
	if(status != MK_CHANGING_CONTEXT)
		NET_FreeURLStruct(URL_s);
}
Exemple #6
0
void
es_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
{
	RDF_Resource		parent = NULL, child = NULL, r;
	_esFEData		*feData;
	char			*newURL, *p;

	feData = (_esFEData *)urls->fe_data;
	if ((status >= 0) && (feData != NULL))
	{
		parent = RDF_GetResource(gNCDB, feData->parent, false);
		child = RDF_GetResource(gNCDB, feData->child, false);
		if ((parent != NULL) && (child != NULL))
		{
			switch(feData->method)
			{
				case	URL_POST_METHOD:
				if (((p = strrchr(resourceID(child), '/')) != NULL) && (*++p != '\0'))
				{
					if ((newURL = append2Strings(resourceID(parent), p)) != NULL)
					{
						if ((r = RDF_GetResource(gNCDB, newURL, 1)) != NULL)
						{
							setContainerp(r, containerp(child));
							setResourceType(r, resourceType(child));
						
							remoteStoreAdd(gRemoteStore, r,
								gCoreVocab->RDF_parent, parent,
								RDF_RESOURCE_TYPE, 1);
						}
						freeMem(newURL);
					}
				}
				break;

				case	URL_DELETE_METHOD:
				remoteStoreRemove(gRemoteStore, child,
					gCoreVocab->RDF_parent, parent,
					RDF_RESOURCE_TYPE);
				break;
			}
		}
	}
	else if (status < 0)
	{
		if ((cx != NULL) && (urls != NULL) && (urls->error_msg != NULL))
		{
			FE_Alert(cx, urls->error_msg);
		}
	}
	if (feData != NULL)
	{
		esFreeFEData(feData);
	}
        NET_FreeURLStruct (urls);
}
extern "C" void
/*ARGSUSED*/
wfUrlExit(URL_Struct *urls, int status, MWContext *cx)
{
	if (status < 0 && urls->error_msg)
	{
		WF_TRACEMSG (("NF: Font downloading unsuccessful : %s.",
			urls->error_msg));
	}
	
	if (status != MK_CHANGING_CONTEXT)
	{
		NET_FreeURLStruct (urls);
	}
}
Exemple #8
0
static void
lo_script_src_exit_fn(URL_Struct *url_struct, int status, MWContext *context)
{
    lo_DestroyScriptData(url_struct->fe_data);
    NET_FreeURLStruct(url_struct);

    /*
     * If our status is negative that means there was an error and the
     *   script won't be executed.  Therefore the MochaDecoder's nesting
     *   url must be cleared, and layout must be unblocked.
     */
    if (status < 0) {
        ET_SetNestingUrl(context, NULL);
        lo_unblock_script_tag(context, TRUE);
    }
}
Exemple #9
0
void
xmlhtml_complete  (NET_StreamClass *stream)
{
  XMLHTMLInclusion ss =stream->data_object;
  XMLFile xml = ss->xml;
  xml->numOpenStreams--;
  if (xml->numOpenStreams == 0) { 
  /* direct the stream to the html parser */
    NET_StreamClass *newstream;
    URL_Struct *nurls =   NET_CreateURLStruct(copyString(xml->address), NET_DONT_RELOAD);
    StrAllocCopy(nurls->content_type, TEXT_HTML);
    newstream = NET_StreamBuilder(1,  nurls, (MWContext*) xml->mwcontext);
    xml->stream = newstream;
    convertToHTML(xml);
    newstream->complete(newstream);
    NET_FreeURLStruct(nurls); 
  }     
}
Exemple #10
0
JSBool
lm_GetURL(JSContext *cx, MochaDecoder *decoder, URL_Struct *url_struct)
{
    MWContext *context;

    context = decoder->window_context;
    if (!context) {
        NET_FreeURLStruct(url_struct);
        return JS_TRUE;
    }

    if (decoder->replace_location) {
	decoder->replace_location = JS_FALSE;
	lm_ReplaceURL(context, url_struct);
    }
    ET_PostGetUrl(context, url_struct);
    return JS_TRUE;
}
Exemple #11
0
void
xmlcss_complete  (NET_StreamClass *stream)
{
  StyleSheet ss =stream->data_object;
  URL_Struct *urls = ss->urls;
  XMLFile xml = ss->xmlFile;
  freeMem(ss->holdOver);
  freeMem(ss->line);
  ss->line = ss->holdOver = NULL; 
  xml->numOpenStreams--;
  if (xml->numOpenStreams == 0) { 
  /* direct the stream to the html parser */
    NET_StreamClass *newstream;
    URL_Struct *nurls =   NET_CreateURLStruct(copyString(xml->address), NET_DONT_RELOAD);
    StrAllocCopy(nurls->content_type, TEXT_HTML);
    newstream = NET_StreamBuilder(1,  nurls, (MWContext*) xml->mwcontext);
    xml->stream = newstream;
    convertToHTML(xml);
    newstream->complete(newstream);
    NET_FreeURLStruct(nurls); 
  }     
}
Exemple #12
0
void
xml_complete (NET_StreamClass *stream)
{
  NET_StreamClass *newstream;
  void *obj=stream->data_object;
  URL_Struct *urls = ((XMLFile)obj)->urls;
  freeMem(((XMLFile)obj)->holdOver);
  freeMem(((XMLFile)obj)->line);
  ((XMLFile)obj)->line = ((XMLFile)obj)->holdOver = NULL; 
  ((XMLFile)obj)->numOpenStreams--;
  if (((XMLFile)obj)->numOpenStreams < 1) {
  /* direct the stream to the html parser */
    URL_Struct *nurls =   NET_CreateURLStruct(copyString(urls->address), NET_DONT_RELOAD);
    StrAllocCopy(nurls->content_type, TEXT_HTML);

    newstream = NET_StreamBuilder(1,  nurls, (MWContext*) ((XMLFile)obj)->mwcontext);
    ((XMLFile)obj)->stream = newstream;
    convertToHTML(((XMLFile)obj));
    newstream->complete(newstream);
    NET_FreeURLStruct(nurls); 
  }
}
Exemple #13
0
  /** go tell the directory that child got added to parent **/
void
ESAddChild (RDF_Resource parent, RDF_Resource child)
{
	URL_Struct		*urls;
	void			*feData, **files_to_post = NULL;

	if ((urls = NET_CreateURLStruct(resourceID(parent), NET_SUPER_RELOAD)) != NULL)
	{
		feData = (void *)esMakeFEData(parent, child, URL_POST_METHOD);
		if ((files_to_post = (char **)XP_ALLOC(2*sizeof(char *))) != NULL)
		{
			files_to_post[0] = nativeFilename(resourceID(child));
			files_to_post[1] = NULL;
		}
		if ((feData != NULL) && (files_to_post != NULL))
		{
			urls->files_to_post = (void *)files_to_post;
			urls->post_to = NULL;
			urls->method = URL_POST_METHOD;
			urls->fe_data = (void *)feData;
			NET_GetURL(urls, FO_PRESENT,
				(MWContext *)gRDFMWContext(),
				es_GetUrlExitFunc);
		}
		else
		{
			if (feData != NULL)
			{
				esFreeFEData(feData);
			}
			if (files_to_post != NULL)
			{
				if (files_to_post[0] != NULL)	freeMem(files_to_post[0]);
				XP_FREE(files_to_post);
			}
			NET_FreeURLStruct(urls);
		}
	}
}
Exemple #14
0
  /** remove the child from the directory **/
void
ESRemoveChild (RDF_Resource parent, RDF_Resource child)
{
	URL_Struct		*urls;
	void			*feData;

	if ((urls = NET_CreateURLStruct(resourceID(child), NET_SUPER_RELOAD)) != NULL)
	{
		feData = (void *)esMakeFEData(parent, child, URL_DELETE_METHOD);
		if (feData != NULL)
		{
			urls->method = URL_DELETE_METHOD;
			urls->fe_data = (void *)feData;
			NET_GetURL(urls, FO_PRESENT,
				(MWContext *)gRDFMWContext(),
				es_GetUrlExitFunc);
		}
		else
		{
			NET_FreeURLStruct(urls);
		}
	}
}
Exemple #15
0
static JSBool
url_load(JSContext *cx, JSObject *obj, const char *url_string, 
         NET_ReloadMethod reload_how)
{
    JSURL *url;
    URL_Struct *url_struct;
    const char *referer;

    url = JS_GetPrivate(cx, obj);
    if (!url)
	return JS_TRUE;
    url_struct = NET_CreateURLStruct(url_string, reload_how);
    if (!url_struct) {
	JS_ReportOutOfMemory(cx);
	return JS_FALSE;
    }
    if (!(referer = lm_GetSubjectOriginURL(cx)) ||
	!(url_struct->referer = JS_strdup(cx, referer))) {
	NET_FreeURLStruct(url_struct);
	return JS_FALSE;
    }
    return lm_GetURL(cx, url->url_decoder, url_struct);
}
void EmbedUrlExit(URL_Struct *pUrl, int iStatus, MWContext *pContext)
{
    //  The embedded item is finished downloading, and possibly has an error and stuff.
    NPEmbeddedApp* pEmbeddedApp = (NPEmbeddedApp*)pUrl->fe_data;

	if (!pEmbeddedApp) {
		NET_FreeURLStruct(pUrl);
		return;
	}

    CNetscapeCntrItem *pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data;

    // if an EMBED tag's SRC attribute is a LOCAL file which does not exist,
    // pItem is NULL.  Bandaid against GPF for 2.0, but later we must fix the
    // FE_GetEmbedSize() and NP_EmbedCreate() combo that cause this problem.
    if(pItem != NULL) {
	    if(wfe_IsTypePlugin(pEmbeddedApp))
	    {
            pItem->m_bLoading = FALSE;
			NET_FreeURLStruct(pUrl);
        	return;
	    }
#ifdef MOCHA
	    {
		    /* only wait on applets if onload flag */
		    lo_TopState *top_state = lo_FetchTopState(XP_DOCID(pContext));
		    if (top_state != NULL && top_state->mocha_loading_embeds_count)
		    {
			    top_state->mocha_loading_embeds_count--;
			    ET_SendLoadEvent(pContext, EVENT_XFER_DONE, NULL, NULL, 
                                 LO_DOCUMENT_LAYER_ID, FALSE);
		    }
	    }
#endif /* MOCHA */

        // else must be an OLE stream exit
        if(iStatus != MK_DATA_LOADED)   {
            //  Load error.
            pItem->m_bBroken = TRUE;
        }
        else if(pUrl->server_status != 0 && pUrl->server_status / 100 != 2 && pUrl->server_status / 100 != 3 && iStatus == MK_DATA_LOADED)  {
            //  Server error.
            pItem->m_bBroken = TRUE;
        }

        //  If the item isn't broken, we can load it up.
        if(pItem->m_bBroken == FALSE)   {
            SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
			if(FALSE == pItem->CreateFromFile(pItem->m_csFileName)) {
				//  Couldn't create for some reason!
				pItem->m_bBroken = TRUE;
			}
            SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
        }
        pItem->m_bLoading = FALSE;

        //  Get the width and height out of our newly created item, if it isn't broken.
	    //	We need to do this two different ways, depending on what type of context we
	    //		are in.
	    CSize csExtents;
	    //	New way.
	    CDCCX *pCX = VOID2CX(pContext->fe.cx, CDCCX);
	    if(pItem->m_bBroken == FALSE)	{
	    	pItem->GetExtent(&csExtents);
	    	csExtents.cx = CASTINT(pCX->Metric2TwipsX(csExtents.cx));
	    	csExtents.cy = CASTINT(pCX->Metric2TwipsY(csExtents.cy));
	    }
	    else	{
	    	LTRB Rect;
	    	int32 x, y;
//	    	pCX->DisplayIcon(Rect.left, Rect.right, IL_IMAGE_BAD_DATA, &x, &y);
            pCX->GetIconDimensions(&x, &y, IL_IMAGE_BAD_DATA);
	    	csExtents.cx = CASTINT(x);
	    	csExtents.cy = CASTINT(y);
	    }
        //  Need to flush all delayed display, and blocked layout.
        //  Do all blocks.
        POSITION rIndex = pItem->m_cplUnblock.GetHeadPosition();
        LO_EmbedStruct *pLayoutData = NULL;
        while(rIndex != NULL && iStatus != MK_INTERRUPTED)   {
            pLayoutData = (LO_EmbedStruct *)pItem->m_cplUnblock.GetNext(rIndex);
			if ((pEmbeddedApp->type ==  NP_OLE) && pItem->m_lpObject) {
				if ( pLayoutData->width)
					csExtents.cx = pLayoutData->width; 
				if ( pLayoutData->height)
					csExtents.cy = pLayoutData->height; 
				pLayoutData->width = csExtents.cx;
				pLayoutData->height = csExtents.cy;

			}
            LO_ClearEmbedBlock(ABSTRACTCX(pContext)->GetDocumentContext(), pLayoutData);        
        }
        pItem->m_cplUnblock.RemoveAll();

#ifdef LAYERS
        rIndex = pItem->m_cplElements.GetHeadPosition();
        while (rIndex != NULL) {
            pLayoutData = (LO_EmbedStruct *)pItem->m_cplElements.GetNext(rIndex);
            // An OLE container is windowless until it is activated.
            LO_SetEmbedType(pLayoutData, PR_FALSE);
        }
#endif // LAYERS
        
        //  Do all needed display.
        rIndex = pItem->m_cplDisplay.GetHeadPosition();
        while(rIndex != NULL)   {
            pLayoutData = (LO_EmbedStruct *)pItem->m_cplDisplay.GetNext(rIndex);

			if ((pEmbeddedApp->type ==  NP_OLE) && pItem->m_lpObject) {
				if ( pLayoutData->width )
					csExtents.cx = pLayoutData->width; 
				if ( pLayoutData->height)
					csExtents.cy = pLayoutData->height;
				pLayoutData->width = csExtents.cx;
				pLayoutData->height = csExtents.cy;
			}
#ifdef LAYERS
            if (pContext->compositor) {
                XP_Rect rect;
                
                CL_GetLayerBbox(pLayoutData->layer, &rect);
                CL_UpdateLayerRect(CL_GetLayerCompositor(pLayoutData->layer),
                                   pLayoutData->layer, &rect, PR_FALSE);
            }
            else
#endif /* LAYERS */
                pContext->funcs->DisplayEmbed(pContext, FE_VIEW, pLayoutData);

        }
        pItem->m_cplDisplay.RemoveAll();
    }

    //  And well, hey, get rid of the url.
    NET_FreeURLStruct(pUrl);
}
Exemple #17
0
int
rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile)
{
	MozillaEvent_rdf_GetURL		*event;
	URL_Struct      		*urls = NULL;
        char				*url;

#ifdef DEBUG_gagan
        return 0;
#endif

    if (cx == NULL)  return 0;
        if (rdfFile->refreshingp && rdfFile->updateURL) {
          url = rdfFile->updateURL;
        } else {
          url = rdfFile->url;
        }
        if (strcmp(url, gNavCntrUrl) == 0) {
          urls = NET_CreateURLStruct(url,  NET_CACHE_ONLY_RELOAD);
#ifdef NU_CACHE
          if (!CacheManager_Contains(url)) {
#else
          if (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)) {
          } else {
#endif
            NET_FreeURLStruct(urls);
            urls = NULL;
          }
        }
	if (!urls) 
          urls = NET_CreateURLStruct(url, (rdfFile->refreshingp ? 
                                           NET_SUPER_RELOAD : NET_NORMAL_RELOAD));
	if (urls == NULL) return 0;
	urls->fe_data = rdfFile;
	if (method) urls->method = method;

	if (PR_CurrentThread() == mozilla_thread)
	{
		htLoadBegins(urls, url);
		NET_GetURL(urls, FO_CACHE_AND_RDF, cx, rdf_GetUrlExitFunc);
	}
	else
	{
		/* send event to Mozilla thread */
		
		if (mozilla_event_queue == NULL)	return(0);
		event = PR_NEW(MozillaEvent_rdf_GetURL);
		if (event == NULL)	return(0);
		PR_InitEvent(&(event->ce.event), cx,
			(PRHandleEventProc)rdf_HandleEvent_GetURL,
			(PRDestroyEventProc)rdf_DisposeEvent_GetURL);
		event->url = copyString(url);
		event->urls = urls;
		event->method = FO_CACHE_AND_RDF;
		event->cx = cx;
		event->exitFunc = rdf_GetUrlExitFunc;
		PR_PostEvent(mozilla_event_queue, &(event->ce.event));
	}
	return 1;
}
#endif /* MOZILLA_CLIENT */



void
possiblyRereadRDFFiles (void* data)
{
	possiblyRefreshRDFFiles();
/*	timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); 
	once every 10 minutes
	diabled for legal reasons.*/
}



void
RDFglueInitialize()
{
#ifdef MOZILLA_CLIENT

	timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); /* once every 10 minutes */
	if (gRLForbiddenDomains != NULL)
	{
		freeMem(gRLForbiddenDomains);
		gRLForbiddenDomains = NULL;
	}
	if (PREF_CopyCharPref("browser.relatedLinksDisabledForDomains", &gRLForbiddenDomains) != PREF_OK)
	{
		gRLForbiddenDomains = NULL;
	}

#endif /* MOZILLA_CLIENT */
}
Exemple #18
0
//  Get URL exit routines.
void CFE_SimpleGetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext)  {
    if(iStatus != MK_CHANGING_CONTEXT)	{
        NET_FreeURLStruct(pUrl);
    }
}
Exemple #19
0
//  Get URL exit routines.
void CFE_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext)  {
	//	Enable clicking now.
	FE_EnableClicking(pContext);

	//	Report any error.
	if(iStatus < 0 && pUrl->error_msg != NULL)	{
		FE_Alert(pContext, pUrl->error_msg);
	}

	// Make sure the context is still valid. It's possible it's been deleted
	// out from under us while we were displaying the modal dialog box (and in
	// a sub-dispatch message loop)
	if (!XP_IsContextInList(pContext)) {
		return;
	}

#ifdef EDITOR
    // Do stuff specific to the editor
    FE_EditorGetUrlExitRoutine(pUrl, iStatus, pContext);

#ifdef MOZ_MAIL_NEWS
    if (IS_MESSAGE_COMPOSE(pContext))
    {
        CGenericFrame * pFrame = wfe_FrameFromXPContext(pContext);
        if (pFrame)
        {
            CComposeFrame * pCompose = (CComposeFrame*)pFrame;
            if (pCompose->UseHtml() && !pCompose->Initialized())
                pCompose->GoldDoneLoading();
        }
    }
#endif // MOZ_MAIL_NEWS
#endif //EDITOR

    ABSTRACTCX(pContext)->GetUrlExitRoutine(pUrl, iStatus, pContext);

	if(iStatus != MK_CHANGING_CONTEXT)	{
		//	We autoproduce a title for those contexts which have none.
        //  Message compose window title is set by msglib. We don't want to overwrite 
        //  it here. - kamal
		if(pContext->title == NULL && pUrl->address != NULL &&
		   (pContext->type == MWContextBrowser || pContext->type == MWContextPane) && !EDT_IS_EDITOR(pContext) )	{

			//	Limit the automatically set titles to 50 chars.
			CString csTitle = pUrl->address;
			WFE_CondenseURL(csTitle, 50, FALSE);
			FE_SetDocTitle(pContext, (char *)(const char *)csTitle);
		}

		//	Since a page was loaded, go through all internal contexts and update their
		//		anchors so that we can have an updated display on all relevant windows.
		XP_RefreshAnchors();

		//	If the url has ncapi data, have it pass off this information to
		//		external applications too (must happen before URL struct is
		//		freed off (all connections complete).
		if(NCAPIDATA(pUrl) != NULL)	{
			NCAPIDATA(pUrl)->EndProgress();
		}

		//	Make sure the NCAPI Url data will let us free off the URL.
		if(NCAPIDATA(pUrl) == NULL || NCAPIDATA(pUrl)->CanFreeUrl() == TRUE)	{
            FEU_DeleteUrlData(pUrl, NULL);
			NET_FreeURLStruct(pUrl);
		}
	}
}
Exemple #20
0
PRIVATE void
net_ParseHTMLHelpLoadHelpDoc(HTMLHelpParseObj *obj, MWContext *context)
{
	URL_Struct *URL_s;
	char *frame_address = NULL;
	char *content_address = NULL;
	MWContext *new_context;
	frame_set_struct *fgs;

	if(obj->id_value || obj->default_id_value)
		content_address = NET_MakeAbsoluteURL(obj->url_to_map_file, 
											  obj->id_value ? 
												obj->id_value : 
												obj->default_id_value);

	if(!content_address)
	  {
		FE_Alert(context, XP_GetString(MK_CANT_LOAD_HELP_TOPIC));
		return;
	  }

	fgs = XP_ListPeekTopObject(obj->frame_group_stack);

	if(fgs)
	  {
		if(fgs->address)
		  {
			frame_address = NET_MakeAbsoluteURL(obj->url_to_map_file, 
												fgs->address);
		  }
	  }

	if(frame_address)
		URL_s = NET_CreateURLStruct(frame_address, NET_DONT_RELOAD);
	else
		URL_s = NET_CreateURLStruct(content_address, NET_DONT_RELOAD);

	if(!URL_s)
		goto cleanup;

	URL_s->window_chrome = XP_NEW(Chrome);	

	if(!URL_s->window_chrome)
		goto cleanup;

	XP_MEMSET(URL_s->window_chrome, 0, sizeof(Chrome));

	if(obj->window_name)
		URL_s->window_target = XP_STRDUP(obj->window_name);
	else
		URL_s->window_target = XP_STRDUP(DEFAULT_HELP_WINDOW_NAME);

	net_help_init_chrome(URL_s->window_chrome, 
						 obj->window_width, 
						 obj->window_height);

	/* We want to revert the character set of the help frame from the standard
	   character set, not whatever happened to be the last viewed source */

	StrAllocCopy(URL_s->charset, INTL_ResourceCharSet());
	
	new_context = XP_FindNamedContextInList(NULL, URL_s->window_target);

	if(frame_address)
	  {
		URL_Struct *content_URL_s;

		/* if there is a frame_address then we load the
		 * frame first and then load the contents
		 * in the frame exit function.
		 */
		content_URL_s = NET_CreateURLStruct(content_address, NET_DONT_RELOAD);

		if(obj->content_target)
			content_URL_s->window_target = XP_STRDUP(obj->content_target);
		else if(fgs->target)
			content_URL_s->window_target = XP_STRDUP(fgs->target);

		/* doesn't work: URL_s->fe_data = (void *) content_URL_s; */

		/* hack for older versions, see pre_exit_routine_above */
		if (obj->helpVersion < 2) {
			frame_content_for_pre_exit_routine = content_URL_s;
		} else {
			frame_content_for_pre_exit_routine = NULL;
			NET_FreeURLStruct(content_URL_s);
		}

		URL_s->pre_exit_fn = net_HelpPreExitRoutine;
	  }

	if(!new_context)
	  {
	  
		/* this will cause the load too */
		new_context = FE_MakeNewWindow(context, 
						 URL_s, 
						 (obj->window_name) ? obj->window_name :  DEFAULT_HELP_WINDOW_NAME, 
						 URL_s->window_chrome);

		if (HELP_INFO_PTR(*new_context) == NULL) {
			new_context->pHelpInfo = XP_NEW_ZAP(HelpInfoStruct);
		}
		
		if (HELP_INFO_PTR(*new_context)->topicURL != NULL) {
			XP_FREE(HELP_INFO_PTR(*new_context)->topicURL);
			HELP_INFO_PTR(*new_context)->topicURL = NULL;
		}
		
		StrAllocCopy(HELP_INFO_PTR(*new_context)->topicURL, content_address);

	  }
	else
	  {
	
		if (HELP_INFO_PTR(*new_context) == NULL) {
			new_context->pHelpInfo = XP_NEW_ZAP(HelpInfoStruct);
		}
		
		if (HELP_INFO_PTR(*new_context)->topicURL != NULL) {
			XP_FREE(HELP_INFO_PTR(*new_context)->topicURL);
			HELP_INFO_PTR(*new_context)->topicURL = NULL;
		}
		
		StrAllocCopy(HELP_INFO_PTR(*new_context)->topicURL, content_address);

		FE_RaiseWindow(new_context);

		/* Compatibility with earlier versions of NetHelp */
		if (obj->helpVersion < 2) {
			FE_GetURL(new_context, URL_s);
		} else {
			LM_SendOnHelp(new_context);
		}
	  }

cleanup:
	FREEIF(frame_address);
	FREE(content_address);

	return;
}
Exemple #21
0
PRIVATE void
simple_exit(URL_Struct *URL_s, int status, MWContext *window_id)
{
	if(status != MK_CHANGING_CONTEXT)
		NET_FreeURLStruct(URL_s);
}
Exemple #22
0
/*
 * Load a document from an external URL.  Assumes that layout is
 *   already blocked
 */
static void
lo_GetScriptFromURL(ScriptData *data, int script_type) 
{
    URL_Struct *url_struct;
    lo_TopState *top_state = data->state->top_state;
    PA_Tag *tag = data->tag;

    url_struct = NET_CreateURLStruct(data->url, top_state->force_reload);
    if (url_struct == NULL) {
        top_state->out_of_memory = TRUE;
	lo_DestroyScriptData(data);
	return;
    }

    url_struct->must_cache = TRUE;
    url_struct->preset_content_type = TRUE;
    if (script_type == SCRIPT_TYPE_CSS) {
        StrAllocCopy(url_struct->content_type, TEXT_CSS);
    } else {
	if (tag->type == P_STYLE || tag->type == P_LINK) {
	    StrAllocCopy(url_struct->content_type, TEXT_JSSS);
	} else {
	    StrAllocCopy(url_struct->content_type, js_content_type);
	}
    }

    XP_ASSERT(top_state->layout_blocking_element);

    if (!url_struct->content_type)
	goto out;

    if (!data->inlineSigned) {
        if (data->archiveSrc) {
            /* ARCHIVE= and SRC= */
            /*
             * Need to set nesting url. Create name of form
             * "archive.jar/src.js" 
             */
             
            char *path = lo_BuildJSArchiveURL(url_struct->address,
                                              data->archiveSrc);    
            if (!path)
                goto out;
            ET_SetNestingUrl(data->context, path);
            /* version taken care of in lo_script_archive_exit_fn */
            XP_FREE(path);
        } else {
            /* SRC= but no ARCHIVE= */
            ET_SetNestingUrl(data->context, url_struct->address);
            ET_SetVersion(data->context, data->version);
        }
    }

    url_struct->fe_data = data;

    if (data->archiveSrc != NULL || data->inlineSigned) {
        NET_GetURL(url_struct, 
                   FO_CACHE_ONLY,
                   data->context,
                   lo_script_archive_exit_fn);
    } else {
        NET_GetURL(url_struct, 
                   FO_CACHE_AND_PRESENT, 
                   data->context,
                   lo_script_src_exit_fn);
    }

    return;
  out:
    top_state->out_of_memory = TRUE;
    NET_FreeURLStruct(url_struct);
    lo_DestroyScriptData(data);
    return;
}
Exemple #23
0
static void
lo_script_archive_exit_fn(URL_Struct *url_struct, int status, MWContext *context)
{
    ScriptData *data = NULL;
    char *name;
    JSPrincipals *principals;
    ETEvalStuff * stuff;

    data = (ScriptData *) url_struct->fe_data;
    stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff);
    if (!stuff)
	return;

    stuff->line_no = 1;
    stuff->scope_to = NULL;
    stuff->want_result = JS_FALSE;
    stuff->version = data->version;
    stuff->data = context;

#ifndef JAVA
    /* No Java; execute without principals. */
    if (data->buffer) {
	stuff->principals = NULL;
        ET_EvaluateScript(context, data->buffer, stuff, lo_ScriptEvalExitFn);
    }
    else {
	XP_FREE(stuff);
    }
#else
    name = data->archiveSrc ? data->archiveSrc : data->id;
    principals = LM_NewJSPrincipals(url_struct, name, data->codebase);
    if (principals != NULL) {
        char *src;
        uint srcSize;

        if (data->archiveSrc) {
            /* Extract from archive using "SRC=" value */
            src = LM_ExtractFromPrincipalsArchive(principals, data->archiveSrc, 
                                                  &srcSize);
                                                  
#ifdef JSDEBUGGER
        if( src != NULL && LM_GetJSDebugActive() )
        {
            char *path = lo_BuildJSArchiveURL(url_struct->address,
            data->archiveSrc);
            if (path)
            {
                LM_JamSourceIntoJSDebug( path, src, srcSize, context );
                XP_FREE(path);
            }
        }
#endif /* JSDEBUGGER */

            if (src == NULL) {
                /* Unsuccessful extracting from archive. Now try normal SRC= lookup. */
                (*principals->destroy)(NULL, principals);
                data->url = NET_MakeAbsoluteURL(data->state->top_state->base_url, 
                                                data->archiveSrc);
                XP_FREEIF(data->archiveSrc);
                data->archiveSrc = NULL;
                lo_GetScriptFromURL(data, data->state->top_state->in_script);
                goto out;
	    }
        } else {
            /* Should be an inline script */
            src = data->buffer;
            srcSize = data->bufferSize;
        }

	stuff->len = srcSize;
	stuff->principals = principals;
        ET_EvaluateScript(context, src, stuff, lo_ScriptEvalExitFn);

        if (data->archiveSrc){
            ET_SetNestingUrl(context, NULL);
            XP_FREE(src);
        }            
    }
    else {
	XP_FREE(stuff);
    }
	 
#endif /* ifdef JAVA */

    lo_DestroyScriptData(data);

out:
    /* Always free (or drop a ref on) the url_struct before returning. */
    NET_FreeURLStruct(url_struct);
}