LWRESULT Cx_PluginLoader::LoadPlugin(const MODID& modid)
{
    int32_ existIndex = GetPluginIndex(modid);

    if (existIndex >= 0 && m_modules[existIndex]->modid.empty())
    {
        return LWDP_PLUGINMGR_MODULE_ALREADY_LOAD;
    }

	Cx_Interface<Ix_FwIntf> iFwIntf(CLSID_FwIntf);
	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_OBJECT_POINTER_IS_NULL, !iFwIntf.IsNull(), 
		             "Cx_PluginLoader::LoadPlugin Get Object(FwIntf) Error");
	Ix_Module* pModule = iFwIntf->Api_Fw_GetModulePtr(modid);
	if(!pModule)
	{
		return LWDP_PLUGINMGR_NOT_FIND_MODULE_ENTRY;
	}

	LWRESULT stat = LWDP_ERROR;
    if (pModule)
    {
    	if((stat = CheckPlugin(pModule)) != LWDP_OK)
    	{
    		if(pModule->GetModuleInstance()) //!< 只有加载的外部模块才Unload
    		{
    			Cx_Interface<Ix_FwIntf> iFwIntf(CLSID_FwIntf);
				ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_OBJECT_POINTER_IS_NULL, !iFwIntf.IsNull(), 
					             "Cx_PluginLoader::LoadPlugin Get Object(FwIntf) Error");
				iFwIntf->Api_Fw_UnLoadModule(pModule->GetModuleMODID());
    		}
			return stat;
    	}
		
    	pModule->Initialize(this, 0);
        if(RegisterPlugin(pModule) == LWDP_OK)
        {
            int32_ moduleIndex = FindModule(pModule->GetModuleMODID());

        	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PLUGINMGR_MODULE_INDEX_ERROR, (moduleIndex >= 0), "Module Index Error");        
        	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PLUGINMGR_MODULE_INDEX_ERROR, (existIndex < 0 || existIndex == moduleIndex), "Module Index Error");        
        }
    }
    else
    {
    	return LWDP_PLUGINMGR_LOADMODULE_ERROR;
    }

    return LWDP_OK;
}
// -----------------------------------------------------------------------------
// CAppDemoAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CAppDemoAppView::ConstructL(const TRect& aRect)
	{
	// Create a window for this application view
	CreateWindowL();
	
	if(CheckPlugin())
		{
		TRAPD(err,iInterface = CInterfaceDefinition::NewL(KAliXPayOperationName));
		}	
	CreateListBox();
	// Set the windows size
	SetRect(aRect);
	// Activate the window, which makes it ready to be drawn
	ActivateL();
	}