/* @(#)Z 1.10 com/src/registry/PartInfi.cpp, odconfig, od96nt, odnt9712d 97/03/21 17:15:54 (96/10/28 13:39:35) */

//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odconfig
//
//   CLASSES: none
//
//   ORIGINS: 27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//   	
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//

/*
 *  This file was generated by the SOM Compiler.
 *  Generated using:
 *     SOM incremental update: somc/smmain.c
 */

/*
 *   File:      partinfi.cpp
 *
 *   Contains:  Implementation of Simple Part
 *
 *   Change History (most recent first):
 *     144288   11/17/95   jso  Fixed GetPartInfo routine for possible trap
 *     143600   11/14/95   jso  Fixed up error codes                
 *     142016   11/06/95   jso  Commented out somLPrintf calls      
 *     129709   10/12/95   jso  Unload dll after registeration      
 *     123247   09/21/95   jso  Added storage of categoryDisplayName
 *     123473   07/14/95   jso  Added SupportsFileType/FileExt
 *     128470   07/07/95   jso  Added ODDebug ifdef for somLPrintf calls
 *     123479   06/28/95   jso  ODPartHandlerKindInfo method
 *     121007   05/31/95   jso  Added storage of objectId.
 *     120348   05/04/95   jso  Fix 'trap with NULL string parms.
 *
 *   To Do:
 *
 *   Copyright: (c) 1993-1994 by IBM Corp., all rights reserved.
 *
 */

/*
 *  This file was generated by the SOM Compiler and Emitter Framework.
 *  Generated using:
 *      SOM Emitter emitxtm: somc/smmain.c
 */
#define ODPartHandlerInfoInt_Class_Source
#define VARIABLE_MACROS
#include <PartInfi.xih>
#include <Part.xh>
#include <PartKind.xh>

#include <iset.h>
#include <csetwrap.h>

#include <rmutil.h>
#include <rmprptyp.h>

#include <string.h>

//## These static variable are used to access the bento properties and types. 
//## They are initialized the first time InitODPartHandlerInfoWithStorage 
//## is called.

static CMType ISOStringType                  = 0;
static CMType stringType                     = 0;
static CMType sequenceType                   = 0;
static CMType OperatingSystemType            = 0;
static CMType longType                       = 0;
static CMProperty PartKindInfoType           = 0;

static CMProperty partHandlerNameProp        = 0;
static CMProperty partHandlerDisplayNameProp = 0;
static CMProperty partHandlerClassNameProp   = 0;
static CMProperty DLLNameProp                = 0;
static CMProperty partKindInfoProp           = 0;
static CMProperty ole2ClassIdProp            = 0;
static CMProperty windowsIconFilenameProp    = 0;
static CMProperty osProp                     = 0;

static CMProperty partKindNameProp           = 0;
static CMProperty partKindDisplayNameProp    = 0;
static CMProperty filenameFiltersProp        = 0;
static CMProperty filenameTypesProp        = 0;
static CMProperty categoriesProp             = 0;
static CMProperty objectIDProp             = 0;
static CMProperty categoryDisplayNameProp    = 0;

#if 0 // defect 22539 - this file cannot be located in the OS/2 tree
#if (defined _PLATFORM_OS2_ )
#ifndef _RMERROR_    // 143600
#include <RMError.h>
#endif
#endif // OS2
#endif // defect 22539

static char* newString( CMObject obj, CMProperty prop, CMType type)
{
    CMValue value;
    string valueData = 0;
    CMSize size     = 0;

    if ( value = CMUseValue( obj, prop, type) )
    {
        //## Get value size, which includes the null terminator.  If size is > 0
        //## then allocate buffer and read data.
        if ( size = CMGetValueSize( value) )
        {
            valueData = string( SOMMalloc( size));
            SOM_Assert( (int)valueData, 1);
            size = CMReadValueData( value, valueData, 0, size);
            SOM_Assert( size, 1);
            #if ODDebug
            // somLPrintf( 1, "Read: %s\n", valueData);
            #endif
        }
    }
    else
    {
       value = CMNewValue( obj, prop, type);
    }
    return valueData;
}

static void writeString( string s, CMObject obj, CMProperty prop, CMType type)
{
    CMValue value;
    string valueData = 0;

    if ( !(value = CMUseValue( obj, prop, type)) )
    {
       value = CMNewValue( obj, prop, type);
    }

    if ( value)
    {
        //## Get value size, which includes the null terminator.  If size is > 0
        //## then allocate buffer and read data.
        if ( s )
        {
            CMWriteValueData( value, (CMPtr)s, 0, strlen(s)+1);
            #if ODDebug
            //somLPrintf( 1, "Write: %s\n", s);
            #endif
        }
        else
            CMWriteValueData(value, "", 0, 0);     /* Make the container manager happy */
    }
}

static long newLong( CMObject obj, CMProperty prop, CMType type)
{
    CMValue value;
    long valueData = 0;

    if ( value = CMUseValue( obj, prop, type) )
    {
        //## Get value size.  If size is > 0 then read data.
        if ( CMGetValueSize( value) )
        {
            SOM_Assert( CMReadValueData( value, &valueData, 0, sizeof(long)), 1);
            #if ODDebug
            //somLPrintf( 1, "Read: %d\n", valueData);
            #endif
        }
    }
    else
    {
       value = CMNewValue( obj, prop, type);
    }
    return valueData;
}

static void writeLong( long valueData, CMObject obj, CMProperty prop, CMType type)
{
    CMValue value;

    if ( !(value = CMUseValue( obj, prop, type)) )
    {
       value = CMNewValue( obj, prop, type);
    }

    if ( value )
    {

        #if ODDebug
        //somLPrintf( 1, "Write: %d\n", valueData);
        #endif
        CMWriteValueData( value, (CMPtr)&valueData, 0, sizeof(long));
    }
}

SOM_Scope long  SOMLINK ODPartHandlerInfoIntInitODPartHandlerInfo(ODPartHandlerInfoInt *somSelf,
                                                          Environment *ev,
                                                          string partClassName,
                                                          string DLLName,
                                                          OperatingSystem os)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntInitODPartHandlerInfo");

    //*** Local varibles ******************************************************
    somId                     classId;
    M_ODPart*                 newClass = 0;
    ODPartHandlerInfoInt*     partInfo;
    static M_ODPart*          partClass = (M_ODPart*)ODPartNewClass( 0, 0);
    static ODPartKind*        testKind  = new ODPartKind;
    ODPartKind*               foundKind;
    char fObjectID[200] = "\0";
//*************************************************************************

  try {
    if ( partClassName )
    {
        #if ODDebug
        //somLPrintf( 1, "partClassName = %s\n", partClassName);
        #endif
        classId = somIdFromString( partClassName);
        if ( !DLLName)
        {
            DLLName = partClassName;
        }

        {
            #if ODDebug
            //somLPrintf( 1, "DLLName = %s\n", DLLName);
            #endif
            newClass = (M_ODPart*)SOMClassMgrObject-> somFindClsInFile( classId, 0, 0, DLLName);
        }
//      else
//      {
//          somLPrintf( 1, "DLLName = (null)\n");
//          newClass = (M_ODPart*)SOMClassMgrObject-> somFindClass( classId, 0, 0);
//      }

        if ( newClass )
        {
            if ( newClass-> somDescendedFrom( newClass) )
            {
                // 129709 added newString so dll can be unloaded
                somThis-> partHandlerName        = newString(newClass-> clsGetODPartHandlerName( ev));
                somThis-> partHandlerDisplayName = newString(newClass-> clsGetODPartHandlerDisplayName( ev));
                // end 129709
                somThis-> partHandlerClassName   = newString( partClassName);
                somThis-> DLLName                = newString( DLLName);
                somThis-> partKindInfo           = newClass-> clsGetODPartKinds( ev);
                // [120348] added the check for NULL
                for( long i = 0; i < somThis-> partKindInfo. _length; i++)
                {  
                   if(!somThis->partKindInfo. _buffer[i]. filenameFilters)
                     somThis-> partKindInfo. _buffer[i]. filenameFilters = newString( "");
                   if(!somThis->partKindInfo. _buffer[i]. filenameTypes)
                     somThis-> partKindInfo. _buffer[i]. filenameTypes = newString( "");
                   if(!somThis->partKindInfo. _buffer[i]. categoryDisplayName)
                     somThis-> partKindInfo. _buffer[i]. categoryDisplayName = newString( "");
                   // We always set the object id
                   strcpy(fObjectID,"<OD_");
                   strcat(fObjectID,somThis-> partHandlerDisplayName);
                   strcat(fObjectID,">");
                   somThis->partKindInfo. _buffer[i]. objectID = newString( fObjectID);
                }

#ifdef _PLATFORM_WIN32_
                somThis-> ole2ClassId
                        = newString (newClass->clsGetOLE2ClassId (ev));

                somThis-> windowsIconFilename
                        = newString (newClass->clsGetWindowsIconFileName (ev));
#endif
                
                somThis-> os                     = os;
//                int rc = SOMClassMgrObject->somUnregisterClass(newClass);
                #if ODDebug
                //if(rc)
                  //somLPrintf( 1, "Unable to unload Class rc = %d", rc);
                #endif
            }
            else
            {
                return errPR_NOT_PART_HANDLER_CLASS;
            }
        }
        else
        {
            return errPR_COULD_NOT_LOAD_CLASS;
        }
    }
    else
    {
        #if ODDebug
        //somLPrintf( 1, "partClassName = (null)\n");
        #endif
        return errPR_INVALID_CLASSNAME;
    }
  }
  catch (ODException _exception ) {
     SetErrorCode(kODNoError);
  } /* end catch */

//    somSelf-> somDumpSelf( 1);
    return PR_NO_ERROR;
}

SOM_Scope string  SOMLINK ODPartHandlerInfoIntGetPartHandlerClassName(ODPartHandlerInfoInt *somSelf,
                                                               Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetPartHandlerClassName");

    return newString( somThis-> partHandlerClassName);
}

SOM_Scope ISOString  SOMLINK ODPartHandlerInfoIntGetPartHandlerName(ODPartHandlerInfoInt *somSelf,
                                                               Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetPartHandlerName");

    return newString( somThis-> partHandlerName);
}

SOM_Scope string  SOMLINK ODPartHandlerInfoIntGetPartHandlerDisplayName(ODPartHandlerInfoInt *somSelf,
                                                               Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetPartHandlerDisplayName");

    return newString( somThis-> partHandlerDisplayName);
}

SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK ODPartHandlerInfoIntGetPartKindInfo(ODPartHandlerInfoInt *somSelf,
                                                               Environment *ev,
                                                               string category)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetPartKindInfo");

    _IDL_SEQUENCE_PartKindInfo partKindInfo;

  try {
    partKindInfo. _length  = somThis-> partKindInfo. _length;
    partKindInfo. _maximum = somThis-> partKindInfo. _maximum;
    partKindInfo. _buffer  = (PartKindInfo*)SOMMalloc( partKindInfo. _maximum * sizeof( PartKindInfo));
    long len = 0; // 144288

    for( long i = 0; i < somThis-> partKindInfo. _length; i++)
    {
        if ( !category || strstr( somThis-> partKindInfo. _buffer[i]. categories, category ) )
        {
            partKindInfo. _buffer[len]. partKindName        = newString( somThis-> partKindInfo. _buffer[i]. partKindName);
            partKindInfo. _buffer[len]. partKindDisplayName = newString( somThis-> partKindInfo. _buffer[i]. partKindDisplayName);
            partKindInfo. _buffer[len]. filenameFilters     = newString( somThis-> partKindInfo. _buffer[i]. filenameFilters);
            partKindInfo. _buffer[len]. filenameTypes     = newString( somThis-> partKindInfo. _buffer[i]. filenameTypes);
            partKindInfo. _buffer[len]. categories          = newString( somThis-> partKindInfo. _buffer[i]. categories);
            partKindInfo. _buffer[len]. categoryDisplayName = newString( somThis-> partKindInfo. _buffer[i]. categoryDisplayName);
            partKindInfo. _buffer[len]. objectID             = newString( somThis-> partKindInfo. _buffer[i]. objectID); 
            len++;  // 144288
        }
    }

    partKindInfo. _length = len;  // 144288
  }  // try
  catch (ODException _exception ) {
     SetErrorCode(kODNoError);
  } /* end catch */

  return partKindInfo;
}

SOM_Scope OperatingSystem  SOMLINK ODPartHandlerInfoIntGetOperatingSystem(ODPartHandlerInfoInt *somSelf,
                                                              Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetOperatingSystem");

    return somThis-> os;
}

SOM_Scope void  SOMLINK ODPartHandlerInfoIntSetOperatingSystem(ODPartHandlerInfoInt *somSelf,
                                                             Environment *ev,
                                                            OperatingSystem os)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntSetOperatingSystem");

    somThis-> os = os;
}

SOM_Scope string  SOMLINK ODPartHandlerInfoIntGetOLE2ClassId(ODPartHandlerInfoInt *somSelf,
                                                           Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetOLE2ClassId");

    return newString( somThis-> ole2ClassId);
}

SOM_Scope string  SOMLINK ODPartHandlerInfoIntGetWindowsIconFileName(ODPartHandlerInfoInt *somSelf,
                                                             Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetWindowsIconFileName");

    return newString( somThis-> windowsIconFilename);
}

SOM_Scope long  SOMLINK ODPartHandlerInfoIntInitODPartHandlerInfoIntWithStorage(ODPartHandlerInfoInt *somSelf,
                                                             Environment *ev,
                                                             CMObject obj)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntInitODPartHandlerInfoIntWithStorage");

    CMValue partKindValue;

  try {
    somSelf-> InitPropertiesAndTypes( ev, obj);

    somThis-> partHandlerName        = newString( obj, partHandlerNameProp        , ISOStringType);
    somThis-> partHandlerDisplayName = newString( obj, partHandlerDisplayNameProp , stringType);
    somThis-> partHandlerClassName   = newString( obj, partHandlerClassNameProp   , stringType);
    somThis-> DLLName                = newString( obj, DLLNameProp                , stringType);

    somThis-> partKindInfo. _maximum = 0;
    somThis-> partKindInfo. _length  = 0;
    somThis-> partKindInfo. _buffer  = 0;

    if ( partKindValue = CMUseValue( obj, partKindInfoProp, PartKindInfoType) )
    {
        CMSize size;

        if ( size = CMGetValueSize( partKindValue) )
        {
            long count = size/sizeof(CMReference);

            #if ODDebug
            //somLPrintf( 10, "%d references found.\n", count);
            #endif

            somThis-> partKindInfo. _maximum = count;
            somThis-> partKindInfo. _length  = count;
            somThis-> partKindInfo. _buffer  = (PartKindInfo*)SOMMalloc( count*sizeof(PartKindInfo));

            CMReference ref = { 0 };

            for( long i = 0; i < count; i++)
            {
                CMReadValueData( partKindValue, ref, i*sizeof(ref), sizeof(ref));
                CMObject partKindInfoObject;
                if ( partKindInfoObject = CMGetReferencedObject( partKindValue, ref) )
                {
                    somThis-> partKindInfo. _buffer[i]. partKindName = newString( partKindInfoObject, partKindNameProp, ISOStringType);
                    somThis-> partKindInfo. _buffer[i]. partKindDisplayName = newString( partKindInfoObject, partKindDisplayNameProp, stringType);
                    somThis-> partKindInfo. _buffer[i]. filenameFilters = newString( partKindInfoObject, filenameFiltersProp, stringType);
                    somThis-> partKindInfo. _buffer[i]. filenameTypes = newString( partKindInfoObject, filenameTypesProp, stringType);
                    somThis-> partKindInfo. _buffer[i]. categories = newString( partKindInfoObject, categoriesProp, stringType);
                    somThis-> partKindInfo. _buffer[i]. categoryDisplayName = newString( partKindInfoObject, categoryDisplayNameProp, stringType);
                    somThis-> partKindInfo. _buffer[i]. objectID = newString( partKindInfoObject, objectIDProp, stringType);
                }
                else
                {
                    SOM_Expect( (int)partKindInfoObject);
                }
            }
        }
    }
    else
    {
        partKindValue = CMNewValue( obj, partKindInfoProp, PartKindInfoType);
       CMWriteValueData(partKindValue, "", 0, 0);     /* Make the container manager happy */
    }

#ifdef _PLATFORM_OS2_
    somThis-> ole2ClassId            = newString( obj, ole2ClassIdProp            , stringType);
    somThis-> windowsIconFilename    = newString( obj, windowsIconFilenameProp    , stringType);
#endif
    somThis-> os                     = newLong( obj, osProp, longType);
  }  // try
  catch (ODException _exception ) {
     SetErrorCode(kODNoError);
  } /* end catch */

  return PR_NO_ERROR;
}

SOM_Scope long  SOMLINK ODPartHandlerInfoIntWriteODPartHandlerInfoIntToStorage(ODPartHandlerInfoInt *somSelf,
                                                               Environment *ev,
                                                               CMObject obj)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntWriteODPartHandlerInfoIntToStorage");

  try {
    somSelf-> InitPropertiesAndTypes( ev, obj);
    if ( obj )
    {

        writeString( somThis-> partHandlerName        , obj, partHandlerNameProp        , ISOStringType);
        writeString( somThis-> partHandlerDisplayName , obj, partHandlerDisplayNameProp , stringType);
        writeString( somThis-> partHandlerClassName   , obj, partHandlerClassNameProp   , stringType);
        writeString( somThis-> DLLName                , obj, DLLNameProp                , stringType);

        CMValue partKindValue;

        if ( !(partKindValue = CMUseValue( obj, partKindInfoProp, PartKindInfoType)) )
        {
            partKindValue = CMNewValue( obj, partKindInfoProp, PartKindInfoType);
//            CMWriteValueData(partKindValue, "", 0, 1);     /* Make the container manager happy */
        }
 
        if ( partKindValue )
        {
            CMReference ref = { 0 };
            CMContainer container = CMGetObjectContainer( obj);

            for( long i = 0; i < somThis-> partKindInfo. _length; i++)
            {
                CMObject partKindInfoObject = CMNewObject( container);

                if ( partKindInfoObject )
                {
                    writeString( somThis-> partKindInfo. _buffer[i]. partKindName , partKindInfoObject, partKindNameProp, ISOStringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. partKindDisplayName , partKindInfoObject, partKindDisplayNameProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. filenameFilters , partKindInfoObject, filenameFiltersProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. filenameTypes , partKindInfoObject, filenameTypesProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. categories , partKindInfoObject, categoriesProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. categoryDisplayName , partKindInfoObject, categoryDisplayNameProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. objectID , partKindInfoObject, objectIDProp, stringType);
                    CMNewReference( partKindValue, partKindInfoObject, ref);
                    CMWriteValueData( partKindValue, ref, i*sizeof(ref), sizeof(ref));
                }
                else
                {
                    SOM_Assert( (int)partKindInfoObject, 1);
                }
            }
        }
        else
        {
            SOM_Assert( (int)partKindValue, 1);
        }
#ifdef _PLATFORM_WIN32_
        writeString( somThis-> ole2ClassId            , obj, ole2ClassIdProp            , stringType);
        writeString( somThis-> windowsIconFilename    , obj, windowsIconFilenameProp    , stringType);
#endif
        writeLong( somThis-> os                       , obj, osProp, longType);


    }
  }  // try
  catch (ODException _exception ) {
     SetErrorCode(kODNoError);
  } /* end catch */
  return PR_NO_ERROR;
}

SOM_Scope long  SOMLINK ODPartHandlerInfoIntWriteODPartHandlerInfoIntToRegistry(ODPartHandlerInfoInt *somSelf,
                                                             Environment *ev,
                                                             Node partHandlers)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntWriteODPartHandlerInfoIntToRegistry");

    /* Return statement to be customized: */
      long retVal;  
      return (retVal); 
}

SOM_Scope void  SOMLINK ODPartHandlerInfoIntInitPropertiesAndTypes(ODPartHandlerInfoInt *somSelf,
                                                               Environment *ev,
                                                               CMObject obj)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntInitPropertiesAndTypes");

    CMContainer container = CMGetObjectContainer( obj);

    ISOStringType       = CMRegisterType( container, kRMISOStringType);
    stringType          = CMRegisterType( container, kRMstringType);
    sequenceType        = CMRegisterType( container, kRMsequenceType);
    OperatingSystemType = CMRegisterType( container, kRMOperatingSystemType);
    longType            = CMRegisterType( container, kRMlongType);
    PartKindInfoType    = CMRegisterType( container, kRMPartKindInfoType);

    partHandlerNameProp        = CMRegisterProperty( container, kRMpartHandlerNameProp);
    partHandlerDisplayNameProp = CMRegisterProperty( container, kRMpartHandlerDisplayNameProp);
    partHandlerClassNameProp   = CMRegisterProperty( container, kRMpartHandlerClassNameProp);
    DLLNameProp                = CMRegisterProperty( container, kRMDLLNameProp);
    partKindInfoProp           = CMRegisterProperty( container, kRMpartKindInfoProp);
    ole2ClassIdProp            = CMRegisterProperty( container, kRMole2ClassIdProp);
    windowsIconFilenameProp    = CMRegisterProperty( container, kRMwindowsIconFilenameProp);
    osProp                     = CMRegisterProperty( container, kRMosProp);

    partKindNameProp           = CMRegisterProperty( container, kRMpartKindNameProp);
    partKindDisplayNameProp    = CMRegisterProperty( container, kRMpartKindDisplayNameProp);
    filenameFiltersProp        = CMRegisterProperty( container, kRMfilenameFiltersProp);
    filenameTypesProp          = CMRegisterProperty( container, kRMfilenameTypesProp);
    categoriesProp             = CMRegisterProperty( container, kRMcategoriesProp);
    categoryDisplayNameProp    = CMRegisterProperty( container, kRMcategoryDisplayNameProp);
    objectIDProp               = CMRegisterProperty( container, kRMobjectIDProp);
}

SOM_Scope ODPartHandlerInfoInt*  SOMLINK ODPartHandlerInfoIntClone(ODPartHandlerInfoInt *somSelf,
                                                               Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntClone");

    ODPartHandlerInfoInt* partInfo = new ODPartHandlerInfoInt;
    ODPartHandlerInfoIntData *partInfoData = ODPartHandlerInfoIntGetData( partInfo);

  try {
    partInfoData-> partHandlerName        = newString( somThis-> partHandlerName        );
    partInfoData-> partHandlerDisplayName = newString( somThis-> partHandlerDisplayName );
    partInfoData-> partHandlerClassName   = newString( somThis-> partHandlerClassName   );
    partInfoData-> DLLName                = newString( somThis-> DLLName                );
    partInfoData-> ole2ClassId            = newString( somThis-> ole2ClassId            );
    partInfoData-> windowsIconFilename    = newString( somThis-> windowsIconFilename    );
    partInfoData-> os                     = somThis-> os;

    partInfoData-> partKindInfo. _maximum  = somThis-> partKindInfo. _maximum;
    partInfoData-> partKindInfo. _length  = somThis-> partKindInfo. _length;
    partInfoData-> partKindInfo. _buffer  = (PartKindInfo*)SOMMalloc( partInfoData-> partKindInfo. _maximum * sizeof(PartKindInfo));

    for ( long i = 0; i < somThis-> partKindInfo. _length; i++)
    {
        partInfoData-> partKindInfo. _buffer[i]. partKindName        = newString( somThis-> partKindInfo. _buffer[i]. partKindName);
        partInfoData-> partKindInfo. _buffer[i]. partKindDisplayName = newString( somThis-> partKindInfo. _buffer[i]. partKindDisplayName);
        partInfoData-> partKindInfo. _buffer[i]. filenameFilters     = newString( somThis-> partKindInfo. _buffer[i]. filenameFilters);
        partInfoData-> partKindInfo. _buffer[i]. filenameTypes     =  newString( somThis-> partKindInfo. _buffer[i]. filenameTypes);
        partInfoData-> partKindInfo. _buffer[i]. categories          = newString( somThis-> partKindInfo. _buffer[i]. categories);
        partInfoData-> partKindInfo. _buffer[i]. categoryDisplayName = newString( somThis-> partKindInfo. _buffer[i]. categoryDisplayName);
        partInfoData-> partKindInfo. _buffer[i]. objectID          = newString( somThis-> partKindInfo. _buffer[i]. objectID);
    }

  }  // try
  catch (ODException _exception ) {
     SetErrorCode(kODNoError);
  } /* end catch */
  return partInfo;
}

SOM_Scope boolean  SOMLINK ODPartHandlerInfoIntSupportsKind(ODPartHandlerInfoInt *somSelf,
                                                        Environment *ev,
                                                        ISOString partKindName)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntSupportsKind");

    if ( partKindName )
    {
        for ( long i = 0; i < somThis-> partKindInfo. _length; i++)
        {
            if ( !strcmp( somThis-> partKindInfo. _buffer[i]. partKindName, partKindName) )
            {
                return true;
            }
        }
        return false;
    }
    else
    {
        return true;
    }
}

SOM_Scope boolean  SOMLINK ODPartHandlerInfoIntSupportsCategory(ODPartHandlerInfoInt *somSelf,
                                                             Environment *ev,
                                                             string category)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntSupportsCategory");

    if ( category )
    {
        for ( long i = 0; i < somThis-> partKindInfo. _length; i++)
        {
            if ( strstr( somThis-> partKindInfo. _buffer[i]. categories, category) )
            {
                return true;
            }
        }
        return false;
    }
    else
    {
        return true;
    }
}

SOM_Scope string  SOMLINK ODPartHandlerInfoIntGetKey(ODPartHandlerInfoInt *somSelf,
                                                      Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetKey");

    return somSelf-> _get_partHandlerName( ev);
}

SOM_Scope void  SOMLINK ODPartHandlerInfoIntsomInit(ODPartHandlerInfoInt *somSelf)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntsomInit");

    somThis-> partHandlerName        = 0;
    somThis-> partHandlerDisplayName = 0;
    somThis-> partHandlerClassName   = 0;
    somThis-> DLLName                = 0;
    somThis-> partKindInfo. _maximum = 0;
    somThis-> partKindInfo. _length  = 0;
    somThis-> partKindInfo. _buffer  = 0;
    somThis-> ole2ClassId            = 0;
    somThis-> windowsIconFilename    = 0;
    somThis-> os                     = OS2;

    ODPartHandlerInfoInt_parent_ODPartHandlerInfo_somInit(somSelf);
}

SOM_Scope void  SOMLINK ODPartHandlerInfoIntsomUninit(ODPartHandlerInfoInt *somSelf)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntsomUninit");

    SOMFree( somThis-> partHandlerName);
    SOMFree( somThis-> partHandlerDisplayName);
    SOMFree( somThis-> partHandlerClassName);
    SOMFree( somThis-> DLLName);

    for ( long i = 0; i < somThis-> partKindInfo. _length; i++)
    {
        SOMFree( somThis-> partKindInfo. _buffer[i]. partKindName);
        SOMFree( somThis-> partKindInfo. _buffer[i]. partKindDisplayName);
        SOMFree( somThis-> partKindInfo. _buffer[i]. filenameFilters);
        SOMFree( somThis-> partKindInfo. _buffer[i]. filenameTypes);
        SOMFree( somThis-> partKindInfo. _buffer[i]. categories);
        SOMFree( somThis-> partKindInfo. _buffer[i]. categoryDisplayName);
        SOMFree( somThis-> partKindInfo. _buffer[i]. objectID);
    }
    SOMFree( somThis-> partKindInfo. _buffer);
    SOMFree( somThis-> ole2ClassId);
    SOMFree( somThis-> windowsIconFilename);

    ODPartHandlerInfoInt_parent_ODPartHandlerInfo_somUninit(somSelf);
}

SOM_Scope void  SOMLINK ODPartHandlerInfoIntsomDumpSelfInt(ODPartHandlerInfoInt *somSelf,
                                                        long level)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntsomDumpSelfInt");

    if ( somThis-> partHandlerName)
      somLPrintf( level,   "partHandlerName         : %s\n", somThis-> partHandlerName);

    if ( somThis-> partHandlerDisplayName)
      somLPrintf( level,   "partHandlerDisplayName  : %s\n", somThis-> partHandlerDisplayName);

    if ( somThis-> partHandlerClassName)
      somLPrintf( level,   "partHandlerClassName  : %s\n", somThis-> partHandlerClassName);

    if ( somThis-> DLLName)
      somLPrintf( level,   "DLLName                 : %s\n", somThis-> DLLName);

    showSeq( somThis-> partKindInfo, level);

    for ( int i = 0; i < somThis-> partKindInfo. _length; i++)
    {
        somLPrintf( level, "partKindInfo[%d] @  %0x\n", i, &somThis-> partKindInfo. _buffer[i]);
        PartKindInfo& ki = somThis-> partKindInfo. _buffer[i];

        if ( ki. partKindName)
            somLPrintf( level+1, "partKindName         : %s\n", ki. partKindName);

        if ( ki. partKindDisplayName)
            somLPrintf( level+1, "partKindDisplayName  : %s\n", ki. partKindDisplayName);

        if ( ki. filenameFilters)
            somLPrintf( level+1, "filenameFilters  : %s\n", ki. filenameFilters);

        if ( ki. filenameTypes)
            somLPrintf( level+1, "filenameTypes  : %s\n", ki. filenameTypes);

        if ( ki. categories)
            somLPrintf( level+1, "categories  : %s\n", ki. categories);

        if ( ki. categoryDisplayName)
            somLPrintf( level+1, "categoryDisplayName  : %s\n", ki. categoryDisplayName);

        if ( ki. objectID)
            somLPrintf( level+1, "objectID  : %s\n", ki. objectID);
    }

    if ( somThis-> ole2ClassId )
        somLPrintf( level, "ole2ClassId          : %s\n", somThis-> ole2ClassId);

    if ( somThis-> windowsIconFilename )
        somLPrintf( level, "windowsIconFilename  : %s\n", somThis-> windowsIconFilename);
}

SOM_Scope string  SOMLINK ODPartHandlerInfoIntGetDLLName(ODPartHandlerInfoInt *somSelf,
                                                          Environment *ev)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntGetDLLName");


    return newString( somThis-> DLLName);
}

SOM_Scope long  SOMLINK ODPartHandlerInfoIntWriteODPartHandlerKindInfo(ODPartHandlerInfoInt *somSelf,
                                     Environment *ev,
                                     CMObject obj,
                                     _IDL_SEQUENCE_PartKindInfo * newKindInfo )
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntWriteODPartHandlerKindInfo");

  try {
    if(newKindInfo-> _length != somThis->partKindInfo. _length)
       return errPR_PART_KIND_NOT_FOUND;   // need a better error for this

    somSelf-> InitPropertiesAndTypes( ev, obj);

    if ( obj )
    {

        writeString( somThis-> partHandlerName        , obj, partHandlerNameProp        , ISOStringType);
        writeString( somThis-> partHandlerDisplayName , obj, partHandlerDisplayNameProp , stringType);
        writeString( somThis-> partHandlerClassName   , obj, partHandlerClassNameProp   , stringType);
        writeString( somThis-> DLLName                , obj, DLLNameProp                , stringType);
        CMValue partKindValue;

        if ( !(partKindValue = CMUseValue( obj, partKindInfoProp, PartKindInfoType)) )
        {
            partKindValue = CMNewValue( obj, partKindInfoProp, PartKindInfoType);
           CMWriteValueData(partKindValue, "", 0, 0);     /* Make the container manager happy */
        }

        if ( partKindValue )
        {
            CMReference ref = { 0 };
            CMContainer container = CMGetObjectContainer( obj);

            for( long i = 0; i < somThis-> partKindInfo. _length; i++)
            {
                CMObject partKindInfoObject = CMNewObject( container);

                if ( partKindInfoObject )
                {
                    writeString( somThis-> partKindInfo. _buffer[i]. partKindName , partKindInfoObject, partKindNameProp, ISOStringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. partKindDisplayName , partKindInfoObject, partKindDisplayNameProp, stringType);
                    // swap in the new values for filenameFilters and filenameTypes
                    SOMFree(somThis-> partKindInfo. _buffer[i]. filenameFilters);
                    SOMFree(somThis-> partKindInfo. _buffer[i]. filenameTypes);
                    somThis-> partKindInfo. _buffer[i]. filenameFilters
                        = newString( newKindInfo-> _buffer[i].filenameFilters);
                    somThis-> partKindInfo. _buffer[i]. filenameTypes 
                        = newString( newKindInfo-> _buffer[i].filenameTypes);
                    writeString( somThis-> partKindInfo. _buffer[i]. filenameFilters , partKindInfoObject, filenameFiltersProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. filenameTypes , partKindInfoObject, filenameTypesProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. categories , partKindInfoObject, categoriesProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. categoryDisplayName , partKindInfoObject, categoryDisplayNameProp, stringType);
                    writeString( somThis-> partKindInfo. _buffer[i]. objectID , partKindInfoObject, objectIDProp, stringType);
                    CMNewReference( partKindValue, partKindInfoObject, ref);
                    CMWriteValueData( partKindValue, ref, i*sizeof(ref), sizeof(ref));
                }
                else
                {
                    SOM_Assert( (int)partKindInfoObject, 1);
                }
            }
        }
        else
        {
            SOM_Assert( (int)partKindValue, 1);
        }

        writeString( somThis-> ole2ClassId            , obj, ole2ClassIdProp            , stringType);
        writeString( somThis-> windowsIconFilename    , obj, windowsIconFilenameProp    , stringType);
        writeLong( somThis-> os                       , obj, osProp, longType);

    }
  }  // try
  catch (ODException _exception ) {
     SetErrorCode(kODNoError);
  } /* end catch */
  return PR_NO_ERROR;
}

SOM_Scope boolean  SOMLINK ODPartHandlerInfoIntSupportsFileType(ODPartHandlerInfoInt *somSelf,
                                                                Environment *ev,
                                                                string fileType)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntSupportsFileType");

    if ( fileType )
    {
        for ( long i = 0; i < somThis-> partKindInfo. _length; i++)
        {
            if ( strstr( somThis-> partKindInfo. _buffer[i]. filenameTypes, fileType) )
            {
                return true;
            }
        }
        return false;
    }
    else
    {
        return false;
    }
}

SOM_Scope boolean  SOMLINK ODPartHandlerInfoIntSupportsFileExtension(ODPartHandlerInfoInt *somSelf,
                                                          Environment *ev,
                                                          string fileExtension)
{
    ODPartHandlerInfoIntData *somThis = ODPartHandlerInfoIntGetData(somSelf);
    ODPartHandlerInfoIntMethodDebug("ODPartHandlerInfoInt","ODPartHandlerInfoIntSupportsFileExtension");

    if ( fileExtension )
    {
        for ( long i = 0; i < somThis-> partKindInfo. _length; i++)
        {
            if ( strstr( somThis-> partKindInfo. _buffer[i]. filenameFilters, fileExtension) )
            {
                return true;
            }
        }
        return false;
    }
    else
    {
        return false;
    }
}
