예제 #1
0
파일: OEMVector.c 프로젝트: bgtwoigu/1110
/*=============================================================================
FUNCTION: CVector_New

DESCRIPTION:

PARAMETERS:
	*ps: 
	*pIModule: 
	**ppObj: 

RETURN VALUE:
int: 

COMMENTS:

SIDE EFFECTS:

SEE ALSO:

=============================================================================*/
static int CVector_New(IShell   *ps,
                       IModule  *pIModule,
                       IVector **ppObj)
{
   CVector *cv;

   cv = OEM_Malloc(sizeof(CVector));
   if (NULL == cv) {
      return ENOMEMORY;
   }

   MEMSET(cv,
          0,
          sizeof(CVector));

   INIT_VTBL(cv,
             IVector,
             gIVectorMethods);

   cv->m_nRefs     = 1;
   cv->m_pModule   = pIModule;

   (void) IMODULE_AddRef(pIModule);

   CVector_FreeData(cv);

   *ppObj = (IVector*)cv;
   return SUCCESS;
}
예제 #2
0
// ================================================================================
// FUNCTION		: SyncEngExt_New
// DESCRIPTION	: Construction of the class and initialization of it's members
// ================================================================================
int SyncEngExt_New(int16 nSize, IShell *pIShell, IModule* pIModule, IModule ** ppMod)
{
	SyncEngExt *			   pMe = NULL;
	
	VTBL(ISyncEngExt) *	modFuncs;

	if( !ppMod || !pIShell || !pIModule )
		return EFAILED;

	*ppMod = NULL;
	

	// Allocate memory for the ExtensionCls object
	if( nSize < sizeof(SyncEngExt) )
		nSize += sizeof(SyncEngExt);

	if( (pMe = (SyncEngExt *)MALLOC(nSize + sizeof(ISyncEngExtVtbl))) == NULL )
		return ENOMEMORY;

	// Allocate the vtbl and initialize it. Note that the modules and apps must not
	// have any static data. Hence, we need to allocate the vtbl as well.
	modFuncs = (ISyncEngExtVtbl *)((byte *)pMe + nSize);
	
	//Initialize individual entries in the VTBL
	modFuncs->AddRef			= SyncEngExt_AddRef;
	modFuncs->Release			= SyncEngExt_Release;
	
	modFuncs->SyncContacts		= SyncEngExt_SyncContacts;
	modFuncs->RegisterNewUser	= SyncEngExt_RegisterNewUser;
	modFuncs->HandleEvent		= SyncEngExt_HandleEvent;
	modFuncs->IsRegistered		= SyncEngExt_IsRegistered;
	modFuncs->GetSheduleTime	= SyncEngExt_GetSheduleTime;
	modFuncs->UploadPhoto		= SyncEngExt_UploadPhoto;
	modFuncs->SyncAlbum			= SyncEngExt_SyncAlbum;
	modFuncs->GetContacts		= SyncEngExt_GetContacts;
	modFuncs->ShareAlbum		= SyncEngExt_ShareAlbum;
	modFuncs->SaveSms			= SyncEngExt_SaveSms;
	modFuncs->GetSms			= SyncEngExt_GetSms;
	modFuncs->UploadSms			= SyncEngExt_UploadSms;

	// initialize the vtable
	INIT_VTBL(pMe, IModule, *modFuncs);

	// initialize the data members
	pMe->m_nRefs      = 1;
	pMe->m_pIShell    = pIShell;
	pMe->m_pIModule   = pIModule;
	
	pMe->m_pContHandler = NULL;
	
	ISHELL_AddRef(pIShell);
	IMODULE_AddRef(pIModule);
	
		
	// Set the pointer in the parameter
	*ppMod = (IModule*)pMe;

	return AEE_SUCCESS;
}
예제 #3
0
파일: OEMVector.c 프로젝트: bgtwoigu/1110
/*=============================================================================
FUNCTION: IVectorMod_New

DESCRIPTION: Module create function

PARAMETERS:
	nSize: 
	*pIShell: 
	*ph: 
	**ppMod: 
	pfnMC: 
	pfnMF: 

RETURN VALUE:
int: 

COMMENTS:

SIDE EFFECTS:

SEE ALSO:

=============================================================================*/
int IVectorMod_New(int16            nSize,
                   IShell          *pIShell,
                   void            *ph,
                   IModule        **ppMod,
                   PFNMODCREATEINST pfnMC,
                   PFNFREEMODDATA   pfnMF)
{
   if (!ppMod) return EFAILED;
   *ppMod = NULL;

// IMPORTANT NOTE: g_dwAEEStdLibEntry global variable is defined for SDK ONLY!
// This variable should NOT BE (1) overwritten and/or (2) USED DIRECTLY
// by BREW SDK users.
// It is used as an entry point to AEEStdLib.
// DO NOT REMOVE next three lines.
#ifdef AEE_SIMULATOR
   g_dwAEEStdLibEntry = (uint32)ph;
   if (!pIShell || !ph) return EFAILED;
#else
   if (!pIShell) return EFAILED;
#endif

   MEMSET(&gIVectorMod,
          0,
          sizeof(IVectorMod));

   INIT_VTBL(&gIVectorMod,
             IModule,
             gModFuncs);

	gIVectorMod.m_nRefs = 1;

   *ppMod = (IModule *)&gIVectorMod;

   return AEE_SUCCESS;
}
예제 #4
0
/*===========================================================================

Function:  AEEStaticMod_New()

Description:
   This is the module load function for static modules. It is directly 
   invoked by static modules when the static module is being loaded. 
   It also serves as a helper function for dynamic modules. 
   It creates an instance of the AEEMod structure and initializes the data
   members appropriately. The only difference between this function and the
   one used for dynamic mods is that this function takes an additional 
   parameter that specifies the CreateInstance function of the static module.

Prototype:
   boolean AEEStaticMod_New(int nSize, IShell *pIShell, void *ph, 
                            IModule **ppMod,PFNMODCREATEINST pfn)

Parameters:
   nSize: Specifies the size (in bytes) of the structure to be allocated for 
           the module.  Typically, this is the size of the AEEMod structure
   piShell: Pointer to IShell interface
   ph:  Not used on phone. In SDK, this is a pointer to the AEEHelperFuncs 
           structure. 
   ppMod: [ou]: On return, *ppMod contains a valid pointer to the AEEMod 
           structure
   pfn: Pointer to the modules' CreateInstance() function

Return Value:
   SUCCESS: If successful
   Error code: IF failed

Comments:  None

Side Effects: None

==============================================================================*/
int AEEStaticMod_New(int16 nSize, IShell *pIShell, void *ph, IModule **ppMod,
                     PFNMODCREATEINST pfnMC,PFNFREEMODDATA pfnMF)
{
   AEEMod *pMe = NULL;
   VTBL(IModule) *modFuncs;

   if (!ppMod || !pIShell) {
      return EFAILED;
   }

   *ppMod = NULL;
  
#ifdef AEE_SIMULATOR
   // IMPORTANT NOTE: g_pvtAEEStdLibEntry global variable is defined for 
   //   SDK ONLY! This variable should NOT BE:
   //
   //      (1) overwritten 
   //      (2) USED DIRECTLY by BREW SDK users. 
   //
   //  g_pvtAEEStdLibEntry is used as an entry point to AEEStdLib,
   //   DO NOT REMOVE the next five lines.
   if (!ph) {
      return EFAILED;
   } else {
      g_pvtAEEStdLibEntry = (AEEHelperFuncs *)ph;
   }
#endif

   //Allocate memory for the AEEMod object

   if (nSize < sizeof(AEEMod)) {
      nSize += sizeof(AEEMod);
   }

   if (NULL == (pMe = (AEEMod *)MALLOC(nSize + sizeof(IModuleVtbl)))) {
      return ENOMEMORY;
   }
  
   // Allocate the vtbl and initialize it. Note that the modules and apps 
   // must not have any static data. Hence, we need to allocate the vtbl as 
   // well.

   modFuncs = (IModuleVtbl *)((byte *)pMe + nSize);

   // Initialize individual entries in the VTBL
   modFuncs->AddRef         = AEEMod_AddRef;
   modFuncs->Release        = AEEMod_Release;
   modFuncs->CreateInstance = AEEMod_CreateInstance;
   modFuncs->FreeResources  = AEEMod_FreeResources;


   // initialize the vtable
   INIT_VTBL(pMe, IModule, *modFuncs);

   // initialize the data members

   // Store address of Module's CreateInstance function
   pMe->pfnModCrInst = pfnMC;

   // Store Address of Module's FreeData function
   pMe->pfnModFreeData = pfnMF;

   pMe->m_nRefs = 1;
   pMe->m_pIShell = pIShell;

   // Set the pointer in the parameter
   *ppMod = (IModule*)pMe;

   return SUCCESS;
}