Example #1
0
int XFE_ComposeAttachFolderView::verifySafeToAttach()
{
#if 0
    // this check is no longer needed - back end can handle
    // multiple simultaneous attachment operations
    if (MSG_DeliveryInProgress(getPane())) {
        char *msg=PR_smprintf(XP_GetString(XFE_MN_DELIVERY_IN_PROGRESS));
        if (msg) {
            fe_Alert_2(getBaseWidget(),msg);
            XP_FREE(msg);
        }
        return FALSE;
    }
#endif
    return TRUE;
}
Example #2
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;
}
Example #3
0
int XFE_ComposeAttachFolderView::validateAttachment(Widget widget,const char *url)
{
    if (!url)
        return FALSE;

    // strip off any file: prefix before validating
    const char *data=url;
    if (XP_STRNCASECMP(url,"file:",5)==0)
        data=url+5;
    
    if (strlen(data)==0)
        return FALSE;

    // accept only URL's that resolve to a document
    // reject mailto:, mailbox: folders etc.
    if (NET_URL_Type(data)!=0) {
        // reject addressbook add command, without error dialog
        if (XP_STRNCASECMP(url,"addbook:add?vcard=",18)==0)
            return FALSE;
        
        // accept regular address book cards
        if (XP_STRNCASECMP(url,"addbook:",8)==0)
            return TRUE;

        // accept anything we know how to display as a document
        if (MSG_RequiresMailMsgWindow(url) ||
            MSG_RequiresNewsMsgWindow(url) ||
            MSG_RequiresBrowserWindow(url))
            return TRUE;
        else {
            char *msg=PR_smprintf(XP_GetString(XFE_MN_INVALID_ATTACH_URL),data);
            if (msg) {
                fe_Alert_2(widget,msg);
                XP_FREE(msg);
            }
            return FALSE;
        }
    }
    
    // file must exist
    if (!fe_isFileExist((char*)data)) {
        char *msg=PR_smprintf(XP_GetString(XFE_INVALID_FILE_ATTACHMENT_DOESNT_EXIST),data);
        if (msg) {
            fe_Alert_2(widget,msg);
            XP_FREE(msg);
        }
        return FALSE;
    }

    // file must be readable
    if (!fe_isFileReadable((char*)data)) {
        char *msg=PR_smprintf(XP_GetString(XFE_INVALID_FILE_ATTACHMENT_NOT_READABLE),data);
        if (msg) {
            fe_Alert_2(widget,msg);
            XP_FREE(msg);
        }
        return FALSE;
    }

    // cannot attach directory
    if (fe_isDir((char*)data)) {
        char *msg=PR_smprintf(XP_GetString( XFE_INVALID_FILE_ATTACHMENT_IS_A_DIRECTORY ),data);
        if (msg) {
            fe_Alert_2(widget,msg);
            if (msg) XP_FREE(msg);
        }
        return FALSE;
    }

    return TRUE;
}
Example #4
0
void
fe_showNetcaster(Widget toplevel)

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

  if (!fe_IsNetcasterInstalled())
    return;

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

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

      if (netcasterURL)
		{

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

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

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