Esempio n. 1
0
/*	Lock the prefetch_list and normalize the item values.
*/
PRIVATE int 
pre_LockNormalizeAndSort() 
{
	int count;
	double sum=0;
	PrefetchURLStruct* pus = NULL;
	XP_List* pList = prefetch_list;

	count = XP_ListCount(prefetch_list);
	if (0 == count)
		return 0;

	while((pus = (PrefetchURLStruct*)XP_ListNextObject(pList)))
		sum += pus->prevalue;
	
	if (sum != 0)
	{
		XP_List* pList = prefetch_list;
		while((pus = (PrefetchURLStruct*)XP_ListNextObject(pList)))
			pus->prevalue = pus->prevalue/sum;
	}
	else 
		return -1;
	return count;
}
Esempio n. 2
0
void CSlaveWindow::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if(m_pHandlers) {
        //  Go through list of handlers, see if anyone wanted this
        //      message.
        //  Keep a seperate list, so callbacks can add and remove
        //      themselves via the registration and not cause a
        //      crash.
        //  This also has the side effect of calling the callbacks
        //      in the order of registration, instead of in the
        //      reverse order.
        XP_List *pTraverse = m_pHandlers;
        XP_List *pTemp = NULL;
        SlaveStruct *pSlave = NULL;
        while(pSlave = (SlaveStruct *)XP_ListNextObject(pTraverse)) {
            if(pSlave->m_msg == uMsg)   {
                if(NULL == pTemp) {
                    pTemp = XP_ListNew();
                }
                if(pTemp) {
                    XP_ListAddObject(pTemp, (void *)pSlave);
                }
            }
        }
        if(pTemp) {
            pTraverse = pTemp;
            while(pSlave = (SlaveStruct *)XP_ListNextObject(pTraverse)) {
                //  Fire.
                pSlave->m_swc(uMsg, wParam, lParam);
            }
            XP_ListDestroy(pTemp);
            pTemp = NULL;
        }
    }
}
XP_List *
XFE_FrameListMenu::getShownFrames()
{
	XP_List *	frame_list = XFE_MozillaApp::theApp()->getAllFrameList();
	Cardinal	frame_count = XP_ListCount(frame_list);

	XP_List *	shown_frame_list = NULL;
	Cardinal	i;

	// Find the shown frames and add them to a list
	for (i = 0; i < frame_count; i++)
	{
		// Get the next frame
		XFE_Frame * frame = (XFE_Frame*) XP_ListNextObject(frame_list);

		// Add it to list if valid and shown
		if (frame && XfeIsAlive(frame->getBaseWidget()) && frame->isShown())
		{
			// Create a new list as soon as we find the first shown item
			if (!shown_frame_list)
			{
				shown_frame_list = XP_ListNew();
			}

			XP_ListAddObject(shown_frame_list,frame);
		}
	}

	return shown_frame_list;
}
Esempio n. 4
0
XP_Bool
XFE_MozillaApp::isOkToExitFrameList(XP_List *frame_list)
{
        XP_List *start;
	XP_Bool okFlag = True;
        XFE_Frame *frame;

        start = frame_list;

        while ((frame = (XFE_Frame*)XP_ListNextObject(start)) != NULL)
        {
			XP_ASSERT(frame);
			if (frame && ( fe_IsContextProtected(frame->getContext()) ||
				!(okFlag = frame->isOkToClose())  ) ) 
			{ 
			  okFlag = False;
			  break;
			}
		}
	return okFlag;	
}
Esempio n. 5
0
PRIVATE void
pre_ProcessList(MWContext* context) 
{
	int count = XP_ListCount(prefetch_list);
	if (XP_ListCount(prefetch_list)>0) 
	{
		/* Normalize the prefetch-list based on the values */
		if (pre_LockNormalizeAndSort() > 0) 
		{
			/* Invoke NET_GetURL on the prefetch_list */
			int i;
			for (i=0; i<count; i++) {
				PrefetchURLStruct* pusTop;
				PrefetchURLStruct* pus;
				XP_List* pList = prefetch_list;

				while((pus = (PrefetchURLStruct*)XP_ListNextObject(pList)))
				{
					if (pusTop) 
					{
						if (pusTop->prevalue < pus->prevalue)
							pusTop = pus;
					}
					else
						pusTop = pus;

				}
				if (pusTop->prevalue > USER_SETTING)
				{
					NET_GetURL (pus->URL_s,
						FO_CACHE_ONLY,
						context,
						pre_Finished); 
				}
				XP_ListRemoveObject(prefetch_list, pusTop);
			}
		}
	}
}
Esempio n. 6
0
CSlaveWindow::~CSlaveWindow()
{
    if(m_hWnd)  {
        VERIFY(::DestroyWindow(m_hWnd));
        m_hWnd = NULL;
    }

    if(m_hInstance) {
        VERIFY(::UnregisterClass(pSlaveWindowClass, m_hInstance));
        m_hInstance = NULL;
    }

    if(m_pHandlers) {
        XP_List *pTraverse = m_pHandlers;
        SlaveStruct *pSlave = NULL;
        while(pSlave = (SlaveStruct *)XP_ListNextObject(pTraverse))    {
            delete pSlave;
        }

        XP_ListDestroy(m_pHandlers);
        m_pHandlers = NULL;
    }
}
Esempio n. 7
0
MWContext *FE_CreateNewEditWindow(MWContext *pContext, URL_Struct *pURL)	{
	if(pContext != NULL)	{
		if(ABSTRACTCX(pContext)->IsDestroyed())	{
			TRACE("Context %p Destroyed :: CreateNewDocWindow Blocking\n", pContext);
			//	Don't allow this to happen if the context has been destroyed...
			return(NULL);
		}

		MWContext *pRetval = ABSTRACTCX(pContext)->CreateNewDocWindow(pContext, pURL);
		if(pRetval != NULL)	{
			return(pRetval);
		}
	}

	//	Regardless of the type of context we currently are, we are going to
	//		create a new CMainFrame.
	//	The contexts can do whatever they want in the derived class, but this is
	//		the base implementation.  If they return a context, then we won't do this.

	//	Cause a frame to open.
	if(NULL == theApp.m_EditTmplate->OpenDocumentFile(NULL))	{
		return(NULL);
	}

	//	The new frame will be the last one in the application's frame list.
	CMainFrame *pFrame;
	CGenericFrame *pGenFrame;
	for(pGenFrame = theApp.m_pFrameList; pGenFrame->m_pNext; pGenFrame = pGenFrame->m_pNext) {
		/* No Body */;
	}
    
    pFrame = (CMainFrame *) pGenFrame;
	MWContext *pNewContext = pFrame->GetMainContext()->GetContext();

	//	Appropriate assignment of options/prefs can only happen if we are also
	//		owned by a CMainFrame, check.
	if(pContext != NULL && ABSTRACTCX(pContext)->IsFrameContext() && 
       pContext->type == MWContextBrowser){
        pFrame->m_iCSID = INTL_DefaultDocCharSetID(pContext);
	}

	//	Set the miscellaneous XP context properties.
	if(pContext != NULL)	{
		pNewContext->fancyFTP = pContext->fancyFTP;	
		pNewContext->fancyNews = pContext->fancyNews;

		//	Copy the session history over.
		SHIST_CopySession(pNewContext, pContext);
	}

	//	If there was no URL specified to load, load what's in the history.
	//	Only take URLs from a browser window.
	if(pURL == NULL)	{
		//	Load the oldest thing in it's history (most likely the home page).
		XP_List *pOldest = SHIST_GetList(pNewContext);
		History_entry *pEntry = (History_entry *)XP_ListNextObject(pOldest);
		if(pEntry == NULL)	{
			//	Nothing to load, we're done.
			return(pNewContext);
		}

		//	don't load from non browser windows.
		if(pContext == NULL || pContext->type == MWContextBrowser || pContext->type == MWContextPane)	{
            URL_Struct *pUrl = SHIST_CreateURLStructFromHistoryEntry(pContext ? pContext : pNewContext, pEntry);
			if(pUrl == NULL)	{
				//	Nothing to load?  we're done.
				return(pNewContext);
			}

			//	Set the current session history for the new context.
			SHIST_SetCurrent(&(pNewContext->hist), 0);

			//	finally Load it.
			ABSTRACTCX(pNewContext)->GetUrl(pUrl, FO_CACHE_AND_EDIT);
		}
	}
	else if(pURL != NULL)	{
		//	Load the URL passed into this function.
		ABSTRACTCX(pNewContext)->GetUrl(pURL, FO_CACHE_AND_EDIT);
	}

	//	New frame window up, and filled out appropriately.
	return(pNewContext);
}
Esempio n. 8
0
void CContentView::CalcChildSizes()
{
    //  Ask each descendant window what size it would like to be.
    ::EnumChildWindows(GetSafeHwnd(), QuerySizeCallback, (LPARAM)this);

    CRect crClient;
    GetClientRect(crClient);
    int cx = crClient.Width();
    int cy = crClient.Height();

    //  Total the sizes of all the child window vectors.
    //  This will let us scale by percentage.
    XP_List *pTraverse = m_pChildSizeInfo;
    NAVCENTPOS *pPos = NULL;
    int iTotalHeight = 0;
    while(pPos = (NAVCENTPOS *)XP_ListNextObject(pTraverse)) {
        iTotalHeight += pPos->m_iYVector;
    }
    
    //  Find the child with the lowest Y disposition.
    int iCurPos;
    int iNextY = 0;
    while(XP_ListCount(m_pChildSizeInfo)) {
        pTraverse = m_pChildSizeInfo;
        iCurPos = INT_MAX;
        //  Find topmost position.
        while(pPos = (NAVCENTPOS *)XP_ListNextObject(pTraverse)) {
            if(pPos->m_iYDisposition < iCurPos) {
                iCurPos = pPos->m_iYDisposition;
            }
        }
        pTraverse = m_pChildSizeInfo;
        while(pPos = (NAVCENTPOS *)XP_ListNextObject(pTraverse)) {
            if(pPos->m_iYDisposition == iCurPos) {
                //  Resize it.
                float fPercent = (float)(pPos->m_iYVector) / (float)iTotalHeight;
                int iNewHeight = (int)(fPercent * (float)cy);
                
                //  Handle rounding errors.
                if(iNextY + iNewHeight > cy) {
                    iNewHeight = cy - iNextY;
                }
                
				RECT rect;
				::GetClientRect(pPos->m_hChild, &rect);
				::SetWindowPos(pPos->m_hChild, HWND_BOTTOM, 0, iNextY, cx, iNewHeight, SWP_NOZORDER);
                
				iNextY += iNewHeight;
                
                //  Remove this one from the list.
                XP_ListRemoveObject(m_pChildSizeInfo, pPos);
                XP_FREE(pPos);
                break;
            }
        }
    }
    
    if(m_pChildSizeInfo) {
        XP_ListDestroy(m_pChildSizeInfo);
        m_pChildSizeInfo = NULL;
    }
}
Esempio n. 9
0
static BOOL wfe_IsRegisteredForPlugin(int iFormatOut, URL_Struct *pUrlStruct, MWContext *pContext)
{
	//	Find the callers mime/type in the iFormatOut registry list,
	//  and return true if found.
	CString csMimeType = pUrlStruct->content_type;
	
	//	Find the relevant mime type in our list.
	//	There should always be a wild on the end of the list, but if not, duh.
	XP_List *list = NET_GetRegConverterList(iFormatOut);
    ContentTypeConverter *pConv;

	while(pConv = (ContentTypeConverter *)XP_ListNextObject(list))
	{
		
		//	Do a wild compare on the mime types
		if(WildMime(csMimeType, pConv->format_in))
		{
            //  May have found an appropriate converter.

            //  Only when the viewer is not automated,
            //  and the mime types are a case insensitive
            //  match, return TRUE.
			// ZZZ: Make sure it's a plug-in and not an automated viewer.
			// We're doing it this demented way because pConv->bAutomated is
			// getting stomped and points to garbage
			if ((pConv->bAutomated == FALSE) && NPL_FindPluginEnabledForType(pConv->format_in)) {
				// only check for can handle by OLE when there is no plugin register for
				// the mine type.
				// Find out can we handle by OLE.
				if (strcmp(pConv->format_in, "*") == 0) 
					/* there previously was a call to FE_FileType here, but it is clearly
					unnecessary given the check of fe_CanHandlebyOLE we've added.  byrd.
					reminder - we should overhaul/remove FE_FileType and it's other call.
					&& 
					FE_FileType(pUrlStruct->address, pUrlStruct->content_type,
									pUrlStruct->content_encoding))
									*/
				{
					if(iFormatOut == FO_EMBED){
						/* don't have to worry about FO_CACHE_AND_EMBED since cache bit cleared by NET_CacheConverter */
						/* also, don't want to interfere w/ full-page case... */
						char* ext[1];
						ext[0] = FE_FindFileExt(pUrlStruct->address);

						if(ext[0] && fe_CanHandleByOLE(ext,1))
							return FALSE;
						else
							return TRUE;
					}

					else return FALSE;
				}
				else
                    return TRUE;
            }
            //  Only when the viewer is not automated,
            //  and the handler is for wildcard MIME type,
            //  and OLE doesn't want it, return TRUE.
			// ZZZ: See above comment
            if ((pConv->bAutomated == FALSE) && XP_STRCMP(pConv->format_in, "*") == 0 &&
				NPL_FindPluginEnabledForType("*")) {
                // the following code is copied from EmbedStream(), OLE related stuff
                // BUG: this code needs to be shared code!

                // extract the extension of the file name
                char aExt[_MAX_EXT];
                size_t stExt = 0;
                DWORD dwFlags = EXT_NO_PERIOD;
                
#ifdef XP_WIN16
                dwFlags |= EXT_DOT_THREE;
#endif
                aExt[0] = '\0';
                stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pUrlStruct->address, pUrlStruct->content_type);
                CString csFinalExtension = aExt;

                //  Check to see if the embedded file matches any known extensions.
                //  If not, then consider the file of no use to the user.
	            //	Use new way if we are in a different style of context.
                if(wfe_IsExtensionRegistrationValid(csFinalExtension, ABSTRACTCX(pContext)->GetDialogOwner(), FALSE) == FALSE) {
                    return TRUE;
                }		
            }
		}
	}
    return FALSE;
}
void
XFE_FrameListMenu::cascading()
{
	XP_List *	frame_list = getShownFrames();

	XFE_Frame *	frame;
	int			i;
	int			frame_count = XP_ListCount(frame_list);

	Cardinal	num_children;
	WidgetList	children;

	int			total_slots_needed;
	int			slots_to_add;
	int			count;

	XfeChildrenGet(m_submenu,&children,&num_children);

	XP_ASSERT( num_children > 1 );

	// Total number of slots needed
	total_slots_needed = m_firstslot + 1 + frame_count;

	// Number of slots to add
	slots_to_add = total_slots_needed - num_children;

	// Add more slots if needed
	if (slots_to_add > 0)
	{
		for (i = 0; i < slots_to_add; i++)
		{
			Widget item = XtVaCreateWidget(xfeCmdFrameListRaiseItem,
										   //xmToggleButtonGadgetClass,
										   xmPushButtonGadgetClass,
										   m_submenu,
										   NULL);

			XtAddCallback(item,
						  XmNactivateCallback,
						  //XmNvalueChangedCallback,
						  &XFE_FrameListMenu::item_activate_cb,
						  (XtPointer) this);
		}

		// Update num_slots, since we added stuff
		XfeChildrenGet(m_submenu,&children,&num_children);
	}

	count = 1;

	// Configure the items
	for (i = (int) m_firstslot + 1; i < (int) num_children; i++)
	{
		// Get the next frame
		frame = (XFE_Frame*) XP_ListNextObject(frame_list);

		// If the frame is valid, add its title to the slot buttons
		if (frame)
		{
			MWContext *			context = m_parentFrame->getContext();
			INTL_CharSetInfo	c = LO_GetDocumentCharacterSetInfo(context);
			XmFontList			font_list;
			char				name[1024];

			XP_SPRINTF(name,"%d. %s",count++,frame->getTitle());

			INTL_MidTruncateString(INTL_GetCSIWinCSID(c), 
								   name, 
								   name,
								   MAX_ITEM_WIDTH);

			XmString label = fe_ConvertToXmString((unsigned char *) name,
												  INTL_GetCSIWinCSID(c), 
												  NULL, 
												  XmFONT_IS_FONT,
												  &font_list);

			if (label)
			{
				XtVaSetValues(children[i],XmNlabelString,label,NULL);

				XmStringFree(label);
			}

			XtManageChild(children[i]);
		}
		// If the frame is not valid, the unmanage the slot button
		else
		{
			XtUnmanageChild(children[i]);
		}
	}

	// Update the display so that the gadget buttons get drawn
	XmUpdateDisplay(m_submenu);

	if (frame_list)
	{
		XP_ListDestroy(frame_list);
	}
}