Ejemplo n.º 1
0
void
DeskbarControlView::DetachedFromWindow()
{
	if (LockLooper()) {
		StopWatching(fControllerMessenger, kMsgControllerCaptureStarted);
		StopWatching(fControllerMessenger, kMsgControllerCaptureStopped);	
		StopWatching(fControllerMessenger, kMsgControllerCapturePaused);	
		StopWatching(fControllerMessenger, kMsgControllerCaptureResumed);	
		UnlockLooper();
	}
}
NS_IMETHODIMP
sbWin32FileSystemWatcher::Observe(nsISupports *aObject,
                                  const char *aTopic,
                                  const PRUnichar *aData)
{
  LOG("%s: observing %s", __FUNCTION__, aTopic);
  if (strcmp(aTopic, "quit-application") == 0) {
    if (mIsWatching) {
      // Pass in PR_FALSE - the owner of the file system watcher should stop
      // the class themselves in order to save the current tree to disk.
      StopWatching(PR_FALSE);
    }

    // Remove observer hook
    nsresult rv;
    nsCOMPtr<nsIObserverService> obsService =
      do_GetService("@mozilla.org/observer-service;1", &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    obsService->RemoveObserver(this, "quit-application");
    NS_ENSURE_SUCCESS(rv, rv);
  }

  return NS_OK;
}
Ejemplo n.º 3
0
void
GeoLocation::Run(const String& command) {
	if(!command.IsEmpty()) {
		Uri commandUri;
		commandUri.SetUri(command);
		String method = commandUri.GetHost();
		StringTokenizer strTok(commandUri.GetPath(), L"/");
		if(strTok.GetTokenCount() > 1) {
			strTok.GetNextToken(callbackId);
			AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer());
		}
		AppLogDebug("Method %S, Callback: %S", method.GetPointer(), callbackId.GetPointer());
		// used to determine callback ID
		if(method == L"com.phonegap.Geolocation.watchPosition" && !callbackId.IsEmpty() && !IsWatching()) {
			AppLogDebug("watching position...");
			StartWatching();
		}
		if(method == L"com.phonegap.Geolocation.stop" && IsWatching()) {
			AppLogDebug("stop watching position...");
			StopWatching();
		}
		if(method == L"com.phonegap.Geolocation.getCurrentPosition" && !callbackId.IsEmpty() && !IsWatching()) {
			AppLogDebug("getting current position...");
			GetLastKnownLocation();
		}
		AppLogDebug("GeoLocation command %S completed", command.GetPointer());
	}
}
Ejemplo n.º 4
0
void CFileEvent::AddFile (LPCTSTR pszPathName)
  {
    CFileInfo *pFileInfo;
    if (m_mapFileInfo.Lookup (pszPathName, pFileInfo))
      return;
    pFileInfo = new CFileInfo (pszPathName);
    m_mapFileInfo.SetAt (pszPathName, pFileInfo);
    POSITION pos = m_lstFilePath.GetHeadPosition ();
    CFilePath *pFilePath;
    while (pos)
      {
        pFilePath = m_lstFilePath.GetNext (pos);
        ASSERT (pFilePath);
        if (!_tcscmp (pFilePath->GetPath (), pFileInfo->GetPath ()))
          {
            pFilePath->Inc ();
            return;
          }
      }
    m_lstFilePath.AddTail (new CFilePath (pFileInfo->GetPath ()));
    if (m_bEvent)
      {
        StopWatching ();
        StartWatching ();
      }
  }
Ejemplo n.º 5
0
NS_IMETHODIMP
nsWindowsRegKey::StartWatching(bool aRecurse)
{
  if (NS_WARN_IF(!mKey)) {
    return NS_ERROR_NOT_INITIALIZED;
  }

  if (mWatchEvent) {
    return NS_OK;
  }

  mWatchEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
  if (!mWatchEvent) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  DWORD filter = REG_NOTIFY_CHANGE_NAME |
                 REG_NOTIFY_CHANGE_ATTRIBUTES |
                 REG_NOTIFY_CHANGE_LAST_SET |
                 REG_NOTIFY_CHANGE_SECURITY;

  LONG rv = RegNotifyChangeKeyValue(mKey, aRecurse, filter, mWatchEvent, TRUE);
  if (rv != ERROR_SUCCESS) {
    StopWatching();
    // On older versions of Windows, this call is not implemented, so simply
    // return NS_OK in those cases and pretend that the watching is happening.
    return (rv == ERROR_CALL_NOT_IMPLEMENTED) ? NS_OK : NS_ERROR_FAILURE;
  }

  mWatchRecursive = aRecurse;
  return NS_OK;
}
Ejemplo n.º 6
0
void CFlowNode_WatchCodeCheckpoint::ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
{
	switch(event)
	{

	case eFE_Initialize:
	{
		m_actInfo = *pActInfo;

		RemoveAsWatcher();

		// Reset state
		m_checkPointIdx	= ~0;
		m_pCheckPoint				= NULL;
	}
	break;

	case eFE_Activate:
	{
		if(IsPortActive(pActInfo,eInputPorts_StartWatching))
		{
			StartWatching(pActInfo);
		}
		else if(IsPortActive(pActInfo,eInputPorts_StopWatching))
		{
			StopWatching(pActInfo);
		}
	}
	break;
	}
}
NS_IMETHODIMP
DecoderDoctorDocumentWatcher::Notify(nsITimer* timer)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(timer == mTimer);

  // Forget timer. (Assuming timer keeps itself and us alive during this call.)
  mTimer = nullptr;

  if (!mDocument) {
    return NS_OK;
  }

  if (mDiagnosticsSequence.Length() > mDiagnosticsHandled) {
    // We have new diagnostic data.
    mDiagnosticsHandled = mDiagnosticsSequence.Length();

    SynthesizeAnalysis();

    // Restart timer, to redo analysis or stop watching this document,
    // depending on whether anything new happens.
    EnsureTimerIsStarted();
  } else {
    DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::Notify() - No new diagnostics to analyze -> Stop watching",
             this, mDocument);
    // Stop watching this document, we don't expect more diagnostics for now.
    // If more diagnostics come in, we'll treat them as another burst, separately.
    // 'true' to remove the property from the document.
    StopWatching(true);
  }

  return NS_OK;
}
Ejemplo n.º 8
0
NS_IMETHODIMP
nsWindowsRegKey::StartWatching(PRBool recurse)
{
#ifdef WINCE
  return NS_ERROR_NOT_IMPLEMENTED;
#else

  NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);

  if (mWatchEvent)
    return NS_OK;
  
  mWatchEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  if (!mWatchEvent)
    return NS_ERROR_OUT_OF_MEMORY;
  
  DWORD filter = REG_NOTIFY_CHANGE_NAME |
                 REG_NOTIFY_CHANGE_ATTRIBUTES |
                 REG_NOTIFY_CHANGE_LAST_SET |
                 REG_NOTIFY_CHANGE_SECURITY;

  LONG rv = RegNotifyChangeKeyValue(mKey, recurse, filter, mWatchEvent, TRUE);
  if (rv != ERROR_SUCCESS) {
    StopWatching();
    // On older versions of Windows, this call is not implemented, so simply
    // return NS_OK in those cases and pretend that the watching is happening.
    return (rv == ERROR_CALL_NOT_IMPLEMENTED) ? NS_OK : NS_ERROR_FAILURE;
  }

  mWatchRecursive = recurse;
  return NS_OK;
#endif
}
Ejemplo n.º 9
0
		void ObjectWatcher::Signal(Delegate* delegate) {
			// Signaling the delegate may result in our destruction or a nested call to
			// StartWatching(). As a result, we save any state we need and clear previous
			// watcher state before signaling the delegate.
			HANDLE object = object_;
			StopWatching();
			delegate->OnObjectSignaled(object);
		}
Ejemplo n.º 10
0
status_t
BPrinter::SetTo(const BEntry& entry)
{
	StopWatching();
	entry.GetRef(&fPrinterEntryRef);

	return InitCheck();
}
Ejemplo n.º 11
0
CPUFreqDriverInterface::~CPUFreqDriverInterface()
{
	StopWatching();
	delete fFrequencyStates;
	
	if (InitCheck() == B_OK)
		close(fDriverHandler);
}
Ejemplo n.º 12
0
CJSWatchDog::~CJSWatchDog()
{
	StopWatching();

	pthread_attr_destroy(&m_attr);
	pthread_mutex_destroy(&m_mutex);
	pthread_cond_destroy(&m_cond);
}
Ejemplo n.º 13
0
status_t
BPrinter::SetTo(const entry_ref& entryRef)
{
	StopWatching();
	fPrinterEntryRef = entryRef;

	return InitCheck();
}
Ejemplo n.º 14
0
status_t ArpConfigureFile::StartWatching(const BMessenger& destination,
        BMessage* message)
{
    StopWatching();
    mWatcher = destination;
    mWatchMessage = message;
    return StartWatcher();
}
Ejemplo n.º 15
0
 void RegKey::Close()
 {
     StopWatching();
     if(key_)
     {
         ::RegCloseKey(key_);
         key_ = NULL;
     }
 }
Ejemplo n.º 16
0
FileWatcher::~FileWatcher()
{
    StopWatching();
#if defined(ENABLE_FILEWATCHER)
#if defined(__linux__)
    close(watchHandle_);
#endif
#endif
}
Ejemplo n.º 17
0
NS_IMETHODIMP
nsWindowsRegKey::SetKey(HKEY aKey)
{
  // We do not close the older aKey!
  StopWatching();

  mKey = aKey;
  return NS_OK;
}
Ejemplo n.º 18
0
status_t
BPrinter::SetTo(const BDirectory& directory)
{
	StopWatching();

	BEntry entry;
	directory.GetEntry(&entry);
	entry.GetRef(&fPrinterEntryRef);

	return InitCheck();
}
Ejemplo n.º 19
0
NS_IMETHODIMP
nsWindowsRegKey::Close()
{
  StopWatching();

  if (mKey) {
    RegCloseKey(mKey);
    mKey = nullptr;
  }
  return NS_OK;
}
Ejemplo n.º 20
0
void IJSWatchDog::DisArm()
{
	if(m_iRefCount > 0)
	{
		m_iRefCount--;

		if(m_iRefCount == 0)
		{
			StopWatching();
		}
	}
}
Ejemplo n.º 21
0
void triebWerk::CFileWatcher::Watch(const char * a_pDirectory, bool a_WatchSubDirectory)
{
	if (m_Active)
	{
		StopWatching();
	}

	m_Active = true;
	m_PathWatching = a_pDirectory;

	m_Thread = std::thread(&CFileWatcher::Spectate,this, a_pDirectory, a_WatchSubDirectory);
}
Ejemplo n.º 22
0
NS_IMETHODIMP
nsWindowsRegKey::HasChanged(bool* aResult)
{
  if (mWatchEvent && WaitForSingleObject(mWatchEvent, 0) == WAIT_OBJECT_0) {
    // An event only gets signaled once, then it's done, so we have to set up
    // another event to watch.
    StopWatching();
    StartWatching(mWatchRecursive);
    *aResult = true;
  } else {
    *aResult = false;
  }
  return NS_OK;
}
Ejemplo n.º 23
0
status_t
BPrinter::StartWatching(const BMessenger& listener)
{
	StopWatching();

	if (!listener.IsValid())
		return B_BAD_VALUE;

	fListener = new(std::nothrow) BMessenger(listener);
	if (!fListener)
		return B_NO_MEMORY;

	node_ref nodeRef;
	nodeRef.device = fPrinterEntryRef.device;
	nodeRef.node = fPrinterEntryRef.directory;

	return watch_node(&nodeRef, B_WATCH_DIRECTORY, *fListener);
}
Ejemplo n.º 24
0
void
App::MessageReceived(BMessage* msg)
{
	switch(msg->what)
	{
		case MSG_REFRESH_FOLDERS:
		{
			StopWatching();
			ReloadFolders();
			StartWatching();
			break;
		}
		case B_NODE_MONITOR:
		{
			HandleNodeMonitoring(msg);
			break;
		}
		default:
			BApplication::MessageReceived(msg);
			break;
	}
}
Ejemplo n.º 25
0
CFileEvent::~CFileEvent ()
  {
    if (m_bEvent)
      StopWatching ();
    POSITION pos = m_mapFileInfo.GetStartPosition ();
    CString sPathName;
    CFileInfo *pFileInfo;
    while (pos)
      {
        m_mapFileInfo.GetNextAssoc (pos, sPathName, pFileInfo);
        ASSERT (pFileInfo);
        delete pFileInfo;
      }
    pos = m_lstFilePath.GetHeadPosition ();
    CFilePath *pFilePath;
    while (pos)
      {
        pFilePath = m_lstFilePath.GetNext (pos);
        ASSERT (pFilePath);
        delete pFilePath;
      }
  }
void
SocketMessageWatcher::OnFileCanReadWithoutBlocking(int aFd)
{
  BluetoothStatus status;

  switch (mLen) {
    case 0:
      status = RecvMsg1();
      break;
    case MSG1_SIZE:
      status = RecvMsg2();
      break;
    default:
      /* message-size error */
      status = STATUS_FAIL;
      break;
  }

  if (IsComplete() || status != STATUS_SUCCESS) {
    StopWatching();
    Proceed(status);
  }
}
Ejemplo n.º 27
0
CJSWatchDog::~CJSWatchDog()
{
	StopWatching();
}
Ejemplo n.º 28
0
BPrinter::~BPrinter()
{
	StopWatching();
}
Ejemplo n.º 29
0
		ObjectWatcher::~ObjectWatcher() {
			StopWatching();
		}
Ejemplo n.º 30
0
		void ObjectWatcher::WillDestroyCurrentMessageLoop() {
			// Need to shutdown the watch so that we don't try to access the MessageLoop
			// after this point.
			StopWatching();
		}