Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
void
fe_showNetcaster(Widget toplevel)

/*
 * description:
 *	This function shows the Netcaster window, starting
 *	Netcaster if necessary.  If Netcaster is not installed,
 *  this function does nothing.
 *
 ****************************************/
{
  MWContext * netcasterContext;

  if (!fe_IsNetcasterInstalled())
    return;

  if(!(netcasterContext=FE_IsNetcasterRunning()))
	{ 

	  Chrome      netcasterChrome;
	  URL_Struct* URL_s;
	  const char* netcasterURL = xfe_netcaster_url();

      if (netcasterURL)
		{

		  if (!LM_GetMochaEnabled() || !LJ_GetJavaEnabled())
			{
			  fe_Alert_2(toplevel, XP_GetString(XP_ALERT_NETCASTER_NO_JS));
			  return;
			}

		  memset(&netcasterChrome, 0, sizeof(Chrome));

		  netcasterChrome.w_hint             = 21;
		  netcasterChrome.h_hint             = 59;
		  netcasterChrome.l_hint             = -1000;
		  netcasterChrome.t_hint             = -1000;
		  netcasterChrome.topmost            = TRUE;
		  netcasterChrome.z_lock             = TRUE;
		  netcasterChrome.location_is_chrome = TRUE;
		  netcasterChrome.disable_commands   = TRUE;
		  netcasterChrome.hide_title_bar     = TRUE;
		  netcasterChrome.restricted_target  = TRUE;
      
		  URL_s = NET_CreateURLStruct(netcasterURL, NET_DONT_RELOAD);
      
		  netcasterContext = xfe2_MakeNewWindow(toplevel,NULL,
												URL_s,
												netcasterWindowName,
												MWContextBrowser,
												False,
												&netcasterChrome);
		}
	  else
		{
		  fe_Alert_2(toplevel, XP_GetString(XP_ALERT_CANT_RUN_NETCASTER));
		} 
	}
  else
	{
	  FE_RaiseWindow(netcasterContext);
	}
}