Example #1
0
int QueueWindow::PushQueueItem(QueueOperation * op) {
	QueueOperation::QueueType type = op->GetType();
	if (!ValidType(type))
		return -1;

	LVITEM lvi;
	lvi.mask = LVIF_TEXT | LVIF_PARAM;
	lvi.iItem = GetNrItems();
	lvi.iSubItem = 0;
	lvi.lParam = (LPARAM)op;
	lvi.pszText = (TCHAR*)(type==QueueOperation::QueueTypeDownload||type==QueueOperation::QueueTypeDownloadHandle?TEXT("Download"):TEXT("Upload"));

	int index = ListView_InsertItem(m_hwnd,  &lvi);
	if (index == -1)
		return -1;

	ListView_SetItemText(m_hwnd, index, 1, TEXT("0.0%") );

	TCHAR * path = NULL;
	if (type == QueueOperation::QueueTypeDownload) {
		QueueDownload * qdld = (QueueDownload*)op;
		path = SU::Utf8ToTChar(qdld->GetExternalPath());
	} else if (type == QueueOperation::QueueTypeDownloadHandle) {
		QueueDownloadHandle * qdld = (QueueDownloadHandle*)op;
		path = SU::Utf8ToTChar(qdld->GetExternalPath());
	} else if (type == QueueOperation::QueueTypeUpload) {
		QueueUpload * quld = (QueueUpload*)op;
		path = SU::Utf8ToTChar(quld->GetExternalPath());
	}

	ListView_SetItemText(m_hwnd, index, 2, path );
	SU::FreeTChar(path);

	return 0;
}
Example #2
0
int QueueWindow::PopQueueItem(QueueOperation * op) {
	if (!ValidType(op->GetType()))
		return -1;

	int index = GetNrItems()-1;
	if (index == -1)
		return -1;

	LVITEM lvi;
	lvi.iItem = 0;
	lvi.iSubItem = 0;
	lvi.mask = LVIF_PARAM;
	BOOL res = ListView_GetItem(m_hwnd, &lvi);
	if (res == FALSE)
		return -1;

	if ((QueueOperation*)lvi.lParam != op)
		return -1;

	res = ListView_DeleteItem(m_hwnd,index);
	if (res == FALSE)
		return -1;

	return 0;
}
Example #3
0
/***
	Seta o tipo da copia. Pode ser:
		cl - Copia cliente
		sr - Copia de servidor
		mn - Copia monousuario
		rt - Copia Runtime
		rd - Servidor preparado para modo rede
	Importante:
		O tipo deve ser com letras minĂºsculas
	Retorna:
		PE_OK ou
		PE_ERROR
***/
int
SetType( char *szFileName, char *szType )
{
	FILE	*fp;

	if( !ValidType( szType ) ){
		// O tipo passado inexiste
		return( PE_ERROR );
	}
	/* procura a estrutura str_pers
	 */
	if( (fp = localiza( szFileName, str_pers )) == NULL ) {
		return( PE_ERROR );
	}
	if( fseek( fp, lPosicao, 0 ) == -1 ) {
		fclose( fp );
		return( PE_ERROR );
	}
	// Nao decriptografo pois a informacao do tipo nao esta em
	// area criptografada.
	strcpy( TIPO( str_pers ), szType );
	if( fwrite( (char *) str_pers, sizeof str_pers, 1, fp ) != 1 ) {
		fclose( fp );
		return( PE_ERROR );
	}
	fclose( fp );
	return( PE_OK );
}
Example #4
0
int QueueWindow::GetItemIndex(QueueOperation * op) {
	if (!ValidType(op->GetType()))
		return -1;

	int index = -1;
	int nritems = GetNrItems();

	LVITEM lvi;
	lvi.iItem = -1;
	lvi.iSubItem = 0;
	lvi.mask = LVIF_PARAM;
	lvi.lParam = 0;

	while((QueueOperation*)lvi.lParam != op && lvi.iItem < nritems) {
		lvi.iItem++;
		index++;
		BOOL res = ListView_GetItem(m_hwnd, &lvi);
		if (res == FALSE)
			return -1;
	}

	if (lvi.iItem == nritems)
		return -1;

	return index;
}
Example #5
0
bool mrShaderFilter::ValidateReturnType(ParamBlockDesc2& pbDesc) {

	// Go through all the parameters of the block
	int count = pbDesc.Count();
	for(int i = 0; i < count; ++i) {
		const ParamDef& paramDef = pbDesc.GetParamDef(pbDesc.IndextoID(i));
		
		if(ValidType(paramDef.type))
			return true;
	}

	return false;
}
Example #6
0
int QueueWindow::RemoveQueueItem(QueueOperation * op) {
	if (!ValidType(op->GetType()))
		return -1;

	int index = GetItemIndex(op);
	if (index == -1)
		return -1;

	BOOL res = ListView_DeleteItem(m_hwnd,index);
	if (res == FALSE)
		return -1;

	return -1;
}
Example #7
0
bool mrShaderFilter::ValidateReturnType(ClassDesc& classDesc) {


	SClass_ID superClassID = classDesc.SuperClassID();

	if(superClassID == MATERIAL_CLASS_ID) {

		// Validate if we want a TYPE_MTL return type
		//return ValidType(TYPE_MTL);
		
		// Do not validate types for materials. Only use the apply type for validatoin.
		return true;
	}
	else if(superClassID == TEXMAP_CLASS_ID) {

		imrShaderClassDesc* shaderClassDesc = Get_mrShaderClassDesc(&classDesc);

		if(shaderClassDesc == NULL) {
			// Assume that the texture returns a color
			return ValidType(static_cast<ParamType2>(TYPE_RGBA));
		}
		else {

			// Go through the results structure
			ParamBlockDesc2* pbDesc = shaderClassDesc->GetResultPBDesc();
			if((pbDesc != NULL) && ValidateReturnType(*pbDesc)) {
				return true;
			}

			// Go through the sub-structures, is allowed
			if(m_acceptStructs) {
				Tab<ParamBlockDesc2*>& resultDescs = shaderClassDesc->GetResultPBDescs();
				int count = resultDescs.Count();
				for(int i = 0; i < count; ++i) {
					ParamBlockDesc2* pbDesc = resultDescs[i];
					if((pbDesc != NULL) && ValidateReturnType(*pbDesc)) {
						return true;
					}
				}
			}			

			return false;
		}
	}
	else {
		// Shouldn't occur
		DbgAssert(false);
		return false;
	}
}
Example #8
0
FieldSpec *
NewFieldSpec(int    type,	/* numeric code for data type */
	     int    rank)	/* number of dimensions */
{
    FieldSpec	*field;		/* new FieldSpec structure */

    /* Check for bad arguments. */

    if (!ValidType(type) || rank < 0)
	return NULL;

    /* Allocate new struct. */

    field = (FieldSpec *) malloc(sizeof(*field));
    if (field == NULL)
	return NULL;

    /* Fill in default values for members. */

    field->type = type;
    field->rank = rank;

    if (type == NO_TYPE || rank == 0)
	field->dim = NULL;
    else
    {
	/* Allocate dimension vector according to rank. */

	field->dim = (long *) malloc(rank * sizeof(long));
	if (field->dim == NULL)
	{
	    free(field);
	    return NULL;
	}
    }

    field->occurrence = REQUIRED;
    field->name = NULL;
    field->subfields = NULL;
    field->units = NULL;
    field->scale = 1.0;
    field->offset = 0.0;
    field->axis_names = NULL;
    field->data = NULL;
    field->present = TRUE;
    field->fullname = NULL;

    return field;
}
/*--------------------------------------------------------------------------------*/
void TinyXMLADMData::CollectObjects(const TiXmlNode *node)
{
  const TiXmlNode *subnode; 

  for (subnode = node->FirstChild(); subnode; subnode = subnode->NextSibling())
  {
    if (subnode->Type() == TiXmlNode::TINYXML_ELEMENT)
    {
      if (ValidType(subnode->Value()))
      {
        if (Parse(subnode->Value(), (void *)subnode))
        {
          CollectObjects(subnode);
        }
      }
    }
  }
}
Example #10
0
int QueueWindow::ProgressQueueItem(QueueOperation * op) {
	if (!ValidType(op->GetType()))
		return -1;

	int index = GetItemIndex(op);
	if (index == -1)
		return -1;

	if (index != 0) {
		return -1;
	}

	TCHAR buffer[10];
	float progress = op->GetProgress();
	if (progress > 100.0f || progress < 0.0f) {
		lstrcpy(buffer, TEXT("??"));
	} else {
		SU::TSprintf(buffer, 10, TEXT("%.1f%%"), progress);
	}

	ListView_SetItemText(m_hwnd, index, 1, buffer );

	return 0;
}