/** Process a message for this logical channel */
void DTestResManLdd::HandleMsg(TMessageBase* aMsg)
	{
	TThreadMessage& m=*(TThreadMessage*)aMsg;
	TInt id=m.iValue;

	if (id==(TInt)ECloseMsg)
		{
		// Channel close.
		m.Complete(KErrNone,EFalse);
		return;
		}
	else if (id==KMaxTInt)
		{
		// DoCancel
		m.Complete(KErrNone,ETrue);
		return;
		}
	else if (id<0)
		{
		// DoRequest
		TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
		TInt r=DoRequest(~id,pS,m.Ptr1(),m.Ptr2());
		if (r!=KErrNone)
			Kern::RequestComplete(iClientThreadPtr,pS,r);
		m.Complete(KErrNone,ETrue);
		}
	else
		{
		// DoControl
		TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
		m.Complete(r,ETrue);
		}
	}
EXPORT_C void DStifKernelTestClassBase::HandleMsg( TMessageBase* aMsg )
    {       
    __KTRACE_OPT(KHARDWARE, 
        Kern::Printf("DStifKernelTestClassBase::HandleMsg"));
    
    TThreadMessage& m=*(TThreadMessage*)aMsg;

    // Get the id
    TInt id=m.iValue;
   
    if(id == (TInt)ECloseMsg)
        {
        // Lets close the channel
        m.Complete( KErrNone, EFalse );
        return;
        }
        
    if (id == KMaxTInt)
        {
        // Cancel operations are not needed because we don't use async requests
        m.Complete( KErrNone, ETrue );
        return;
        }
   
    if( id > 0 ) 
        {
        // Process the DoControl call
        TInt r = DoControl( id, m.Ptr0(), m.Ptr1() );
        m.Complete( r, ETrue );
        return;
        }        
    }
Beispiel #3
0
void DChannelComm::HandleMsg(TMessageBase* aMsg)
	{
	TThreadMessage& m = *(TThreadMessage*)aMsg;
	TInt id = m.iValue;
	if (id == (TInt)ECloseMsg)
		{
		Shutdown();
		iStatus = EClosed;
		m.Complete(KErrNone, EFalse);
		return;
		}
	else if (id == KMaxTInt)
		{
		// DoCancel
		DoCancel(m.Int0());
		m.Complete(KErrNone, ETrue);
		return;
		}

	if (id < 0)
		{
		// DoRequest
		TRequestStatus* pS = (TRequestStatus*)m.Ptr0();
		TInt r = DoRequest(~id, pS, m.Ptr1(), m.Ptr2());
		if (r != KErrNone)
			Kern::RequestComplete(iClient, pS, r);
		m.Complete(KErrNone, ETrue);
		}
	else
		{
		// DoControl
		TInt r = DoControl(id, m.Ptr0(), m.Ptr1());
		m.Complete(r, ETrue);
		}
	}
Beispiel #4
0
TInt DEventDD::Request(TInt aReqNo,TAny* a1,TAny* a2)
	{
	// Decode the message type and dispatch it to the relevent handler function...
	// only using synchronous control messages
	if (static_cast<TUint>(aReqNo)<static_cast<TUint>(KMaxTInt))
		return DoControl(aReqNo,a1,a2);
	return KErrNotSupported;
	}
/**
Called by the Device driver framework upon user request. 

@param aFunction	A number identifying the  message type
@param a1			A 32-bit Value passed by the user
@param a2			A 32-bit Value passed by the user

@return	KErrNone	If successful, otherwise one of the system wide error code
 */
TInt DExDriverLogicalChannel::Request(TInt aReqNo, TAny *a1, TAny *a2)
	{
	TInt r = KErrNone;
	
	KEXDEBUG(Kern::Printf("++DExDriverLogicalChannel::Request"));
	
	DThread* client;
	// Handle the synchronous requests. This is implementation specific,
	// however as a general practice, they are handled in DoControl().
	// Retrieve the current thread information using the kernel API. This
	// API gets the current Symbian OS thread, i.e reference to DThread
	// object.This thread information is required later in driver to
	// perform operations like data copy etc. across different threads.
	//
	client=&Kern::CurrentThread();


	// Check the capabilities of the thread before openning the handle.
	// As the handle sharing is allowed the client capabilities shall be checked
	// at the request level.
	// 
	if(!((client)->HasCapability(ECapabilityCommDD,
					__PLATSEC_DIAGNOSTIC_STRING("Checked by Tutorial Driver"))))
		{
		// If the required capability is not present for the user
        // thread to process this request, then deny the request.
        //
        return KErrPermissionDenied;
        }
        
	// Open kernel side refernce-counted object by calling DObject::Open()
	// DThread is derived from DObject. Opening this object increments the
	// reference count by one atomically.
	//
	((DObject*)client)->Open();
	
	r = DoControl(aReqNo, a1, a2);
	
	// Close the reference on client thread using the kernel API
	// Kern::SafeClose(). It swaps the kernel side reference counted object
	// to NULL value atomically and closes the object. This operation is
	// done in response to DObject::Close() in Logical Channel's destructor.
	//
	NKern::ThreadEnterCS();
	Kern::SafeClose((DObject*&)client,NULL);
	NKern::ThreadLeaveCS();
	
	// return result of above operations	
	return r;			
	}
void DNanoWait::HandleMsg(TMessageBase* aMsg)
	{
	TInt r=KErrNone;
	TThreadMessage& m=*(TThreadMessage*)aMsg;
	TInt id=m.iValue;
	if (id==(TInt)ECloseMsg)
		{
		m.Complete(KErrNone,EFalse);
		iMsgQ.CompleteAll(KErrServerTerminated);
		return;
		}
	else
		{
		r=DoControl(id,m.Ptr0(),m.Ptr1());
		}
	m.Complete(r,ETrue);
	}
Beispiel #7
0
/**
  Process a message for this logical channel.
  This function is called in the context of a DFC thread.

  @param aMessage The message to process.
	              The iValue member of this distinguishes the message type:
	              iValue==ECloseMsg, channel close message
	              iValue==KMaxTInt, a 'DoCancel' message
	              iValue>=0, a 'DoControl' message with function number equal to iValue
	              iValue<0, a 'DoRequest' message with function number equal to ~iValue
*/
void DZeroCopyLoopbackChannel::HandleMsg(TMessageBase* aMsg)
	{
	TThreadMessage& m=*(TThreadMessage*)aMsg;

	// Get message type
	TInt id=m.iValue;

	// Decode the message type and dispatch it to the relevent handler function...

	if (id==(TInt)ECloseMsg)
		{
		// Channel Close
		PRINT_PROBE_POINTS("ldd");
		DoCancel(RZeroCopyLoopbackDriver::EAllRequests);
		m.Complete(KErrNone, EFalse);
		return;
		}

	if (id==KMaxTInt)
		{
		// DoCancel
		DoCancel(m.Int0());
		m.Complete(KErrNone,ETrue);
		return;
		}

	if (id<0)
		{
		// DoRequest
		TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
		TInt r=DoRequest(~id,pS,m.Ptr1(),m.Ptr2());
		if (r!=KErrNone)
			{
			Kern::RequestComplete(iClient,pS,r);
			}
		m.Complete(KErrNone,ETrue);
		}
	else
		{
		// DoControl
		TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
		m.Complete(r,ETrue);
		}
	}
//
// DTrkXtiChannel::HandleMsg
//
void DTrkXtiChannel::HandleMsg(TMessageBase* aMsg)
{
	LOG_MSG("DTrkXtiChannel::HandleMsg()");
	
	TThreadMessage& m = *(TThreadMessage*)aMsg;
	TInt id = m.iValue;


	if (id == (TInt)ECloseMsg)
	{
        if (iTrkXtiSubscriber)
        {
            Kern::SemaphoreWait(*iLock);
            delete iTrkXtiSubscriber;
            iTrkXtiSubscriber = NULL;   
            Kern::SemaphoreSignal(*iLock);              
        }
		m.Complete(KErrNone, EFalse);
		return;
	}

	if (id == KMaxTInt)
	{
		// DoCancel
		DoCancel(m.Int0());
		m.Complete(KErrNone, ETrue); 
		return;
	}

	if (id < 0)
	{
		// DoRequest
		TRequestStatus* pStatus = (TRequestStatus*)m.Ptr0();
		DoRequest(~id, pStatus, m.Ptr1(), m.Ptr2());
		m.Complete(KErrNone, ETrue);
	}
	else
	{
		// DoControl
		TInt err = DoControl(id, m.Ptr0(), m.Ptr1());
		m.Complete(err, ETrue);
	}
}
void DExampleChannel::HandleMsg(TMessageBase* aMsg)
{
    TThreadMessage& m=*(TThreadMessage*)aMsg;
    TInt id=m.iValue;

    if (id==(TInt)ECloseMsg)
    {
        Shutdown();
        m.Complete(KErrNone,EFalse);
        return;
    }

    // we only support one client
    if (m.Client() != iClient)
    {
        m.Complete(KErrAccessDenied,ETrue);
        return;
    }

    if (id==KMaxTInt)
    {
        // DoCancel
        DoCancel(m.Int0());
        m.Complete(KErrNone,ETrue);
        return;
    }
    else if (id<0)
    {
        // DoRequest
        TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
        TInt r=DoRequest(~id,pS,m.Ptr1(),m.Ptr2());
        if (r!=KErrNone)
            Kern::RequestComplete(m.Client(),pS,r);
        m.Complete(KErrNone,ETrue);
    }
    else
    {
        // DoControl
        TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
        m.Complete(r,ETrue);
    }
}
Beispiel #10
0
BOOL
DoResume(PMAIN_WND_INFO Info)
{
    HWND hProgress;
    BOOL bRet = FALSE;

    /* Create a progress window to track the progress of the resuming service */
    hProgress = CreateProgressDialog(Info->hMainWnd,
                                     IDS_PROGRESS_INFO_RESUME);
    if (hProgress)
    {
        /* Set the service name and reset the progress bag */
        InitializeProgressDialog(hProgress, Info->pCurrentService->lpServiceName);

        /* Resume the requested service */
        bRet = DoControl(Info, hProgress, SERVICE_CONTROL_CONTINUE);

        /* Complete and destroy the progress bar */
        DestroyProgressDialog(hProgress, bRet);
    }

    return bRet;
}
void CStacked3PluginConn::DoRequest(CFsPluginConnRequest& aRequest)
	{
	DoControl(aRequest);
	}
static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
{
	GCEVENT *gce = (GCEVENT*)lParam, save_gce;
	GCDEST *gcd = NULL, save_gcd;
	TCHAR* pWnd = NULL;
	char* pMod = NULL;
	BOOL bIsHighlighted = FALSE;
	BOOL bRemoveFlag = FALSE;
	int iRetVal = GC_EVENT_ERROR;

	if ( gce == NULL )
		return GC_EVENT_ERROR;

	gcd = gce->pDest;
	if ( gcd == NULL )
		return GC_EVENT_ERROR;

	if ( gce->cbSize != SIZEOF_STRUCT_GCEVENT_V1 && gce->cbSize != SIZEOF_STRUCT_GCEVENT_V2 )
		return GC_EVENT_WRONGVER;

	if ( !IsEventSupported( gcd->iType ) )
		return GC_EVENT_ERROR;

	EnterCriticalSection(&cs);

	#if defined( _UNICODE )
		if ( !( gce->dwFlags & GC_UNICODE )) {
			save_gce = *gce;
			save_gcd = *gce->pDest;
			gce->pDest->ptszID = a2tf( gce->pDest->ptszID, gce->dwFlags );
			gce->ptszUID       = a2tf( gce->ptszUID,       gce->dwFlags );
			gce->ptszNick      = a2tf( gce->ptszNick,      gce->dwFlags );
			gce->ptszStatus    = a2tf( gce->ptszStatus,    gce->dwFlags );
			gce->ptszText      = a2tf( gce->ptszText,      gce->dwFlags );
			gce->ptszUserInfo  = a2tf( gce->ptszUserInfo,  gce->dwFlags );
		}
	#endif

	// Do different things according to type of event
	switch(gcd->iType) {
	case GC_EVENT_ADDGROUP:
		{
			STATUSINFO* si = SM_AddStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
			if ( si && gce->dwItemData)
				si->hIcon = CopyIcon((HICON)gce->dwItemData);
		}
		iRetVal = 0;
		goto LBL_Exit;

	case GC_EVENT_CHUID:
	case GC_EVENT_CHANGESESSIONAME:
	case GC_EVENT_SETITEMDATA:
	case GC_EVENT_GETITEMDATA:
	case GC_EVENT_CONTROL:
	case GC_EVENT_SETSBTEXT:
	case GC_EVENT_ACK:
	case GC_EVENT_SENDMESSAGE :
	case GC_EVENT_SETSTATUSEX :
		iRetVal = DoControl(gce, wParam);
		goto LBL_Exit;

	case GC_EVENT_SETCONTACTSTATUS:
		iRetVal = SM_SetContactStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData );
		goto LBL_Exit;

	case GC_EVENT_TOPIC:
	{
		SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
		if ( si ) {
			if ( gce->pszText ) {
				replaceStr( &si->ptszTopic, gce->ptszText);
				DBWriteContactSettingTString( si->windowData.hContact, si->pszModule , "Topic", RemoveFormatting( si->ptszTopic ));
				if ( DBGetContactSettingByte( NULL, "Chat", "TopicOnClist", 0 ))
					DBWriteContactSettingTString( si->windowData.hContact, "CList" , "StatusMsg", RemoveFormatting( si->ptszTopic ));
		}	}
		break;
	}
	case GC_EVENT_ADDSTATUS:
		SM_GiveStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus );
		break;

	case GC_EVENT_REMOVESTATUS:
		SM_TakeStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
		break;

	case GC_EVENT_MESSAGE:
	case GC_EVENT_ACTION:
		if ( !gce->bIsMe && gce->pDest->pszID && gce->pszText ) {
			SESSION_INFO* si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule );
			if ( si )
				if ( IsHighlighted( si, gce->ptszText ))
					bIsHighlighted = TRUE;
		}
		break;

	case GC_EVENT_NICK:
		SM_ChangeNick( gce->pDest->ptszID, gce->pDest->pszModule, gce);
		break;

	case GC_EVENT_JOIN:
		AddUser(gce);
		break;

	case GC_EVENT_PART:
	case GC_EVENT_QUIT:
	case GC_EVENT_KICK:
		bRemoveFlag = TRUE;
		break;
	}

	// Decide which window (log) should have the event
	if ( gcd->pszID ) {
		pWnd = gcd->ptszID;
		pMod = gcd->pszModule;
	}
	else if ( gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION ) {
		SESSION_INFO* si = GetActiveSession();
		if ( si && !lstrcmpA( si->pszModule, gcd->pszModule )) {
			pWnd = si->ptszID;
			pMod = si->pszModule;
		}
		else {
			iRetVal = 0;
			goto LBL_Exit;
		}
	}
	else {
		// Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc
		SM_AddEventToAllMatchingUID( gce );
		if ( !bRemoveFlag ) {
			iRetVal = 0;
			goto LBL_Exit;
	}	}

	// add to log
	if ( pWnd ) {
		SESSION_INFO* si = SM_FindSession(pWnd, pMod);

		// fix for IRC's old stuyle mode notifications. Should not affect any other protocol
		if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !( gce->dwFlags & GCEF_ADDTOLOG )) {
			iRetVal = 0;
			goto LBL_Exit;
		}

		if (gce && gce->pDest->iType == GC_EVENT_JOIN && gce->time == 0) {
			iRetVal = 0;
			goto LBL_Exit;
		}

		if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
			if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd) {
				SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
			}
			else if (si->hWnd) {
				SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
			}
			DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
			if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled)
				LogToFile(si, gce);
		}

		if ( !bRemoveFlag ) {
			iRetVal = 0;
			goto LBL_Exit;
	}	}

	if ( bRemoveFlag )
		iRetVal = ( SM_RemoveUser( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID ) == 0 ) ? 1 : 0;

LBL_Exit:
	LeaveCriticalSection(&cs);

	#if defined( _UNICODE )
		if ( !( gce->dwFlags & GC_UNICODE )) {
			mir_free((void*)gce->ptszText );
			mir_free((void*)gce->ptszNick );
			mir_free((void*)gce->ptszUID );
			mir_free((void*)gce->ptszStatus );
			mir_free((void*)gce->ptszUserInfo );
			mir_free((void*)gce->pDest->ptszID );
			*gce = save_gce;
			*gce->pDest = save_gcd;
		}
	#endif

	return iRetVal;
}
void CTemplatePluginConn::DoRequest(CFsPluginConnRequest& aRequest)
	{
	DoControl(aRequest);
	}
/**
 Handle the incoming client messages (synchronous, asynchronous) of the 
 driver. This is called in context of DFC thread. Received message is 
 passed as the argument, TThreadMessage object. It is upto the driver to
 interpret the request type and handle it accordingly. Driver should call
 TThreadMessage::Complete() to end, to unblock the user thread and notify
 that the message is received and will be handled.
  
 @param	aMsg
 		received message
 */
void DExDriverLogicalChannel::HandleMsg(TMessageBase* aMsg)
	{			
	// Retrieve the message object	
	TThreadMessage& m = *(TThreadMessage*)aMsg;
		
	// Get the request value	
	TInt id = m.iValue;
	
	// Handle logical channel close message called when client closes logical
	// channel. ECloseMsg request is issued by the framework DLogicalChannel::Close(), 
	// which is called when closing channel by RHandle::Close()
	//
	if (id==(TInt)ECloseMsg)
		{
		// DoCancel() will process the cancel request, by cancelling any 
		// pending asynchronous requests.
		//
		DoCancel(RExDriverChannel::EAllRequests);
		
		// TMessageBase::Complete() completes the kernel message and optionally
        // receives the next one. KErrNone specifies successful completion of message
        // and EFalse specifies not allowing receiving next message in the queue.
        // Unblocks the client thread that made the request.
        //	
		m.Complete(KErrNone,EFalse);
		return;
		}	
		
	// Check if the message is from the thread that created the logical 
	// channel. It does not support requests from any other threads.
	//
    if(m.Client()!=iClient)
        {
        // TMessageBase::PanicClient() panics the sender of a kernel message.
        // It also completes the message with reason code KErrDied, so that the
        // open reference on the client can be closed. This API will take care
        // of killing the thread and completing the message,(equivalent to what is
        // done in d_expio_ldd.cpp)
        //
        aMsg->PanicClient(_L("Tutorial Driver Panic"),ERequestFromWrongThread);        
        return;
        }
        
	// If client cancels asynchronous operation, the framework will issue a 
	// request with a special value of KMaxTInt(0x7FFFFFFF).
	//
    if (id==KMaxTInt)
        {
        // Handle the cancel operation from client by cancelling the specified 
        // operation. Operation is specified in the first message parameter.  
        //
        DoCancel(m.Int0());        
        // TMessageBase::Complete() completes the kernel message and optionally
        // receives the next one. KErrNone specifies successful completion of message
        // and ETrue specifies allowing receiving next message in the queue. Unblocks
        // the client thread that made the request.
        //
        m.Complete(KErrNone,ETrue);
        return;
        }
        
    // If the request value is negative, then it is an asynchronous request.
    // This type of message is a result of user side DoRequest() request with 
    // function number equal to iValue. 
    //    
    if (id<0)
    	{
    	
    	// Message first parameter will hold the TRequestStatus object. TRequestStatus
    	// is used to hold the completion status of the request. This is updated by driver
    	// and it is checked by the client after request complete notification. 
    	//
    	// Since TRequestStatus from the client's address space is not read into this thread
    	// address space (The Kernel address space) driver cannot operate on it in any way
    	// other than for completing the request.(Kern::RequestComplete will use inter 
    	// thread APIs to write to client address space). Otherwise we would have to create
    	// a local copy and read the request status from client address space.
    	// 
    	TRequestStatus* pS = (TRequestStatus*)m.Ptr0();
    	
    	// DoRequest() handles asynch requests with ~id giving async request value
    	TInt r = DoRequest(~id, pS, m.Ptr1(), m.Ptr2());
    	if (r!=KErrNone)
    		{
    		// Notify the client (iClient) that the request is completed and 
    		// TRequestStatus object is updated with the status and the completion
    		// code. At this point, client thread is blocked and is waiting on message
    		// queue semaphore till message complete notification.
    		//    
    		Kern::RequestComplete(iClient,pS,r);
    		}
    		
    	// Complete the message	successfully and enable receiving next message    	
    	m.Complete(KErrNone,ETrue);
    	}
        
	// If the request value is 0 or positive, then it is a synchronous 
	// request. This type of message is result of user side DoControl()
	// request with function number equal to iValue.
	//
	if (id>=0)
		{
		// Handle the synchronous requests. This is implementation specific,
		// however as a general practice, they are handled in DoControl().
		// m.Ptr0() and m.Ptr1() gets the arguments provided with the request.
		//
		TAny* ptr = m.Ptr0();
		
		TInt r = DoControl(id,ptr);
		
		// Unblock the user thread and notify the completion of handling 
		// the request successfully.ETrue here sets the option of receiving
		// next kernel message to true.
		//
		m.Complete(r,ETrue);		
		}	
	}
Beispiel #15
0
void __attribute__((interrupt, no_auto_psv)) _ADC1Interrupt(void)
{
        IFS0bits.AD1IF = 0;
        
        // acumulate encoder counts since last interrupt  
        CalcVelIrp();
        
        /** Increment count variable that controls stop */
        iStopLoopCnt++;     
        
        if(!uGF.bit.TStop)
        {
            
            /* check if lock time elapsed */
            if(iStopLoopCnt == BUTTON_STOP_TIME)
            {
                /* set stop command */
                uGF.bit.TStop = 1;
                /** Disable the driver IC on the motor control PCB */
                pinPWMOutputEnable_ = 1;
            }
        }
        /** it was a previous stop, time to recover is considered */
        else 
        {
            /* check the counter for BUTTON_STOP_TIME */
            /* if elapsed, stop may be deaserted */
            if(iStopLoopCnt == BUTTON_STOP_TIME)
            {
                uGF.bit.TStop = 0;
            }
        }
        
        if( eStateControl != CNTRL_STOP )
        {
                // Calculate qIa,qIb
                MeasCompCurr();
                
                // Calculate qId,qIq from qSin,qCos,qIa,qIb
                ClarkePark();
                               
                // Calculate control values
                DoControl();
                
                // Calculate qSin,qCos from qAngle
                SinCos();
                
                // Calculate qValpha, qVbeta from qSin,qCos,qVd,qVq
                InvPark();
                
                // Calculate Vr1,Vr2,Vr3 from qValpha, qVbeta 
                CalcRefVec();
                
                // Calculate and set PWM duty cycles from Vr1,Vr2,Vr3
                CalcSVGen();
                
                /** Increment count variable that controls buttons lock */
                iLockLoopCnt++;
                /* check if lock time elapsed */
                if((uGF.bit.TLock)&&(iLockLoopCnt == BUTTON_LOCK_TIME))
                {
                    /* reset lock for buttons command */
                    uGF.bit.TLock = 0; /* reset lock */
                }
        }
}
void CUnremovablePluginConn::DoRequest(CFsPluginConnRequest& aRequest)
	{
	DoControl(aRequest);
	}
void CPreModifierPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
	{
	DoControl(aRequest);
	}
Beispiel #18
0
void CExclusiveAccessPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
	{
	DoControl(aRequest);
	}
Beispiel #19
0
static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
{
	GCEVENT *gce = (GCEVENT*)lParam;
	BOOL bIsHighlighted = FALSE;
	BOOL bRemoveFlag = FALSE;

	if (gce == NULL)
		return GC_EVENT_ERROR;

	GCDEST *gcd = gce->pDest;
	if (gcd == NULL)
		return GC_EVENT_ERROR;

	if (gce->cbSize != sizeof(GCEVENT))
		return GC_EVENT_WRONGVER;

	if (!IsEventSupported(gcd->iType))
		return GC_EVENT_ERROR;

	NotifyEventHooks(hHookEvent, wParam, lParam);

	SESSION_INFO *si;
	mir_cslock lck(cs);

	// Do different things according to type of event
	switch (gcd->iType) {
	case GC_EVENT_ADDGROUP:
	{
		STATUSINFO *si = ci.SM_AddStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
		if (si && gce->dwItemData)
			si->hIcon = CopyIcon((HICON)gce->dwItemData);
	}
		return 0;

	case GC_EVENT_CHUID:
	case GC_EVENT_CHANGESESSIONAME:
	case GC_EVENT_SETITEMDATA:
	case GC_EVENT_GETITEMDATA:
	case GC_EVENT_CONTROL:
	case GC_EVENT_SETSBTEXT:
	case GC_EVENT_ACK:
	case GC_EVENT_SENDMESSAGE:
	case GC_EVENT_SETSTATUSEX:
		return DoControl(gce, wParam);

	case GC_EVENT_SETCONTACTSTATUS:
		return ci.SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData);

	case GC_EVENT_TOPIC:
		if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
			if (gce->ptszText) {
				replaceStrT(si->ptszTopic, RemoveFormatting(gce->ptszText));
				db_set_ts(si->hContact, si->pszModule, "Topic", si->ptszTopic);
				if (ci.OnSetTopic)
					ci.OnSetTopic(si);
				if (db_get_b(NULL, CHAT_MODULE, "TopicOnClist", 0))
					db_set_ts(si->hContact, "CList", "StatusMsg", si->ptszTopic);
			}
		}
		break;

	case GC_EVENT_ADDSTATUS:
		ci.SM_GiveStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
		bIsHighlighted = ci.IsHighlighted(NULL, gce);
		break;

	case GC_EVENT_REMOVESTATUS:
		ci.SM_TakeStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
		bIsHighlighted = ci.IsHighlighted(NULL, gce);
		break;

	case GC_EVENT_MESSAGE:
	case GC_EVENT_ACTION:
		if (!gce->bIsMe && gce->pDest->ptszID && gce->ptszText) {
			si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
			bIsHighlighted = ci.IsHighlighted(si, gce);
		}
		break;

	case GC_EVENT_NICK:
		ci.SM_ChangeNick(gce->pDest->ptszID, gce->pDest->pszModule, gce);
		bIsHighlighted = ci.IsHighlighted(NULL, gce);
		break;

	case GC_EVENT_JOIN:
		AddUser(gce);
		bIsHighlighted = ci.IsHighlighted(NULL, gce);
		break;

	case GC_EVENT_PART:
	case GC_EVENT_QUIT:
	case GC_EVENT_KICK:
		bRemoveFlag = TRUE;
		bIsHighlighted = ci.IsHighlighted(NULL, gce);
		break;
	}

	// Decide which window (log) should have the event
	LPCTSTR pWnd = NULL;
	LPCSTR pMod = NULL;
	if (gcd->ptszID) {
		pWnd = gcd->ptszID;
		pMod = gcd->pszModule;
	}
	else if (gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION) {
		si = ci.GetActiveSession();
		if (si && !lstrcmpA(si->pszModule, gcd->pszModule)) {
			pWnd = si->ptszID;
			pMod = si->pszModule;
		}
		else return 0;
	}
	else {
		// Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc
		ci.SM_AddEventToAllMatchingUID(gce);
		if (!bRemoveFlag)
			return 0;
	}

	// add to log
	if (pWnd) {
		si = ci.SM_FindSession(pWnd, pMod);

		// fix for IRC's old stuyle mode notifications. Should not affect any other protocol
		if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG))
			return 0;

		if (gce && gce->pDest->iType == GC_EVENT_JOIN && gce->time == 0)
			return 0;

		if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
			int isOk = ci.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
			if (ci.OnAddLog)
				ci.OnAddLog(si, isOk);
			if (!(gce->dwFlags & GCEF_NOTNOTIFY))
				ci.DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
			if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
				ci.LogToFile(si, gce);
		}

		if (!bRemoveFlag)
			return 0;
	}

	if (bRemoveFlag)
		return ci.SM_RemoveUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID) == 0;

	return GC_EVENT_ERROR;
}