LRESULT CALLBACK TabBackingProcStub(HWND hwnd,UINT uMsg,
WPARAM wParam,LPARAM lParam,UINT_PTR uIdSubclass,DWORD_PTR dwRefData)
{
	CContainer *pContainer = (CContainer *)dwRefData;

	return pContainer->TabBackingProc(hwnd,uMsg,wParam,lParam);
}
LRESULT CALLBACK BookmarksToolbarSubclassStub(HWND hwnd,UINT uMsg,
WPARAM wParam,LPARAM lParam,UINT_PTR uIdSubclass,DWORD_PTR dwRefData)
{
	CContainer *pContainer = (CContainer *)dwRefData;

	return pContainer->BookmarksToolbarSubclass(hwnd,uMsg,wParam,lParam);
}
Example #3
0
TRIGRET_TYPE CContainer::OnContTriggerForLoop( CScript &s, CTextConsole * pSrc, CScriptTriggerArgs * pArgs, CGString * pResult, CScriptLineContext & StartContext, CScriptLineContext & EndContext, RESOURCE_ID_BASE rid, DWORD dwArg, int iDecendLevels )
{
	ADDTOCALLSTACK("CContainer::OnContTriggerForLoop");
	if ( rid.GetResIndex() != 0 )
	{
		CItem* pItem = GetContentHead();
		CItem * pItemNext;
		for ( ; pItem!=NULL; pItem=pItemNext)
		{
			pItemNext = pItem->GetNext();
			
			if ( pItem->IsResourceMatch( rid, dwArg ))
			{
				s.SeekContext( StartContext );
				TRIGRET_TYPE iRet = pItem->OnTriggerRun( s, TRIGRUN_SECTION_TRUE, pSrc, pArgs, pResult );
				if ( iRet == TRIGRET_BREAK )
				{
					EndContext = StartContext;
					break;
				}
 				if (( iRet != TRIGRET_ENDIF ) && ( iRet != TRIGRET_CONTINUE ))
					return( iRet );
				if ( iRet == TRIGRET_CONTINUE )
					EndContext = StartContext;
				else
					EndContext = s.GetContext();
			}
			if ( iDecendLevels <= 0 )
				continue;
			CItemContainer * pCont = dynamic_cast <CItemContainer*>(pItem);
			if ( pCont != NULL )
			{
				if ( pCont->IsSearchable())
				{
					CContainer * pContBase = dynamic_cast <CContainer *> (pCont);
					TRIGRET_TYPE iRet = pContBase->OnContTriggerForLoop( s, pSrc, pArgs, pResult, StartContext, EndContext, rid, dwArg, iDecendLevels-1 );
					if ( iRet != TRIGRET_ENDIF )
					{
						return( iRet );
					}

					// Since the previous call has already found the EndContext, set it.
					EndContext = s.GetContext();
				}
			}
		}
	}
	if ( EndContext.m_lOffset <= StartContext.m_lOffset )
	{
		CScriptObj * pScript = dynamic_cast <CScriptObj *> (this);
		TRIGRET_TYPE iRet = pScript->OnTriggerRun( s, TRIGRUN_SECTION_FALSE, pSrc, pArgs, pResult );
		if ( iRet != TRIGRET_ENDIF )
			return( iRet );
	}
	else
		s.SeekContext( EndContext );
	return( TRIGRET_ENDIF );
}
Example #4
0
void CContainer::IdentificationCompletedCallback(TTankIndex Tank, TGenericCockie Cockie)
{
    CContainer *InstancePtr = reinterpret_cast<CContainer *>(Cockie);

    // Erase the callback pointers after callback was done.
    InstancePtr->SetIdentificationCompletedCallback(Tank, NULL, NULL);

    InstancePtr->m_TanksArray[Tank]->SetEventIdentificationCompletion();
}
Example #5
0
void CGraphPlugIn::GetCellValue(cell c, char *s)
{
	CContainer *cnt = fParent->GetContainer();
	
	try
	{
		BAutolock lock(cnt);
		cnt->GetCellResult(c, s, true);
	}
	catch(...){}
} // CGraphPlugIn::GetCellValue
Example #6
0
ret_ CNetworkHandle::OnMessage(const ub_1 *pMsg,
                               size_ nSize,
                               const TMsgInfo *pMsgInfo)
{
#ifdef _DEBUG_
    if (!pMsg)
        return PARAMETER_NULL | PARAMETER_1;

    if (0 == nSize)
        return PARAMETER_ERROR | PARAMETER_2;

    if (!pMsgInfo)
        return PARAMETER_NULL | PARAMETER_3;
#endif

    CNetworkConf *pConf = (CNetworkConf *)GetConf();

#ifdef _DEBUG_
    if (!pConf)
        return NO_ELEMENT_IN_CONTAINER;
#endif

    CPDUInfo *pPDUInfo = null_v;

    try
    {
        v_ CommandID((size_ *)(pMsg +
                               pConf->GetCommandID()->Offset(pMsg, nSize)));
        ret_ Ret = pConf->IdentifyID(CommandID, pPDUInfo, DIRECTION_IN);

        if (SUCCESS != Ret)
            return Ret;
    }
    catch (error_code err)
    {
        return err;
    }

    TMU tmu;

    tmu.pPDUInfo = pPDUInfo;
    tmu.pMessage = (ub_1 *)pMsg;
    tmu.nSize = nSize;
    tmu.pMsgInfo = (TMsgInfo *)pMsgInfo;

    CContainer *pContainer = CUIManager::Instance()->GetCurContainer();

    if (pContainer)
        pContainer->OnMessage(&tmu);

    return SUCCESS;
}
Example #7
0
void COptEnable::Work(const TMU *pTMU)
{
	CContainer *pContainer = CUIManager::Instance()->GetCurContainer();

	if (!pContainer)
		throw WINDOW_IS_NOT_EXIST;

	CWindow * pWindow = pContainer->GetChild(m_szWindowName);

	if (pWindow)
		pWindow->Enable(m_bIsEnable);
	else
		pContainer->Enable(m_bIsEnable);
}
Example #8
0
void COptWaitMessage::Work(const TMU *pTMU)
{
	CPDUInfo *pPDUInfo = null_v;

	if (SUCCESS != CProtocolManager::Instance()->GetProtocol()->GetPDU(
			m_szMessageName, pPDUInfo))
	{
		throw OPERATOR_OPERAITON_ERROR;
	}

	CContainer *pContainer = CUIManager::Instance()->GetCurContainer();

	if (pContainer)
		pContainer->WaitMessage(pPDUInfo);
	else
		throw OPERATOR_OPERAITON_ERROR;
}
Example #9
0
bool CGraphPlugIn::GetCellTime(cell c, time_t *t)
{
	CContainer *cnt = fParent->GetContainer();
	
	try
	{
		BAutolock lock(cnt);
		Value v;
		if (cnt->GetValue(c, v) && v.fType == eTimeData)
		{
			*t = v.fTime;
			return true;
		}
	}
	catch (...) { }

	return false;
} /* GetCellTime */
Example #10
0
bool CGraphPlugIn::GetCellDouble(cell c, double *d)
{
	CContainer *cnt = fParent->GetContainer();
	
	try
	{
		BAutolock lock(cnt);
		Value v;
		if (cnt->GetValue(c, v) && v.fType == eNumData)
		{
			*d = v.fDouble;
			return true;
		}
	}
	catch (...) { }

	return false;
} /* GetCellDouble */
Example #11
0
bool CGraphPlugIn::GetCellText(cell c, char *s)
{
	CContainer *cnt = fParent->GetContainer();
	
	try
	{
		BAutolock lock(cnt);
		Value v;
		if (cnt->GetValue(c, v) && v.fType == eTextData)
		{
			strcpy(s, v.fText);
			return true;
		}
	}
	catch (...) { }

	return false;
} /* GetCellText */
Example #12
0
bool CGraphPlugIn::GetCellBool(cell c, bool *b)
{
	CContainer *cnt = fParent->GetContainer();
	
	try
	{
		BAutolock lock(cnt);

		Value v;
		if (cnt->GetValue(c, v) && v.fType == eBoolData)
		{
			*b = v.fBool;
			return true;
		}
	}
	catch (...) { }

	return false;
} /* GetCellBool */
Example #13
0
void CItemContainer::OnWeightChange( int iChange )
{
	ADDTOCALLSTACK("CItemContainer::OnWeightChange");
	CContainer::OnWeightChange( iChange );
	UpdatePropertyFlag(AUTOTOOLTIP_FLAG_WEIGHT);

	if ( iChange == 0 )
		return;	// no change

	// some containers do not add weight to you.
	if ( ! IsWeighed())
		return;

	// Propagate the weight change up the stack if there is one.
	CContainer * pCont = dynamic_cast <CContainer*>(GetParent());
	if ( pCont == NULL )
		return;	// on ground.
	pCont->OnWeightChange( iChange );
}
Example #14
0
void CRadioBox::performGroupStateChanged()
{
    CContainer *pParentContainer = NULL;
    CCNode *pParent = getParent();
    while( pParent != NULL )
    {
        CContainer *pContainer = dynamic_cast<CContainer *>(pParent);
        if( pContainer != NULL && pContainer->getIsForm() )
        {
            pParentContainer = pContainer;
            break;
        }
        pParent = pParent->getParent();
    }
    
    if(pParentContainer == NULL)
        return;
    
    
}
Example #15
0
void CCPropsItemChar::SetPropertyNum(int iPropIndex, PropertyValNum_t iVal, CObjBase* pLinkedObj, RESDISPLAY_VERSION iLimitToExpansion, bool fDeleteZero)
{
    ADDTOCALLSTACK("CCPropsItemChar::SetPropertyNum");
    ASSERT(!IsPropertyStr(iPropIndex));
    ASSERT((iLimitToExpansion >= RDS_PRET2A) && (iLimitToExpansion < RDS_QTY));

    if ((fDeleteZero && (iVal == 0)) || (_iPropertyExpansion[iPropIndex] > iLimitToExpansion))
    {
        if (0 == _mPropsNum.erase(iPropIndex))
            return; // I didn't have this property, so avoid further processing.
    }
    else
        _mPropsNum[iPropIndex] = iVal;

    if (!pLinkedObj)
        return;

    // Do stuff to the pLinkedObj
    switch (iPropIndex)
    {
        case PROPITCH_WEIGHTREDUCTION:
        {
            CItem *pItemLink = static_cast<CItem*>(pLinkedObj);
            int oldweight = pItemLink->GetWeight();
            CContainer * pCont = dynamic_cast <CContainer*> (pItemLink->GetParent());
            if (pCont)
            {
                ASSERT(pItemLink->IsItemEquipped() || pItemLink->IsItemInContainer());
                pCont->OnWeightChange(pItemLink->GetWeight() - oldweight);
                pLinkedObj->UpdatePropertyFlag();
            }
            break;
        }

        //default:
        //    pLinkedObj->UpdatePropertyFlag();
        //    break;
    }
}
Example #16
0
void CClient::Cmd_EditItem( CObjBase *pObj, int iSelect )
{
	ADDTOCALLSTACK("CClient::Cmd_EditItem");
	// ARGS:
	//   iSelect == -1 = setup.
	//   m_Targ_Text = what are we doing to it ?
	//
	if ( !pObj )
		return;

	CContainer *pContainer = dynamic_cast<CContainer *>(pObj);
	if ( !pContainer )
	{
		addGumpDialogProps(pObj->GetUID());
		return;
	}

	if ( iSelect == 0 )		// cancelled
		return;

	if ( iSelect > 0 )		// we selected an item
	{
		if ( static_cast<size_t>(iSelect) >= COUNTOF(m_tmMenu.m_Item) )
			return;

		if ( m_Targ_Text.IsEmpty() )
			addGumpDialogProps(m_tmMenu.m_Item[static_cast<size_t>(iSelect)]);
		else
			OnTarg_Obj_Set(CGrayUID(m_tmMenu.m_Item[static_cast<size_t>(iSelect)]).ObjFind());
		return;
	}
	
	CMenuItem item[minimum(COUNTOF(m_tmMenu.m_Item), MAX_MENU_ITEMS)];	// Most as we want to display at one time.
	item[0].m_sText.Format("Contents of %s", pObj->GetName());

	size_t count = 0;
	for ( CItem *pItem = pContainer->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
	{
		count++;
		m_tmMenu.m_Item[count] = pItem->GetUID();
		item[count].m_sText = pItem->GetName();
		ITEMID_TYPE idi = pItem->GetDispID();
		item[count].m_id = static_cast<WORD>(idi);
		item[count].m_color = 0;

		if ( !pItem->IsType(IT_EQ_MEMORY_OBJ) )
		{
			HUE_TYPE wHue = pItem->GetHue();
			if ( wHue != 0 )
			{
				wHue = (wHue == 1 ? 0x7FF : wHue - 1);
				item[count].m_color = wHue;
			}
		}

		if ( count >= (COUNTOF(item) - 1) )
			break;
	}
	
	ASSERT(count < COUNTOF(item));
	addItemMenu(CLIMODE_MENU_EDIT, item, count, pObj);
}
Example #17
0
TRIGRET_TYPE CScriptObj::OnTriggerRun( CScript &s, TRIGRUN_TYPE trigrun, CTextConsole * pSrc, CScriptTriggerArgs * pArgs, CGString * pResult )
{
	// ARGS:
	//	TRIGRUN_SECTION_SINGLE = just this 1 line.
	// RETURN:
	//  TRIGRET_RET_FALSE = 0 = return and continue processing.
	//  TRIGRET_RET_TRUE = 1 = return and handled. (halt further processing)
	//  TRIGRET_RET_DEFAULT = 2 = if process returns nothing specifically.

	// CScriptFileContext set g_Log.m_pObjectContext is the current context (we assume)
	// DEBUGCHECK( this == g_Log.m_pObjectContext );

	static LPCTSTR const m_ExcKeys[] =
	{
		"parsing",
		"parsing IF statement",
		"parsing begin/loop cycle",
		"foritem",
		"forchar",
		"forclients",
		"forobjs",
		"forplayers",
		"for",
		"while",
		"forcharlayer/memorytype",
		"forcont",
		"forcontid/type",
		"dorand/doswitch",
		"return",
		"CALLing a subfunction",
		"VERBing a value",
	};

	#ifdef WIN32
		EXC_TRY(("OnTriggerRun(%x,%i,%x,%x,%x)", s.GetKey(), trigrun, pSrc, pArgs, pResult));
	#else
		EXC_TRY(("OnTriggerRun(??,%i,%x,%x,%x)", trigrun, pSrc, pArgs, pResult));
	#endif
	
	bool fSectionFalse = (trigrun == TRIGRUN_SECTION_FALSE || trigrun == TRIGRUN_SINGLE_FALSE);
	if ( trigrun == TRIGRUN_SECTION_EXEC || trigrun == TRIGRUN_SINGLE_EXEC )	// header was already read in.
		goto jump_in;

	EXC_SET(m_ExcKeys[0]);
	while ( s.ReadKeyParse())
	{
		// Hit the end of the next trigger.
		if ( s.IsKeyHead( "ON", 2 ))	// done with this section.
			break;

jump_in:
		SK_TYPE iCmd = (SK_TYPE) FindTableSorted( s.GetKey(), sm_szScriptKeys, COUNTOF( sm_szScriptKeys )-1 );
		TRIGRET_TYPE iRet;

		switch ( iCmd )
		{
		case SK_ENDIF:
		case SK_END:
		case SK_ENDDO:
		case SK_ENDFOR:
		case SK_ENDRAND:
		case SK_ENDSWITCH:
		case SK_ENDWHILE:
			return( TRIGRET_ENDIF );

		case SK_ELIF:
		case SK_ELSEIF:
			return( TRIGRET_ELSEIF );

		case SK_ELSE:
			return( TRIGRET_ELSE );
		}

		if ( fSectionFalse )
		{
			// Ignoring this whole section. don't bother parsing it.
			switch ( iCmd )
			{
			case SK_IF:
				EXC_SET(m_ExcKeys[1]);
				do
				{
					iRet = OnTriggerRun( s, TRIGRUN_SECTION_FALSE, pSrc, pArgs, pResult );
				} while ( iRet == TRIGRET_ELSEIF || iRet == TRIGRET_ELSE );
				break;
			case SK_WHILE:
			case SK_FOR:
			case SK_FORCHARLAYER:
			case SK_FORCHARMEMORYTYPE:
			case SK_FORCHAR:
			case SK_FORCLIENTS:
			case SK_FORCONT:
			case SK_FORCONTID:
			case SK_FORCONTTYPE:
			case SK_FORITEM:
			case SK_FOROBJ:
			case SK_FORPLAYERS:
			case SK_DORAND:
			case SK_DOSWITCH:
			case SK_BEGIN:
				EXC_SET(m_ExcKeys[2]);
				iRet = OnTriggerRun( s, TRIGRUN_SECTION_FALSE, pSrc, pArgs, pResult );
				break;
			}
			if ( trigrun >= TRIGRUN_SINGLE_EXEC )
				return( TRIGRET_RET_DEFAULT );
			continue;	// just ignore it.
		}

		switch ( iCmd )
		{
		case SK_FORITEM:	EXC_SET(m_ExcKeys[3]); iRet = OnTriggerForLoop( s, 1, pSrc, pArgs, pResult );			break;
		case SK_FORCHAR:	EXC_SET(m_ExcKeys[4]); iRet = OnTriggerForLoop( s, 2, pSrc, pArgs, pResult );			break;
		case SK_FORCLIENTS:	EXC_SET(m_ExcKeys[5]); iRet = OnTriggerForLoop( s, 0x12, pSrc, pArgs, pResult );		break;
		case SK_FOROBJ:		EXC_SET(m_ExcKeys[6]); iRet = OnTriggerForLoop( s, 3, pSrc, pArgs, pResult );			break;
		case SK_FORPLAYERS:	EXC_SET(m_ExcKeys[7]); iRet = OnTriggerForLoop( s, 0x22, pSrc, pArgs, pResult );		break;
		case SK_FOR:		EXC_SET(m_ExcKeys[8]); iRet = OnTriggerForLoop( s, 4, pSrc, pArgs, pResult );			break;
		case SK_WHILE:		EXC_SET(m_ExcKeys[9]); iRet = OnTriggerForLoop( s, 8, pSrc, pArgs, pResult );			break;
		case SK_FORCHARLAYER:
		case SK_FORCHARMEMORYTYPE:
			{
				EXC_SET(m_ExcKeys[10]);
				CChar * pCharThis = dynamic_cast <CChar *> (this);
				if ( pCharThis )
				{
					if ( s.HasArgs() )
					{
						if ( iCmd == SK_FORCHARLAYER )
							iRet = pCharThis->OnCharTrigForLayerLoop( s, pSrc, pArgs, pResult, (LAYER_TYPE) s.GetArgVal() );
						else
							iRet = pCharThis->OnCharTrigForMemTypeLoop( s, pSrc, pArgs, pResult, s.GetArgVal() );
						break;
					}
				}
			}
		case SK_FORCONT:
			{
				EXC_SET(m_ExcKeys[11]);
				if ( s.HasArgs() )
				{
					TCHAR * ppArgs[2];
					TCHAR * tempPoint;
					TCHAR 	*porigValue = Str_GetTemp();
					
					int iArgQty = Str_ParseCmds( (TCHAR*) s.GetArgRaw(), ppArgs, COUNTOF(ppArgs), " \t," );
					
					if ( iArgQty >= 1 )
					{
						strcpy(porigValue, ppArgs[0]);
						tempPoint = porigValue;
						ParseText( tempPoint, pSrc, 0, pArgs );
						
						CGrayUID pCurUid = (DWORD) Exp_GetVal(tempPoint);
						if ( pCurUid.IsValidUID() )
						{
							CObjBase * pObj = pCurUid.ObjFind();
							if ( pObj && pObj->IsContainer() )
							{
								CContainer * pContThis = dynamic_cast <CContainer *> (pObj);
								
								CScriptLineContext StartContext = s.GetContext();
								CScriptLineContext EndContext = StartContext;
								iRet = pContThis->OnGenericContTriggerForLoop( s, pSrc, pArgs, pResult, StartContext, EndContext, ppArgs[1] != NULL ? Exp_GetVal(ppArgs[1]) : 255 );
								break;
							}
						}
					}
				}
			}
		case SK_FORCONTID:
		case SK_FORCONTTYPE:
			{
				EXC_SET(m_ExcKeys[12]);
				CContainer * pCont = dynamic_cast <CContainer *> (this);
				if ( pCont )
				{
					if ( s.HasArgs() )
					{
						LPCTSTR pszKey = s.GetArgRaw();
						SKIP_SEPERATORS(pszKey);
					
						TCHAR * ppArgs[2];
						Str_ParseCmds( (TCHAR*) pszKey, ppArgs, COUNTOF(ppArgs), " \t," );

						CScriptLineContext StartContext = s.GetContext();
						CScriptLineContext EndContext = StartContext;
#ifdef _WIN32
						iRet = pCont->OnContTriggerForLoop( s, pSrc, pArgs, pResult, StartContext, EndContext, g_Cfg.ResourceGetID( ( iCmd == SK_FORCONTID ) ? RES_ITEMDEF : RES_TYPEDEF, ppArgs[0] ), 0, ppArgs[1] != NULL ? Exp_GetVal( ppArgs[1] ) : 255 );
#else
						iRet = pCont->OnContTriggerForLoop( s, pSrc, pArgs, pResult, StartContext, EndContext, g_Cfg.ResourceGetID( ( iCmd == SK_FORCONTID ) ? RES_ITEMDEF : RES_TYPEDEF, (const char*&) ppArgs[0] ), 0, ppArgs[1] != NULL ? Exp_GetVal( ppArgs[1] ) : 255 );
#endif
						break;
					}
				}
			}
		default:
			// Parse out any variables in it. (may act like a verb sometimes?)
			EXC_SET(m_ExcKeys[0]);
			ParseText( s.GetArgRaw(), pSrc, 0, pArgs );
		}

		switch ( iCmd )
		{
		case SK_FORITEM:
		case SK_FORCHAR:
		case SK_FORCHARLAYER:
		case SK_FORCHARMEMORYTYPE:
		case SK_FORCLIENTS:
		case SK_FORCONT:
		case SK_FORCONTID:
		case SK_FORCONTTYPE:
		case SK_FOROBJ:
		case SK_FORPLAYERS:
		case SK_FOR:
		case SK_WHILE:
			if ( iRet != TRIGRET_ENDIF )
			{
				if ( iRet > TRIGRET_RET_DEFAULT )
				{
					DEBUG_MSG(( "WARNING: Trigger Bad For Ret %d '%s','%s'\n", iRet, s.GetKey(), s.GetArgStr()));
				}
				return( iRet );
			}
			break;
		case SK_DORAND:	// Do a random line in here.
		case SK_DOSWITCH:
			{
			EXC_SET(m_ExcKeys[13]);
			int iVal = s.GetArgVal();
			if ( iCmd == SK_DORAND )
				iVal = Calc_GetRandVal(iVal);
			for ( ;true; iVal-- )
			{
				iRet = OnTriggerRun( s, (!iVal) ? TRIGRUN_SINGLE_TRUE : TRIGRUN_SINGLE_FALSE, pSrc, pArgs, pResult );
				if ( iRet == TRIGRET_RET_DEFAULT )
					continue;
				if ( iRet == TRIGRET_ENDIF )
					break;
				if ( iRet > TRIGRET_RET_DEFAULT )
				{
					DEBUG_MSG(( "WARNING: Trigger Bad Ret %d '%s','%s'\n", iRet, s.GetKey(), s.GetArgStr()));
				}
				return( iRet );
			}
			}
			break;
		case SK_RETURN:		// Process the trigger.
			EXC_SET(m_ExcKeys[14]);
			if ( pResult )
			{
				pResult->Copy( s.GetArgStr() );
				return (TRIGRET_TYPE) 1;
			}
			return ( (TRIGRET_TYPE) s.GetArgVal() );
		case SK_IF:
			{
				EXC_SET(m_ExcKeys[1]);
				bool fTrigger = s.GetArgVal() ? true : false;
				bool fBeenTrue = false;
				while (true)
				{
					iRet = OnTriggerRun( s, fTrigger ? TRIGRUN_SECTION_TRUE : TRIGRUN_SECTION_FALSE, pSrc, pArgs, pResult );
					if ( iRet < TRIGRET_ENDIF )
						return( iRet );
					if ( iRet == TRIGRET_ENDIF )
						break;
					fBeenTrue |= fTrigger;
					if ( fBeenTrue )
						fTrigger = false;
					else if ( iRet == TRIGRET_ELSE )
						fTrigger = true;
					else if ( iRet == TRIGRET_ELSEIF )
					{
						ParseText( s.GetArgStr(), pSrc, 0, pArgs );
						fTrigger = s.GetArgVal() ? true : false;
					}
				}
			}
			break;

		case SK_BEGIN:
			// Do this block here.
			{
				EXC_SET(m_ExcKeys[2]);
				iRet = OnTriggerRun( s, TRIGRUN_SECTION_TRUE, pSrc, pArgs, pResult );
				if ( iRet != TRIGRET_ENDIF )
				{
					if ( iRet > TRIGRET_RET_DEFAULT )
					{
						DEBUG_MSG(( "WARNING: Trigger Bad Ret %d '%s','%s'\n", iRet, s.GetKey(), s.GetArgStr()));
					}
					return( iRet );
				}
			}
			break;

		default:
			if ( IsSetEF( EF_Scripts_Parse_Verbs ) )
			{
				EXC_SET(m_ExcKeys[0]);
				ParseText( s.GetKeyBuffer(), pSrc, 0, pArgs );
			}
			EXC_SET(m_ExcKeys[0]);
			if ( pArgs && pArgs->r_Verb( s, pSrc ) )
				;
			else
			{
				bool	fRes;
				if ( !strcmpi( (char *)s.GetKey(), "call" ) )
				{
					EXC_SET(m_ExcKeys[15]);
					LPCTSTR	pszArgs	= strchr( s.GetArgRaw(), ' ' );
					if ( pszArgs )
						GETNONWHITESPACE( pszArgs );
					if ( !pszArgs || !*pszArgs )
					{
						fRes	= this->r_Call( s.GetArgRaw(), pSrc, pArgs );
					}
					else
					{
						CScriptTriggerArgs	Args( pszArgs );
						if ( pArgs )
							Args.m_VarsLocal	= pArgs->m_VarsLocal;
						fRes	= this->r_Call( s.GetArgRaw(), pSrc, &Args );
						if ( pArgs )
							pArgs->m_VarsLocal	= Args.m_VarsLocal;
					}
				}
				else
				{
					EXC_SET(m_ExcKeys[16]);
					fRes	= r_Verb( s, pSrc );
				}

				if ( !fRes  )
				{
					DEBUG_MSG(( "WARNING: Trigger Bad Verb '%s','%s'\n", s.GetKey(), s.GetArgStr()));
				}
			}
			break;
		}

		if ( trigrun >= TRIGRUN_SINGLE_EXEC )
			return( TRIGRET_RET_DEFAULT );
	}
	EXC_CATCH("running trigger line");
	return( TRIGRET_RET_DEFAULT );
}
Example #18
0
// We recall messages stored in the database
size_t CPartner::Recall( const string&  rsClientData,
                               CSocket* poSocket )
  {
  typedef map<string, string> CMapString2String;
  CMapString2String moQuery;

  for (string::size_type p1=0, p2=0;
       string::npos != ( p2 = rsClientData.find('\n', p1) );
       p1 = p2+1)
    {
    string s = rsClientData.substr(p1, p2-p1);
    size_t l = s.length();
    if ( (l > 2) && (s[1] == ':') )
      {
      if ( l > 4)
        moQuery[ s.substr(0, 3) ] = s.substr(4);
        else
        moQuery[ s.substr(0, 3) ] = "";
      }
    } // for (string::size_type p1=0, p2=0; ...

/*
        client command      | send to server   | receive from server
        ====================+==================+====================
        list all            | l:a              |  m:<message-id>
                            |                  | [...]
        list partially      | l:p <message-id> |  m:<message-id>
                            |                  | [...]
        list mine           | l:m              |  m:<message-id>
                            |                  | [...]
        list mine partially | l:y <message-id> |  m:<message-id>
                            |                  | [...]
        list senders        | l:s              |  s:<sender-id>
                            |                  | [...]
        call all            | c:a              |  m:<message-id>
                            |                  | [...]
        call MsgID          | c:m <message-id> |  m:<message-id>
                            |                  | [<body>]
                            |                  | [n:<next message-id>]
        cbsr MsgID          | c:s <message-id> |  m:<message-id>
                            |                  | [<body>]
                            |                  | [n:<next message-id>]
*/
  for ( CMapString2String::iterator itQuery  = moQuery.begin();
                                    itQuery != moQuery.end();
                                  ++itQuery)
    {
    if ( g_bVerbose)
      {
      cout << " * " << itQuery->first;
      if ( itQuery->second.length() > 0 ) cout << " with " << itQuery->second;
      cout << "\n";
      }

    CContainerMapByCLUID::iterator it;

    switch ( itQuery->first[0] )
      {
      case 'l': // list operations
        switch ( itQuery->first[2] )
          {
          case 'a': // l:a list all
            if ( g_bVerbose) cout << " * list all \n";
/*
              1) get the recipient from the TLS-session
              2) resend all message ids for this sender
 */
            for ( it = g_oContainerMapByCLUID.begin(); it != g_oContainerMapByCLUID.end(); ++it )
              {
              *poSocket << it->first << "\n";
              }
            break;
          case 'p': // l:p list part, beginning with message-id
/*
              1) get the recipient from the TLS-session
              2) resend all message ids for this sender starting with the given message-id
 */
            if ( g_bVerbose) cout << " * list partial, beginning with '" << itQuery->second << "'\n";
            for ( it = g_oContainerMapByCLUID.find(itQuery->second); it != g_oContainerMapByCLUID.end(); ++it )
              {
              *poSocket << it->first << "\n";
              }
            break;
          case 'm': // l:m list mine (sent by me)
            if ( g_bVerbose) cout << " * list mine\n";
/*
              1) get the recipient from the TLS-session
              2) resend all message ids from this sender
 */
            break;
          case 'y': // l:y list mine part, beginning with message-id
            if ( g_bVerbose) cout << " * list mine partial, beginning with '" << itQuery->second << "'\n";
/*
              1) get the recipient from the TLS-session
              2) resend all message ids from this sender starting at the given message-id
 */
            break;
          case 's': // l:s list senders
            if ( g_bVerbose) cout << " * list senders\n";
/*
              1) get the recipient from the TLS-session
              2) resend all senders with messages for this recipients
 */
            typedef map<string, bool> CMapString2Bool;
            CMapString2Bool omSenders;
            for ( it = g_oContainerMapByCLUID.begin(); it != g_oContainerMapByCLUID.end(); ++it )
              {
              omSenders[ it->second->SenderGet() ] = true;
              }
            for ( CMapString2Bool::iterator itSenders = omSenders.begin(); itSenders != omSenders.end(); ++itSenders )
              {
              *poSocket << itSenders->first << "\n";
              }
            break;
          } // switch ( itQuery->first[2] )
        break; // switch ( itQuery->first[0] ) => case 'l'

      case 'c': // call operations
        CContainer*          poc;
        CContainer::iterator itc;
        switch ( itQuery->first[2] )
          {
          case 'a': // c:a = call all
            if ( g_bVerbose) cout << " * recall all for me\n";
/*
              1) get the recipient from the TLS-session
              2) resend all messages for the recipient
 */
            for ( it = g_oContainerMapByCLUID.begin(); it != g_oContainerMapByCLUID.end(); ++it )
              {
              poc = it->second;

              *poSocket << string(1, CContainer::scn_sender)  << ":" << poc->SenderGet() << "\n";
              *poSocket << it->first                          << "\n";

              for ( itc  = poc->begin(); itc != poc->end(); ++itc )
                {
                *poSocket << *itc << "\n";
                } // for ( CContainer::iterator itc  = poc->begin();
              } // for ( it = g_oContainerMapByCLUID.begin(); ...
            break; // case 'a': // c:a = call all

          case 'm': // c:m = call message
            if ( g_bVerbose) cout << " * recall message '" << itQuery->second << "'\n";
/*
              1) get the recipient from the TLS-session
              2) resend the queried message if its for the recipient
              3) resend the next message-id from the same sender (if any)
 */
            it = g_oContainerMapByCLUID.find( itQuery->second );
            if ( it != g_oContainerMapByCLUID.end() )
              {
              poc = it->second;

              *poSocket << string(1, CContainer::scn_sender)  << ":" << poc->SenderGet() << "\n";
              *poSocket << it->first                          << "\n";

              for ( itc  = poc->begin(); itc != poc->end(); ++itc )
                {
                *poSocket << *itc << "\n";
                } // for ( CContainer::iterator itc  = poc->begin();

              // the next message id (has to be filtered for receiver later)
              if ( ++it != g_oContainerMapByCLUID.end() )
                {
                *poSocket << string(1, CContainer::scn_messageid_next) << ":" << it->first << "\n";
                } // if ( ++it != g_oContainerMapByCLUID.end() )
              } // if ( it != g_oContainerMapByCLUID.end() )
            break; // case 'm': // c:m = call message

          case 's': // c:s = call message by sender
            if ( g_bVerbose) cout << " * recall message '" << itQuery->second << "' by sender\n";
/*
              1) get the sender from the message-id
              2) resend the queried message
              3) resend the next message-id from the same sender (if any)
 */
            string sMsgId = itQuery->second;
            size_t nCut   = sMsgId.find( ":" );
            if ( nCut != string::npos )
              {
              string sSender = sMsgId.substr(0, nCut);
              if ( g_bVerbose) cout << " * from sender '" << sSender << "'\n";

              for ( it = g_oContainerMapByCLUID.find( itQuery->second ); it != g_oContainerMapByCLUID.end(); ++it )
                {
                poc = it->second;
                if ( poc->SenderGet() != sSender ) continue;

                *poSocket << string(1, CContainer::scn_sender)  << ":" << poc->SenderGet() << "\n";
                *poSocket << it->first                          << "\n";

                for ( itc  = poc->begin(); itc != poc->end(); ++itc )
                  {
                  *poSocket << *itc << "\n";
                  } // for ( CContainer::iterator itc  = poc->begin();
                } // for ( it = g_oContainerMapByCLUID.begin(); ...
              } // if ( nCut != string:npos )
            break; // case 's': // c:s = call message by sender

          } // switch ( itQuery->first[2] )
        break; // switch ( itQuery->first[0] ) => case 'c'
      } // switch ( itQuery->first[0] )
    } //   for ( CMapString2String::iterator itQuery  = moQuery.begin();

  return 0;
  } // size_t CPartner::Recall( ... )
Example #19
0
void CContainer::GetLiquidTanksWeightAckResponse(int TransactionId, PVOID Data, unsigned DataLength, TGenericCockie Cockie)
{
    TOCBLiquidTanksWeightResponse *StatusMsg = static_cast<TOCBLiquidTanksWeightResponse *>(Data);

    // Get a pointer to the instance
    CContainer *InstancePtr = reinterpret_cast<CContainer *>(Cockie);

    //Verify size of message
    if(DataLength != sizeof(TOCBLiquidTanksWeightResponse))
    {
        CQLog::Write(LOG_TAG_EOL, "Container \"GetLiquidTanksWeightAckResponse\" length error");
        return;
    }

    if(static_cast<int>(StatusMsg->MessageID) != OCB_LIQUID_TANK_WEIGHT)
    {
        FrontEndInterface->NotificationMessage("Container \"GetLiquidTanksWeightAckResponse\" message id error");
        CQLog::Write(LOG_TAG_EOL, "Container \"GetLiquidTanksWeightAckResponse\" message id error (0x%X)", (int)StatusMsg->MessageID);
        return;
    }
    float Weights[TOTAL_NUMBER_OF_CONTAINERS_INCLUDING_WASTE] =
        INIT_MSG_VALUES_W_ARRAY(StatusMsg, Weight);

    // Updating the Weights of the liquid tanks
    for(int i = FIRST_TANK_INCLUDING_WASTE_TYPE; i < LAST_TANK_INCLUDING_WASTE_TYPE; i++)
        InstancePtr->m_TanksArray[i]->SetTankWeight(Weights[i]);

    // Write the new weights the Log only if one of the 'Printed' weights is different atleast in 40 gr
    bool NeedToWriteWeightsToLog = false;

    for(int i = FIRST_TANK_INCLUDING_WASTE_TYPE; i < TOTAL_NUMBER_OF_CONTAINERS; i++)
    {
        if(InstancePtr->m_TanksArray[i]->IsPrintWeightNecessary())
            NeedToWriteWeightsToLog = true;
    }

    int WeightArray[TOTAL_NUMBER_OF_CONTAINERS_INCLUDING_WASTE];
    QString tmp = "Liquids weight: ";
    for(int i = FIRST_TANK_INCLUDING_WASTE_TYPE; i < LAST_TANK_INCLUDING_WASTE_TYPE; i++)
    {
        WeightArray[i] = InstancePtr->GetTankWeightInGram((TTankIndex)i);
        tmp += TankToStr((TTankIndex)i) + " = " + QFloatToStr(WeightArray[i]) + "; ";
    }
    InstancePtr->UpdateLiquidTankInserted(TYPE_TANK_WASTE, (InstancePtr->m_TanksArray[TYPE_TANK_WASTE]->GetTankWeightInGram(true) > WASTE_IS_EMPTY));
    if(NeedToWriteWeightsToLog)
        CQLog::Write(LOG_TAG_EOL, tmp);

    for(int i = FIRST_TANK_TYPE; i < LAST_TANK_TYPE; i++)
    {
        // Update the front end with the status of the containers
        FrontEndInterface->UpdateStatus(FE_CURRENT_TANK_STATUS_BASE + i,
                                        (int)(WeightArray[i] > (InstancePtr->m_ParamsMgr->WeightLevelLimitArray[TankToStaticChamber((TTankIndex)i)]
                                                + WEIGHT_ERROR_WARNNING_DELTA)));

        WeightArray[i] -= InstancePtr->m_ParamsMgr->WeightLevelLimitArray[TankToStaticChamber((TTankIndex)i)];
        // Update the front end with the current weight
        FrontEndInterface->UpdateStatus(FE_CURRENT_TANK_WEIGHT_BASE + i,
                                        ((WeightArray[i] > 0) && (! InstancePtr->IsTankInOverconsumption((TTankIndex)i))) ? WeightArray[i] : 0);

        // Update the front end with the relative weight
        FrontEndInterface->UpdateStatus(FE_CURRENT_TANK_RELATIVE_WEIGHT_BASE + i,
                                        WeightArray[i] * 100 /
                                        InstancePtr->m_ParamsMgr->CartridgeFullWeight);
    }
    // Update the front end with the status of the containers
    FrontEndInterface->UpdateStatus(FE_CURRENT_TANK_STATUS_WASTE_TANK,
                                    (int)(WeightArray[TYPE_TANK_WASTE] < (InstancePtr->m_ParamsMgr->WeightLevelLimitArray[TYPE_CHAMBER_WASTE]
                                            - WASTE_WEIGHT_ERROR_WARNNING_DELTA)));

    FrontEndInterface->UpdateStatus(FE_TANK_EXISTENCE_STATUS_WASTE_TANK, (int)(InstancePtr->IsActiveLiquidTankInserted((int)TYPE_CHAMBER_WASTE)));

    // Update the front end with the current weight
    FrontEndInterface->UpdateStatus(FE_CURRENT_TANK_WEIGHT_WASTE_TANK, WeightArray[TYPE_TANK_WASTE] > 0 ? WeightArray[TYPE_TANK_WASTE] : 0);

    // Display a service alert in case the waste cartride is full
    if(WeightArray[TYPE_TANK_WASTE] > (InstancePtr->m_ParamsMgr->WeightLevelLimitArray[TYPE_CHAMBER_WASTE] - WASTE_WEIGHT_ERROR_WARNNING_DELTA))
    {
        if(!InstancePtr->m_WasteAlert)
        {
            FrontEndInterface->UpdateStatus(FE_SERVICE_ALERT, WASTE_CARTRIDGE_ALERT_ID, true);
            InstancePtr->m_WasteAlert  = true;
            InstancePtr->m_WasteIsFull = true;
        }
    }
    else
    {
        if(InstancePtr->m_WasteAlert)
        {
            FrontEndInterface->UpdateStatus(FE_CLEAR_SERVICE_ALERT, 0, true);
            InstancePtr->m_WasteAlert  = false;
            InstancePtr->m_WasteIsFull = false;
        }
    }
}//GetLiquidTanksWeightAckResponse
Example #20
0
void CCellView::HandleDrop(BMessage *inMessage)
{
	long l;
	void * p;
	BPoint dp = inMessage->DropPoint();
	
	fDragIsAcceptable = false;
	
	if (inMessage->FindPointer("container", &p) == B_NO_ERROR)
	{
		key_info ki;
		get_key_info(&ki);
		
		CContainer *srcContainer;
		range srcRange, dstRange;
		CCellView *srcView;
		int action;
		
		srcContainer = (CContainer *)p;
		FailOSErr(inMessage->FindData("range", 'rang', (const void**)&p, &l), errMessageMissing);
		srcRange = *(range *)p;
		FailOSErr(inMessage->FindPointer("cellview", &p), errMessageMissing);
		srcView = (CCellView *)p;
		
		if (srcView != this)
			action = dragCopy;
		else
			action = dragMove;
		
		inMessage->FindBool("dragacopy", &fDragACopy);
		
		if (srcView == this &&
		    (ki.modifiers & B_CONTROL_KEY ||
			fDragACopy))
		{
			BPopUpMenu popup("dragpopup", false);
			popup.SetFont(be_plain_font);
			popup.AddItem(new BMenuItem(GetMessage(msgLinkHere), NULL));
			popup.AddItem(new BMenuItem(GetMessage(msgMoveHere), NULL));
			popup.AddItem(new BMenuItem(GetMessage(msgCopyHere), NULL));
			popup.AddSeparatorItem();
			popup.AddItem(new BMenuItem(GetMessage(msgCancel), NULL));
			
			BMenuItem *item = popup.Go(dp, false, true);
			int result = item ? popup.IndexOf(item) : -1;
			switch (result)
			{
				case 0: action = dragLink; break;
				case 1: action = dragMove; break;
				case 2: action = dragCopy; break;
				default:
					ClearAnts();
					fCurCell = fSelection.TopLeft();
					return;
			}
		}
	
		dstRange = srcRange;
		dstRange.OffsetBy(fCurCell.h - dstRange.left,
			fCurCell.v - dstRange.top);
		
		((CCellWindow *)Window())->
			RegisterCommand(new CDragCommand(this, srcContainer,
				fContainer, &srcRange, &dstRange, action));
	}
	else if (inMessage->FindData("text/plain", B_MIME_DATA, (const void **)&p, &l) == B_NO_ERROR)
	{
		cell dc;
		
		ConvertFromScreen(&dp);
		GetCellHitBy(dp, dc);
		
		BMemoryIO buf(p, l);
		CContainer *srcContainer = new CContainer;
		range srcRange, dstRange;
		
		CTextConverter conv(buf, srcContainer);
		conv.ConvertFromText(srcRange);
		
		dstRange = srcRange;
		dstRange.OffsetBy(dc.h - srcRange.left, dc.v - srcRange.top);
		
		((CCellWindow *)Window())->
			RegisterCommand(new CDragCommand(this, srcContainer,
				fContainer, &srcRange, &dstRange, dragMove));

		srcContainer->Release();
	}
	else
	{
		beep();
		ClearAnts();
		fCurCell = fSelection.TopLeft();
	}
} /* CCellView::HandleDrop */