⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osmo4_appview.cpp

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	m_mx = gf_mx_new();	m_window = Window();	m_session = CEikonEnv::Static()->WsSession();	//load config file	m_user.config = gf_cfg_new("\\private\\F01F9075\\", "GPAC.cfg");	if (!m_user.config) {		first_launch = 1;		FILE *ft = fopen("\\private\\F01F9075\\GPAC.cfg", "wt");		if (!ft) {			MessageBox("Cannot create GPAC Config file", "Fatal Error");			User::Leave(KErrGeneral);		} else {			fclose(ft);		}		m_user.config = gf_cfg_new("\\private\\F01F9075\\", "GPAC.cfg");		if (!m_user.config) {			MessageBox("GPAC Configuration file not found", "Fatal Error");			User::Leave(KErrGeneral);		}	}	SetupLogs();	gf_set_progress_callback(this, Osmo4_progress_cbk);	opt = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory");	if (!opt) first_launch = 2;		if (first_launch) {		/*hardcode module directory*/		gf_cfg_set_key(m_user.config, "General", "ModulesDirectory", "\\sys\\bin");		/*hardcode cache directory*/		gf_cfg_set_key(m_user.config, "General", "CacheDirectory", "\\private\\F01F9075\\cache");		gf_cfg_set_key(m_user.config, "Downloader", "CleanCache", "yes");		/*startup file*/		//gf_cfg_set_key(m_user.config, "General", "StartupFile", "\\private\\F01F9075\\gpac.mp4");		/*setup UDP traffic autodetect*/		gf_cfg_set_key(m_user.config, "Network", "AutoReconfigUDP", "yes");		gf_cfg_set_key(m_user.config, "Network", "UDPNotAvailable", "no");		gf_cfg_set_key(m_user.config, "Network", "UDPTimeout", "10000");		gf_cfg_set_key(m_user.config, "Network", "BufferLength", "3000");				gf_cfg_set_key(m_user.config, "Rendering", "RendererName", "GPAC 2D Renderer");		gf_cfg_set_key(m_user.config, "FontEngine", "TextureTextMode", "3D");				/*save cfg and reload*/		gf_cfg_del(m_user.config);		m_user.config = gf_cfg_new("\\private\\F01F9075\\", "GPAC.cfg");		if (!m_user.config) {			MessageBox("Cannot save initial GPAC Config file", "Fatal Error");			User::Leave(KErrGeneral);		}		MessageBox("Osmo4", "Thank you for Installing");	}	/*load modules*/	opt = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory");	m_user.modules = gf_modules_new(opt, m_user.config);	if (!m_user.modules || !gf_modules_get_count(m_user.modules)) {		MessageBox(m_user.modules ? "No modules available" : "Cannot create module manager", "Fatal Error");		if (m_user.modules) gf_modules_del(m_user.modules);		gf_cfg_del(m_user.config);		User::Leave(KErrGeneral);	}	if (first_launch) {		/*first launch, register all files ext*/		for (u32 i=0; i<gf_modules_get_count(m_user.modules); i++) {			GF_InputService *ifce = (GF_InputService *) gf_modules_load_interface(m_user.modules, i, GF_NET_CLIENT_INTERFACE);			if (!ifce) continue;			if (ifce) {				ifce->CanHandleURL(ifce, "test.test");				gf_modules_close_interface((GF_BaseInterface *)ifce);			}		}	}	/*we don't thread the terminal, ie appart from the audio renderer, media decoding and visual rendering is 	handled by the app process*/	m_user.init_flags = GF_TERM_NO_VISUAL_THREAD | GF_TERM_NO_REGULATION;	m_user.EventProc = GPAC_EventProc;	m_user.opaque = this;	m_user.os_window_handler = (void *) &m_window;	m_user.os_display = (void *) &m_session;	m_term = gf_term_new(&m_user);	if (!m_term) {		MessageBox("Cannot load GPAC terminal", "Fatal Error");		gf_modules_del(m_user.modules);		gf_cfg_del(m_user.config);		User::Leave(KErrGeneral);	}	//MessageBox("GPAC terminal loaded", "Success !");	/*ok set output size*/	TSize s = m_window.Size();	gf_term_set_size(m_term, s.iWidth, s.iHeight);	/*start our callback (every ms)*/	const TInt KTickInterval = 33000;	m_pTimer = CPeriodic::NewL(CActive::EPriorityStandard);	m_pTimer->Start(KTickInterval, KTickInterval, TCallBack(myTick, this));	opt = gf_cfg_get_key(m_user.config, "General", "StartupFile");	if (opt) gf_term_connect(m_term, opt);}// -----------------------------------------------------------------------------// COsmo4AppView::Draw()// Draws the display.// -----------------------------------------------------------------------------//void COsmo4AppView::Draw( const TRect& /*aRect*/ ) const{	if (!m_term) {		CWindowGc& gc = SystemGc();		TRgb black(0,0,0);		gc.SetBrushColor(black);		gc.Clear();	} else {		/*FIXME - this is just to force a screen flush, needs rework*/		gf_term_set_option(m_term, GF_OPT_FREEZE_DISPLAY, 0);	}}void COsmo4AppView::ShowHide(Bool show){	if (show) {		MakeVisible(ETrue);		if (m_term) {			gf_term_set_option(m_term, GF_OPT_VISIBLE, 1);			DrawDeferred();		}	} else {		MakeVisible(EFalse);		if (m_term) gf_term_set_option(m_term, GF_OPT_VISIBLE, 0);	}}// -----------------------------------------------------------------------------// COsmo4AppView::SizeChanged()// Called by framework when the view size is changed.// -----------------------------------------------------------------------------//void COsmo4AppView::SizeChanged(){  	if (m_term) {		TSize s = m_window.Size();		gf_term_set_size(m_term, s.iWidth, s.iHeight);	}	DrawNow();}void COsmo4AppView::Connect(const char *url){	char the_url[1024];	/*copy before removing from recent files*/	strcpy(the_url, url);	gf_cfg_set_key(m_user.config, "RecentFiles", the_url, NULL);	gf_cfg_insert_key(m_user.config, "RecentFiles", the_url, "", 0);	u32 count = gf_cfg_get_key_count(m_user.config, "RecentFiles");	if (count > 10) gf_cfg_set_key(m_user.config, "RecentFiles", gf_cfg_get_key_name(m_user.config, "RecentFiles", count-1), NULL);	if (m_term) gf_term_connect(m_term, the_url);}TKeyResponse COsmo4AppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType){	GF_Event evt;	u32 ret;	evt.key.hw_code = aKeyEvent.iScanCode;	evt.key.flags = 0;	switch (aType) {	case EEventKeyUp:		evt.type = GF_EVENT_KEYUP;		break;	case EEventKeyDown:	case EEventKey:		evt.type = GF_EVENT_KEYDOWN;		break;	default:		return EKeyWasNotConsumed;	}	switch (aKeyEvent.iCode) {	case EKeyLeftArrow: evt.key.key_code = GF_KEY_LEFT; break;	case EKeyRightArrow: evt.key.key_code = GF_KEY_RIGHT; break;	case EKeyUpArrow: evt.key.key_code = GF_KEY_UP; break;	case EKeyDownArrow: evt.key.key_code = GF_KEY_DOWN; break;	case EKeyIncVolume: evt.key.key_code = GF_KEY_VOLUMEUP; break;	case EKeyDecVolume: evt.key.key_code = GF_KEY_VOLUMEDOWN; break;	default:		switch (aKeyEvent.iScanCode) {		case EStdKeyIncVolume: evt.key.key_code = GF_KEY_VOLUMEUP; break;		case EStdKeyDecVolume: evt.key.key_code = GF_KEY_VOLUMEDOWN; break;		default:			return EKeyWasNotConsumed;		}	}	ret = gf_term_user_event(m_term, &evt);	/*generate a key up*/	if (aType==EEventKey) {		evt.type = GF_EVENT_KEYUP;		ret += gf_term_user_event(m_term, &evt);	}	return ret ? EKeyWasConsumed : EKeyWasNotConsumed;}void COsmo4AppView::MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct){	GF_Event e;	switch (aOperationId) {/*    TRequestStatus status;	case ERemConCoreApiPausePlayFunction:	case ERemConCoreApiStop:	case ERemConCoreApiRewind:	case ERemConCoreApiForward:	case ERemConCoreApiFastForward:	case ERemConCoreApiBackward:		switch (aButtonAct) {		case ERemConCoreApiButtonPress:			break;		case ERemConCoreApiButtonRelease:			break;		case ERemConCoreApiButtonClick:			break;		default:			break;		}*/	case ERemConCoreApiVolumeUp:	case ERemConCoreApiVolumeDown:		e.key.hw_code = 0;		e.key.flags = 0;		e.key.key_code = (aOperationId==ERemConCoreApiVolumeUp) ? GF_KEY_VOLUMEUP : GF_KEY_VOLUMEDOWN;		switch (aButtonAct) {		case ERemConCoreApiButtonPress: 			e.type = GF_EVENT_KEYDOWN; 			gf_term_user_event(m_term, &e);			break;		case ERemConCoreApiButtonRelease: 			e.type = GF_EVENT_KEYUP; 			gf_term_user_event(m_term, &e);			break;		default: 			e.type = GF_EVENT_KEYDOWN; 			gf_term_user_event(m_term, &e);			e.type = GF_EVENT_KEYUP; 			gf_term_user_event(m_term, &e);			break;		}		break;	default:		break;	}}void COsmo4AppView::ReloadTerminal(){	COsmo4AppUi *app = (COsmo4AppUi *) CEikonEnv::Static()->AppUi();	GF_Terminal *term = m_term;	app->SetInfo("Reloading terminal...");	m_term = NULL;	gf_term_del(term);	m_term = gf_term_new(&m_user);	app->SetInfo(NULL);	if (!m_term) {		MessageBox("Couldn't reload terminal", "Fatal Error !");		Panic(EOsmo4Ui);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -