Ejemplo n.º 1
0
extern char* vr_findVerRegName()
{
    OSErr   err;
    FSRef   foundRef;
    
    err = FSFindFolder(kLocalDomain, kDomainLibraryFolderType, kDontCreateFolder, &foundRef);
    if (err == noErr)
    {
        FSRef parentRef;
        err = FSMakeFSRefUnicode(&foundRef, UNICHAR_ARRAY_LEN(kOSXRegParentName), kOSXRegParentName,
                                 kTextEncodingUnknown, &parentRef);
        if (err == fnfErr)
        {
            err = FSCreateDirectoryUnicode(&foundRef, UNICHAR_ARRAY_LEN(kOSXRegParentName), kOSXRegParentName,
                                           kFSCatInfoNone, NULL, &parentRef, NULL, NULL);
        }
        if (err == noErr)
        {
            FSRef regRef;
            err = FSMakeFSRefUnicode(&parentRef, UNICHAR_ARRAY_LEN(kOSXVersRegName), kOSXVersRegName,
                                     kTextEncodingUnknown, &regRef);
            if (err == fnfErr)
            {
                FSCatalogInfo catalogInfo;
                FileInfo fileInfo = { 'REGS', 'MOSS', 0, { 0, 0 }, 0 };
                BlockMoveData(&fileInfo, &(catalogInfo.finderInfo), sizeof(FileInfo));
                err = FSCreateFileUnicode(&parentRef, UNICHAR_ARRAY_LEN(kOSXVersRegName), kOSXVersRegName,
                                               kFSCatInfoFinderInfo, &catalogInfo, &regRef, NULL);
            }
            if (err == noErr)
            {
                UInt8 pathBuf[PATH_MAX];
                err = FSRefMakePath(&regRef, pathBuf, sizeof(pathBuf));
                if (err == noErr)
                    verRegName = XP_STRDUP(pathBuf);
            }
        }
    }
    return verRegName;
}
Ejemplo n.º 2
0
/* load the HTML help mapping file and search for
 * the id or text to load a specific document
 */
PUBLIC void
NET_GetHTMLHelpFileFromMapFile(MWContext *context,
							   char *map_file_url,
							   char *id,
							   char *search_text)
{
	URL_Struct *URL_s;

	XP_ASSERT(map_file_url && id);

	if(!map_file_url || !id)
		return;

	URL_s = NET_CreateURLStruct(map_file_url, NET_DONT_RELOAD);

	if(!URL_s)
		return;

	URL_s->fe_data = XP_STRDUP(id);

	NET_GetURL(URL_s, FO_CACHE_AND_LOAD_HTML_HELP_MAP_FILE, context, simple_exit);
}
Ejemplo n.º 3
0
/* Returns the text and/or icon to display at the top of the column.
 */
char*
XFE_AddrBookView::getColumnHeaderText(int column)
{

  char *tmp = 0;
  switch (column) {
  case OUTLINER_COLUMN_TYPE:
    tmp = XP_STRDUP(" ");
    break;

  case OUTLINER_COLUMN_NAME:
    tmp = XP_GetString(XFE_AB_HEADER_NAME);
    break;

  case OUTLINER_COLUMN_NICKNAME:
    tmp = XP_GetString(XFE_AB_HEADER_NICKNAME);
    break;

  case OUTLINER_COLUMN_EMAIL:
    tmp = XP_GetString(XFE_AB_HEADER_EMAIL);
    break;

  case OUTLINER_COLUMN_PHONE:
    tmp = XP_GetString(XFE_AB_HEADER_PHONE);
    break;

  case OUTLINER_COLUMN_COMPANY:
    tmp = XP_GetString(XFE_AB_HEADER_COMPANY);
    break;

  case OUTLINER_COLUMN_LOCALITY:
    tmp = XP_GetString(XFE_AB_HEADER_LOCALITY);
    break;

  }/* switch () */

  return tmp;
}
Ejemplo n.º 4
0
void CFE_SetDocTitle(MWContext *pContext, char *pTitle)	{
	if(ABSTRACTCX(pContext)->IsDestroyed())	{
		//	Don't allow this to happen if the context has been destroyed...
		TRACE("Context %p Destroyed :: SetDocTitle Blocking\n", pContext);
		return;
	}

	//	Default implementation allocs a string to put into the context.
	if(pContext->title != NULL)	{
		XP_FREE(pContext->title);
		pContext->title = NULL;
	}

	if(pTitle != NULL)	{
		pContext->title = XP_STRDUP(pTitle);
	}

    ABSTRACTCX(pContext)->SetDocTitle(pContext, pTitle);

	//	Update the session history after calling context class, they may have
	//		munged the title.
	SHIST_SetTitleOfCurrentDoc( pContext );
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// NetStream
//-----------------------------------------------------------------------------
CStreamOutNet::CStreamOutNet( MWContext* pContext )
{
    URL_Struct * URL_s;
    Chrome chrome;

    XP_BZERO( &chrome, sizeof( Chrome ) );
    chrome.allow_close = TRUE;
    chrome.allow_resize = TRUE;
    chrome.show_scrollbar = TRUE;
#ifndef XP_WIN
	// NOTE:  need to verify this change on XP_WIN and remove the
	//        ifndef... [ works on XP_UNIX & XP_MAC ]
	//
	chrome.type = MWContextDialog;
#endif

    //
    // LTNOTE: Ownership of the 'chrome' struct isn't documented in the interface.
    //  The windows implementation doesn't appear to keep pointers to the struct.
    //
    MWContext *pNewContext = FE_MakeNewWindow(pContext, NULL, "view-source",
                    &chrome );
    pNewContext->edit_view_source_hack = TRUE;

    URL_s = NET_CreateURLStruct(XP_GetString(EDT_VIEW_SOURCE_WINDOW_TITLE), NET_DONT_RELOAD);  

    URL_s->content_type = XP_STRDUP(TEXT_PLAIN);

    m_pStream = NET_StreamBuilder(FO_PRESENT, URL_s, pNewContext);

    if(!m_pStream){
        XP_ASSERT( FALSE );
        m_status = EOS_FileError;
    } 
    m_status = EOS_NoError;
}
Ejemplo n.º 6
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.º 7
0
/* parse lines in an HTML help mapping file.
 * get window_size and name, etc...
 *
 * when the id is found function returns HTML_HELP_ID_FOUND
 * on error function returns negative error code.
 */
PRIVATE int
net_ParseHTMLHelpLine(HTMLHelpParseObj *obj, char *line_data)
{
	char *line = XP_StripLine(line_data);
	char *token;
	char *next_word;

	if(*line == '<')
	  {
		/* find and terminate the end '>' */
		XP_STRTOK(line, ">");

		token = XP_StripLine(line+1);

		if(!strncasecomp(token, 
						 ID_MAP_TOKEN, 
						 sizeof(ID_MAP_TOKEN)-1))
		  {
			obj->in_id_mapping = TRUE;
		  }
		else if(!strncasecomp(token, 
						 END_ID_MAP_TOKEN, 
						 sizeof(END_ID_MAP_TOKEN)-1))
		  {
			obj->in_id_mapping = FALSE;
		  }
		else if(!strncasecomp(token, 
						 FRAME_GROUP_TOKEN, 
						 sizeof(FRAME_GROUP_TOKEN)-1))
		  {
			char *cp = token + sizeof(FRAME_GROUP_TOKEN)-1;
			frame_set_struct * fgs = XP_NEW(frame_set_struct);

			while(isspace(*cp)) cp++;

			if(fgs)
			  {
				XP_MEMSET(fgs, 0, sizeof(frame_set_struct));

				next_word=NULL; /* init */

				do {
					if(!strncasecomp(cp, SRC_TOKEN, sizeof(SRC_TOKEN)-1))
				  	  {
						char *address = net_get_html_help_token(
														cp+sizeof(SRC_TOKEN)-1,
														&next_word);
						cp = next_word;
						fgs->address = XP_STRDUP(address);
				  	  }
					else if(!strncasecomp(cp, 
									  WINDOW_TOKEN, 
									  sizeof(WINDOW_TOKEN)-1))
				      {
					    char *window = net_get_html_help_token(
													cp+sizeof(WINDOW_TOKEN)-1, 
													&next_word);
					    cp = next_word;
					    fgs->target = XP_STRDUP(window);
				      }
					else
					  {
						/* unknown attribute.  Skip to next whitespace
						 */ 
						while(*cp && !isspace(*cp)) 
							cp++;


						if(*cp)
						  {
							while(isspace(*cp)) cp++;
							next_word = cp;
						  }
						else
						  {
							next_word = NULL;
						  }
					  }

				  } while(next_word);
			
				XP_ListAddObject(obj->frame_group_stack, fgs);
			  }
		  }
		else if(!strncasecomp(token, 
						 END_FRAME_GROUP_TOKEN, 
						 sizeof(END_FRAME_GROUP_TOKEN)-1))
		  {
			frame_set_struct *fgs;

			fgs = XP_ListRemoveTopObject(obj->frame_group_stack);

			if(fgs)
				net_help_free_frame_group_struct(fgs);
		  }
	  }
	else if(!obj->in_id_mapping)
	  {
		if(!strncasecomp(line, 
					 	WINDOW_SIZE_TOKEN, 
					 	sizeof(WINDOW_SIZE_TOKEN)-1))
		  {
			/* get window size */
			char *comma=0;
			char *window_size = net_get_html_help_token(line+
												sizeof(WINDOW_SIZE_TOKEN)-1, 
												NULL);

			if(window_size)
				comma = XP_STRCHR(window_size, ',');

			if(comma)
			  {
				*comma =  '\0';
				obj->window_width = XP_ATOI(window_size);
				obj->window_height = XP_ATOI(comma+1);
			  }
		  }
		else if(!strncasecomp(line, 
						 	WINDOW_NAME_TOKEN, 
						 	sizeof(WINDOW_NAME_TOKEN)-1))
		  {
			char *window_name = net_get_html_help_token(line+
												sizeof(WINDOW_NAME_TOKEN)-1,
												NULL);

			if(window_name)
			  {
				FREEIF(obj->window_name);
				obj->window_name = XP_STRDUP(window_name);
			  }
		  }
		else if(!strncasecomp(line, 
					 	HELP_VERSION_TOKEN, 
					 	sizeof(HELP_VERSION_TOKEN)-1))
		  {
			/* get window size */
			char *help_version = net_get_html_help_token(line+
												sizeof(HELP_VERSION_TOKEN)-1, 
												NULL);

			if(help_version)
			  {
				obj->helpVersion = XP_ATOI(help_version);
			  }
		  }
	  }
	else
	  {
		/* id mapping pair */
		if(!strncasecomp(line, obj->id, XP_STRLEN(obj->id)))
		  {
			char *id_value = net_get_html_help_token(line+XP_STRLEN(obj->id),
													 &next_word);

			if(id_value)
			  {
			  	obj->id_value = XP_STRDUP(id_value);

				while(next_word)
				  {
					char *cp = next_word;

                    if(!strncasecomp(cp,
                                     TARGET_TOKEN,
                                      sizeof(TARGET_TOKEN)-1))
                      {
                        char *target = net_get_html_help_token(
                                                    cp+sizeof(TARGET_TOKEN)-1,
                                                    &next_word);
                        cp = next_word;
                        obj->content_target = XP_STRDUP(target);
                      }
					else
					  {
                        /* unknown attribute.  Skip to next whitespace
                         */
                        while(*cp && !isspace(*cp))
                            cp++;

                        if(*cp)
                          {
                            while(isspace(*cp)) cp++;
                            next_word = cp;
                          }
                        else
                          {
                            next_word = NULL;
                          }
					  }
				  }
			  }
		
			return(HTML_HELP_ID_FOUND);
		  }
		if(!strncasecomp(line, DEFAULT_HELP_ID, sizeof(DEFAULT_HELP_ID)-1))
		  {
			char *default_id_value = net_get_html_help_token(
												line+sizeof(DEFAULT_HELP_ID)-1,
												NULL);

            if(default_id_value)
                obj->default_id_value = XP_STRDUP(default_id_value);
		  }
		
	  }

	return(0);
}
Ejemplo n.º 8
0
//
// This function will create a composition window and just attach
// the attachments of interest and pop up the window...
//
// Return: appropriate MAPI return code...
//
//
extern "C" LONG
DoPartialMAPIMailOperation(MAPISendDocumentsType *sendDocPtr)
{   
CGenericDoc             *pDocument;

  // Get a context to use for this call...
  MWContext *pOldContext = GetUsableContext();
  if (!pOldContext)
  {
    return(MAPI_E_FAILURE);
  }

  // Don't allow a compose window to be created if the user hasn't 
  // specified an email address
  const char *real_addr = FE_UsersMailAddress();
  if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0)
  {
    return(MAPI_E_FAILURE);
  }

  //
  // Now, build the fields object w/o much info...
  //
  BOOL    bEncrypt = FALSE;
  BOOL    bSign    = FALSE;

  PREF_GetBoolPref("mail.crypto_sign_outgoing_mail", &bSign);
  PREF_GetBoolPref("mail.encrypt_outgoing_mail", &bEncrypt);

  MSG_CompositionFields *fields =
      MSG_CreateCompositionFields(real_addr, real_addr, NULL, 
                  "", "",
									"", "", "",
									"", "", "",
									"", "", "",
									"", 
                  bEncrypt,
                  bSign);
  if (!fields)
  {
    return(MAPI_E_FAILURE);
  }

  // RICHIE - INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext);
  // int16 win_csid = INTL_GetCSIWinCSID(csi);

  pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, NULL, /*RICHIE win_csid,*/ TRUE);
  if ( !pDocument )
  {
    // cleanup fields object
    MSG_DestroyCompositionFields(fields);
    return(MAPI_E_FAILURE);
  }

  CWinCX * pContext = (CWinCX*) pDocument->GetContext();
  if ( !pContext ) 
  {
    return(MAPI_E_FAILURE);
  }

  MSG_CompositionPaneCallbacks Callbacks;
  Callbacks.CreateRecipientsDialog = CreateRecipientsDialog;
  Callbacks.CreateAskHTMLDialog = CreateAskHTMLDialog;

  MWContext *context = pContext->GetContext();
  CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd();
  pCompose->SetComposeStuff(context,fields); // squirl away stuff for post-create

  // This needs to be set TRUE if using the old non-HTML text frame
  // to prevent dropping dragged URLs
  pContext->m_bDragging = !pCompose->UseHtml();
  if (!pCompose->UseHtml()) 
  {
    pCompose->SetMsgPane(MSG_CreateCompositionPane(
      pContext->GetContext(), 
      context,
      g_MsgPrefs.m_pMsgPrefs, fields,
      WFE_MSGGetMaster()));
  }

  ASSERT(pCompose->GetMsgPane());
  MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose);

  pCompose->UpdateAttachmentInfo();

  // Pass doccsid info to new context for MailToWin conversion
  /***
  doccsid = INTL_GetCSIDocCSID(LO_GetDocumentCharacterSetInfo(pOldContext));

  INTL_SetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context), 
    (doccsid ? doccsid : INTL_DefaultDocCharSetID(pOldContext)));
  ****/

  pCompose->DisplayHeaders(NULL);

  CComposeBar * pBar = pCompose->GetComposeBar();
  ASSERT(pBar);
  LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface();

  if (!pIAddressList->IsCreated()) 
  {
    pBar->CreateAddressingBlock();
  }

  // Always do plain text composition!
  pCompose->CompleteComposeInitialization();

  //
  // Finally deal with the attachments...
  //
  NSstringSeq     mailInfoSeq = (NSstringSeq) &(sendDocPtr->dataBuf[0]);
  DWORD           stringCount = 0;
  DWORD           i;

  TRACE("MAPI: ProcessMAPISendDocuments() # of Attachments = [%d]\n", sendDocPtr->nFileCount);

  if (sendDocPtr->nFileCount > 0)
  {
      MSG_AttachmentData *pAttach = (MSG_AttachmentData *)
                    XP_CALLOC((sendDocPtr->nFileCount + 1),
                    sizeof(MSG_AttachmentData));
      if (!pAttach)
      {
        return(MAPI_E_INSUFFICIENT_MEMORY);
      }

      memset(pAttach, 0, (sendDocPtr->nFileCount + 1) * 
                                  sizeof(MSG_AttachmentData));
      for (i=0; i<sendDocPtr->nFileCount; i++)
      {
        CString cs;
        // Create URL from filename...
        WFE_ConvertFile2Url(cs, 
            (const char *)NSStrSeqGet(mailInfoSeq, stringCount++));
        pAttach[i].url = XP_STRDUP(cs);

        // Now also include the "display" name...
        StrAllocCopy(pAttach[i].real_name, NSStrSeqGet(mailInfoSeq, stringCount++));
      }

      // Set the list!
      MSG_SetAttachmentList(pCompose->GetMsgPane(), pAttach);

      // Now free everything...
      for (i=0; i<sendDocPtr->nFileCount; i++)
      {
        if (pAttach[i].url)
          XP_FREE(pAttach[i].url);

        if (pAttach[i].real_name)
          XP_FREE(pAttach[i].real_name);
      }

      XP_FREE(pAttach);
  }
    
  // 
  // Now some checking for ... well I'm not sure...
  //
  if (MSG_GetAttachmentList(pCompose->GetMsgPane()))
    pCompose->SetModified(TRUE);
  else
    pCompose->SetModified(FALSE);

  // Post message to compose window to set the initial focus.
  pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS);

  //
  // Now, just popup the window...
  //
  pCompose->ShowWindow(TRUE);

  // return pCompose->GetMsgPane(); rhp - used to return the MsgPane
  return(SUCCESS_SUCCESS);
}
Ejemplo n.º 9
0
// external access for old xfe code - if a url points to a URL file (NetscapeURL, WebJumper)
// then extract the URL and return it.
//
// Note:'translateWebJumper' determines whether SGI WebJumpers will be resolved or not.
// In some cases, we want to keep them as indirect jumpers (attaching to an email.)
// In other cases we want to resolve them (opening a WebJumper in the browser.)
extern "C" int XFE_DesktopTypeTranslate(const char *url,char **desktop_url,int translateWebJumper) {
    if (desktop_url==NULL)
        return FALSE;

    *desktop_url=NULL;
    
    if (url==NULL || strlen(url)==0)
        return FALSE;    
    
    // if url points to a local file, extract the filename
    char *filename;
    if (strncmp(url,"file:",5)==0 && strlen(url+5)>0)
        filename=XP_STRDUP(url+5);
    else if (strncmp(url,"/",1)==0)
        filename=XP_STRDUP(url);
    else
        return FALSE;

    // strip trailing spaces
    int i=strlen(filename);
    while (isspace(filename[--i]))
        filename[i]='\0';
    
    int retval=FALSE;

    // open file and see if it's a Netscape desktop file
    FILE *fp;
    if (fp=fopen(filename,"r")) {
        const int MAX_LENGTH=4000;
        char line[MAX_LENGTH+1];
        line[MAX_LENGTH]='\0';
        line[0]='\0'; // ensure string will be null-terminated
        fgets(line,MAX_LENGTH,fp);

        // NetscapeURL
        if (XFE_URLDesktopType::isDesktopType(line)) {
            XFE_URLDesktopType urlData(fp);
            if (urlData.numItems()>0) {
                *desktop_url=XP_STRDUP(urlData.url(0));
                retval=TRUE;
            }
        }
        // WebJumper
        else if (translateWebJumper && XFE_WebJumperDesktopType::isDesktopType(line)) {
            XFE_WebJumperDesktopType wjData(fp);
            if (wjData.url()) {
                *desktop_url=XP_STRDUP(wjData.url());
                retval=TRUE;
            }
        }   
        // nyi - check for other Netscape desktop types here
        
        // file is not a Netscape desktop file
        else {
            retval=FALSE;
        }
        
        fclose(fp);
    }
    return retval;
}
Ejemplo n.º 10
0
char *XP_PlatformPartialPathToXPPartialPath(const char *platformPath)
{
    /* using the unix XP_PlatformFileToURL, there is no escaping! */
    return XP_STRDUP(platformPath);
}
Ejemplo n.º 11
0
// tooltips and doc string
char *XFE_AddrBookView::getDocString(CommandType cmd)
{
	uint32 count = 0;
	const int *indices = 0;
	m_outliner->getSelection(&indices, (int *) &count);

	if (count > 0) {
		char *names = 0;
		char a_line[512];
		a_line[0] = '\0';
		int len = 0;
		for (int i=0; i < count && len < 512; i++) {
			/* Take the first one 
			 */
#if defined(USE_ABCOM)
			AB_AttributeValue *value = NULL;
			int error = 
				AB_GetEntryAttributeForPane(m_pane,
											(MSG_ViewIndex) indices[i],
											AB_attribFullName,
											&value);
			XP_ASSERT(value && value->attrib == AB_attribFullName);

			XP_SAFE_SPRINTF(a_line, sizeof(a_line),
							"%s",
							value->u.string?value->u.string:"");
			AB_FreeEntryAttributeValue(value);
#else
			ABID entry;		
			entry = AB_GetEntryIDAt((AddressPane *) m_abPane, 
									(uint32) indices[i]);
			AB_GetFullName(m_dir, m_AddrBook, entry, a_line);
#endif /* USE_ABCOM */
			if (a_line) {
				len += XP_STRLEN(a_line);
				if (i)
					len += 2;

				names = names?
					((char *) XP_REALLOC(names, (len+1)*sizeof(char))):
					((char *) XP_CALLOC(1+len, sizeof(char)));

				if (i)
					names = XP_STRCAT(names, ", ");
				names = XP_STRCAT(names, a_line);			
			}/* if */
		}/* for i */

		char *cstr = 0;
		if (cmd == xfeCmdComposeMessage ||
			cmd == xfeCmdComposeMessageHTML ||
			cmd == xfeCmdComposeMessagePlain) {
			cstr = XP_STRDUP(XP_GetString(XFE_SEND_MSG_TO));	
		} else if (cmd == xfeCmdABCall) {
			cstr = XP_STRDUP(XP_GetString(XFE_PLACE_CONFERENCE_CALL_TO));
		}
		len += XP_STRLEN(cstr);
		cstr = (char *) XP_REALLOC(cstr, (1+len)*sizeof(char));
		cstr = (char *) XP_STRCAT(cstr, names);
		return cstr;
	}/* if */
	return NULL;
}
Ejemplo n.º 12
0
/*
 * Unlike hk_TagIndexToFunctionString (above) this function is passed
 * a PA_Tag inside extra, so it can even make the dynamic hook
 * name for UNKNOWN HTML tags.
 */
char *
hk_TagFunctionString(const char *func_name, void *extra)
{
	PA_Tag *tag;
	char *tag_text;
	char *total_name;

	tag_text = NULL;
	tag = (PA_Tag *)extra;

	if ((tag == NULL)||(func_name == NULL))
	{
		return NULL;
	}

	if (tag->type == P_TEXT)
	{
		tag_text = XP_STRDUP("TEXT");
	}
	else if (tag->type == P_UNKNOWN)
	{
		char *tptr;
		int32 cnt;

		tptr = (char *)tag->data;
		cnt = 0;
		while ((*tptr != '>')&&(!XP_IS_SPACE(*tptr))&&
			(cnt < tag->data_len))
		{
			tptr++;
			cnt++;
		}
		if ((cnt > 0)&&(cnt < tag->data_len))
		{
			char tchar;

			tchar = *tptr;
			*tptr = '\0';
			tag_text = XP_STRDUP((char *)tag->data);
			*tptr = tchar;
		}
		else
		{
			tag_text = XP_STRDUP("UNKNOWN");
		}
	}
	else
	{
		const char *tag_name;

		tag_name = PA_TagString((int32)tag->type);
		if (tag_name == NULL)
		{
			tag_text = XP_STRDUP("UNKNOWN");
		}
		else
		{
			tag_text = XP_STRDUP(tag_name);
		}
	}

	if (tag_text != NULL)
	{
		int32 total_len;

		total_len = XP_STRLEN(func_name) + XP_STRLEN(tag_text) + 3;
		total_name = XP_ALLOC(total_len);
		if (total_name == NULL)
		{
			XP_FREE(tag_text);
			return NULL;
		}
		XP_STRCPY(total_name, tag_text);
		XP_STRCAT(total_name, func_name);

		return total_name;
	}
	else
	{
		return NULL;
	}
}
Ejemplo n.º 13
0
int XFE_ComposeAttachFolderView::addAttachments(const char **items,int numItems,int pre_existing,Boolean attach_binary)
{
    // lock out addition of existing attachments after first time through
    _addedExistingAttachments=TRUE;
    
    // abort if attachment adding or delivery is in progress
    // (and not adding pre_exisiting attachments)
    if (!pre_existing && !verifySafeToAttach())
        return FALSE;

    if (!items || numItems==0)
        return FALSE;

    int addStatus=FALSE;
    
    // desired type is NULL == as-is (used to read from format toggle buttons.)
    char *desiredType=NULL;

    // if an icon has focus, restore it when we remap the pane
    Widget focusWidget=XmGetFocusWidget(getBaseWidget());
    if (focusWidget && XtParent(focusWidget)!=_attachPanel->pane())
        focusWidget=NULL;
    
    _attachPanel->unmapPane();
    for (int i=0;i<numItems;i++) {
        // is there space in the list?
        if (_numAttachments>=_maxAttachments) {
            char *msg=PR_smprintf(XP_GetString(XFE_MN_TOO_MANY_ATTACHMENTS));
            if (msg) {
                fe_Alert_2(getBaseWidget(),msg);
                XP_FREE(msg);
            }
            break;
        }

        // is the item already attached?
        int duplicate=FALSE;
        for (int j=0;j<_numAttachments;j++) {
            if (strcmp(items[i],_attachments[j].url)==0) {
                char *msg=PR_smprintf(XP_GetString(XFE_MN_ITEM_ALREADY_ATTACHED),items[i]);
                if (msg) {
                    fe_Alert_2(getBaseWidget(),msg);
                    XP_FREE(msg);
                }
                duplicate=TRUE;
                break;
            }
        }
        if (duplicate)
            continue;

        // nyi - hack "addbook:add?vcard=" URL to be vcard data, and accept as attachment
        // (then turn back on dragging of addbook:add URL's in XFE_HTMLDrag)
        // WinFE does this already.

        // is it a valid attachment?
        if ((!pre_existing) && (!validateAttachment(getBaseWidget(),items[i])))
            continue;

        // at least one attachment was accepted, return success status
        addStatus=TRUE;
        
        // add to internal attachment list
        struct MSG_AttachmentData m = { 0 };
        m.url=XP_STRDUP(items[i]);
        m.desired_type=desiredType;
        if (attach_binary)
            m.real_type= "application/octet-stream";
        else if (IsWebJumper(m.url))
            m.real_type= "text/webjumper";
        else
            m.real_type=NULL;
        _attachments[_numAttachments]=m;
        _numAttachments++;

        char *itemLabel=parseItemLabel(items[i]);
        
        // add icon to attachment panel
        _attachPanel->addItem(items[i],itemLabel);
        XP_FREE(itemLabel);
    }

    // always select last-added item
    if (addStatus && _attachPanel->numItems()>0) {
        _attachPanel->selectItem(_attachPanel->items()[_attachPanel->numItems()-1]);
        if (!pre_existing) {
            focusWidget=_attachPanel->items()[_attachPanel->numItems()-1]->image();
        }
    }
    
    // update attachment panel
    _attachPanel->updateDisplay();
    _attachPanel->mapPane();

    // restore focus if we had it before the unmapPane()
    if (focusWidget)
        XmProcessTraversal(focusWidget,XmTRAVERSE_CURRENT);

    // update internal attachment list, if not adding pre-exisiting attachments
    if (addStatus && !pre_existing)
        updateAttachments();    

    // pop attachment folder to top, if not adding pre-exisiting attachments
    if (!pre_existing) {
        getParent()->doCommand(xfeCmdViewAttachments);
    }

    return addStatus;
}
Ejemplo n.º 14
0
/* this is the main converter for external viewers.
 * it returns the stream object as well
 * as a data object that it can reference 
 * internally to save the state of the document
 */
NET_StreamClass *external_viewer_disk_stream(int iFormatOut, void *pDataObj, URL_Struct *pUrl, MWContext *pContext)	
{
    ASSERT(pUrl);
    ASSERT(pUrl->address);

	//	Lookup the helper app, if one exists.
	//	If not found, create one on the fly.
	CNetscapeApp *pNetscape = (CNetscapeApp *)AfxGetApp();
	CHelperApp *pHelper;
	XP_Bool isNewHelper = FALSE;

	if(0 == pNetscape->m_HelperListByType.Lookup(pUrl->content_type, (CObject *&)pHelper))	{
		//	couldn't find one.
		//	create the new mime type.
		CString csText = pUrl->content_type;

		//	If there's no slash, just send the type as the file type
		//		(this usually only happens on server error, but we
		//		should still behave ourselves).
		int iSlash = csText.Find('/');
		if(iSlash != -1)	{
			// this mess splits the string into the stuff before the slash and
			//   the stuff after the slash
			pHelper = fe_AddNewFileFormatType(csText.Left(iSlash),
				csText.Right(csText.GetLength() - iSlash - 1));
			isNewHelper = TRUE;
		}
		else	{
			pHelper = fe_AddNewFileFormatType(csText, "");
			isNewHelper = TRUE;
		}
	}

	//	The helper app is now defined for the mime type in any case.
	//	See how it is to be handled.
	BOOL bExternal = FALSE;
	BOOL bSave = FALSE;
	BOOL bMoreInfo = FALSE;

	switch(pHelper->how_handle)	{
	case HANDLE_UNKNOWN:	{
		//	See what this is supposed to do via user input.
		CUnknownTypeDlg dlgUnknown(GetFrame(pContext)->GetFrameWnd(), pUrl->content_type, pHelper);
		int iDlg = dlgUnknown.DoModal();
		if(iDlg == IDCANCEL)	{
			//	User hit cancel.  Abort the load.
			if (pHelper && pHelper->cd_item && isNewHelper) {
				if (XP_ListRemoveObject(cinfo_MasterListPointer(), pHelper->cd_item)) {
					if (pHelper->cd_item) {
						if (pHelper->cd_item->ci.type) {
							theApp.m_HelperListByType.RemoveKey(pHelper->cd_item->ci.type);
							XP_FREE( pHelper->cd_item->ci.type );
						}
						XP_FREE (pHelper->cd_item);
					}
					delete pHelper;
				}
			}
			return(NULL);
		}
		else if(iDlg == HANDLE_EXTERNAL)	{
            char buf[256];

			bExternal = TRUE;

			// We need to indicate that this is a user-defined MIME type. If we
			// don't, then we won't remember it the next time the Navigator is run
            sprintf(buf,"TYPE%d",theApp.m_iNumTypesInINIFile);
            theApp.m_iNumTypesInINIFile++;
            theApp.WriteProfileString("Viewers", buf, pUrl->content_type);
            pHelper->bNewType = FALSE;

		}
		else if(iDlg == HANDLE_SAVE)	{
			bSave = TRUE;
		}
		else if(iDlg == HANDLE_MOREINFO)	{
			bMoreInfo = TRUE;
		}
		break;
	}
	case HANDLE_EXTERNAL:	
	case HANDLE_BY_OLE: {
		bExternal = TRUE;
		break;
	}
	case HANDLE_SHELLEXECUTE:	{
		bExternal = TRUE;
		break;
	}
	case HANDLE_SAVE:	{
		bSave = TRUE;
		break;
	}
	default:	{
		//	Shouldn't ever be other than the above types at this
		//		point!
		ASSERT(0);
		return(NULL);
	}
	}

	//	We know that we are either saving or spawning an external
	//		viewer at this point.
	NET_StreamClass *pRetval = NULL;
	if (bSave == TRUE)	{
		return ExternalFileSave(iFormatOut, pUrl, pContext);
	} else if (bExternal == TRUE)	{
		//	Prompt the user for a file name.
		//  Security rist to let path information in externally provided
		//      filename (content disposition, filename =)
		// XXX This code could be cleaned up -- eliminate aFileName 
		// and just use what was allocated by WH_TempFileName.

		char aFileName[_MAX_PATH];
		char *pSuggestedName = NULL;
		BOOL bUseContentName = FALSE;
        if (pUrl->content_name != NULL &&
            strstr(pUrl->content_name, "../") == NULL &&
            strstr(pUrl->content_name, "..\\") == NULL) {
			bUseContentName = TRUE;
		}
		else {
			pSuggestedName = fe_URLtoLocalName(pUrl->address, pUrl->content_type);
		}
		char *pDestination;

		ASSERT(pNetscape->m_pTempDir);
		if(pNetscape->m_pTempDir != NULL && pSuggestedName != NULL)	{
			sprintf(aFileName, "%s\\%s", pNetscape->m_pTempDir, pSuggestedName);
			XP_FREE(pSuggestedName);
			pSuggestedName = NULL;
			pDestination = aFileName;
		}
		else	{
            char aExt[_MAX_EXT];
            size_t stExt = 0;
            DWORD dwFlags = 0;
            const char *pName = pUrl->address;
            
            if(bUseContentName) {
                pName = pUrl->content_name;
            }
#ifdef XP_WIN16
            dwFlags |= EXT_DOT_THREE;
#endif
            aExt[0] = '\0';
            stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pName, pUrl->content_type);
            char *pTemp = WH_TempFileName(xpTemporary, "M", aExt);
            if(pTemp) {
                strcpy(aFileName, pTemp);
                XP_FREE(pTemp);
                pTemp = NULL;
            }
            else {
                aFileName[0] = '\0';
            }
		}
		pDestination = aFileName;


		//	Figure out the application that we'll be spawning.
		//	Strip off odd things at the right hand side.
		CString csCommand;
        if(pHelper->how_handle == HANDLE_EXTERNAL)  {
            csCommand = pHelper->csCmd;
		    int iStrip = csCommand.ReverseFind('%');
		    if(iStrip > 0)	{
			    csCommand = csCommand.Left(iStrip - 1);
		    }
        }

		//	See if it's actually OK to spawn this application.
        CString csSpawn = csCommand;
        BOOL bShellExecute = FALSE;
        if(pHelper->how_handle == HANDLE_SHELLEXECUTE ||
			pHelper->how_handle == HANDLE_BY_OLE) {
            //  Shell execute type, figure out the exe.
            char aExe[_MAX_PATH];
            memset(aExe, 0, sizeof(aExe));
            if(FEU_FindExecutable(pDestination, aExe, FALSE)) {
                csSpawn = aExe;
                if(pHelper->how_handle == HANDLE_SHELLEXECUTE) {
                    bShellExecute = TRUE;
                }
            }
            else     {
                csSpawn.Empty();
            }
        }

		// See whether the user wants to be prompted before we open the file
		if (pContext->type != MWContextPrint && theApp.m_pSpawn->PromptBeforeOpening((LPCSTR)csSpawn)) {
			BOOL	bFree = FALSE;
			LPCSTR	lpszFilename = NULL;

			if (pUrl->content_name != NULL &&
				strstr(pUrl->content_name, "../") == NULL &&
				strstr(pUrl->content_name, "..\\") == NULL) {
				lpszFilename = pUrl->content_name;
			}

			if (!lpszFilename) {
				lpszFilename = fe_URLtoLocalName(pUrl->address, pUrl->content_type);
				bFree = TRUE;
			}
			char* docExt[1];
			const char * ptr1 = lpszFilename;
			int type = NET_URL_Type(pUrl->address);
			BOOL canHandleOLE = FALSE;

			if ((type != MAILBOX_TYPE_URL) && (type !=NEWS_TYPE_URL) && (type != IMAP_TYPE_URL) ) {
				docExt[0] = FE_FindFileExt((char*)ptr1);
				if (docExt[0])
					canHandleOLE = fe_CanHandleByOLE(docExt, 1);
			}
			CLaunchHelper	dlg(lpszFilename, (LPCSTR)csSpawn, canHandleOLE, GetFrame(pContext)->GetFrameWnd());
	
			if (bFree)
				XP_FREE((LPVOID)lpszFilename);

			// Initialize the dialog to some defaults.
			dlg.m_bAlwaysAsk = TRUE;
			//dlg.m_nAction = HELPER_SAVE_TO_DISK; //Old statement CRN_MIME
			dlg.m_nAction = (pHelper->how_handle == HANDLE_SHELLEXECUTE) ? HELPER_OPEN_IT : HELPER_SAVE_TO_DISK; //New Statement. Set m_nAction based on pHelper->how_handle... CRN_MIME
			dlg.m_bHandleByOLE = fe_IsHandleByOLE(pUrl->content_type);
	
			// Ask the user
			if (dlg.DoModal() == IDCANCEL)
				return NULL;
	
			// See if they no longer want to be asked
			if (!dlg.m_bAlwaysAsk) {
				if (dlg.m_nAction == HELPER_SAVE_TO_DISK) {
					// User wants to just save to disk
					pHelper->how_handle = HANDLE_SAVE;
					pHelper->csCmd = MIME_SAVE;
					pHelper->bChanged = TRUE;
				
				} else {
					ASSERT(dlg.m_nAction == HELPER_OPEN_IT);
					theApp.m_pSpawn->SetPromptBeforeOpening((LPCSTR)csSpawn, FALSE);
				}
			}

			// Check whether the user wants to launch the application or save it
			// do disk
			if (dlg.m_nAction == HELPER_SAVE_TO_DISK)
				return ExternalFileSave(iFormatOut, pUrl, pContext);
			else { // open it case.
				// user want to handle this by OLE.
				if (dlg.m_bHandleByOLE) {
					fe_SetHandleByOLE(pUrl->content_type, pHelper, TRUE);
				}
				// Since mail and new will not be able launch using OLE inplace server, so we should not try to change helper app
				// how_handle here.
				else if (pHelper->how_handle == HANDLE_BY_OLE) {
					fe_SetHandleByOLE(pUrl->content_type, pHelper, FALSE);
				}
			}
		}
		// MWH -- see could we handle this via OLE.
		if ((iFormatOut == FO_PRESENT || iFormatOut == FO_PRINT)  &&
			(pHelper->how_handle == HANDLE_BY_OLE) &&
				FE_FileType(pUrl->address, pUrl->content_type, pUrl->content_encoding)) {

			// can be handle by OLE.
				return OLE_ViewStream(iFormatOut, pDataObj, pUrl,pContext);
		}

		//	It's OK to spawn this application.
		//	Attempt to split it off into a seperate context.
		if(bShellExecute) {
		    pRetval = CSaveCX::ViewUrlObject(pUrl, NULL);
		}
		else {
		    pRetval = CSaveCX::ViewUrlObject(pUrl, csSpawn);
		}
		if(pRetval != NULL)	{
			return(pRetval);
		}
		//	Couldn't split off into a new context.
		//	Handle as was handled before.

		//	We have a destination file name.
		FILE *pSink = XP_FileOpen(pDestination, xpTemporary, "wb");
		if(pSink == NULL)	{
			FE_Alert(pContext, szLoadString(IDS_FAILED_CREATE_TEMP_FILE));
			XP_FREE(pDestination);
			return(NULL);
		}

		//	Create the data object that will be passed along down
		//		the stream.
		DataObject *pMe = new DataObject;
        if(!pMe)
            return(NULL);

		memset(pMe, 0, sizeof(DataObject));
		pMe->how_handle = pHelper->how_handle;
		pMe->fp = pSink;
		pMe->context = pContext;
		pMe->format_out = iFormatOut;
		pMe->filename = pDestination;
		pMe->content_length = pUrl->content_length < 0 ? 0 : pUrl->content_length;
		pMe->cur_loc = 0;
		StrAllocCopy(pMe->address, pUrl->address);
		StrAllocCopy(pMe->format_in, pUrl->content_type);

		//	The spawn command.
        if(pMe->how_handle == HANDLE_EXTERNAL)  {
            pMe->params = XP_STRDUP(pDestination);
        }
        else if(pMe->how_handle == HANDLE_SHELLEXECUTE)    {
		    csCommand += pDestination;
        }
        else if(pMe->how_handle == HANDLE_BY_OLE)    {
		    csCommand += pDestination;
        }
		pMe->command = XP_STRDUP(csCommand);

		//	Progress.
		FE_SetProgressBarPercent(pContext, 0);

		//	Delete the file on exit.
		FE_DeleteFileOnExit(pDestination, pUrl->address);

		//	Set the waiting mode???
		FE_EnableClicking(pContext);

		//	Create the stream.
		pRetval = NET_NewStream("ServeAndView",
                    			disk_stream_write,
                    			disk_stream_complete,
                    			disk_stream_abort,
                    			write_ready,
                    			pMe,
                    			pContext);

	}
	if(bMoreInfo == TRUE)	{
		char * url = NULL;
		PREF_CopyConfigString("internal_url.more_info_plugin.url",&url);
		if (url) {
			CString csUrlAddress = url;
			csUrlAddress += "?";
			csUrlAddress += pUrl->content_type;
			(ABSTRACTCX(pContext))->NormalGetUrl(csUrlAddress, pUrl->address, csUrlAddress);
			XP_FREE(url);
		}
    }

	//	Return the stream that was created.
	return(pRetval);
}
Ejemplo n.º 15
0
static NET_StreamClass *
ExternalFileSave(int iFormatOut, URL_Struct *pUrl, MWContext *pContext)
{
	//
	// While we have a pointer to the original frame window query
	//   for a filename
	//
	char 			*pDestination;
	char 			*pSuggested = NULL;
	NET_StreamClass *pRetval = NULL;

	//	Prompt the user for a file name.
	//  Security rist to let path information in externally provided
	//      filename (content disposition, filename =)
	if (pUrl->content_name != NULL &&
		strstr(pUrl->content_name, "../") == NULL &&
		strstr(pUrl->content_name, "..\\") == NULL) {
		// Make a copy of the name, because that's what fe_URLtoLocalName() does
		// and the code below is going to XP_FREE pSuggested
		pSuggested = XP_STRDUP(pUrl->content_name);
	}
	if (!pSuggested)
		pSuggested = fe_URLtoLocalName(pUrl->address, pUrl->content_type);
#ifdef XP_WIN16
	char dosName[13];
	FE_LongNameToDosName(dosName, pSuggested);
	pDestination = wfe_GetSaveFileName(GetFrame(pContext)->GetFrameWnd()->m_hWnd, szLoadString(IDS_SAVE_AS), dosName, NULL);
#else
	pDestination = wfe_GetSaveFileName(GetFrame(pContext)->GetFrameWnd()->m_hWnd, szLoadString(IDS_SAVE_AS), pSuggested, NULL);
#endif
	if(pSuggested != NULL)	{
		XP_FREE(pSuggested);
	}
	if(pDestination == NULL)	{
		return(NULL);
	}

	//	We're going to be saving this stream.
	//	Check to see if we should attempt to save the file in the
	//		old fashion, or in the new external contexts.
	if(NET_IsSafeForNewContext(pUrl) != FALSE)	{
		//	Attempt to split it off into a new context.
		pRetval = CSaveCX::SaveUrlObject(pUrl, NULL, pDestination);

	} else {
		//	We need to continue to use the old method of saving.

		//	We have a destination file name.
		FILE *pSink = XP_FileOpen(pDestination, xpTemporary, "wb");
		if(pSink == NULL)	{
			FE_Alert(pContext, szLoadString(IDS_FAILED_CREATE_TEMP_FILE));
			XP_FREE(pDestination);
			return(NULL);
		}

		//	Create the data object that will be passed along down
		//		the stream.
		DataObject *pMe = new DataObject;
		if(!pMe)
			return(NULL);

		memset(pMe, 0, sizeof(DataObject));
		pMe->how_handle = HANDLE_SAVE;
		pMe->fp = pSink;
		pMe->context = pContext;
		pMe->format_out = iFormatOut;
		pMe->filename = pDestination;
		pMe->content_length = pUrl->content_length < 0 ? 0 : pUrl->content_length;
		pMe->cur_loc = 0;
		StrAllocCopy(pMe->address, pUrl->address);
		StrAllocCopy(pMe->format_in, pUrl->content_type);

		//	Progress.
		FE_SetProgressBarPercent(pContext, 0);

		//	Set the waiting mode???
		FE_EnableClicking(pContext);

		//	Create the stream.
		pRetval = NET_NewStream("ServeAndSave",
								disk_stream_write,
								disk_stream_complete,
								disk_stream_abort,
								write_ready,
								pMe,
								pContext);

		if(!pRetval)
			return(NULL);
	}

	return pRetval;
}
Ejemplo n.º 16
0
/*
 * Take a header and children packed in a block the way hot_write_Header 
 * packs it.  Return the new header item if we created one
 */
PRIVATE HotlistStruct *
hot_read_Header(char * buffer, HotlistStruct * pListParent, HotlistStruct * item, int bLongFormat, int32 * lBytesEaten)
{

    int32 kids = 0;
    int16 sVal;
    HotlistStruct * new_item = NULL;

    if(!buffer)
        return(NULL);

    /* can only read long format headers */
    if(bLongFormat) {                 

        int32 addition;

        /* get the name */
        char * name = buffer;
        char * ptr = strchr(name, '\n');
        char * description = NULL;
        if(!ptr)
            return(NULL);

        /* skip over the \n but change it to a \0 so strcpy() will work */
        *ptr++ = '\0';

        /* addition date */
        XP_MEMCPY(&addition, ptr, 4);
        ptr += 4;

        /* number of children to read */
        XP_MEMCPY(&kids, ptr, 4);
        ptr += 4;

        /* get the description (it should be NULL terminated) */
        description = ptr;

        /* we should really strip leading whitespace */
        new_item = HOT_CreateEntry(HOT_HeaderType, name, NULL, 0, 0);
        new_item->addition_date = addition;
        new_item->description = XP_STRDUP(description);
        *lBytesEaten = XP_STRLEN(description) + (description - buffer) + 1;

        /* handle all of the kids now */
        if(kids) {

            int i;
            HotlistStruct * kid = NULL;

            new_item->children = XP_ListNew();
            buffer += *lBytesEaten;

            for(i = 0; i < kids; i++) {

                int32 lEat;

                /* determine the type of the next entry */
                sVal = 0;
                XP_MEMCPY(&sVal, buffer, 2);
                buffer += 2;
                *lBytesEaten += 2;

                switch(sVal) {
                case HOT_URLType:
                    kid = hot_read_URL(buffer, new_item, kid, bLongFormat, &lEat);
                    *lBytesEaten += lEat;
                    buffer += lEat;
                    break;
                case HOT_HeaderType:
                    kid = hot_read_Header(buffer, new_item, kid, bLongFormat, &lEat);
                    *lBytesEaten += lEat;
                    buffer += lEat;
                    break;
                case HOT_SeparatorType:
                    kid = hot_read_Separator(buffer, new_item, kid, bLongFormat, &lEat);
                    *lBytesEaten += lEat;
                    buffer += lEat;
                    break;
                default:
                    /* bogus type.  Who knows whats going on.  Just quit and get out */
                    break;
                }
            
            }        

        } else {

            /* no kids */
            new_item->children = NULL;

        }

    }

    if(item)
        HOT_InsertItemAfter(item, new_item);
    else
        HOT_InsertItemInHeaderOrAfterItem(pListParent, new_item);
        
    return(new_item);
               
}
Ejemplo n.º 17
0
/*
 * Take a URL packed in a block the way hot_write_URL packs it.
 * Return the new item if we created one
 */
PRIVATE HotlistStruct *
hot_read_URL(char * buffer, HotlistStruct * pListParent, HotlistStruct * item, int bLongFormat, int32 * lBytesEaten)
{

    HotlistStruct * new_item = NULL;

    if(!buffer)
        return(NULL);
                              
    if(bLongFormat) {                 

        int32 addition, visit;

        /* get the name */
        char * name = buffer;
        char * address = strchr(name, '\n');
        char * description = NULL;
        char * ptr;
        if(!address)
            return(NULL);

        *address++ = '\0';

        /* get the address */
        ptr = strchr(address, '\n');
        if(!ptr)
            return(NULL);

        *ptr++ = '\0';

        /* addition date */
        XP_MEMCPY(&addition, ptr, 4);
        ptr += 4;

        /* visiting date */
        XP_MEMCPY(&visit, ptr, 4);
        ptr += 4;

        /* get the description (it should be NULL terminated) */
        description = ptr;

        /* we should really strip leading whitespace */
        new_item = HOT_CreateEntry(HOT_URLType, name, address, 0, visit);
        new_item->addition_date = addition;
        new_item->description = XP_STRDUP(description);
        *lBytesEaten = XP_STRLEN(description) + (description - buffer) + 1;

    } else {

        char * end = strchr(buffer, '\n');

        /* if there was a return NULL terminate the current string */
        if(end)
            *end++ = '\0';

        /* we should really strip leading whitespace */
        new_item = HOT_CreateEntry(HOT_URLType, buffer, buffer, 0, 0);
        new_item->addition_date = time ((time_t *) NULL);
        *lBytesEaten = XP_STRLEN(buffer) + 1;

    }

    if(item)
        HOT_InsertItemAfter(item, new_item);
    else
        HOT_InsertItemInHeaderOrAfterItem(pListParent, new_item);
        
    return(new_item);
               
}
Ejemplo n.º 18
0
void XFE_ABNameGenTabView::getDlgValues()
{
#if defined(DEBUG_tao_)
	printf("\n XFE_ABNameGenTabView::getDlgValues \n");
#endif
  XFE_ABNameFolderDlg *dlg = (XFE_ABNameFolderDlg *)getToplevel();
#if defined(USE_ABCOM)
  XFE_PropertySheetView *folderView = (XFE_PropertySheetView *) getParent();
  MSG_Pane *pane = folderView->getPane();

  uint16 numItems = AB_LAST+1;
  AB_AttributeValue *values = 
	  (AB_AttributeValue *) XP_CALLOC(numItems, 
									  sizeof(AB_AttributeValue));
  char *tmp = NULL;

  //
  tmp = fe_GetTextField(m_textFs[AB_FIRST_NAME]);
  values[AB_FIRST_NAME].attrib = AB_attribGivenName;
  if (tmp && strlen(tmp))
	  values[AB_FIRST_NAME].u.string = tmp;
  else
	  values[AB_FIRST_NAME].u.string = XP_STRDUP("");

  //
  tmp = fe_GetTextField(m_textFs[AB_LAST_NAME]);
  values[AB_LAST_NAME].attrib = AB_attribFamilyName;
  if (tmp && strlen(tmp))
	  values[AB_LAST_NAME].u.string = tmp;
  else
	  values[AB_LAST_NAME].u.string = XP_STRDUP("");

  // AB_attribInfo
  tmp = fe_GetTextField(m_notesTxt);
  values[AB_DISPLAY_NAME].attrib = AB_attribInfo;
  if (tmp && strlen(tmp))
	  values[AB_DISPLAY_NAME].u.string = tmp;
  else
	  values[AB_DISPLAY_NAME].u.string = XP_STRDUP("");

  //
  tmp = fe_GetTextField(m_textFs[AB_EMAIL]);
  values[AB_EMAIL].attrib = AB_attribEmailAddress;
  if (tmp && strlen(tmp))
	  values[AB_EMAIL].u.string = tmp;
  else
	  values[AB_EMAIL].u.string = XP_STRDUP("");

  //
  tmp = fe_GetTextField(m_textFs[AB_NICKNAME]);
  values[AB_NICKNAME].attrib = AB_attribNickName;
  if (tmp && strlen(tmp))
	  values[AB_NICKNAME].u.string = tmp;
  else
	  values[AB_NICKNAME].u.string = XP_STRDUP("");

  //
  tmp = fe_GetTextField(m_textFs[AB_TITLE]);
  values[AB_TITLE].attrib = AB_attribTitle;
  if (tmp && strlen(tmp))
	  values[AB_TITLE].u.string = tmp;
  else
	  values[AB_TITLE].u.string = XP_STRDUP("");

  //
  tmp = fe_GetTextField(m_textFs[AB_COMPANY_NAME]);
  values[AB_COMPANY_NAME].attrib = AB_attribCompanyName;
  if (tmp && strlen(tmp))
	  values[AB_COMPANY_NAME].u.string = tmp;
  else
	  values[AB_COMPANY_NAME].u.string = XP_STRDUP("");

  //
  values[AB_LAST].u.boolValue = XmToggleButtonGetState(m_prefHTMLTog);
  values[AB_LAST].attrib = AB_attribHTMLMail;

  //set values 
  int error = AB_SetPersonEntryAttributes(pane, 
										  values, 
										  numItems);
  AB_FreeEntryAttributeValues(values, numItems);

#else
  PersonEntry& entry = dlg->getPersonEntry();

  /* setting up the defaults 
   */
  char *tmp;

  tmp = fe_GetTextField(m_textFs[AB_NICKNAME]);
  if (tmp && strlen(tmp))
	  entry.pNickName = tmp;
  else
	  entry.pNickName = XP_STRDUP("");

  tmp = fe_GetTextField(m_textFs[AB_FIRST_NAME]);
  if (tmp && strlen(tmp))
	  entry.pGivenName = tmp;
  else
	  entry.pGivenName = XP_STRDUP("");

  tmp = fe_GetTextField(m_textFs[AB_LAST_NAME]);
  if (tmp && strlen(tmp))
	  entry.pFamilyName = tmp;
  else
	  entry.pFamilyName = XP_STRDUP("");

  tmp = fe_GetTextField(m_textFs[AB_COMPANY_NAME]);
  if (tmp && strlen(tmp))
	  entry.pCompanyName = tmp;
  else
	  entry.pCompanyName = XP_STRDUP("");

  tmp = fe_GetTextField(m_textFs[AB_TITLE]);
  if (tmp && strlen(tmp))
	  entry.pTitle = tmp;
  else
	  entry.pTitle = XP_STRDUP("");

  tmp = fe_GetTextField(m_textFs[AB_EMAIL]);
  if (tmp && strlen(tmp))
	  entry.pEmailAddress = 
		  fe_GetTextField(m_textFs[AB_EMAIL]);
  else
	  entry.pEmailAddress = XP_STRDUP("");

  tmp = fe_GetTextField(m_notesTxt);
  if (tmp && strlen(tmp))
	  entry.pInfo = tmp;
  else
	  entry.pInfo = XP_STRDUP("");

  entry.HTMLmail = XmToggleButtonGetState(m_prefHTMLTog);
#endif /* USE_ABCOM */

  // set title
  if (tmp = dlg->getFullname()) {
	  char tmp2[AB_MAX_STRLEN];
	  XP_SAFE_SPRINTF(tmp2, sizeof(tmp2),
					  XP_GetString(XFE_AB_NAME_CARD_FOR),
					  tmp);
	  dlg->setCardName(tmp2);
	  XP_FREE((char *) tmp);
  }/* if */
  else 
	  dlg->setCardName(XP_GetString(XFE_AB_NAME_NEW_CARD));
}
Ejemplo n.º 19
0
void
lo_ProcessScriptTag(MWContext *context, lo_DocState *state, PA_Tag *tag, JSObject *obj)
{
    lo_TopState *top_state;
    pa_DocData *doc_data;
    XP_Bool type_explicitly_set=FALSE;
    XP_Bool saw_archive=FALSE;
#ifdef DEBUG_ScriptPlugin
	char * mimebuf = NULL;
#endif

    top_state = state->top_state;
    doc_data = (pa_DocData *)top_state->doc_data;
    XP_ASSERT(doc_data != NULL || state->in_relayout || tag->lo_data);

    if (tag->is_end == FALSE) {
        PA_Block buff;
        char *str, *url, *archiveSrc, *id, *codebase;

        /* Controversial default language value. */
        top_state->version = JSVERSION_DEFAULT;
        if (tag->type == P_STYLE || tag->type == P_LINK) {
            top_state->in_script = top_state->default_style_script_type;
        }
        else {
            /* in order to get old script behaviour, pretend
             * that the content-type is explicitly set for all scripts
             */
            type_explicitly_set = TRUE;
            top_state->in_script = SCRIPT_TYPE_MOCHA;
        }

        /* XXX account for HTML comment bytes and  "lost" newlines */
        if (lo_IsAnyCurrentAncestorSourced(state))
            top_state->script_bytes = top_state->layout_bytes;
        else
            top_state->script_bytes = top_state->layout_bytes - tag->true_len;
        if (tag->lo_data != NULL) {
            top_state->script_bytes += (int32)tag->lo_data - 1;
            tag->lo_data = NULL;
        } 
        else if (doc_data != NULL) {
            top_state->script_bytes += doc_data->comment_bytes;
        } 
        else {
            XP_ASSERT(state->in_relayout);
        }

	lo_ParseScriptLanguage(context, tag, &top_state->in_script,
			       &top_state->version);
#ifdef DEBUG_ScriptPlugin
		if (top_state->in_script == SCRIPT_TYPE_UNKNOWN)
		{
			mimebuf = npl_Script2mimeType(context,tag);
			if (mimebuf){
				if (NPL_FindPluginEnabledForType(mimebuf)){
					top_state->in_script = SCRIPT_TYPE_PLUGIN;
					XP_ASSERT(top_state->mimetype == NULL);
					StrAllocCopy((char *)top_state->mimetype,mimebuf);
					XP_FREE(mimebuf);
					mimebuf = NULL;
				}
				else{
					XP_FREE(mimebuf);
					mimebuf = NULL;
				}
			}
		}
#endif /* DEBUG_ScriptPlugin */

        buff = lo_FetchParamValue(context, tag, PARAM_TYPE);
        if (buff != NULL) {
            PA_LOCK(str, char *, buff);
            if ((XP_STRCASECMP(str, js_content_type) == 0) ||
                (!XP_STRCASECMP(str, "text/javascript"))) {
		if(tag->type == P_STYLE || tag->type == P_LINK)
		{
		    top_state->in_script = SCRIPT_TYPE_JSSS;
		    top_state->default_style_script_type = SCRIPT_TYPE_JSSS;
		}
		else
		{
		    top_state->in_script = SCRIPT_TYPE_MOCHA;                    
		}
                type_explicitly_set = TRUE;
            } 
            else if ((XP_STRCASECMP(str, TEXT_CSS) == 0)) {
                top_state->in_script = SCRIPT_TYPE_CSS;
                top_state->default_style_script_type = SCRIPT_TYPE_CSS;
                type_explicitly_set = TRUE;
            } 
            else {
                top_state->in_script = SCRIPT_TYPE_UNKNOWN;
                top_state->default_style_script_type = SCRIPT_TYPE_UNKNOWN;
            }
            PA_UNLOCK(buff);
            PA_FREE(buff);
        } 

	/* check for media=screen
	 * don't load the style sheet if there 
	 * is a media not equal to screen
	 */
	buff = lo_FetchParamValue(context, tag, PARAM_MEDIA);
	if (buff) {
	    if (strcasecomp((char*)buff, "screen")) {
		/* set the script type to UNKNOWN
		 * so that it will get thrown away
		 */
		top_state->in_script = SCRIPT_TYPE_UNKNOWN;
	    }
	    PA_FREE(buff);
	}

        /*
         * Flush the line buffer so we can start storing Mocha script
         * source lines in there.
         */
        lo_FlushLineBuffer(context, state);

        url = archiveSrc = id = codebase = NULL;
        if (top_state->in_script != SCRIPT_TYPE_NOT) {
            /*
             * Check for the archive parameter for known languages.
             */
            buff = lo_FetchParamValue(context, tag, PARAM_ARCHIVE);
            if (buff != NULL) {
                saw_archive = TRUE;
                PA_LOCK(str, char *, buff);
                url = NET_MakeAbsoluteURL(top_state->base_url, str);
                PA_UNLOCK(buff);
                PA_FREE(buff);
		if (url == NULL) {
                    top_state->out_of_memory = TRUE;
                    return;
		}
            }

            /* 
             * Look for ID attribute. If it's there we have may have
             * an inline signed script.
             */
            buff = lo_FetchParamValue(context, tag, PARAM_ID);
            if (buff != NULL) {
                PA_LOCK(str, char *, buff);
                StrAllocCopy(id, str);
                PA_UNLOCK(buff);
                PA_FREE(buff);
		if (id == NULL) {
                    top_state->out_of_memory = TRUE;
		    XP_FREEIF(url);
                    return;
		}
            }

            /*
             * Now look for a SRC="url" attribute for known languages.
             * If found, synchronously load the url.
             */
	    buff = lo_FetchParamValue(context, tag, PARAM_SRC);  /* XXX overloaded rv */
            if (buff != NULL) {
		XP_Bool allowFileSrc = FALSE;
                char *absUrl;

                PA_LOCK(str, char *, buff);

		PREF_GetBoolPref(lo_jsAllowFileSrcFromNonFile, &allowFileSrc);
                absUrl = NET_MakeAbsoluteURL(top_state->base_url, str);
		if (absUrl == NULL) {
		    top_state->out_of_memory = TRUE;
		    XP_FREEIF(id);
                } else if (allowFileSrc == FALSE &&
		           NET_URL_Type(absUrl) == FILE_TYPE_URL &&
		           NET_URL_Type(top_state->url) != FILE_TYPE_URL) {
		    /*
		     * Deny access from http: to file: via SCRIPT SRC=...
		     * XXX silently
		     */
                    top_state->in_script = SCRIPT_TYPE_UNKNOWN;
                    XP_FREE(absUrl);
                    XP_FREEIF(url);
		    XP_FREEIF(id);
		} else if (url != NULL) {
                    XP_FREE(absUrl);
                    StrAllocCopy(archiveSrc, str);
		    if (archiveSrc == NULL) {
			top_state->out_of_memory = TRUE;
			XP_FREE(url);
			XP_FREEIF(id);
		    }
                } else {
                    url = absUrl;
                }
                PA_UNLOCK(buff);
                PA_FREE(buff);
		if (top_state->out_of_memory)
		    return;

                /*
                 * If we are doing a <script src=""> mocha script but JS
                 *   is turned off just ignore the tag
                 */
		if (!LM_CanDoJS(context)) {
                    top_state->in_script = SCRIPT_TYPE_UNKNOWN;
                    XP_FREE(url);
		    XP_FREEIF(id);
		    XP_FREEIF(archiveSrc);
                    return;
                }
            }
        }

        /*
         * Set text_divert so we know to accumulate text in line_buf
         * without interpretation.
         */
        state->text_divert = tag->type;

        /*
         * XXX need to stack these to handle blocked SCRIPT tags
         */
        top_state->script_lineno = tag->newline_count + 1;

        /* if we got here as a result of a LINK tag
         * check to make sure rel=stylesheet and then
         * check for an HREF and if one does not exist
         * fail
         */
        if (tag->type == P_LINK) {
            char *cbuff = (char*)lo_FetchParamValue(context, tag, PARAM_REL);
                        
            if (cbuff && !strcasecomp(cbuff, "stylesheet")) {
                XP_FREE(cbuff);

                cbuff = (char*)lo_FetchParamValue(context, tag, PARAM_HREF);

                if (cbuff) {
                    if (saw_archive && url) {
                        archiveSrc = XP_STRDUP(cbuff);
                    } else {
		        XP_FREEIF(url);
                        url = NET_MakeAbsoluteURL(top_state->base_url, cbuff);
                    }
		}
            }

            XP_FREEIF(cbuff);
        }

        if (url != NULL || id != NULL || codebase != NULL) {
            if ((doc_data != NULL) &&
                (state->in_relayout == FALSE) &&
                SCRIPT_EXEC_OK(top_state, state, tag->type, P_SCRIPT)) {
                ScriptData *data;

                data = XP_ALLOC(sizeof(ScriptData));
                if (data == NULL) {
                    top_state->out_of_memory = TRUE;
                    return;
                }
                data->context = context;
                data->state = state;
                data->tag = PA_CloneMDLTag(tag);
                if (data->tag == NULL) {
                    top_state->out_of_memory = TRUE;
		    XP_FREE(data);
                    return;
                }
                data->url = url;
                data->archiveSrc = archiveSrc;
                data->id = id;
                if (codebase == NULL) {
                    StrAllocCopy(codebase, top_state->base_url);
                }
                data->codebase = codebase;
                data->buffer = NULL;
                data->bufferSize = 0;
                data->version = top_state->version;

		/*
		 * Only SCRIPT ARCHIVE= ID= without SRC= is an inline signed
		 * script -- if there is a SRC= attribute, archiveSrc will be
		 * non-null.
		 */
                data->inlineSigned = (JSBool)
		    (url != NULL && archiveSrc == NULL && id != NULL);

                /* Reset version accumulator */
                top_state->version = JSVERSION_UNKNOWN;

                XP_ASSERT (tag->type == P_SCRIPT || tag->type == P_STYLE || 
			   tag->type == P_LINK);

	        /* 
		 * Out-of-line included (by src=) or inline signed script.
		 * Save continuatation data on top_state.  If it's signed,
		 * we'll verify the signature once we see </script> and
		 * have the inline script to verify.
		 */
		top_state->scriptData = data;

            } 
	    else {
                XP_FREE(url);
		XP_FREEIF(id);
		XP_FREEIF(archiveSrc);
            }
        }
    } 
    else {

	/*
	 * We are in the </script> tag now...
	 */

        size_t line_buf_len;
        intn script_type;
        char *scope_to=NULL;
        char *untransformed = NULL;

        script_type = top_state->in_script;
        top_state->in_script = SCRIPT_TYPE_NOT;

	/* guard against superfluous end tags */
	if (script_type == SCRIPT_TYPE_NOT)
	    goto end_tag_out;

	/* convert from CSS to JavaScript here */
        if (tag->type != P_LINK && script_type == SCRIPT_TYPE_CSS) {
            char *new_buffer;
            int32 new_buffer_length;

            CSS_ConvertToJS((char *)state->line_buf, 
                            state->line_buf_len,
                            &new_buffer,
                            &new_buffer_length);

            if (!new_buffer) {
                /* css translator error, unblock layout and return */
                state->text_divert = P_UNKNOWN;
                state->line_buf_len = 0; /* clear script text */
                goto end_tag_out;
            }

            untransformed = (char *) state->line_buf;
            state->line_buf = (PA_Block) new_buffer;
            state->line_buf_len = new_buffer_length;
            state->line_buf_size = new_buffer_length;

            if (state->line_buf_len)
                state->line_buf_len--; /* hack: subtract one to remove final \n */

            script_type = SCRIPT_TYPE_JSSS;
        }

        if (tag->type == P_STYLE) {
            /* mocha scoped to document == jsss */
            scope_to = "document";
        }

        /*
         * Reset these before potentially recursing indirectly through
         * the document.write() built-in function, which writes to the
         * very same doc_data->parser_stream that this <SCRIPT> tag
         * came in on.
         */
        state->text_divert = P_UNKNOWN;
        line_buf_len = state->line_buf_len;
        state->line_buf_len = 0;

        if (script_type != SCRIPT_TYPE_UNKNOWN && 
	    script_type != SCRIPT_TYPE_NOT) {
            /*
             * If mocha is disabled or can't be done in this context we
             *   are going to just ignore the buffer contents
             */
            if (!LM_CanDoJS(context)) {
				top_state->in_script = SCRIPT_TYPE_UNKNOWN;
                goto end_tag_out;
            }

            if ((doc_data != NULL) &&
                (state->in_relayout == FALSE) &&
                SCRIPT_EXEC_OK(top_state, state, tag->type, P_SCRIPT)) {

                /*
                 * First off, make sure layout is blocking on us
                 */
                if (lo_create_script_blockage(context, state, 
					tag->type == P_SCRIPT ? LO_SCRIPT : LO_UNKNOWN)) 
				{
                    ScriptData *data;

                    /*
                     * Extreme hackery.  Hideous and shameful.  See the comment
						* in lo_BlockScriptTag before similar is_end/overflow code
						* and commence vomiting.
                     */
                    lo_BlockScriptTag(context, state, NULL);

		    if (tag->is_end == (PRPackedBool)1) {
			  PA_PushOverflow(doc_data);
			  doc_data->overflow_depth ++;
		    }

		    /*
		     * Set the document.write tag insertion point.
		     */
             top_state->input_write_point[top_state->input_write_level] = &top_state->tags;

		    data = top_state->scriptData;
                    top_state->scriptData = NULL;
                    if (data && data->url) {
			/*
			 * Three cases:
			 * 1.  SCRIPT SRC=: url non-null
			 * 2.  SCRIPT ARCHIVE= SRC=: url, archiveSrc non-null
			 * 3.  SCRIPT ARCHIVE= ID=: url, id non-null
			 * In the last case, we copy the inline script into
			 * data's buffer and let lo_script_archive_exit_fn do
			 * the eval.  We use an inlineSigned flag to avoid a
			 * bunch of (url != NULL && archiveSrc == NULL && id
			 * != NULL) tests.
			 */
			if (data->inlineSigned) {
                            StrAllocCopy(data->buffer, (char *) state->line_buf);
                            data->bufferSize = line_buf_len;
			}
			lo_GetScriptFromURL(data, script_type);
                    }
		    else {
                        JSPrincipals *principals = NULL;
			ETEvalStuff * stuff;
			
                        if (data) {
			    principals = LM_NewJSPrincipals(NULL, data->id, 
							    data->codebase);
                            if (untransformed &&
				!LM_SetUntransformedSource(principals, 
                                                           untransformed,
                                                           (char *) state->line_buf))
                            {
                                top_state->out_of_memory = TRUE;
                            }
                            lo_DestroyScriptData(data);
			}

                        /* 
                         * send the buffer off to be evaluated 
			 */
#ifdef DEBUG_ScriptPlugin
			 			if (script_type == SCRIPT_TYPE_PLUGIN)
						{
							XP_ASSERT(mimebuf == NULL);
							npl_ScriptPlugin(context, state, tag, line_buf_len,top_state->mimetype);
						    lo_unblock_script_tag(context, TRUE);
						}
						else
#endif /* DEBUG_ScriptPlugin */
 

			stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff);
			if (!stuff)
			    goto end_tag_out;

			stuff->len = line_buf_len;
			stuff->line_no = top_state->script_lineno;
			if (scope_to)
			    stuff->scope_to = XP_STRDUP(scope_to);
			else
			    stuff->scope_to = NULL;
			stuff->want_result = JS_FALSE;
			stuff->data = context;
			stuff->version = top_state->version;
			stuff->principals = principals;

                        ET_EvaluateScript(context, 
                                          (char *) state->line_buf,
					  stuff,
                                          lo_ScriptEvalExitFn);
                    }

                    /* Reset version accumulator */
                    top_state->version = JSVERSION_UNKNOWN;
                }
            }
        }
      end_tag_out:
	/*
	 * If we got a </SCRIPT> and still have scriptData set here, it must
	 *   be left over from an error case above, so we free it.
	 */
	if (top_state->scriptData) {
	    XP_ASSERT(!top_state->layout_blocking_element);
            lo_DestroyScriptData(top_state->scriptData);
	    top_state->scriptData = NULL;
	}
        XP_FREEIF(untransformed);
    }
}
Ejemplo n.º 20
0
void XFE_AddrBookView::abCall()
{
  int count = 0;
  const int *indices = 0;
  m_outliner->getSelection(&indices, &count);
  if (count > 0 && indices) {
#if defined(USE_ABCOM)
#else
	  /* Take the first one 
	   */
	  ABID type;
	  ABID entry;
	  
	  entry = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) indices[0]);
    
	  if (entry == MSG_VIEWINDEXNONE) 
		  return;

	  AB_GetType(m_dir, m_AddrBook, entry, &type);
    
	  /* Select
	   */
	  if (type != ABTypePerson)
		  return;
		  
	  char a_line[AB_MAX_STRLEN];
	  a_line[0] = '\0';
	  
	  char cmdstr[AB_MAX_STRLEN];
	  cmdstr[0] = '\0';
	  char *email= NULL;

	  if ((AB_GetEmailAddress(m_dir, m_AddrBook, entry, a_line) != MSG_VIEWINDEXNONE)&&
		  XP_STRLEN(a_line))
		  email = XP_STRDUP(a_line);
	  else {
		  /* Can not call w/o email
		   */
		  // Prompt the user to enter the email address
		  char tmp[128];
		  XP_SAFE_SPRINTF(tmp, sizeof(tmp),
						  "%s",
						  XP_GetString(MK_MSG_CALL_NEEDS_EMAILADDRESS));
		  fe_Message(m_contextData, tmp);
		  return;
	  }/* else */

	  char *coolAddr = NULL;
	  if (AB_GetCoolAddress(m_dir, m_AddrBook, entry, a_line) != MSG_VIEWINDEXNONE)
		  coolAddr = XP_STRDUP(a_line);

	  short use;
	  if (AB_GetUseServer(m_dir, m_AddrBook, entry, &use) == MSG_VIEWINDEXNONE)
		  /* Can't determine which mode; use default
		   */
		  use = kDefaultDLS;

	  if (email && XP_STRLEN(email))
		  fe_showConference(getBaseWidget(), email, use, coolAddr);
	  else {
		  /* prompt user to enter email address for this person
		   */
			  char tmp[128];
			  XP_SAFE_SPRINTF(tmp, sizeof(tmp),
							  "%s",
							  XP_GetString(MK_MSG_CALL_NEEDS_EMAILADDRESS));
			  fe_Message(m_contextData, tmp);

	  }/* else */
	  if (email)
		  XP_FREE((char *) email);
	  if (coolAddr)
		  XP_FREE((char *) coolAddr);
#endif /* USE_ABCOM */
  }/* if */
}
Ejemplo n.º 21
0
char * SU_GetString(int id) 
{
  char *str = XP_GetString(id);
  PR_ASSERT(str != NULL);
  return XP_STRDUP(str);
}
Ejemplo n.º 22
0
// write temporary files for transferring internal data to desktop
// if application wants files dragged as symbolic links, oblige it, and
// just return a list of file names.
void XFE_URLDesktopType::writeDataFiles(int dragFilesAsLinks)
{
    if (_tmpDirectory!=NULL)
        return;

    if (_numItems==0)
        return;

    if (!dragFilesAsLinks) {
        // if any items need to be written as files, create a tmp directory for them.
        if ((_tmpDirectory=createTmpDirectory())==NULL)
            return;
    }
    
    XDEBUG(printf("XFE_URLDesktopType::writeDataFiles(%s)\n",_tmpDirectory));
    
    
    int i;
    
    // build return list with tmp files or paths as necessary
    for (i=0;i<_numItems; i++) {
        if (_url[i]==NULL || strlen(_url[i])==0)
            _filename[i]=NULL;
        else if (dragFilesAsLinks) {
            XDEBUG(printf("  %s\n",_url[i]));
            
            // Return filename instead of indirecting through a NetscapeURL file
            // cleanupDataFiles() is smart enough not to delete the original file in this case.
            if (strncmp(_url[i],"file:",5)==0 && strlen(_url[i]+5)>0)
                _filename[i]=XP_STRDUP(_url[i]+5);
            else if (strlen(_url[i])>0)
                _filename[i]=XP_STRDUP(_url[i]);
            else
                _filename[i]=NULL;
            
            // strip trailing '/', or IRIX desktop will get confused by directory drop.
            if (_filename[i]) {
                char *lastchar=_filename[i]+strlen(_filename[i])-1;
                if (*lastchar=='/')
                    *lastchar='\0';
            }	    
            XDEBUG(printf("       %s\n",_filename[i]));
        }
        else {
            // create a tmp file containing URL etc. for each item
            char *fname=getFilename(i);
            _filename[i]=(char*)XP_ALLOC(strlen(_tmpDirectory)+1+strlen(fname)+1);
            sprintf(_filename[i],"%s/%s",_tmpDirectory,fname);
            XP_FREE(fname);
            FILE *fp;
            if (fp=fopen(_filename[i],"w")) {
                fprintf(fp,"#NetscapeURL\n\n%s\n",getString());
                fclose(fp);
            }
            else {
                XP_FREE(_filename[i]);
                _filename[i]=NULL;
            }
        }
    }
}
Ejemplo n.º 23
0
void XFE_PrefsLdapPropDialog::cb_ok(Widget    w,
                                    XtPointer closure,
                                    XtPointer callData)
{
    XFE_PrefsLdapPropDialog *theDialog = (XFE_PrefsLdapPropDialog *)closure;
    PrefsDataLdapProp       *fep = theDialog->getData();
    Bool                     create = theDialog->getEditDir() ? False : True;
    DIR_Server              *dir = 0;

    if (create) {
        dir = (DIR_Server *)XP_ALLOC(sizeof(DIR_Server));
        DIR_InitServer(dir);
    }
    else {
        dir = theDialog->getEditDir();
        XP_FREEIF(dir->description);
        XP_FREEIF(dir->serverName);
        XP_FREEIF(dir->searchBase);
        DIR_InitServer(dir);
    }

    char   *desc = 0;
    char   *server = 0;
    char   *root = 0;
    char   *port_num_text = 0;
    char   *num_hits_text = 0;
    char    dummy;
    int     port_num = 0;
    int     num_hits = 0;
    Boolean b;
    char    temp[1024];
    char   *ptr;

    // TODO: error checking

    desc = fe_GetTextField(fep->desc_text);
    server = fe_GetTextField(fep->server_text);
    root = fe_GetTextField(fep->root_text);
    XtVaGetValues(fep->port_number_text, XmNvalue, &port_num_text, 0);
    XtVaGetValues(fep->number_of_hit_text, XmNvalue, &num_hits_text, 0);

    if (1 != sscanf(port_num_text, " %d %c", &port_num, &dummy) ||
            port_num < 0) {
        // TODO: error
    }
    if (port_num_text) XtFree(port_num_text);

    if (1 == sscanf(num_hits_text, " %d %c", &num_hits, &dummy) &&
            num_hits < 0) {
        // TODO: error
    }
    if (num_hits_text) XtFree(num_hits_text);

    if (ptr = XP_STRCHR(server, '.')) {
        XP_STRCPY(temp, ptr+1);
        if (ptr = XP_STRCHR(temp, '.')) {
            *ptr = '\0';
        }
    }
    else {
        XP_STRCPY(temp, server);
    }

    dir->description = desc ? desc : XP_STRDUP("");
    dir->serverName =  server ? server : XP_STRDUP("");
    dir->searchBase =  root ? root : XP_STRDUP("");
    // dir->htmlGateway =  NULL; // no loner use
    dir->fileName = WH_FileName(WH_TempName(xpAddrBook, temp), xpAddrBook);
    dir->port = port_num;
    dir->maxHits = num_hits;
    XtVaGetValues(fep->secure_toggle, XmNset, &b, 0);
    dir->isSecure = b;
#if 0
    XtVaGetValues(fep->save_passwd_toggle, XmNset, &b, 0);
    dir->savePassword = b;
#endif
    dir->dirType = LDAPDirectory;

    // Insert into list if this is create

    if (create) {
        XFE_PrefsPageMailNewsAddrBook *dir_page = theDialog->getAddrBookPage();
        dir_page->insertDir(dir);
    }

    // Simulate a cancel

    theDialog->cb_cancel(w, closure, callData);
}
Ejemplo n.º 24
0
//
// This function will create a composition window and either do
// a blind send or pop up the compose window for the user to 
// complete the operation
//
// Return: appropriate MAPI return code...
//
// 
extern "C" LONG
DoFullMAPIMailOperation(MAPISendMailType      *sendMailPtr,
											  const char            *pInitialText,
                        BOOL                  winShowFlag)
{   
CGenericDoc             *pDocument;
LPSTR                   subject;
NSstringSeq             mailInfoSeq;
DWORD                   stringCount = 6;
DWORD                   i;
CString                 csDefault;

  // Get a context to use for this call...
  MWContext *pOldContext = GetUsableContext();
  if (!pOldContext)
  {
    return(MAPI_E_FAILURE);
  }

  // Don't allow a compose window to be created if the user hasn't 
  // specified an email address
  const char *real_addr = FE_UsersMailAddress();
  if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0)
  {
    return(MAPI_E_FAILURE);
  }

  //
  // Now, we must build the fields object...
  //
  mailInfoSeq = (NSstringSeq) &(sendMailPtr->dataBuf[0]);
  subject = NSStrSeqGet(mailInfoSeq, 0);

  // We should give it a subject to preven the prompt from coming
  // up...
  if ((!subject) || !(*subject))
  {
    csDefault.LoadString(IDS_COMPOSE_DEFAULTNOSUBJECT);
    subject = csDefault.GetBuffer(2);
  }

  TRACE("MAPI: ProcessMAPISendMail() Subject   = [%s]\n", subject);
  TRACE("MAPI: ProcessMAPISendMail() Text Size = [%d]\n", strlen((const char *)pInitialText));
  TRACE("MAPI: ProcessMAPISendMail() # of Recipients  = [%d]\n", sendMailPtr->MSG_nRecipCount);


  char  toString[1024] = "";
  char  ccString[1024] = "";
  char  bccString[1024] = "";

  for (i=0; i<sendMailPtr->MSG_nRecipCount; i++)
  {
    LPSTR   ptr;
    UCHAR   tempString[256];

    ULONG addrType = atoi(NSStrSeqGet(mailInfoSeq, stringCount++));

    // figure which type of address this is?
    if (addrType == MAPI_CC)
      ptr = ccString;
    else if (addrType == MAPI_BCC)
      ptr = bccString;
    else
      ptr = toString;
      
    LPSTR namePtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++);
    LPSTR emailPtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++);
    if ( (lstrlen(emailPtr) > 5) && (*(emailPtr + 4) == ':') )
    {
      emailPtr += 5;
    }

    // Now build the temp string to tack on in the format
    // "Rich Pizzarro" <*****@*****.**>
    wsprintf((LPSTR) tempString, "\"%s\" <%s>", namePtr, emailPtr);

    // add a comma if not the first one
    if (ptr[0] != '\0')
      lstrcat(ptr, ",");

    // tack on string!
    lstrcat(ptr, (LPSTR) tempString);
  }

  BOOL    bEncrypt = FALSE;
  BOOL    bSign    = FALSE;

  PREF_GetBoolPref("mail.crypto_sign_outgoing_mail", &bSign);
  PREF_GetBoolPref("mail.encrypt_outgoing_mail", &bEncrypt);
  MSG_CompositionFields *fields =
      MSG_CreateCompositionFields(real_addr, real_addr, 
                  toString, 
                  ccString, 
                  bccString,
									"", "", "",
									"", subject, "",
									"", "", "",
									"", 
                  bEncrypt,
                  bSign);
  if (!fields)
  {
    return(MAPI_E_FAILURE);
  }

  // RICHIE
  // INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext);
  // int16 win_csid = INTL_GetCSIWinCSID(csi);
  
  pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, NULL, /*win_csid RICHIE*/ winShowFlag);
  if ( !pDocument )
  {
    return(MAPI_E_FAILURE);
  }
  
  CWinCX * pContext = (CWinCX*) pDocument->GetContext();
  if ( !pContext ) 
  {
    return(MAPI_E_FAILURE);
  }

  MSG_CompositionPaneCallbacks Callbacks;
  Callbacks.CreateRecipientsDialog = CreateRecipientsDialog;
  Callbacks.CreateAskHTMLDialog = CreateAskHTMLDialog;

  int16 doccsid;
  MWContext *context = pContext->GetContext();
  CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd();

  pCompose->SetComposeStuff(context, fields); // squirl away stuff for post-create

  // This needs to be set TRUE if using the old non-HTML text frame
  // to prevent dropping dragged URLs
  pContext->m_bDragging = !pCompose->UseHtml();
  if (!pCompose->UseHtml()) 
  {
    pCompose->SetMsgPane(
      MSG_CreateCompositionPane(pContext->GetContext(), 
                                context, 
                                g_MsgPrefs.m_pMsgPrefs, 
                                fields,
                                WFE_MSGGetMaster())
                        );
  }

  ASSERT(pCompose->GetMsgPane());
  MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose);  
  pCompose->UpdateAttachmentInfo();

  // Pass doccsid info to new context for MailToWin conversion
  doccsid = INTL_GetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context));
  INTL_SetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context), 
    (doccsid ? doccsid : INTL_DefaultDocCharSetID(context)));

  pCompose->DisplayHeaders(NULL);

  CComposeBar * pBar = pCompose->GetComposeBar();
  ASSERT(pBar);
  LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface();

  if (!pIAddressList->IsCreated()) 
  {
    pBar->CreateAddressingBlock();
  }

  // rhp - Deal with addressing the brute force way! This is a 
  // "fix" for bad behavior when creating these windows and not
  // showing them on the desktop.
  if (!winShowFlag)      // Hack to fix the window not being mapped
  {
    pCompose->AppendAddress(MSG_TO_HEADER_MASK, "");
    pCompose->AppendAddress(MSG_CC_HEADER_MASK, "");
    pCompose->AppendAddress(MSG_BCC_HEADER_MASK, "");
  }

  // Always do plain text composition!
  pCompose->CompleteComposeInitialization();

  // Do this so we don't get popups on "empty" messages
  if ( (!pInitialText) || (!(*pInitialText)) )
    pInitialText = " ";

  const char * pBody = pInitialText ? pInitialText : MSG_GetCompBody(pCompose->GetMsgPane());
  if (pBody)
  {
    FE_InsertMessageCompositionText(context,pBody,TRUE);
  }

  // 
  // Now set the message as being edited!    
  //
  pCompose->SetModified(TRUE);

  //
  // Finally deal with the attachments...
  //
  if (sendMailPtr->MSG_nFileCount > 0)
  {
    // Send this puppy when done with the attachments...
    if (!winShowFlag)
    {
      pCompose->SetMAPISendMode(MAPI_SEND);
    }

    MSG_AttachmentData *pAttach = (MSG_AttachmentData *)
                  XP_CALLOC((sendMailPtr->MSG_nFileCount + 1),
                  sizeof(MSG_AttachmentData));
    if (!pAttach)
    {
      return(MAPI_E_INSUFFICIENT_MEMORY);
    }

    memset(pAttach, 0, (sendMailPtr->MSG_nFileCount + 1) * 
                                sizeof(MSG_AttachmentData));
    for (i=0; i<sendMailPtr->MSG_nFileCount; i++)
    {
      CString cs;
      // Create URL from filename...
      WFE_ConvertFile2Url(cs, 
          (const char *)NSStrSeqGet(mailInfoSeq, stringCount++));
      pAttach[i].url = XP_STRDUP(cs);

      // Now also include the "display" name...
      StrAllocCopy(pAttach[i].real_name, NSStrSeqGet(mailInfoSeq, stringCount++));
    }

    // Set the list!
    MSG_SetAttachmentList(pCompose->GetMsgPane(), pAttach);

    // Now free everything...
    for (i=0; i<sendMailPtr->MSG_nFileCount; i++)
    {
      if (pAttach[i].url)
        XP_FREE(pAttach[i].url);

      if (pAttach[i].real_name)
        XP_FREE(pAttach[i].real_name);
    }

    XP_FREE(pAttach);
  }

  //
  // Now, if we were supposed to do the blind send...do it, otherwise,
  // just popup the window...
  //
  if (winShowFlag)      
  {
    // Post message to compose window to set the initial focus.
    pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS);
  }
  else if (sendMailPtr->MSG_nFileCount <= 0)  // Send NOW if no attachments!
  {
    pCompose->PostMessage(WM_COMMAND, IDM_SEND);
  }

  return(SUCCESS_SUCCESS);
}
Ejemplo n.º 25
0
NET_StreamClass *
IL_ViewStream(FO_Present_Types format_out, void *newshack, URL_Struct *urls,
              OPAQUE_CONTEXT *cx)
{
    IL_Stream *stream = nil, *viewstream;
	il_container *ic = nil;
	char *org_content_type;
    char *image_url;

	/* multi-part reconnect hack */

	ic = (il_container*)urls->fe_data;
	if(ic && ic->multi)
	{
		return IL_NewStream(format_out, IL_UNKNOWN, urls, cx);
	}

	/* Create stream object */
    if (!(stream = XP_NEW_ZAP(NET_StreamClass))) {
		XP_TRACE(("il: IL_ViewStream memory lossage"));
		return 0;
	}
	
    stream->name           = "image view";
    stream->complete       = il_view_complete;
    stream->abort          = il_view_abort;
    stream->is_write_ready = il_view_write_ready;
    stream->data_object    = NULL;
    stream->window_id      = cx;
    stream->put_block      = (MKStreamWriteFunc)il_view_write;

	ILTRACE(0,("il: new view stream, %s", urls->address));

	XP_ASSERT(!unconnected_stream);
	unconnected_stream = stream;
	unconnected_urls = urls;

	if(!newshack)
	{
        char *buffer;

		org_content_type = urls->content_type; 
		urls->content_type = 0;
		StrAllocCopy(urls->content_type, TEXT_HTML);
		urls->is_binary = 1;	/* secret flag for mail-to save as */

		/* Force layout to discard the old document and start a new one.
		   We do this so that the pre-fetched image request won't be
		   destroyed by a layout call to IL_DestroyImageGroup. */

		viewstream = NET_StreamBuilder(format_out, urls, cx);
		if (!viewstream) {
			XP_FREE(stream);
			return NULL;
		}
        buffer = XP_STRDUP("<HTML>");
        if (!buffer) {
            XP_FREE(stream);
            XP_FREE(viewstream);
            return NULL;
        }
		(*viewstream->put_block)(viewstream, buffer,
                                 XP_STRLEN(buffer)+1);
        XP_FREE(buffer);

	} /* !newshack */

	/* Prefetch the image.  We do this so that the image library can
	   process image data even if the parser is blocked on the fake IMG
	   tag that we send.  Note that this image request will persist until
	   the document is destroyed (when IL_DestroyImageGroup will be called.) */
    image_url = (char*) XP_ALLOC(XP_STRLEN(urls->address) + 29);
    if (!image_url) {
        XP_FREE(stream);
        XP_FREE(viewstream);
        return NULL;
    }
    XP_SPRINTF(image_url, "internal-external-reconnect:%s", urls->address);
    if (!il_load_image(cx, image_url, urls->force_reload)) {
        XP_FREE(stream);
        XP_FREE(viewstream);
        return NULL;
    }
    XP_FREE(image_url);

	if (!newshack) {
	    if (viewstream) {
            	char *buffer = (char*)
                XP_ALLOC(XP_STRLEN(fakehtml) + XP_STRLEN(urls->address) + 1);

            if (buffer)
            {
                XP_SPRINTF(buffer, fakehtml, urls->address);
                (*viewstream->put_block)(viewstream,
                                         buffer, XP_STRLEN(buffer));
                XP_FREE(buffer);
            }
			(*viewstream->complete)(viewstream);
		}

		/* this has to be set back for abort to work correctly */
		XP_FREE(urls->content_type);
		urls->content_type = org_content_type;
	} /* !newshack */

    return stream;
}
Ejemplo n.º 26
0
// Registers one plugin.  "pPluginFilespec" is a string containing the file
// name of a DLL.
// This function can be called more than once so a plugin which has copied
// into the plugins subdir AFTER the Nav has started can be registered
// and loaded.
// The DLL is a plugin candidate, and is qualified during
// this function, by checking the DLL VERSIONINFO data structure for a
// MIME type string.  If this string is found successfully, the handle
// of the management block is used to register the plugin for its MIME type.
// The extents which are to be associated with this MIME type are also grokked
// from the VERSIONINFO data structure, once the candidate is accepted.
// This function also takes the opportunity to overrided any helper app, by
// setting a helper app data structure member to allow the plugin to handle
// the MIME type instead of the helper, (pApp->how_handle = HANDLE_VIA_PLUGIN).
// Returns an error if "pPluginFilespec" was not registered.
NPError fe_RegisterPlugin(char* pPluginFilespec)
{
    CString	strName, strDescription;

    // initialize a new plugin list mgt block
    NPPMgtBlk* pNPMgtBlk = new NPPMgtBlk;
    if(pNPMgtBlk == NULL)   // fatal, can't continue
        return NPERR_OUT_OF_MEMORY_ERROR;
        
    pNPMgtBlk->pPluginFuncs = NULL;
    pNPMgtBlk->pLibrary		= NULL;
    pNPMgtBlk->uRefCount    = 0;
    pNPMgtBlk->next         = NULL;
    
    // determine the MIME type and version of this plugin
    if(wfe_GetPluginProperties(pPluginFilespec, pNPMgtBlk, strName, strDescription) != NPERR_NO_ERROR)
    {
        delete pNPMgtBlk;
        return NPERR_GENERIC_ERROR;
    }

    // if a plugin is already registered for this MIME type, return.  this
    // allows downloading and registering new plugins without exiting the nav
    for(NPPMgtBlk* pListBlk = g_pRegisteredPluginList; pListBlk != NULL;
        pListBlk = pListBlk->next) {
        BOOL bSameFile =
            (strcmp(pListBlk->pPluginFilename, pPluginFilespec) == 0);
        BOOL bSameMIMEtype =
            (strstr(pNPMgtBlk->szMIMEType, pListBlk->szMIMEType) != NULL);
        if(bSameFile && bSameMIMEtype) {
            // the plugin DLL's filename and the MIME type it's registering for
            // are the same, don't reregister
            delete pNPMgtBlk;
            return NPERR_GENERIC_ERROR;
        }
    }    

    pNPMgtBlk->pPluginFilename = XP_STRDUP(pPluginFilespec);
    if(pNPMgtBlk->pPluginFilename == NULL) // fatal, can't continue
    {
        delete pNPMgtBlk;
        return NPERR_OUT_OF_MEMORY_ERROR;
    }

    // Register the plugin file with the XP plugin code
    NPL_RegisterPluginFile(strName, pNPMgtBlk->pPluginFilename, strDescription,
                           pNPMgtBlk);

    // Iterate through the filename extensions.  These are a list which are
    // delimited via the '|' character.  The list of MIME Types,File Extents, 
    // and Open Names must all coordinate
    char *pStartMIME, *pEndMIME, *pStartExt, *pEndExt, *pStartName, *pEndName;

    pStartMIME = pNPMgtBlk->szMIMEType;
    pStartExt = pNPMgtBlk->szFileExtents;
    pStartName = pNPMgtBlk->szFileOpenName;

    pEndMIME = strchr(pStartMIME ,'|');
    while (pEndMIME) {
        pEndExt = strchr(pStartExt,'|');
        pEndName = strchr(pStartName,'|');
        if (pEndMIME) *pEndMIME = 0;
        else return NPERR_GENERIC_ERROR;
        if (pEndExt)  *pEndExt = 0;
        else return NPERR_GENERIC_ERROR;
        if (pEndName) *pEndName = 0;
        else return NPERR_GENERIC_ERROR;

        // Register the MIME type with the XP plugin code. We need to pass in
        // a description. If there's a file open template specified, then use the
        // description from there. Otherwise use the MIME type
        LPSTR	lpszDescription = NULL;

        if (pStartName)
            lpszDescription = ExtractDescription(pStartName);

        NPL_RegisterPluginType(pStartMIME, (LPCSTR)pStartExt, lpszDescription ?
                               lpszDescription : pStartMIME, (void *)pStartName, pNPMgtBlk, TRUE);

        if (lpszDescription)
            XP_FREE(lpszDescription);

        CHelperApp *pApp;
        if(theApp.m_HelperListByType.Lookup(pStartMIME, (CObject *&)pApp))  {
            //  We've a match.
            //  Make sure the app is marked to handle the load
            //      via a plugin
            pApp->how_handle = HANDLE_VIA_PLUGIN;
        }

        if ((pEndMIME+1) && (pEndExt+1) && (pEndName+1)) {
            pStartMIME = pEndMIME+1;
            pStartExt = pEndExt+1;
            pStartName = pEndName+1;
        }
        pEndMIME = strchr(pStartMIME ,'|');    
    }

    // Register the MIME type with the XP plugin code. We need to pass in
    // a description. If there's a file open template specified, then use the
    // description from there. Otherwise use the MIME type
    LPSTR	lpszDescription = NULL;

    if (pStartName)
        lpszDescription = ExtractDescription(pStartName);

    NPL_RegisterPluginType(pStartMIME, (LPCSTR)pStartExt, lpszDescription ?
                           lpszDescription : pStartMIME, (void *)pStartName, pNPMgtBlk, TRUE);

    if (lpszDescription)
        XP_FREE(lpszDescription);

    CHelperApp *pApp;
    if(theApp.m_HelperListByType.Lookup(pStartMIME, (CObject *&)pApp))  {
        //  We've a match.
        //  Make sure the app is marked to handle the load
        //      via a plugin
        pApp->how_handle = HANDLE_VIA_PLUGIN;
    }

    // insert the plugin mgt blk at the head of the list of registered plugins.
    // this means they are listed in the reverse order from which they were
    // created, which doesn't matter.
    pNPMgtBlk->next = g_pRegisteredPluginList;
    g_pRegisteredPluginList = pNPMgtBlk;

    return NPERR_NO_ERROR;
}
Ejemplo n.º 27
0
// nyi - extract nice file name from title or url
char *XFE_URLDesktopType::getFilename(int pos)
{
    if (pos<0 || pos>=_numItems || _url[pos]==NULL)
        return XP_STRDUP("unknown");

    // (alastair) code taken from libmsg/msgsend.cpp - be nice just to call into libmsg
    // modified slightly to avoid bug of trailing / generating empty name
    // modified to return truncated label for mail/news URL's

    const char *url=_url[pos];
    
    if (!url || strlen(url)==0)
        return XP_STRDUP("(null)");

    char *s;
    char *s2;
    char *s3;
   
    /* If we know the URL doesn't have a sensible file name in it,
       don't bother emitting a content-disposition. */
    if (!XP_STRNCASECMP(url, "news:", 5))
        return XP_STRDUP("news:");
    if (!XP_STRNCASECMP(url, "snews:", 6))
        return XP_STRDUP("snews:");
    if (!XP_STRNCASECMP(url, "mailbox:", 8))
        return XP_STRDUP("mailbox:");

    char *tmpLabel = XP_STRDUP(url);

    s=tmpLabel;
    /* remove trailing / or \ */
    int len=strlen(s);
    if (s[len-1]=='/' || s[len-1]=='\\')
        s[len-1]='\0';

    s2 = XP_STRCHR (s, ':');
    if (s2) s = s2 + 1;
    /* Take the part of the file name after the last / or \ */
    if (s2 = XP_STRRCHR (s, '/'))
        s = s2+1;
    else if (s2 = XP_STRRCHR (s, '\\'))
        s = s2+1;

    /* if it's a non-file url do some additional massaging */
    if (XP_STRNCASECMP(url,"file:",5)!=0 && url[0]!='/') {
        /* Trim off any named anchors or search data. */
        s3 = XP_STRCHR (s, '?');
        if (s3) *s3 = 0;
        s3 = XP_STRCHR (s, '#');
        if (s3) *s3 = 0;

        /* Check for redundant document name.
         * Use previous URL component to provide more meaningful file name.
         */
        if (s2 &&
            XP_STRCASECMP(s,"index.html")==0 ||
            XP_STRCASECMP(s,"index.htm")==0 ||
            XP_STRCASECMP(s,"index.cgi")==0 ||
            XP_STRCASECMP(s,"index.shtml")==0 ||
            XP_STRCASECMP(s,"home.html")==0 ||
            XP_STRCASECMP(s,"home.htm")==0 ||
            XP_STRCASECMP(s,"home.cgi")==0 ||
            XP_STRCASECMP(s,"home.shtml")==0) {
            /* Trim redundant component and try again */
            *s2='\0';
            s=tmpLabel;
            /* Redo: Take the part of the file name after the last / or \ */
            if (s2 = XP_STRRCHR (s, '/'))
                s = s2+1;
            else if (s2 = XP_STRRCHR (s, '\\'))
                s = s2+1;
        }
    }

    /* Now lose the %XX crap. */
    NET_UnEscape (s);

    char *retLabel=XP_STRDUP(s);
    XP_FREE(tmpLabel);

    return retLabel;
}
Ejemplo n.º 28
0
PUBLIC int
NET_ParseNetHelpURL(URL_Struct *URL_s)
{
	/* this is a nethelp: URL
	 * first, see if it's local or remote by checking for the @ 
	 */
	char *remote_addr_ptr = 0;
	char *remote_addr=0;
	char *topic_ptr = 0;
	char *topic = 0;
	char *scheme_specific = 0;
	char *pCharacter;

	XP_Bool appendProjFile = FALSE;
	
	remote_addr_ptr = XP_STRCHR(URL_s->address, '@');
	
	if (!remote_addr_ptr) {
		char *default_URL = 0;

		/* it's local, so we need to get the default, then append the project file */
		net_get_default_help_URL(&default_URL);
		
		if (default_URL) {
			StrAllocCopy(remote_addr, default_URL);
			XP_FREE(default_URL);
		}
		
		appendProjFile = TRUE;
		
	} else {
		*remote_addr_ptr = '\0';
		
		StrAllocCopy(remote_addr, remote_addr_ptr+1);

		if (remote_addr && (remote_addr[XP_STRLEN(remote_addr)] == '/')) {
		/* Check to see if the remote_addr ends in a slash.  If so, we
		   have some appending to do */

			appendProjFile = TRUE;
		}
	}

	if (!remote_addr) {
		/* We've obviously run into some kind of a memory problem here. */
		/* Time to bail */
		return MK_OUT_OF_MEMORY;
	}

	/* By now, the URL_s->address has been stripped of any location information */
	/* First, remove the scheme, which is guaranteed to be there. */
	
	scheme_specific = XP_STRCHR(URL_s->address, ':') + 1;
	
	topic_ptr = XP_STRCHR(scheme_specific, ':');
	
	if (!topic_ptr) {
		/* This is an error case, but we'll handle it anyway by defaulting to
		   the generic topic */
		   
		StrAllocCopy(topic, DEFAULT_HELP_ID);
	} else {
		*topic_ptr = '\0';
		StrAllocCopy(topic, topic_ptr+1);

	}		
	
	if (appendProjFile) {
		/* Now the URL_s->address will contain only the vendor/component information */
		
		/* In an act of incredible lameness, we want to lowercase the
		   vendor/component, since we say that these will default to 
		   lower case in the spec.
		   
		   FIXME!: Note that this may not be correct for double-byte encoded
		   characters, but the Intl team was unable to come up with a good
		   solution here; in general, we probably won't have any issue, since
		   URLs themselves should be in an ASCII-encoding (?).
		*/

		pCharacter = scheme_specific;

		while (*pCharacter)
		{
			*pCharacter = (char) XP_TO_LOWER((unsigned int) *pCharacter);
			pCharacter++;
		}

		
		StrAllocCat(remote_addr, scheme_specific);
		StrAllocCat(remote_addr, DEFAULT_HELP_PROJECT);
	}
	
	FREE(URL_s->address);
	URL_s->address = remote_addr;
	
	/* If there is no topic, then we'll still attempt to load the project file and
	   its window.  The other code below should detect the non-existence of a topic and
	   either revert to a default or do some other elegant solution. */
	   
	if (topic) {
		NET_UnEscape(topic);
		URL_s->fe_data = XP_STRDUP(topic);
	} else {
		URL_s->fe_data = NULL;
	}
	
	FREEIF(topic);
	
	return MK_DATA_LOADED;
}
Ejemplo n.º 29
0
/*
 * This function takes an error code and associated error data
 * and creates a string containing a textual description of
 * what the error is and why it happened.
 *
 * The returned string is allocated and thus should be freed
 * once it has been used.
 */
PUBLIC char *
NET_ExplainErrorDetails (int code, ...)
{
  va_list args;
  char *msg = 0;
  int sub_error;

  va_start (args, code);

  if (IS_SSL_ERROR(code) || IS_SEC_ERROR(code)) {
	  const char *s = XP_GetString(code);
	  msg = (s ? XP_STRDUP(s) : 0);
  }

  if (!msg)
    switch(code) {
	case MK_INTERRUPTED:
	case MK_USE_FTP_INSTEAD:
	case MK_USE_COPY_FROM_CACHE:
	case MK_MAILTO_NOT_READY:
	case MK_UNABLE_TO_LOGIN:
	case MK_UNABLE_TO_CONVERT:
	case MK_IMAGE_LOSSAGE:  /* image library generic error */
	case MK_ERROR_SENDING_DATA_COMMAND:
	case MK_OFFLINE:
		msg = NULL;
		break;

	case MK_REDIRECT_ATTEMPT_NOT_ALLOWED:
	case MK_SERVER_TIMEOUT:
	case MK_CONNECTION_TIMED_OUT:
	case MK_OUT_OF_MEMORY:
	case MK_TIMEBOMB_URL_PROHIBIT:
	case MK_TIMEBOMB_MESSAGE:
	case MK_RELATIVE_TIMEBOMB_MESSAGE:
	case MK_NO_WAIS_PROXY:
	case MK_CREATING_NEWSRC_FILE:
	case MK_NNTP_SERVER_NOT_CONFIGURED:
	case MK_NNTP_NEWSGROUP_SCAN_ERROR:
	case MK_ZERO_LENGTH_FILE:
	case MK_BAD_CONNECT:
	case MK_UNABLE_TO_USE_PASV_FTP:
	case MK_UNABLE_TO_CHANGE_FTP_MODE:
	case MK_UNABLE_TO_FTP_CWD:
	case MK_UNABLE_TO_SEND_PORT_COMMAND:
	case MK_UNABLE_TO_ACCEPT_SOCKET:
	case MK_UNABLE_TO_CONNECT2:
	case MK_BAD_NNTP_CONNECTION:
	case MK_NNTP_SERVER_ERROR:
	case MK_SERVER_DISCONNECTED:
	case MK_NEWS_ITEM_UNAVAILABLE:
	case MK_UNABLE_TO_OPEN_NEWSRC:
	case MK_COULD_NOT_LOGIN_TO_SMTP_SERVER:
	case MK_MSG_NO_SMTP_HOST:
	case MK_COULD_NOT_GET_USERS_MAIL_ADDRESS:
	case MK_UNABLE_TO_CONNECT_TO_PROXY:
	case MK_UNABLE_TO_LOCATE_PROXY:
	case MK_DISK_FULL:
	case MK_PRINT_LOSSAGE:
	case MK_SECURE_NEWS_PROXY_ERROR:
	case MK_SIGNATURE_TOO_LONG:
	case MK_SIGNATURE_TOO_WIDE:
	case MK_POP3_SERVER_ERROR:
	case MK_POP3_USERNAME_UNDEFINED:
	case MK_POP3_PASSWORD_UNDEFINED:
	case MK_POP3_USERNAME_FAILURE:
	case MK_POP3_PASSWORD_FAILURE:
	case MK_POP3_NO_MESSAGES:
	case MK_POP3_LIST_FAILURE:
	case MK_POP3_LAST_FAILURE:
	case MK_POP3_RETR_FAILURE:
	case MK_POP3_DELE_FAILURE:
	case MK_POP3_OUT_OF_DISK_SPACE:
	case MK_POP3_MESSAGE_WRITE_ERROR:
	case MK_MIME_NO_SENDER:
	case MK_MIME_NO_RECIPIENTS:
	case MK_MIME_NO_SUBJECT:
	case MK_MIME_ERROR_WRITING_FILE:
	case MK_MIME_MULTIPART_BLURB:
	case MK_MSG_CANT_COPY_TO_SAME_FOLDER:
	case MK_MSG_CANT_COPY_TO_QUEUE_FOLDER:
	case MK_MSG_CANT_COPY_TO_QUEUE_FOLDER_OLD:
	case MK_MSG_CANT_COPY_TO_DRAFTS_FOLDER:
	case MK_MSG_CANT_CREATE_FOLDER:
	case MK_MSG_FOLDER_ALREADY_EXISTS:
	case MK_MSG_FOLDER_NOT_EMPTY:
	case MK_MSG_CANT_DELETE_FOLDER:
	case MK_MSG_CANT_CREATE_INBOX:
	case MK_MSG_CANT_CREATE_MAIL_DIR:
	case MK_MSG_NO_POP_HOST:
	case MK_MSG_MESSAGE_CANCELLED:
	case MK_MSG_FOLDER_UNREADABLE:
	case MK_MSG_FOLDER_SUMMARY_UNREADABLE:
	case MK_MSG_TMP_FOLDER_UNWRITABLE:
	case MK_MSG_ID_NOT_IN_FOLDER:
	case MK_MSG_NEWSRC_UNPARSABLE:
	case MK_MSG_NO_RETURN_ADDRESS:
	case MK_MSG_ERROR_WRITING_NEWSRC:
	case MK_MSG_ERROR_WRITING_MAIL_FOLDER:
	case MK_MSG_SEARCH_FAILED:
	case MK_MSG_FOLDER_BUSY:
		msg = XP_STRDUP(XP_GetString(code));
		break;

	case MK_TCP_READ_ERROR:
	case MK_TCP_WRITE_ERROR:
	case MK_UNABLE_TO_CREATE_SOCKET:
	case MK_UNABLE_TO_CONNECT:
	case MK_HTTP_TYPE_CONFLICT:
	case MK_TCP_ERROR:
		sub_error = va_arg(args, int);
		if (IS_SSL_ERROR(sub_error) || IS_SEC_ERROR(sub_error)) {
			/*
			 * For SSL/SEC errors, use the message without a wrapper.
			 */
			msg = XP_STRDUP(XP_GetString(sub_error));
		} else if (code == MK_UNABLE_TO_CONNECT &&
				   (sub_error == XP_ERRNO_EINVAL
					|| sub_error == XP_ERRNO_EADDRINUSE)) {
			/*
			 * With unable-to-connect errors, some errno values/strings
			 * are not more helpful, so just use a plain message for these.
			 */
			msg = XP_STRDUP(XP_GetString(MK_UNABLE_TO_CONNECT2));
		} else {
			msg = PR_smprintf(XP_GetString(code), XP_GetString(sub_error));
		}
		break;

	case MK_MALFORMED_URL_ERROR:
	case MK_COULD_NOT_PUT_FILE:
	case MK_UNABLE_TO_LOCATE_FILE:
	case MK_NNTP_AUTH_FAILED:
	case MK_UNABLE_TO_LOCATE_HOST:
	case MK_UNABLE_TO_LOCATE_SOCKS_HOST:
	case MK_UNABLE_TO_OPEN_FILE:
	case MK_UNABLE_TO_OPEN_TMP_FILE:
	case MK_CONNECTION_REFUSED:
	case MK_NNTP_ERROR_MESSAGE:
	case MK_MSG_COULDNT_OPEN_FCC_FILE:
	case MK_TIMEBOMB_WARNING_MESSAGE:
	case MK_RELATIVE_TIMEBOMB_WARNING_MESSAGE:
	case MK_ERROR_SENDING_FROM_COMMAND:
	case MK_ERROR_SENDING_RCPT_COMMAND:
	case MK_ERROR_SENDING_MESSAGE:
	case MK_SMTP_SERVER_ERROR:
		msg = PR_vsmprintf(XP_GetString(code), args);
		break;

	case -1:
	default:
		msg = PR_smprintf(XP_GetString(MK_COMMUNICATIONS_ERROR), code);
		break;
	}

  va_end (args);

  TRACEMSG(("NET_ExplainErrorDetails generated: %s", msg ? msg : "(none)"));

  return(msg);
}
Ejemplo n.º 30
0
/* NativeComplete
 * copies the file to its final location
 * Tricky, we need to create the directories
 */
int nsInstallFile::NativeComplete()
{
    char* currentName = NULL;
    char* finalName = NULL;
    char* finalNamePlatform;
    int result = 0;

    if (tempFile == NULL) {
        return -1;
    }
    /* Get the names */
    currentName = tempFile->ToNewCString();

    PR_ASSERT(finalFile != NULL);
    finalNamePlatform = finalFile->ToNewCString();
    finalName = XP_PlatformFileToURL(finalNamePlatform);

    if ( finalName == NULL || currentName == NULL ) {
        /* memory or JRI problems */
        result = -1;
        goto end;
    } else {
        /* convert finalName name to xpURL form by stripping "file://" */
        char *temp = XP_STRDUP(&finalName[7]);
        XP_FREE(finalName);
        finalName = temp;
    }

    if (finalName != NULL) {
        if ( XP_STRCMP(finalName, currentName) == 0 ) {
            /* No need to rename, they are the same */
            result = 0;
        } else {
            XP_StatStruct s;
            if ( XP_Stat( finalName, &s, xpURL ) != 0 ) {
                /* Target file doesn't exist, try to rename file */
                result = XP_FileRename(currentName, xpURL, finalName, xpURL);
            } else {
                /* Target exists, can't trust XP_FileRename--do platform
                 * specific stuff in FE_ReplaceExistingFile()
                 */
                result = -1;
            }
        }
    } else {
        /* memory problem */
        result = -1;
    }

    if (result != 0) {
        XP_StatStruct s;
        if ( XP_Stat( finalName, &s, xpURL ) == 0 ) {
            /* File already exists, need to remove the original */
            result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, force);

            if ( result == SU_REBOOT_NEEDED ) {
#ifdef XP_WIN16
                if (!utilityScheduled) {
                    utilityScheduled = PR_TRUE;
                    FE_ScheduleRenameUtility();
                }
#endif
            }
        } else {
            /* Directory might not exist, check and create if necessary */
            char separator;
            char * end;
            separator = '/';
            end = XP_STRRCHR(finalName, separator);
            if (end) {
                end[0] = 0;
                result = XP_MakeDirectoryR( finalName, xpURL);
                end[0] = separator;
                if ( 0 == result )
                    result = XP_FileRename(currentName, xpURL, finalName, xpURL);
            }
        }
#ifdef XP_UNIX
        /* Last try, can't rename() across file systems on UNIX */
        if ( -1 == result ) {
            result = FE_CopyFile(currentName, finalName);
        }
#endif
    }

end:
    XP_FREEIF(finalName);
    delete currentName;
    delete finalNamePlatform;
    return result;
}