Exemple #1
0
bool JabberChatService::sendRawMessage(const Chat &chat, const QByteArray &rawMessage)
{
	if (!m_client)
		return false;

	auto jid = m_resourceService->bestChatJid(chat);
	if (jid.isEmpty())
		return false;

	auto xmppMessage = QXmppMessage{};

	xmppMessage.setBody(rawMessage);
	xmppMessage.setFrom(m_client.data()->clientPresence().id());
	xmppMessage.setStamp(QDateTime::currentDateTime());
	xmppMessage.setTo(jid.full());
	xmppMessage.setType(chatMessageType(chat, jid.bare()));

	m_client.data()->sendPacket(m_chatStateService->withSentChatState(xmppMessage));

	return true;
}
Exemple #2
0
int VariableCheck(Store store, Indexicals indexicals, Stamp *s, Cola Q)
     /*---------------------------------------------------------------
       DESCRIPCION: Implementacion del algoritmo resolutivo basico.
       PARAMETROS: Q: es una cola de variables
                   store : Es el store del Sistema de Restricciones.
         indexicals: Son los indexicals que representan las
         restricciones impuestas sobre el store.
         s: Marca de tiempo para la evaluacion de los indexicals
       USA:
       RETORNA: El estado de la operacion
       PRE:
       POS: La Ope = FAIL || Ope = SUCCESS.
       NOTAS:
       ---------------------------------------------------------------*/
{
  int tokeny, posIndexical, xkey, monot_f;
  FDVariable fdvariabley;
  Domain x_sigma, r_sigma, I;
  Lista IndexSusy;
  Indexical f;

  while(!vaciaCola(Q))
    {/* Mientra la cola no este vacia */
      tokeny = infoCola(Q);
      fdvariabley = getVariableStore(store, tokeny);
      elimCola(Q); /* Q = Q \ {y} */
      IndexSusy = suspended(store, tokeny); /* Indexicals que dependen de la variable y */

      for ( primLista(IndexSusy); !finLista(IndexSusy); sigLista(IndexSusy))
   {
     posIndexical = infoLista(IndexSusy);
     f = elementAtIndexicals(indexicals, posIndexical);
     if (getEntailed(f)) /* Si f esta marcada como deducido */
         {
      indexicals = removeElementAtIndexicals(indexicals, posIndexical);
      store = desrefVariableDepStore(store, posIndexical);
         }
     else
       {
         if(getStampFDVariable(fdvariabley) >= getStamp(f))
      {
        xkey = getX(f);
        x_sigma = Inicp1Domain(getDomainFDVariable(getVariableStore(store, xkey)));
        r_sigma = r_Sigma(store,f);
        I = Inicp1Domain(x_sigma);
        intersectionDomain(I, r_sigma);
        setStamp(f, *s);
        indexicals = setElementAtIndexicals(indexicals, f, posIndexical);
        monot_f = Monotonicity(getCodef(f),store);
        if (!isConsistentDomain(I))
          {/* <Vacio> */
            if (monot_f == MONOTONE|| monot_f == CONSTANT)
         {
           freeDomain(x_sigma);
           freeDomain(r_sigma);
           freeDomain(I);
           freeIndexical(f);
           destruirLista(IndexSusy);
           return FAIL;
         }
          }
        else if (equalsDomain(I, x_sigma)) /* x_sigma */
          {
            if (monot_f == ANTIMONOTONE)
         {
           setEntailed(f,TRUE);
           indexicals = removeElementAtIndexicals(indexicals, posIndexical);
           store = desrefVariableDepStore(store, posIndexical);  
         }
           
          }
        else
          {/* otherwise */
            if (monot_f == MONOTONE || monot_f == CONSTANT)
         {
           (*s)++;
           store = updateVarStampStore(store, xkey,*s);
           if (!updateVarDomStore(store, xkey,I))
             {
               freeDomain(x_sigma);
               freeDomain(r_sigma);
               freeDomain(I);
               freeIndexical(f);
               destruirLista(IndexSusy);
               return FAIL;
             }
           if (!existeElementoCola(Q,xkey))
             {
               adicCola(Q,xkey);
             }
           if (monot_f == CONSTANT)
             {
               setEntailed(f, TRUE);
               indexicals = removeElementAtIndexicals(indexicals, posIndexical);
               store = desrefVariableDepStore(store, posIndexical); 
             }
         }
          }
        freeDomain(x_sigma);
        freeDomain(r_sigma);
        freeDomain(I);
      }
       }
     freeIndexical(f);
   }
      destruirLista(IndexSusy);
    }
  return SUCCESS;
}