// ---------------------------------------------------------
// RFavouritesSrvTable::WriteItemDataL
// ---------------------------------------------------------
//
void RFavouritesSrvTable::WriteItemDataL( const CFavouritesItemImpl& aItem )
{
    // Fill standard attributes.
    __ASSERT_DEBUG( !ReadOnly(), FavouritesPanic( EFavouritesInternal ) );
    // Uid is *NOT* set. We update the current row.
    SetParentFolderL( aItem.ParentFolder() );
    SetTypeL( aItem.Type() );
    SetNameL( aItem.Name() );
    SetUrlL( aItem.Url() );
    SetUsernameL( aItem.UserName() );
    SetPasswordL( aItem.Password() );
    SetWapApL( aItem.WapAp() );
    // Note: read-only flag is *NOT* set. Setting that is accessible via
    // SetReadOnlyL.
    // Note: factory item flag is *NOT* set. Setting that is accessible via
    // SetFactoryItemL.
    SetContextIdL( aItem.ContextId() );
    // Note: last modification time is *NOT* set; PutL will do it.
    // Manual setting (override) is accessible via SetModifiedL.
    SetHiddenL( aItem.IsHidden() );
}
Beispiel #2
0
int Lidar::GetDistance()
{
	while(Write(0, 0x04))
	{
		Wait(.002);
	}
	uint8_t distanceAddress=0x8f;
	uint16_t distance;
	uint8_t distArr[2];
	Wait(.02);
	bool failure=false;
	while(!failure){
		if(!WriteBulk(&distanceAddress,1))
		{
			Wait(0.002);
			failure=!ReadOnly(2, (uint8_t*)distArr);
			distance = (distArr[0] * 256) + distArr[1];
		}
		Wait(.002);
	}
	return((int) distance);
}
// ---------------------------------------------------------
// RFavouritesSrvTable::ReadItemDataL
// ---------------------------------------------------------
//
void RFavouritesSrvTable::ReadItemDataL( CFavouritesItemImpl& aItem ) const
{
    // Fill standard attributes.
    aItem.SetUid( Uid() );
    // No bookmark can exist with the Null Uid.
    __ASSERT_DEBUG( aItem.Uid() != KFavouritesNullUid,
                    FavouritesPanic( EFavouritesNullUidInDatabase ) );
    aItem.SetParentFolder( ParentFolder() );
    aItem.SetType( Type() );
    aItem.SetNameL( Name() );
    HBufC* url = UrlLC();
    aItem.SetUrlL( *url );
    CleanupStack::PopAndDestroy();  // url
    aItem.SetUserNameL( Username() );
    aItem.SetPasswordL( Password() );
    aItem.SetWapAp( WapAp() );
    aItem.SetFactoryItem( FactoryItem() );
    aItem.SetReadOnly( ReadOnly() );
    aItem.SetContextId( ContextId() );
    aItem.SetModified( Modified() );
    aItem.SetHidden( Hidden() );
}
Beispiel #4
0
static int TDBread(tdb_t tdb) {
    rewind(tdb->file);
    if (ReadOnly(tdb->file)) {
        tdb->gzfile = GZdopen(dup(fileno(tdb->file)), "r");
        ParseFile(tdb->gzfile, tdb, 1000000);
        GZclose(tdb->gzfile);
        tdb->gzfile = NULL;
        }
    else {
         int i;
         tdb->gzfile = GZdopen(dup(fileno(tdb->file)),"r");
         ParseFile(tdb->gzfile, tdb, 1000000);
         GZclose(tdb->gzfile);
         tdb->gzfile = GZdopen(dup(fileno(tdb->file)), "w");
         for (i=0;i<tdb->count;i++) {
            int new;
            TDBput(tdb, TDBget(tdb, i), &new);
            }
         }
    fclose(tdb->file);
    tdb->file =  NULL;
    return 0; 
    }      
Beispiel #5
0
bool MPEG_File::strip(int tags, bool freeMemory)
{
	if( ReadOnly() )
	{
		wxLogDebug(wxT("MPEG::File::strip() - Cannot strip tags from a read only file."));
		return false;
	}

	if((tags & MPEG_ID3v2) && m_hasId3v2)
	{
		if( !RemoveBlock(m_id3v2Location, m_id3v2OriginalSize) )
			return false;
		m_id3v2Location = -1;
		m_id3v2OriginalSize = 0;
		m_hasId3v2 = false;
		if(freeMemory)
		{
			delete m_id3v2Tag;
			m_id3v2Tag = NULL;
			m_combinedTag->setID3v2Tag(NULL);
		}

		// v1 tag location has changed, update if it exists
		if(m_id3v1Tag)
		{
			m_id3v1Location = findID3v1();
		}
	}

	if((tags & MPEG_ID3v1) && m_hasId3v1)
	{
		Truncate(m_id3v1Location);
		m_id3v1Location = -1;
		m_hasId3v1 = false;
		if(freeMemory)
		{
			delete m_id3v1Tag;
			m_id3v1Tag = NULL;
			m_combinedTag->setID3v1Tag(NULL);
		}
	}

	if((tags & MPEG_APE) && m_hasApe)
	{
		if( !RemoveBlock(m_apeLocation, m_apeOriginalSize) )
			return false;
		m_apeLocation = -1;
		m_hasApe = false;
		if(m_hasId3v1)
		{
			if (m_id3v1Location > m_apeLocation)
				m_id3v1Location -= m_apeOriginalSize;
		}
		if(freeMemory)
		{
			delete m_apeTag;
			m_apeTag = NULL;
			m_combinedTag->setAPETag(NULL);
		}
	}

	return true;
}
Beispiel #6
0
bool MPEG_File::save(int tags, bool stripOthers)
{
	if(tags == MPEG_NoTags && stripOthers)
		return strip(MPEG_AllTags);

	if( !m_id3v2Tag && !m_id3v1Tag && !m_apeTag )
	{
		if( (m_hasId3v1 || m_hasId3v2 || m_hasApe) && stripOthers)
			return strip(MPEG_AllTags);

		return true;
	}

	if( ReadOnly() )
	{
		wxLogDebug(wxT("MPEG::File::save() -- File is read only."));
		return false;
	}

	// Create the tags if we've been asked to.  Copy the values from the tag that
	// does exist into the new tag.

	if( (tags & MPEG_ID3v2) && m_id3v1Tag )
	{
		Tagger_Tag::duplicate(m_id3v1Tag, ID3v2Tag(true), false);
	}

	if( (tags & MPEG_ID3v1) && m_id3v2Tag )
	{
		Tagger_Tag::duplicate(m_id3v2Tag, ID3v1Tag(true), false);
	}

	bool success = true;

	if(MPEG_ID3v2 & tags)
	{
		if (m_id3v2Tag && !m_id3v2Tag->isEmpty() )
		{
			if(!m_hasId3v2)
			{
				m_id3v2Location = 0;
			}

			success = Insert(m_id3v2Tag->render(), m_id3v2Location, m_id3v2OriginalSize) && success;
		}
		else if(stripOthers)
		{
			success = strip(MPEG_ID3v2, false) && success;
		}
	}
	else if(m_hasId3v2 && stripOthers)
	{
		success = strip(MPEG_ID3v2) && success;
	}

	if(MPEG_ID3v1 & tags)
	{
		if(m_id3v1Tag && !m_id3v1Tag->isEmpty())
		{
			int offset = m_hasId3v1 ? -128 : 0;
			Seek(offset, SJ_SEEK_END);
			success = WriteBlock(m_id3v1Tag->render()) && success;
		}
		else if(stripOthers)
		{
			success = strip(MPEG_ID3v1) && success;
		}
	}
	else if(m_hasId3v1 && stripOthers)
	{
		success = strip(MPEG_ID3v1, false) && success;
	}

	// Dont save an APE-tag unless one has been created

	if((MPEG_APE & tags) && m_apeTag)
	{
		if(m_hasApe)
		{
			success = Insert(m_apeTag->render(), m_apeLocation, m_apeOriginalSize) && success;
		}
		else
		{
			if(m_hasId3v1)
			{
				success = Insert(m_apeTag->render(), m_id3v1Location, 0) && success;
				m_apeOriginalSize = m_apeTag->footer()->completeTagSize();
				m_hasApe = true;
				m_apeLocation = m_id3v1Location;
				m_id3v1Location += m_apeOriginalSize;
			}
			else
			{
				Seek(0, SJ_SEEK_END);
				m_apeLocation = Tell();
				success = WriteBlock(m_apeTag->render()) && success;
				m_apeOriginalSize = m_apeTag->footer()->completeTagSize();
				m_hasApe = true;
			}
		}
	}
	else if(m_hasApe && stripOthers)
	{
		success = strip(MPEG_APE, false) && success;
	}

	return success;
}
Beispiel #7
0
STDMETHODIMP CMetadataElement::put_ReadOnly(VARIANT_BOOL newVal)
{
	ReadOnly(VARIANT_FALSE != newVal);
	return S_OK;
}