/* * Removes the context from the context list * Notifies all its children */ void XP_RemoveContextFromList(MWContext *context) { int howMany; int i; if (context == NULL) return; cx_RemoveChildContext(context); /* Its parent does not point to it any more */ /* Now take care of the children, this should not really happen */ if (context->grid_children) { howMany = XP_ListCount(context->grid_children); for (i = 1; i <= howMany; i++) { MWContext * child; child = (MWContext *)XP_ListGetObjectNum(context->grid_children, 1); if (child) child->grid_parent = NULL; XP_ListRemoveObject(context->grid_children, child); } XP_ListDestroy(context->grid_children); context->grid_children = NULL; } XP_ListRemoveObject(xp_GlobalContextList, context); /* Remove from last active stack. * Remove any nav center info about the context. */ XP_RemoveContextFromLastActiveStack(context); XP_RemoveNavCenterInfo(context); }
/* * The passed context is added to the global context list */ void XP_AddContextToList(MWContext *context) { if (context == NULL) return; if (xp_GlobalContextList == NULL) xp_GlobalContextList = XP_ListNew(); if (xp_GlobalContextList == NULL) return; XP_ListRemoveObject(xp_GlobalContextList, context); /* No dups */ XP_ListAddObject(xp_GlobalContextList, context); cx_AddChildContext(context->grid_parent, context); }
BOOL CSlaveWindow::UnRegister(void *pCookie) { BOOL bRetval = FALSE; // Must have cookie, must have list. if(pCookie && m_pHandlers) { bRetval = XP_ListRemoveObject(m_pHandlers, pCookie); if(bRetval) { SlaveStruct *pDel = (SlaveStruct *)pCookie; delete pCookie; } } return(bRetval); }
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); } } } }
CStreamData *WPM_UnRegisterContentTypeConverter(const char *pServer, const char *pMimeType, FO_Present_Types iFormatOut) { // Purpose: Remove a content type converter from the list of registered // types. // Arguments: pServer The name of the server. // pMimeType The mime type the server should be // registered to handle. // iFormatOut The format out that the server is registered // to handle. // Returns: CStreamData * The data passed in via RegisterContentTypeConverter, // so the application can free it. NULL on failure. // Comments: This function has intimate knowledge of the CStreamData // class and it's heirs. This is so that it can correctly // find the server in the registration list. // Only automated converters can be unregistered. // Revision History: // 01-08-94 created GAB // // Can't handle any caching formats, shouldn't ever be registered! if((iFormatOut & FO_CACHE_ONLY) || (iFormatOut & FO_ONLY_FROM_CACHE)) { ASSERT(0); return(NULL); } XP_List* pList = NET_GetRegConverterList(iFormatOut); void *objPtr = NULL; CStreamData *pAutoStream = (CStreamData *)NET_GETDataObject(pList, (char *)pMimeType, &objPtr); if(pAutoStream) { switch(pAutoStream->GetType()) { case CStreamData::m_DDE: { CDDEStreamData *pDDEStream = (CDDEStreamData *)pAutoStream; // Compare the server names. // This will not be a case sensitive thing, since DDE isn't // case sensitive. if(0 == pDDEStream->m_csServerName.CompareNoCase(pServer)) { // This is the one. Take it out. XP_ListRemoveObject(pList, objPtr); XP_DELETE(objPtr); objPtr = NULL; return(pAutoStream); } break; } case CStreamData::m_OLE: { COLEStreamData *pOLEStream = (COLEStreamData *)pAutoStream; // Compare the server names. // This will be a case sensitive thing. if(pOLEStream->m_csServerName == pServer) { // This is the one. Take it out. XP_ListRemoveObject(pList, objPtr); XP_DELETE(objPtr); objPtr = NULL; return(pAutoStream); } break; } default: // unknown type. ASSERT(0); break; } } // Not successful. return(NULL); }
/* cx_RemoveChildContext * Removes child context from its parent * NULL-safe */ void cx_RemoveChildContext(MWContext * child) { if ((child == NULL) || (child->grid_parent == NULL)) return; XP_ListRemoveObject(child->grid_parent->grid_children, child); }
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; } }
/* 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); }