home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / presentm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  108 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "stdafx.h"
  20.  
  21. #include "presentm.h"
  22.  
  23. #include "strmdata.h"
  24. #include "olectc.h"
  25. #include "ddectc.h"
  26. #include "helper.h"
  27.  
  28. //    All our registered ContentTypeConverters
  29. extern "C" BOOL WPM_RegisterContentTypeConverter(char *pFormatIn,
  30.     FO_Present_Types iFormatOut, void *vpDataObject,
  31.     NET_Converter *pConverterFunc, BOOL bAutomated)    {
  32.  
  33.     NET_RegContentTypeConverter (pFormatIn,iFormatOut,vpDataObject, pConverterFunc,
  34.                                     bAutomated);
  35.     return(TRUE);
  36. }
  37.  
  38. CStreamData *WPM_UnRegisterContentTypeConverter(const char *pServer,
  39.     const char *pMimeType, FO_Present_Types iFormatOut)    {
  40. //    Purpose:    Remove a content type converter from the list of registered
  41. //                        types.
  42. //    Arguments:    pServer    The name of the server.
  43. //                        pMimeType    The mime type the server should be
  44. //                            registered to handle.
  45. //                        iFormatOut    The format out that the server is registered
  46. //                            to handle.
  47. //    Returns:    CStreamData *    The data passed in via RegisterContentTypeConverter,
  48. //                        so the application can free it.  NULL on failure.
  49. //    Comments:    This function has intimate knowledge of the CStreamData
  50. //                            class and it's heirs.  This is so that it can correctly
  51. //                            find the server in the registration list.
  52. //                Only automated converters can be unregistered.
  53. //    Revision History:
  54. //        01-08-94    created GAB
  55. //
  56.  
  57.     //  Can't handle any caching formats, shouldn't ever be registered!
  58.     if((iFormatOut & FO_CACHE_ONLY) || (iFormatOut & FO_ONLY_FROM_CACHE))  {
  59.         ASSERT(0);
  60.         return(NULL);
  61.     }
  62.  
  63.  
  64.     XP_List* pList = NET_GetRegConverterList(iFormatOut);
  65.     void *objPtr = NULL;
  66.     CStreamData *pAutoStream = (CStreamData *)NET_GETDataObject(pList, (char *)pMimeType, &objPtr);
  67.     if(pAutoStream) {
  68.         switch(pAutoStream->GetType())    {
  69.         case CStreamData::m_DDE:    {
  70.             CDDEStreamData *pDDEStream = (CDDEStreamData *)pAutoStream;
  71.  
  72.             //    Compare the server names.
  73.             //    This will not be a case sensitive thing, since DDE isn't
  74.             //        case sensitive.
  75.             if(0 == pDDEStream->m_csServerName.CompareNoCase(pServer)){
  76.                 //    This is the one.  Take it out.
  77.                 XP_ListRemoveObject(pList, objPtr);
  78.                 XP_DELETE(objPtr);
  79.                 objPtr = NULL;
  80.                 return(pAutoStream);
  81.             }
  82.             break;
  83.                                     }
  84.         case CStreamData::m_OLE:    {
  85.             COLEStreamData *pOLEStream = (COLEStreamData *)pAutoStream;
  86.  
  87.             //  Compare the server names.
  88.             //  This will be a case sensitive thing.
  89.             if(pOLEStream->m_csServerName == pServer)   {
  90.                 //  This is the one.  Take it out.
  91.                 XP_ListRemoveObject(pList, objPtr);
  92.                 XP_DELETE(objPtr);
  93.                 objPtr = NULL;                    
  94.                 return(pAutoStream);
  95.             }
  96.             break;
  97.                                     }
  98.         default:
  99.             //    unknown type.
  100.             ASSERT(0);
  101.             break;
  102.         }
  103.     }
  104.  
  105.     //    Not successful.
  106.     return(NULL);
  107. }
  108.