예제 #1
0
파일: tooltip.c 프로젝트: virqin/brew_code
void Tooltip_CtorZ(Tooltip *me, IShell *piShell, IDisplay *piDisplay,
                   int16 yBottom, int16 nX, int16 nDx,
                   uint32 ulDelay, uint32 ulExpires,
                   PFNNOTIFY pfnInvalidate, void *pInvalidateData)
{
    me->piShell         = piShell;
    ISHELL_AddRef(piShell);
    me->piDisplay       = piDisplay;
    IDISPLAY_AddRef(piDisplay);

    me->nX              = nX;
    me->nDx             = nDx;
    me->ulDelay         = ulDelay;
    me->ulExpires       = ulExpires;
    me->pfnInvalidate   = pfnInvalidate;
    me->pInvalidateData = pInvalidateData;

    {
        int nAscent, nDescent;
        IDISPLAY_GetFontMetrics(piDisplay,AEE_FONT_NORMAL,&nAscent,&nDescent);

        me->rc.x = 0;
        me->rc.dy = nAscent + nDescent + 4;
        me->rc.y = MAX(0, yBottom - me->rc.dy - 2);
    }
}
예제 #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
파일: Location.c 프로젝트: TopSoup/BasicLoc
/*======================================================================= 
Function: Loc_Init()
=======================================================================*/
int Loc_Init( IShell *pIShell, IPosDet *pIPos, AEECallback *pcb, LocState **po ) {
   int nErr = SUCCESS;
   LocState *pts = NULL;

   if( !pIShell || !pIPos || !pcb || !po ) {

      nErr = EBADPARM;

   }
   else if( NULL == (pts = MALLOC( sizeof(LocState) )) ){

      nErr = ENOMEMORY;

   }
   else {

      ZEROAT( pts );

      pts->pShell = pIShell;
      ISHELL_AddRef( pIShell );

      pts->pPos = pIPos;
      IPOSDET_AddRef( pIPos );

      /* Install the notification cb */
      CALLBACK_Cancel( pcb );
      pts->pcbResp = pcb;
      pts->pcbResp->pfnCancel   = Loc_Cancel;
      pts->pcbResp->pCancelData = pts;

      CALLBACK_Init( &pts->cbIntervalTimer, Loc_cbInterval, pts );
      CALLBACK_Init( &pts->cbInfo, Loc_cbInfo, pts );
   }

   *po = pts;
   return nErr;

}
예제 #4
0
파일: AEEModGen.c 프로젝트: fmedlin/BrewApp
/*===========================================================================

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;
   }

   if (nSize < 0) {
      return EBADPARM;
   }
   *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;
   ISHELL_AddRef(pIShell);

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

   return SUCCESS;
}