virtual DWORD OnStart()
	{
		if (OneInstance())
		{
			Stop();
			return -1;
		}

		AddWindowFireWall();
		if (IsService())
			ChangeConfig();
		else
		{
			CWin32Svr::StopService(_T("i8vdisksvr"));
			CWin32Svr::RemoveService(_T("i8vdisksvr"));
		}

		CreateTimerQueueTimer(&hTimer, NULL, TimerRoutine, this, 5000, 1000, 0);

		m_pLogger->SetLogFileName(LOG_FILENAME);
		m_pLogger->SetAddDateBefore(false);
		m_pLogger->WriteLog(i8desk::LM_INFO, TEXT("================================================================="));
		m_pLogger->SetAddDateBefore(true);
		m_pLogger->WriteLog(i8desk::LM_INFO, TEXT("Start I8VDisk Service..."));
	
		if (!m_pPlugMgr->Start())
		{
			m_pLogger->WriteLog(i8desk::LM_INFO, TEXT("start plugmgr fail."));
			Stop();
			return ERROR_SUCCESS;
		}
		HideDosWindow();

		return ERROR_SUCCESS;
	}
Exemple #2
0
int main(int argc, char * argv[])
{
	if(argc == 2)
	{
		FRConfig Config;
		FillConfigStruct(&Config,_FO_CFG_PATH);
		ChangeConfig(&Config,argv[1]);
	}
	return 0;
}
/*-------------------------------------------------------------------------*/
INT ViewMsg( CHAR *file, INT renew )
{
    INT              y = 0;
    KEY              k;
    INDEXTXT        *p;
#ifndef _LITE_
    INT              code;
#endif

    WActive ( wmain );
    WActive ( wtext );
    WActive ( wbar  );
#ifndef _LITE_
    SetBar  ( BarView );
#endif
    if( renew )
    {
        ViewHeader( file );
        ViewPage  ( maxXtext, maxYtext, 0 );
    }

    while( 1 )
    {
        k = MGetKey( FALSE );

        switch( k.key )
        {
#ifndef _LITE_
            
            case KEY_F1:
                ViewHelp( "PktView" );
                SetBar( BarView );
                break;

            case KEY_F5:
                CheckUpdatePkt( file );
                CopyPkt( file );
                SetBar( BarView );
                break;
                
            case KEY_F6:
                CheckUpdatePkt( file );
                code = MovePkt( file );
                SetBar( BarView );
                if( code ) break;
                if( mode == FILE_TYPE_MSG )
                {
                    ReindexPkt();
                    WDeactive( wmain );
                    WDeactive( wtext );
                    return( KEY_ESC );
                }
                if( mode == FILE_TYPE_PKT )
                {
                    reload = 1;
                    return( KEY_ESC );
                }
                return( 0 );
                
            case KEY_F8: case KEY_DEL:
                code = DelPkt( file );
                SetBar( BarView );
                if( code ) break;
                if( mode == FILE_TYPE_MSG )
                {
                    ReindexPkt();
                    WDeactive( wmain );
                    WDeactive( wtext );
                    return( KEY_ESC );
                }
                if( mode == FILE_TYPE_PKT )
                {
                    reload = 1;
                    return( KEY_ESC );
                }
                return( 0 );

            case KEY_i: case KEY_I: case ALT_I:
                ShowInfo( file );
                SetBar( BarView );
                break;
                
            case KEY_SPACE: case KEY_INS:
                if( pktIndex == NULL )
                    break;
                if( Current -> sel != ' ' )
                {
                    Current -> sel = ' ';
                    selected--;
                }
                else
                {
                    Current -> sel = '*';
                    selected++;
                }
                ViewSelected();
                break;
                
            case KEY_F3:
                return( KEY_F3 );
                
            case ALT_C:
                SetAttr();
                SetBar( BarView );
                break;
                
            case KEY_F9:
                ChangeConfig();
                SetBar( BarView );
                if( altx )
                {
                    WDeactive( wmain );
                    WDeactive( wtext );
                    return( KEY_ESC );
                }
                break;
                
            case SHIFT_F9:
                SaveConfig( ConfFile );
                break;

#endif

            case KEY_HOME:
                if( y == 0 )
                    break;
                y = 0;
                ViewPage( maxXtext, maxYtext, y );
                break;

            case KEY_DOWN:
                if( txtcount < y + maxYtext + 1 )
                    break;
                y++;
                WSetXY( wtext, 0, 0 ); WDelLine( wtext );
                p = GetCurrentTxt( y + maxYtext - 1 );
                ViewStr ( wtext, maxYtext - 1, maxXtext, p -> str, p -> color );
                break;

            case KEY_UP:
                if( y == 0 )
                    break;
                y--;
                WSetXY( wtext, 0, 0 ); WInsLine( wtext );
                p = GetCurrentTxt( y );
                ViewStr ( wtext, 0, maxXtext, p -> str, p -> color );
                break;

            case KEY_PAGEUP:
                if( y == 0 )
                    break;
                if( y < maxYtext - 1 )
                    y = 0;
                else
                    y -= maxYtext - 1;
                ViewPage( maxXtext, maxYtext, y );
                break;

            case KEY_PAGEDOWN:
                if( txtcount < maxYtext )
                    break;
                if( y + 2 * maxYtext < txtcount )
                    y += maxYtext - 1;
                else
                    y  = txtcount - maxYtext;
                ViewPage( maxXtext, maxYtext, y );
                break;

            case KEY_END:
                if( txtcount < maxYtext )
                    break;
                y = txtcount - maxYtext;
                ViewPage( maxXtext, maxYtext, y );
                break;

            case KEY_LEFT: case CTRL_ENTER: case SHIFT_TAB:
                if( pktcount > 1 && pktNumber > 0 )
                    return( KEY_LEFT );
                break;

            case KEY_RIGHT: case KEY_ENTER: case KEY_GRENTER: case KEY_TAB:
                if( pktcount > 1 && pktNumber + 1 != pktcount )
                    return( KEY_RIGHT );
                break;

            case ALT_X:
                altx = 1;
                
            case KEY_ESC: case KEY_F10: case KEY_L: case KEY_l: case ALT_L:
                WDeactive( wmain );
                WDeactive( wtext );
                return( KEY_ESC );

        }
    }
}
/*-------------------------------------------------------------------------*/
static KEY filter( KEY k )
{
    INT         code;

    if( k.scan == 9 )  k.key = KEY_ASTERISK;
    if( k.scan == 55 ) k.key = KEY_ASTERISK;

    switch( k.key )
    {
#ifndef _LITE_
        
        case KEY_F1:
            ViewHelp( "PktSelect" );
            SetBar( BarList  );
            break;
                
        case KEY_F2:
            if( !Update )
            {
                k.key = 0;
                break;
            }
            SetBar( BarNull );
            if( !UpdatePkt( filename ))
                Update = 0;
            if( PktFile == NULL )
            {
                k.key = KEY_ESC;
                break;
            }
            SetBar( BarList  );
            k.key = 0;
            break;

        case KEY_F3:
            newload = 1;
            k.key = KEY_ESC;
            break;

        case KEY_F4:
            k.key = 0;
            EditHeader();
            SetBar( BarList );
            break;

        case KEY_F5:
            k.key = 0;
            if( !pktcount )
                break;
            CheckUpdatePkt( filename );
            CopyPkt( filename );
            SetBar( BarList );
            break;

        case KEY_F6:
            k.key = 0;
            if( !pktcount )
                break;
            CheckUpdatePkt( filename );
            code = MovePkt( filename );
            SetBar( BarList );
            if( code )
                break;
            if( mode == FILE_TYPE_MSG )
                k.key = ReindexPkt();
            if( mode == FILE_TYPE_PKT )
            {
                reload = 1;
                k.key = KEY_ESC;
            }
            break;

        case KEY_F8: case KEY_DEL:
            k.key = 0;
            if( !pktcount )
                break;
            code = DelPkt( filename );
            SetBar( BarList );
            if( code )
                break;
            if( mode == FILE_TYPE_MSG )
                k.key = ReindexPkt();
            if( mode == FILE_TYPE_PKT )
            {
                reload = 1;
                k.key = KEY_ESC;
            }
            break;

        case KEY_SPACE: case KEY_INS:
            if( !pktcount )
            {
                k.key = 0;
                break;
            }
            if( Current -> sel != ' ' )
            {   Current -> sel = ' ';
                selected--;
            }
            else
            {   Current -> sel = '*';
                selected++;
            }
            ViewSelCount();
            WPShow( popup, FALSE, TRUE, -1, -1 );
            k.key = KEY_DOWN;
            break;
            
        case KEY_s: case KEY_S: case ALT_S:
            if( cfgCurrent.sort && pktcount > 1 )
            {
                PktSort();
                SetBar( BarList );
                before( pktNumber );
            }
            k.key = 0;
            break;
            
        case KEY_i: case KEY_I: case ALT_I:
            k.key = 0;
            if( mode == FILE_TYPE_MSG )
                break;
            ShowInfo( filename );
            SetBar( BarList );
            break;
            
        case KEY_PLUS:
            if( pktcount > 1 )
            {
                PktSelect();
                SetBar( BarList );
                ViewSelCount();
                WPShow( popup, FALSE, TRUE, -1, -1 );
            }
            k.key = 0;
            break;
            
        case KEY_MINUS:
            if( pktcount > 1 )
            {
                PktUnSelect();
                SetBar( BarList );
                ViewSelCount();
                WPShow( popup, FALSE, TRUE, -1, -1 );
            }
            k.key = 0;
            break;
            
        case KEY_ASTERISK:
            if( pktcount > 1 )
            {
                MsgInvert();
                ViewSelCount();
                WPShow( popup, FALSE, TRUE, -1, -1 );
            }
            k.key = 0;
            break;

        case KEY_F9:
            ChangeConfig();
            SetBar( BarList );
            if( altx )
                k.key = KEY_ESC;
            else
                k.key = 0;
            break;
            
        case SHIFT_F9:
            SaveConfig( ConfFile );
            k.key = 0;
            break;

#endif

        case KEY_ENTER: case KEY_GRENTER: case KEY_RIGHT: case KEY_LEFT:
            if( !pktcount )
            {
                k.key = 0;
                break;
            }
            if( mode == FILE_TYPE_MSG )
            {
                filename = Current -> name;
                code = 1;
            }

            if( mode == FILE_TYPE_PKT )
                code = 0;
            
            if( ReadText( code ))
            {
                k.key = KEY_ESC;
                break;
            }

            k.key = ViewMsg( filename, 1 );

            FreeTxtIndex();

            if( reload )
            {
                k.key = KEY_ESC;
                break;
            }

            switch( k.key )
            {
                case KEY_LEFT:
                    k.key = KEY_ENTER;
                    MPutKey( k );
                    k.key = KEY_UP;
                    break;

                case KEY_RIGHT:
                    k.key = KEY_ENTER;
                    MPutKey( k );
                    k.key = KEY_DOWN;
                    break;

                case KEY_F3:
                    newload = 1;
                    k.key = KEY_ESC;
                    break;

                case KEY_ESC: case KEY_F10:
#ifndef _LITE_
                    BarList[4].status = BarList[5].status = BarList[7].status= 1;
                    SetBar( BarList );
                    ViewSelCount();
#endif
                    if( altx )
                        k.key = KEY_ESC;
                    else
                        k.key = 0;
                    break;
            }
            return( k );

        case KEY_ESC: case KEY_F10:
            k.key = KEY_ESC;
            break;

        case ALT_X:
            altx = 1;
            k.key = KEY_ESC;
            break;
    }
    return( k );
}