Esempio n. 1
0
HRESULT __stdcall RTFEditor::RichEditOleCallback::ShowContainerUI(BOOL fShow)
{
	if ( fShow)
	{
		
		mol::punk<IOleInPlaceFrame> frame;
		if ( moe()->axFrameSite )
		{
			moe()->axFrameSite.queryInterface(&frame);
			if ( frame )
			{
				frame->SetBorderSpace(0);
			}
		}
		
		mol::Ribbon::ribbon()->mode(10);
		This()->rtf_.redraw();
	}
	else
	{
		mol::Ribbon::ribbon()->mode(0);
		if (!This()->shuttingDown_)
		{
			This()->rtf_.redraw();
		}
	}
	return S_OK;
}
Esempio n. 2
0
HRESULT __stdcall RTFEditor::RTFDocument::get_Length( long* d)
{
	if (!d )
		return E_INVALIDARG;

	*d = 0;

	if ( This()->richEditOle )
	{
		mol::punk<ITextDocument> textDoc(This()->richEditOle);
		if ( textDoc )
		{
			mol::punk<ITextRange> range;
			long start = 0;
			long end = 0;
			HRESULT hr = textDoc->Range( start,start,&range);
			if ( range)
			{
				hr = range->Expand(tomStory,NULL);
				hr = range->GetEnd(&end);
				*d = end;
			}		
		}
	}
	return S_OK;
}
STDMETHODIMP CoFoldersMonitor::CPFolderMonitorEvents::Unadvise(DWORD dwCookie)
{
	HRESULT hr = S_OK;

	do 
	{
		IFoldersMonitorEvents *pEvents = (IFoldersMonitorEvents*)dwCookie;
		_ASSERT(pEvents);

		ScopedLock<CsLock> cs(This()->m_adviseLock);

		EventsListeners::iterator it = 
			std::find(This()->m_events.begin(), This()->m_events.end(), pEvents);

		if (it == This()->m_events.end())
		{
			// the cookie does not correspond to a valid connection
			hr = CONNECT_E_NOCONNECTION;
			break;
		}

		// release the connection
		pEvents->Release();
		pEvents = nullptr;

		This()->m_events.erase(it);
	} while (0);

	return S_OK;
}
STDMETHODIMP CoFoldersMonitor::CPFolderMonitorEvents::Advise(IUnknown *pUnkSink, DWORD *pdwCookie)
{
	_ASSERT(pUnkSink && pdwCookie);

	if (!pUnkSink || !pdwCookie)
		return E_INVALIDARG;

	*pdwCookie = 0;
	HRESULT hr = S_OK;

	do
	{
		ScopedLock<CsLock> cs(This()->m_adviseLock);

		IFoldersMonitorEvents *pEvents = nullptr;

		HRESULT hr = pUnkSink->QueryInterface(IID_IFoldersMonitorEvents, (void**) &pEvents);
		if (E_NOINTERFACE == hr)
			hr = CONNECT_E_NOCONNECTION;

		if (SUCCEEDED(hr))
		{
			This()->m_events.push_back(pEvents);
			*pdwCookie = DWORD(pEvents);
		}
	} while (0);

	return hr;
}
Esempio n. 5
0
TInt CCallDummyBase::HangUpHandler(TAny* aPtr)
	{
	This(aPtr)->SetUnowned();
	This(aPtr)->iFac->ResetPending( This(aPtr)->iHangUp);
	This(aPtr)->ReqCompleted(This(aPtr)->iHangUp.iTsyReqHandle,KErrNone);
	return KErrNone;
	}
Esempio n. 6
0
TInt CCallDummyBase::NotifyHookChangeHandler(TAny* aPtr)
	{
	//test server Up call
	__ASSERT_ALWAYS(This(aPtr)->UpCallOption(20,NULL)==KErrNotSupported,TsyPanic(KTsyPanicUnexpectedReturnValue));
	This(aPtr)->iFac->ResetPending( This(aPtr)->iNotifyHookChange);
	This(aPtr)->ReqCompleted(This(aPtr)->iNotifyHookChange.iTsyReqHandle,KErrNone);
	return KErrNone;
	}
Esempio n. 7
0
TInt CFaxDummyBase::WaitForEndOfPageHandler(TAny* aPtr)
//
//	Completed	req
//
	{
	This(aPtr)->iFac->ResetPending( This(aPtr)->iWaitForEndOfPage);
	This(aPtr)->ReqCompleted(This(aPtr)->iWaitForEndOfPage.iTsyReqHandle,KErrNone);
	return KErrNone;
	}
Esempio n. 8
0
TInt CFaxDummyBase::ReadHandler(TAny* aPtr)
//
//	Completed Request
//
	{
	This(aPtr)->iReadParams->Copy(DACQ_FAX_BUF_DATA);
	This(aPtr)->iFac->ResetPending( This(aPtr)->iRead);
	This(aPtr)->ReqCompleted(This(aPtr)->iRead.iTsyReqHandle,KErrNone);
	return KErrNone;
	}
Esempio n. 9
0
void wxThread::Exit( ExitCode status )
{
    wxASSERT_MSG( This() == this,
                  wxT("wxThread::Exit() can only be called in the context of the same thread") );

    // don't enter m_critsect before calling OnExit() because the user code
    // might deadlock if, for example, it signals a condition in OnExit() (a
    // common case) while the main thread calls any of functions entering
    // m_critsect on us (almost all of them do)
    OnExit();

    MPTaskID threadid = m_internal->GetId();

    if ( IsDetached() )
    {
        delete this;
    }
    else // joinable
    {
        // update the status of the joinable thread
        wxCriticalSectionLocker lock( m_critsect );
        m_internal->SetState( STATE_EXITED );
    }

    MPTerminateTask( threadid, (long)status );
}
Esempio n. 10
0
// also test whether we were paused
bool wxThread::TestDestroy()
{
    wxASSERT_MSG( This() == this,
                  wxT("wxThread::TestDestroy() can only be called in the context of the same thread") );

    m_critsect.Enter();

    if ( m_internal->GetState() == STATE_PAUSED )
    {
        m_internal->SetReallyPaused( true );

        // leave the crit section or the other threads will stop too if they attempt
        // to call any of (seemingly harmless) IsXXX() functions while we sleep
        m_critsect.Leave();

        m_internal->Pause();
    }
    else
    {
        // thread wasn't requested to pause, nothing to do
        m_critsect.Leave();
    }

    return m_internal->WasCancelled();
}
Esempio n. 11
0
bool SFtpFileEngine::mkdir(const QString &dirName,
                           bool createParentDirectories) const
{
    Q_UNUSED(createParentDirectories);

    qDebug() << "mkdir()" << _fileName << dirName;

    SFtpFileEngine* This(const_cast<SFtpFileEngine *>(this));
    if (!This->sftpConnect())
        return false;

    QUrl url(PathComp::fixUrl(dirName));

    bool result = !libssh2_sftp_mkdir(_sftp_session,
                                      _textCodec->fromUnicode(
                                          url.path()).data(),
                                      LIBSSH2_SFTP_S_IRWXU |
                                      LIBSSH2_SFTP_S_IRGRP |
                                      LIBSSH2_SFTP_S_IXGRP |
                                      LIBSSH2_SFTP_S_IROTH |
                                      LIBSSH2_SFTP_S_IXOTH);

    This->sftpDisconnect();

    if (result)
        This->refreshFileInfoCache(url.path());

    return result;
}
Esempio n. 12
0
bool SFtpFileEngine::rmdir(const QString &dirName,
                          bool recurseParentDirectories) const
{
    Q_UNUSED(recurseParentDirectories);

    qDebug() << "rmdir()" << _fileName << dirName;

    SFtpFileEngine* This(const_cast<SFtpFileEngine*>(this));

    if (!This->sftpConnect())
        return false;

    QUrl url(PathComp::fixUrl(dirName));

    bool result = !libssh2_sftp_rmdir(_sftp_session,
                                      _textCodec->fromUnicode(
                                          url.path()).data());

    if (result)
    {
        // remove cache entry
        This->_fileInfoCache->removeFileInfo(This->getCachePath(url.path()));
        if (_path == url.path())
            This->_fileFlags = QAbstractFileEngine::FileType;
    }

    This->sftpDisconnect();

    return result;
}
Esempio n. 13
0
wxThreadError wxThread::Resume()
{
    wxCHECK_MSG( This() != this, wxTHREAD_MISC_ERROR,
                 _T("a thread can't resume itself") );

    wxCriticalSectionLocker lock(m_critsect);

    wxThreadState state = m_internal->GetState();

    switch ( state )
    {
        case STATE_PAUSED:
            wxLogTrace(TRACE_THREADS, _T("Thread %ld suspended, resuming."),
                       GetId());

            m_internal->Resume();

            return wxTHREAD_NO_ERROR;

        case STATE_EXITED:
            wxLogTrace(TRACE_THREADS, _T("Thread %ld exited, won't resume."),
                       GetId());
            return wxTHREAD_NO_ERROR;

        default:
            wxLogDebug(_T("Attempt to resume a thread which is not paused."));

            return wxTHREAD_MISC_ERROR;
    }
}
Esempio n. 14
0
/*
 * Manual page at function.def
 */
INT16 CGEN_PROTECTED CFunction::This()
{
  FNC_DELEGATE This();                                                          // Use a weird macro (see function.def)
  m_iAi     = NULL;                                                             // Clear activate instance
  m_bAiUsed = FALSE;                                                            // Declare virginal
  m_iAi2    = NULL;                                                             // Clear secondary activate instance
  return O_K;                                                                   // Have done
}
Esempio n. 15
0
 hyresult DeRef() {
     Result res;
     
     TracerPtr tracer;
     res = This()->GetTracer(tracer.EditPtr());
     
     if(mCount > 0) {
         --mCount;
     }
     
     if(mCount == 0) {
         res = This()->Destruct();
         RETURN_IF_FAIL(res, tracer);
     }
     
     return res;
 }
Esempio n. 16
0
 double elapsed()
 {
     if (!registered_on_exit_)
     {
         registered_on_exit_ = hpx::register_on_exit(
             util::bind(&accumulator_stats::print_stats, This()));
     }
     return timer_.elapsed();
 }
Esempio n. 17
0
DoSomethingDifferent()
{
	This();
	Is();
	Not();
	A();
	Love();
	Song();
}
Esempio n. 18
0
 void restart()
 {
     if (!registered_on_exit_)
     {
         registered_on_exit_ = hpx::register_on_exit(
             util::bind(&accumulator_stats::print_stats, This()));
     }
     timer_.restart();
 }
Esempio n. 19
0
 /**
  * Return the XPCLocaleCallbacks that's hidden away in |cx|, or null
  * if there isn't one. (This impl uses the locale callbacks struct
  * to store away its per-context data.)
  *
  * NB: If the returned XPCLocaleCallbacks hasn't yet been bound to a
  * thread, then a side effect of calling MaybeThis() is to bind it
  * to the calling thread.
  */
 static XPCLocaleCallbacks*
 MaybeThis(JSContext* cx)
 {
   JSLocaleCallbacks* lc = JS_GetLocaleCallbacks(cx);
   return (lc &&
           lc->localeToUpperCase == LocaleToUpperCase &&
           lc->localeToLowerCase == LocaleToLowerCase &&
           lc->localeCompare == LocaleCompare &&
           lc->localeToUnicode == LocaleToUnicode) ? This(cx) : nsnull;
 }
STDMETHODIMP CoFoldersMonitor::CPFolderMonitorEvents::GetConnectionPointContainer(IConnectionPointContainer **ppcpc)
{
	_ASSERT(ppcpc);
	if (!ppcpc)
		return E_INVALIDARG;

	// returns the containing object
	(*ppcpc = This())->AddRef();
	return S_OK;
}
Esempio n. 21
0
void Pdb::Data()
{
	switch(tab.Get()) {
	case TAB_AUTOS: Autos(); break;
	case TAB_LOCALS: Locals(); break;
	case TAB_THIS: This(); break;
	case TAB_WATCHES: Watches(); break;
	case TAB_EXPLORER: Explorer(); break;
	case TAB_MEMORY: memory.Refresh(); break;
	}
}
Esempio n. 22
0
wxThread::ExitCode wxThread::Wait(wxThreadWait WXUNUSED(waitMode))
{
    wxCHECK_MSG( This() != this, (ExitCode)-1,
                 wxT("a thread can't wait for itself") );

    wxCHECK_MSG( !m_isDetached, (ExitCode)-1,
                 wxT("can't wait for detached thread") );

    m_internal->Wait();

    return m_internal->GetExitCode();
}
Esempio n. 23
0
wxThreadError wxThread::Delete(ExitCode *rc)
{
    wxCHECK_MSG( This() != this, wxTHREAD_MISC_ERROR,
                 _T("a thread can't delete itself") );

    bool isDetached = m_isDetached;

    m_critsect.Enter();
    wxThreadState state = m_internal->GetState();

    // ask the thread to stop
    m_internal->SetCancelFlag();

    m_critsect.Leave();

    switch ( state )
    {
        case STATE_NEW:
            // we need to wake up the thread so that PthreadStart() will
            // terminate - right now it's blocking on run semaphore in
            // PthreadStart()
            m_internal->SignalRun();

            // fall through

        case STATE_EXITED:
            // nothing to do
            break;

        case STATE_PAUSED:
            // resume the thread first
            m_internal->Resume();

            // fall through

        default:
            if ( !isDetached )
            {
                // wait until the thread stops
                m_internal->Wait();

                if ( rc )
                {
                    // return the exit code of the thread
                    *rc = m_internal->GetExitCode();
                }
            }
            //else: can't wait for detached threads
    }

    return wxTHREAD_NO_ERROR;
}
Esempio n. 24
0
	// This function is called from the cache to read the next data block from the server into memory
	static int CacheCallback(void* p_Buffer, DWORD u32_Offset, DWORD u32_Count)
	{
		CExtractUrl* p_This = (CExtractUrl*)This();
		
		DWORD u32_Read, u32_ApiErr, u32_Status;
		if (u32_ApiErr = p_This->mi_Internet.DownloadFilePartToMemory(p_Buffer, 
			             u32_Offset, u32_Count, &u32_Read, &u32_Status))
		{
			p_This->mi_Error.Set(FDIERROR_INTERNET, u32_ApiErr, u32_Status);
			return -1; // Error
		}
		return u32_Read;
	}
Esempio n. 25
0
HRESULT __stdcall RTFEditor::RTFDocument::Range( long start, long end,  IDispatch** d)
{
	if (!d )
		return E_INVALIDARG;

	*d = 0;

	if ( This()->richEditOle )
	{
		mol::punk<ITextDocument> textDoc(This()->richEditOle);
		if ( textDoc )
		{
			mol::punk<ITextRange> range;
			HRESULT hr = textDoc->Range( start,end,&range);
			if ( range)
			{
				return range.queryInterface(d);				
			}		
		}
	}
	return S_OK;
}
Esempio n. 26
0
HRESULT __stdcall RTFEditor::RTFDocument::get_Selection( IDispatch** d)
{
	if (!d )
		return E_INVALIDARG;

	*d = 0;

	if ( This()->richEditOle )
	{
		mol::punk<ITextDocument> textDoc(This()->richEditOle);
		if ( textDoc )
		{
			mol::punk<ITextSelection> selection;
			HRESULT hr = textDoc->GetSelection(&selection);
			if ( selection)
			{
				return selection.queryInterface(d);
			}		
		}
	}
	return S_OK;
}
Esempio n. 27
0
wxThreadError wxThread::Kill()
{
    wxCHECK_MSG( This() != this, wxTHREAD_MISC_ERROR,
                 _T("a thread can't kill itself") );

    switch ( m_internal->GetState() )
    {
        case STATE_NEW:
        case STATE_EXITED:
            return wxTHREAD_NOT_RUNNING;

        case STATE_PAUSED:
            // resume the thread first
            Resume();

            // fall through

        default:
#ifdef HAVE_PTHREAD_CANCEL
            if ( pthread_cancel(m_internal->GetId()) != 0 )
#endif // HAVE_PTHREAD_CANCEL
            {
                wxLogError(_("Failed to terminate a thread."));

                return wxTHREAD_MISC_ERROR;
            }

#ifdef HAVE_PTHREAD_CANCEL
            if ( m_isDetached )
            {
                // if we use cleanup function, this will be done from
                // wxPthreadCleanup()
#ifndef wxHAVE_PTHREAD_CLEANUP
                ScheduleThreadForDeletion();

                // don't call OnExit() here, it can only be called in the
                // threads context and we're in the context of another thread

                DeleteThread(this);
#endif // wxHAVE_PTHREAD_CLEANUP
            }
            else
            {
                m_internal->SetExitCode(EXITCODE_CANCELLED);
            }

            return wxTHREAD_NO_ERROR;
#endif // HAVE_PTHREAD_CANCEL
    }
}
        log_processor(std::string const & filename,
                synchronized<job_registry> & registry)
            : filename_(filename)
            , registry_(registry)
        #if BOOST_VERSION < 103500
            , interrupt_thread_(false)
        #endif
            , log_initialized_(false)
            , thread_(boost::bind<void>(boost::ref(*This())))
        {
            SAGA_LOG_DEBUG(("Condor adaptor: Processing log "
                + filename_).c_str());

            boost::mutex::scoped_lock lock(log_initialized_mtx_);
            while (!log_initialized_)
                log_initialized_cond_.wait(lock);
        }
Esempio n. 29
0
void wxThread::Exit(ExitCode status)
{
    wxASSERT_MSG( This() == this,
                  _T("wxThread::Exit() can only be called in the context of the same thread") );

    if ( m_isDetached )
    {
        // from the moment we call OnExit(), the main program may terminate at
        // any moment, so mark this thread as being already in process of being
        // deleted or wxThreadModule::OnExit() will try to delete it again
        ScheduleThreadForDeletion();
    }

    // don't enter m_critsect before calling OnExit() because the user code
    // might deadlock if, for example, it signals a condition in OnExit() (a
    // common case) while the main thread calls any of functions entering
    // m_critsect on us (almost all of them do)
    OnExit();

    // delete C++ thread object if this is a detached thread - user is
    // responsible for doing this for joinable ones
    if ( m_isDetached )
    {
        // FIXME I'm feeling bad about it - what if another thread function is
        //       called (in another thread context) now? It will try to access
        //       half destroyed object which will probably result in something
        //       very bad - but we can't protect this by a crit section unless
        //       we make it a global object, but this would mean that we can
        //       only call one thread function at a time :-(
        DeleteThread(this);
        pthread_setspecific(gs_keySelf, 0);
    }
    else
    {
        m_critsect.Enter();
        m_internal->SetState(STATE_EXITED);
        m_critsect.Leave();
    }

    // terminate the thread (pthread_exit() never returns)
    pthread_exit(status);

    wxFAIL_MSG(_T("pthread_exit() failed"));
}
Esempio n. 30
0
wxThreadError wxThread::Pause()
{
    wxCHECK_MSG( This() != this, wxTHREAD_MISC_ERROR,
                 wxT("a thread can't pause itself") );

    wxCriticalSectionLocker lock(m_critsect);

    if ( m_internal->GetState() != STATE_RUNNING )
    {
        wxLogDebug( wxT("Can't pause thread which is not running.") );

        return wxTHREAD_NOT_RUNNING;
    }

    // just set a flag, the thread will be really paused only during the next
    // call to TestDestroy()
    m_internal->SetState( STATE_PAUSED );

    return wxTHREAD_NO_ERROR;
}