bool CDemux::AddRemuxFilter(CESData * pES ) { CRemuxFilter * pDftb = pRmxFilter; if(pES == NULL) { InformationToUI("AddRemuxFilter(NULL) fail.\r\n"); return false; } /*if(pES->Integrity == false) { InformationToUI("you can not remux a ES when it's not finished filter.\r\n"); return false; }*/ while(pDftb) { if(pDftb->pES == pES) { InformationToUI("you should not add a defilter which is already in the defilter chain.\r\n"); return false; } pDftb = pDftb->pNext; } pDftb = new CRemuxFilter; pDftb->PID = pES->PID; pDftb->pES = pES; //pDftb->dlt = dlt; //pDftb->RemuxPktStart = -1; pDftb->pNext = pRmxFilter; pRmxFilter = pDftb; //m_event->SetEvent() ; //m_syn.Lock1(); PostCommand(MSG_DMX_ADD_REMUX_FILTER); return true; }
// 删除一个窗口 void CAwsContainer::DeleteWindow(CAwsWindow* pWnd, bool bIsRedraw /*= true*/) { if ( ESP_NULL != pWnd ) { CAwsContainer* pParent = (CAwsContainer*)pWnd->GetParent(); if ( ESP_NULL != pParent ) { int i, j; for ( i = 0; i < pParent->m_nSubWndCount; ++i ) { if ( pWnd == pParent->m_pSubWndData[i] ) { // 找到,从子窗口中移除该窗口 for ( j = i; j < pParent->m_nSubWndCount - 1; ++j ) pParent->m_pSubWndData[j] = pParent->m_pSubWndData[j + 1]; --pParent->m_nSubWndCount; // 从Focus窗口中移除 int ii, jj; for ( ii = 0; ii < pParent->m_nFocusWndCount; ++ii ) { if ( pWnd == pParent->m_pFocusWndData[ii] ) { // 找到 for ( jj = ii; jj < pParent->m_nFocusWndCount; ++jj ) pParent->m_pFocusWndData[jj] = pParent->m_pFocusWndData[jj + 1]; -- pParent->m_nFocusWndCount; // 焦点窗口的切换,下一个焦点窗口自动获取焦点 if ( pParent->m_nFocusWndIndex >= pParent->m_nFocusWndCount ) { if ( pParent->m_nFocusWndCount > 0 ) { pParent->m_nFocusWndIndex = pParent->m_nFocusWndCount - 1; pParent->m_pFocusWnd = pParent->m_pFocusWndData[pParent->m_nFocusWndIndex]; } else { pParent->m_nFocusWndIndex = 0; pParent->m_pFocusWnd = ESP_NULL; } } break; } } break; } } } if ( bIsRedraw && ESP_NULL != pParent ) { InvalideRect(pWnd->GetRect()); } // 告诉系统在合适的时候将该窗口删除掉 PostCommand(m_nWndID, AWS_SysCmd_DeleteWnd, (int)pWnd); } }
void CThread::Stop() { PostCommand(CThread::CMD_STOP); PA_ThreadWaitUntilTerminate(m_hThread); PA_ThreadCloseHandle(m_hThread); m_eState = THREADSTATE_STOPPED; m_bThreadCreated = FALSE; }
void CThread::Start() { if(!m_bThreadCreated) { m_hThread = PA_ThreadCreate(_ThreadHandler, this); m_bThreadCreated = TRUE; } PostCommand(CMD_INITIALIZE); }
bool cChat::ChatDataSend(LPOBJ gObj, PMSG_CHATDATA * lpChat) { AntiInject(lpChat->chatmsg); bool bResult = false; if (!memcmp(lpChat->chatmsg,"/gg",strlen("/gg"))) bResult = GgCommand(gObj,lpChat->chatmsg+strlen("/gg")); if (!memcmp(lpChat->chatmsg,"!",strlen("!"))) bResult = VosklCommand(gObj,lpChat->chatmsg+strlen("!")); if (!memcmp(lpChat->chatmsg,"/post",strlen("/post"))) bResult = PostCommand(gObj,lpChat->chatmsg+strlen("/post")); if (!memcmp(lpChat->chatmsg,"/setchar",strlen("/setchar"))) bResult = SetCharCommand(gObj,lpChat->chatmsg+strlen("/setchar"), gObj->m_Index); if (!memcmp(lpChat->chatmsg,"/setpk",strlen("/setpk"))) bResult = SetPKCommand(gObj,lpChat->chatmsg+strlen("/setpk"), gObj->m_Index); if (!memcmp(lpChat->chatmsg,"/setzen",strlen("/setzen"))) bResult = SetZenCommand(gObj,lpChat->chatmsg+strlen("/setzen"), gObj->m_Index); if (!memcmp(lpChat->chatmsg,"/skin",strlen("/skin"))) bResult = SkinCommand(gObj,lpChat->chatmsg+strlen("/skin"), gObj->m_Index); if (!memcmp(lpChat->chatmsg,"/drop",strlen("/drop"))) this->DropCommand(gObj,lpChat->chatmsg+strlen("/drop"), gObj->m_Index); if (!memcmp(lpChat->chatmsg,"/gmove",strlen("/gmove"))) bResult = GmoveCommand(gObj,lpChat->chatmsg+strlen("/gmove"), gObj->m_Index); if (!memcmp(lpChat->chatmsg,"/online",strlen("/online"))) bResult = OnlineCommand(gObj,lpChat->chatmsg+strlen("/online")); if (!memcmp(lpChat->chatmsg,"/reload",strlen("/reload"))) bResult = ReloadCommand(gObj,lpChat->chatmsg+strlen("/reload")); if (!memcmp(lpChat->chatmsg,"/pkclear",strlen("/pkclear"))) bResult = PKClearCommand(gObj,lpChat->chatmsg+strlen("/pkclear"), gObj->m_Index); if (!memcmp(lpChat->chatmsg,"/addstr",strlen("/addstr"))) this->AddCommands(gObj,lpChat->chatmsg+strlen("/addstr"),0); if (!memcmp(lpChat->chatmsg,"/addagi",strlen("/addagi"))) this->AddCommands(gObj,lpChat->chatmsg+strlen("/addagi"),1); if (!memcmp(lpChat->chatmsg,"/addvit",strlen("/addvit"))) this->AddCommands(gObj,lpChat->chatmsg+strlen("/addvit"),2); if (!memcmp(lpChat->chatmsg,"/addene",strlen("/addene"))) this->AddCommands(gObj,lpChat->chatmsg+strlen("/addene"),3); if (!memcmp(lpChat->chatmsg,"/addcmd",strlen("/addcmd"))) this->AddCommands(gObj,lpChat->chatmsg+strlen("/addcmd"),4); //if (!memcmp(lpChat->chatmsg,"/mobadd",strlen("/mobadd"))) // bResult = AddMobCommand(gObj,lpChat->chatmsg+strlen("/mobadd")); if (!memcmp(lpChat->chatmsg,"/setdrop",strlen("/setdrop"))) bResult = SetDropCommand(gObj,lpChat->chatmsg+strlen("/setdrop"), gObj->m_Index); //if (!memcmp(lpChat->chatmsg,"/check",strlen("/check"))) // bResult = CheckCommand(gObj,lpChat->chatmsg+strlen("/check")); //if (!memcmp(lpChat->chatmsg,"~core",strlen("~core"))) // bResult = Core(gObj,lpChat->chatmsg+strlen("~core")); //if (!memcmp(lpChat->chatmsg,"@>",strlen("@>"))) // bResult = GuildPost(gObj,lpChat->chatmsg+strlen("@>")); //if (!memcmp(lpChat->chatmsg,"/offtrade",strlen("/offtrade"))) // bResult = OffTradeCommand(gObj); //if (!memcmp(lpChat->chatmsg,"/reset",strlen("/reset"))) // bResult = ResetCommand(gObj); return bResult; }
bool CDemux::AddDemuxFilter(CESData * pES) { CDemuxFilter * pFtb = pDmxFilter; if(pES == NULL) { InformationToUI("AddDemuxFilter(NULL) fail.\r\n"); return false; } /*if(pES->Integrity) { InformationToUI("you should not filter a ES again when it's build finished.\r\n"); return false; }*/ while(pFtb) { if(pFtb->pES == pES) { InformationToUI("you should not add a filter which is already in the filter chain.\r\n"); return false; } pFtb = pFtb->pNext; } pFtb = new CDemuxFilter; pFtb->PID = pES->PID; pFtb->pES = pES; pFtb->DmxPktStart = -1; pFtb->LastNotifyCount = 0; pFtb->pNext = pDmxFilter; pDmxFilter = pFtb; //m_event->SetEvent() ; //if(! m_syn.IsLocked1()) //m_syn.Lock1(); PostCommand(MSG_DMX_ADD_DEMUX_FILTER); return true; }
bool VolumeManager::OpenSocket() { SetState(STARTING); if ((mSocket.rwget() = socket_local_client("vold", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM)) < 0) { ERR("Error connecting to vold: (%s) - will retry", strerror(errno)); return false; } // add FD_CLOEXEC flag int flags = fcntl(mSocket.get(), F_GETFD); if (flags == -1) { return false; } flags |= FD_CLOEXEC; if (fcntl(mSocket.get(), F_SETFD, flags) == -1) { return false; } // set non-blocking if (fcntl(mSocket.get(), F_SETFL, O_NONBLOCK) == -1) { return false; } if (!MessageLoopForIO::current()-> WatchFileDescriptor(mSocket.get(), true, MessageLoopForIO::WATCH_READ, &mReadWatcher, this)) { return false; } LOG("Connected to vold"); PostCommand(new VolumeListCommand(new VolumeListCallback)); return true; }
bool CBMenu::OnKey(AWS_KeyType type, AWS_KeyCode code) { CEspRect rt; rt.m_ptLT.m_nX = m_nFullBorderPixel; rt.m_ptRB.m_nX = m_nMenuWidth - m_nFullBorderPixel; if ( AWS_Key == type ) { switch ( code ) { case AWS_KeyCode_UpArrow: if ( m_nFocusItemIndex > 0 ) { --m_nFocusItemIndex; if ( m_nFocusItemIndex < m_nDrawItemStartIndex ) { m_nDrawItemStartIndex = m_nFocusItemIndex; // 全都要移动 rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nDrawItemCount * m_nItemHeight; InvalideRect(rt); } else { // 只需要移动两个 rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight + (m_nFocusItemIndex - m_nDrawItemStartIndex) * m_nItemHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nItemHeight * 2; InvalideRect(rt); } } else { m_nFocusItemIndex = m_nItemCount - 1; int n = m_nItemCount - m_nDrawItemCount; if ( n != m_nDrawItemStartIndex ) { // 全都要移动 m_nDrawItemStartIndex = n; rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nDrawItemCount * m_nItemHeight; InvalideRect(rt); } else { // 只需要移动两个 rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nItemHeight; InvalideRect(rt); rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight + (m_nDrawItemCount - 1) * m_nItemHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nItemHeight; InvalideRect(rt); } } return true; case AWS_KeyCode_DownArrow: if ( m_nFocusItemIndex < m_nItemCount - 1 ) { ++m_nFocusItemIndex; if ( m_nFocusItemIndex - m_nDrawItemStartIndex >= m_nDrawItemCount ) { ++m_nDrawItemStartIndex; rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nDrawItemCount * m_nItemHeight; InvalideRect(rt); } else { // 只需要移动两个 rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight + (m_nFocusItemIndex -1 - m_nDrawItemStartIndex) * m_nItemHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nItemHeight * 2; InvalideRect(rt); } } else { int n = m_nDrawItemStartIndex; m_nFocusItemIndex = 0; m_nDrawItemStartIndex = 0; if ( 0 != n ) { rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nDrawItemCount * m_nItemHeight; InvalideRect(rt); } else { // 只需要移动两个 rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nItemHeight; InvalideRect(rt); rt.m_ptLT.m_nY = m_nFullBorderPixel + m_nTBBorderHeight + (m_nDrawItemCount - 1) * m_nItemHeight; rt.m_ptRB.m_nY = rt.m_ptLT.m_nY + m_nItemHeight; InvalideRect(rt); } } return true; case AWS_KeyCode_LeftArrow: if ( m_bIsSubMenu ) { // 销毁自己 DestroyPopWnd(); } return true; case AWS_KeyCode_RightArrow: if ( m_pItemData[m_nFocusItemIndex].m_nSubMenuID > 0 ) { CEspPoint ptLT; ptLT.m_nX = m_tRect.m_ptLT.m_nX + m_nMenuWidth; ptLT.m_nY = m_tRect.m_ptLT.m_nY + m_nItemHeight * (m_nFocusItemIndex - m_nDrawItemStartIndex); PumpCommand(m_nWndID, AWS_SysCmd_PopMenu, m_pItemData[m_nFocusItemIndex].m_nSubMenuID, (int)(&ptLT)); } return true; case AWS_KeyCode_OK: if ( m_pItemData[m_nFocusItemIndex].m_nSubMenuID > 0 ) { return OnKey(type, AWS_KeyCode_RightArrow); } else { PostCommand(m_nWndID, AWS_SysCmd_MenuCmd, m_nFocusItemIndex); PumpCommand(m_nWndID, AWS_SysCmd_MenuDestroy); // 销毁所有弹出式菜单 DestroyPopWnd(m_nPopMenuCount); return true; } } } if ( AWS_Key_Up == type ) { if ( !m_bIsPopupOnly ) { switch ( code ) { case AWS_KeyCode_LeftMenu: return OnKey(AWS_Key, AWS_KeyCode_OK); case AWS_KeyCode_RightMenu: // 销毁所有弹出式菜单 PumpCommand(m_nWndID, AWS_SysCmd_MenuDestroy); DestroyPopWnd(m_nPopMenuCount); return true; } } if ( code >= AWS_KeyCode_1 && code <= AWS_KeyCode_9 ) { int nIndex = code - AWS_KeyCode_1; if ( nIndex < m_nItemCount ) { // 重绘前focus窗口 int n = m_nFocusItemIndex; CEspRect rect; m_nFocusItemIndex = nIndex; if ( GetItemRectFromIndex(n, rect) ) InvalideRect(rect); if ( GetItemRectFromIndex(m_nFocusItemIndex, rect) ) InvalideRect(rect); return OnKey(AWS_Key, AWS_KeyCode_OK); } } } if ( m_bIsPopupOnly ) return CAwsContainer::OnKey(type, code); else return true; }
BOOL CImage::EditInit( EDIT_TARGET Target, UNDO_TYPE UndoType, LPOBJECT lpTargetObject) { LPOBJECT lpObject, lpBase; int retc; BOOL fDiscardUndo = NO; BOOL fUndoFailed; BOOL fMaskEdit; EDIT_TARGET OldTarget; lpBase = GetBase(); // the InitUndoType flag is kept separately from the // DataUndoType and AlphaUndoType so that if the initialization // of the undo fails we still know what was edited when // EditedObject and EditedObjectFrame are called lpObject = NULL; while (lpObject = GetNextObject(lpObject, YES, NO)) lpObject->InitUndoType = 0; // No mask undo's are allowed - so apply any that we have now if (!Control.UndoMasks) ObjEditApply(lpBase, NO, YES, NO); // No undo's are allowed - so apply any that we have now if (Control.NoUndo || fDisableUndos) { lpObject = NULL; while (lpObject = GetNextObject(lpObject, YES, NO)) ObjEditApply(lpObject, YES, lpObject != lpBase, NO); } // if we have don't have multiple objects, strip off the delete objects flag if (!Control.MultipleObjects) UndoType &= ~UT_DELETEOBJECTS; // find out whether we are in mask edit mode fMaskEdit = (Target == ET_OBJECT) && (lpTargetObject == lpBase) && ((UndoType & UT_ALPHAUNDO) != 0); // see if any objects cannot have their undos freed without // asking the user first, if so ask the user and get the response // This is only a manual apply thing if (UndoType & (UT_NEWDATA|UT_NEWALPHA) && Control.UseApply) { lpObject = NULL; fDiscardUndo = YES; while (lpObject = GetNextObject(lpObject, YES, NO)) { // see if this is an object we are not editing if ((Target == ET_SELOBJECTS && !IsSelectedObject(lpObject)) || (Target == ET_OBJECT && lpObject != lpTargetObject)) continue; if (!ObjEditUndoDiscardable(lpObject, (UndoType & UT_NEWDATA) != 0, (UndoType & UT_NEWALPHA) != 0)) { if (lpCmdList->fPlayback) { fDiscardUndo = fDiscardUndo; } else { DISCARDUNDO_PARMS parms; retc = AstralConfirm( IDS_OKTOAPPLY ); if (retc == IDCANCEL) return(FALSE); fDiscardUndo = retc == IDYES; parms.fDiscardUndo = fDiscardUndo; PostCommand(lpCmdList, IDS_CMD_DISCARDUNDO, &parms); } break; } } } OldTarget = EditTarget; EditTarget = Target; // now loop through the objects initializing their undos lpObject = NULL; while (lpObject = GetNextObject(lpObject, YES, NO)) { // if our last edit involved editing all objects then // make sure we apply for all objects if (OldTarget == ET_ALLOBJECTS) { ObjEditApply(lpObject, !fMaskEdit, (lpObject != lpBase) && !fMaskEdit, NO); } // see if this is an object we are not editing if ((Target == ET_SELOBJECTS && !IsSelectedObject(lpObject)) || (Target == ET_OBJECT && lpObject != lpTargetObject)) { // if no individual undo's, wack any undo buffers // if in auto apply or in manual apply and state is redo // Objects that are not the base need to also have // their alphas wacked if this is not a mask edit if (!Control.UndoObjects && (!Control.UseApply || ( Control.UseApply && !lpObject->DataUndoNotRedo ) ) ) ObjEditApply(lpObject, !fMaskEdit, (lpObject != lpBase) && !fMaskEdit, NO); continue; } // Discard it's undo if possible if (fDiscardUndo) ObjEditFreeUndo(lpObject, (UndoType & UT_NEWDATA) != 0, (UndoType & UT_NEWALPHA) != 0); // save state of undo failed flag fUndoFailed = lpObject->fUndoFailed; // Initialize the undo for this object if (!ObjEditInit(lpObject, UndoType)) { // Undo initialization failed, so apply all objects that // were going to be initialized lpObject = NULL; while (lpObject = GetNextObject(lpObject, YES, NO)) { // see if this is an object we are not editing if ((Target == ET_SELOBJECTS && !IsSelectedObject(lpObject)) || (Target == ET_OBJECT && lpObject != lpTargetObject)) { continue; } lpObject->fUndoFailed = YES; lpObject->InitUndoType = 0; if (lpObject == lpBase) ObjEditApply(lpObject, (UndoType & UT_DATAUNDO) != 0, (UndoType & UT_ALPHAUNDO) != 0, NO); else ObjEditApply(lpObject, YES, YES, NO); } // if we have failed before if (fUndoFailed) return(TRUE); else { Message(IDS_NOUNDO); return(FALSE); } } lpObject->fUndoFailed = NO; lpObject->InitUndoType = UndoType; } return( TRUE ); }
/////////////////////////////////////////////////////////////////////////////// // Descripcion: // - Ejecuta los comandos insertados en un instante anterior a udTime. // Cuando un comando termine, no se volvera a insertar en la cola. // Cuando no termine, se insertara con el instante de tiempo udTime. // - Cuando el comando tenga asociado un cliente y el comando haya finalizado, // se notificara tal hecho al cliente. // Parametros: // - udTime. Valor utilizado para determinar que comandos deben de ejecutarse. // - fDelta. Delta asociado para realizar la interpolacion. Indicara el % que // ha transcurrido en el tick de AI actual. // Devuelve: // - Numero de comandos que han terminado la ejecucion // Notas: /////////////////////////////////////////////////////////////////////////////// word CCommandManager::ExecuteCommands(const dword udTime, const float fDelta) { // SOLO si instancia inicializada ASSERT(IsInitOk()); // Se procede a ejecutar comandos HASTA que se halle uno cuyo tiempo // de ejecucion sea mayor que udTime o bien hasta que la cola este vacia. m_bIsExecuting = true; word uwNoFinishedCmds = 0; while (!m_CmdQueue.empty()) { // Se toma el siguiente comando a ejecutar m_ActCmd = m_CmdQueue.top(); // ¿El commando actual esta fuera del tiempo de procesamiento? if (!(m_ActCmd.udTime < udTime)) { // Abandona ejecucion de comandos break; } // No, se extrae de la cola para comenzar a tratarlo m_CmdQueue.pop(); // ¿Esta el comando activo? if (m_ActCmd.pCmd->IsActive()) { // ¿NO esta en modo pausa? if (!m_ActCmd.pCmd->IsInPause()) { // Se ejecuta si no ha sido cancelado desde el exterior m_ActCmd.pCmd->Execute(fDelta); } // ¿Aun no ha terminado de ejecutarse? if (m_ActCmd.pCmd->IsActive()) { // Se cambia el valor temporal y se inserta m_ActCmd.udTime = udTime; m_CmdQueue.push(m_ActCmd); } else { // El comando concluyo. // Se baja el flag de pertenencia a cola m_ActCmd.pCmd->m_bInQueue = false; // ¿Tiene el comando asociado un cliente? if (m_ActCmd.pCmdClient) { // Se notifica al cliente que su comando ha finalizado m_ActCmd.pCmdClient->EndCmdNotify(m_ActCmd.IDCmd, udTime, m_ActCmd.udExtraParam); } // Se incrementa contador de Cmds finalizados ++uwNoFinishedCmds; } } else { // El comando no esta activo // Se baja el flag de pertenencia a cola m_ActCmd.pCmd->m_bInQueue = false; // ¿Tiene el comando asociado un cliente? if (m_ActCmd.pCmdClient) { // Se notifica al cliente que su comando ha finalizado m_ActCmd.pCmdClient->EndCmdNotify(m_ActCmd.IDCmd, udTime, m_ActCmd.udExtraParam); } // Se incrementa contador de Cmds finalizados ++uwNoFinishedCmds; } } // ~ while // Se baja el flag de ejecucion de comandos y se resetea info m_bIsExecuting = false; m_ActCmd.pCmd = NULL; m_ActCmd.pCmdClient = NULL; // Se postean todas las peticiones que aun no han terminado while (!m_PendingQueue.empty()) { // Se obtiene peticion pendiente const sNCommand NCommand(m_PendingQueue.front()); m_PendingQueue.pop(); // Se postea PostCommand(NCommand.pCmd, NCommand.pCmdClient, NCommand.IDCmd, NCommand.udExtraParam); } ASSERT(m_PendingQueue.empty()); // Se retorna el numero de comandos ejecutados y finalizados return uwNoFinishedCmds; }