Beispiel #1
0
/*=============================================================================
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;
}
// ================================================================================
// 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;
}