Exemple #1
0
void manta::Detach()
{
   /* Stop the polling thread while we mess with the connection list */
   StopThreadAndWait();
   if(Attached())
   {
      post("manta: Detaching from manta %d", ConnectedManta->GetSerialNumber());
      if(ConnectedManta->GetReferenceCount() == 1)
      {
         /* TODO: if the polling thread is still running here and the callbacks
          * get called for the cancelled USB transfers, there will probably
          * be a segfault */
         post("manta: no more connections to manta %d, destroying.",ConnectedManta->GetSerialNumber());
         delete ConnectedManta;
         ConnectedMantaList.remove(ConnectedManta);
         ConnectedManta = NULL;
      }
      else
      {
         /* There are still other MantaFlext instances connected to this MantaMulti,
          * so just detach ourselves */
         ConnectedManta->DetachClient(this);
         ConnectedManta = NULL;
      }
   }
   if(! ConnectedMantaList.empty())
   {
      StartThread();
   }
}
Exemple #2
0
void fmms::Run(string base)
{
    
    // Collect mms info
    for ( int i = 0; i < mms.size(); i++ )
    {
        print mmsFile(mms[i].c_str(), base);
        string link("<A href=\"" + mms[i] 
                + "\" target=\"mmsframe\">" 
                + mms[i] + "</A><BR>\n");
        file->Write(link.c_str());
        string path = strPath + "/" + mms[i];
        string slm = slmPath + "/" + mms[i];
        
        // Header
        ReadHead(path, &mmsFile);

        // Attachment links
       string base;
        Attached(path, slm, &mmsFile);

        // Message
        ReadText(path, &mmsFile);

        mmsFile.CloseTable(0,1);
        mmsFile.Close();
    }
}
 ///////////////////////////////////////////////////////////////////////
 ///  Function: On_WM_CLOSE_WindowMessage
 ///
 ///    Author: $author$
 ///      Date: 5/11/2012
 ///////////////////////////////////////////////////////////////////////
 virtual LRESULT On_WM_CLOSE_WindowMessage
 (HWND hWnd,
  UINT msg,
  WPARAM wParam,
  LPARAM lParam) 
 {
     LRESULT lResult = FALSE;
     ShowWindow(Attached(), SW_HIDE);
     return lResult;
 }
Exemple #4
0
/* this function attaches the Mantaflext instance to a Manta instance, but does
 * not connect that Manta instance to an actual hardware manta */
void manta::Attach(int serialNumber)
{
   MantaMutex.Lock();
   if(! Attached())
   {
      MantaMulti *device = FindConnectedMantaBySerial(serialNumber);
      /* see if the device is already in the connected list */
      if(NULL != device)
      {
         post("manta: Attaching to manta %d", device->GetSerialNumber());
         device->AttachClient(this);
         ConnectedManta = device;
         MantaMutex.Unlock();
      }
      else
      {
         MantaMutex.Unlock();
         /* TODO: open by serial number */
         device = new MantaMulti;
         try
         {
            device->Connect(serialNumber);
            MantaMutex.Lock();
            post("manta: Connecting manta %d and attaching", device->GetSerialNumber());
            device->AttachClient(this);
            device->ResendLEDState();
            ConnectedManta = device;
            ConnectedMantaList.push_back(ConnectedManta);
            if(ConnectedMantaList.size() == 1)
            {
               StartThread();
            }
            MantaMutex.Unlock();
         }
         catch(MantaNotFoundException e)
         {
            post("manta: could not find matching manta");
            delete device;
         }
         catch(MantaOpenException e)
         {
            post("manta: Could not connect to attached Manta");
            delete device;
         }
      }
   }
   else
   {
      MantaMutex.Unlock();
      post("manta: already attached");
   }
}
Exemple #5
0
void ProcessProxy::CheckProcess()
{
	if ( !m_process )
	{
		if ( Utils::FindProcess(Utils::qtow(m_procPath).c_str(), m_process) )
			emit Attached();

		return;
	}

	if ( WAIT_OBJECT_0 == WaitForSingleObject(m_process, 0) )
	{
		CloseHandle(m_process);
		m_process = NULL;
		emit Finished();
	}
}
    ///////////////////////////////////////////////////////////////////////
    /// Function: OnWindowMessageDefaultObserve
    ///
    ///   Author: $author$
    ///     Date: 5/11/2012
    ///////////////////////////////////////////////////////////////////////
    virtual LRESULT OnWindowMessageDefaultObserve
    (HWND hWnd,
     UINT msg,
     WPARAM wParam,
     LPARAM lParam)
    {
        LRESULT lResult = 0;
        switch(msg)
        {
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
            case IDM_MENU_PROPS:
                ShowWindow(Attached(), SW_SHOWNORMAL);
                break;

            case IDM_MENU_CONNECT:
                m_client.ConnectToServer();
                break;

            case IDM_MENU_DISCONNECT:
                m_client.DisconnectFromServer();
                break;

            case IDM_MENU_CONNECT_PEER:
                m_client.ConnectToPeer();
                break;

            case IDM_MENU_DISCONNECT_PEER:
                m_client.DisconnectFromPeer();
                break;

            case IDM_MENU_GL_OFF:
                m_client.DontUseOpenGLRenderer();
                break;

            case IDM_MENU_GL_ON:
                m_client.UseOpenGLRenderer();
                break;
            }
            break;
        }
        return lResult;
    }