Esempio n. 1
0
// Create CDDB file
bool Dbase::Write(const Cddb::Album& album)
{
    CachePut(album);

    const QString genre = !album.discGenre.isEmpty() ?
        album.discGenre.toLower().toUtf8() : "misc";

    LOG(VB_MEDIA, LOG_INFO, "WriteDB " + genre +
        QString(" %1 ").arg(album.discID,0,16) +
        album.artist + " / " + album.title);

    if (QDir(GetDB()).mkpath(genre))
    {
        QFile file(GetDB() + '/' + genre + '/' + 
            QString::number(album.discID,16));
        if (file.open(QIODevice::WriteOnly | QIODevice::Text))
        {
            QTextStream(&file) << album;
            return true;
        }
        else
            LOG(VB_GENERAL, LOG_ERR, "Cddb can't write " + file.fileName());
    }
    else
        LOG(VB_GENERAL, LOG_ERR, "Cddb can't mkpath " + GetDB() + '/' + genre);
    return false;
}
Esempio n. 2
0
Boolean  Pfml2::InnerGetAlmStatus(TBlkAttr *pAboObj,UINT nID)
{
	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->GetAlmStatus(pAboObj,nID);
	return SDB_RET_FAILED ;
};
Esempio n. 3
0
BOOL KGatewayDataProcess::CheckConnectAddress()
{
	S3PDBConVBC* pConn = GetDB(0);
	if (pConn)
		return S3PAccount::CheckAddress(pConn, m_Address, m_Port) == ACTION_SUCCESS;
	return FALSE;
}
Esempio n. 4
0
static VALUE
bdb_sary_slice_bang(int argc, VALUE *argv, VALUE obj)
{
    VALUE arg1, arg2;
    long pos, len;
    bdb_DB *dbst;

    GetDB(obj, dbst);
    if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
	pos = NUM2LONG(arg1);
	len = NUM2LONG(arg2);
      delete_pos_len:
	if (pos < 0) {
	    pos = dbst->len + pos;
	}
	arg2 = bdb_sary_subseq(obj, pos, len);
	bdb_sary_replace(obj, pos, len, Qnil);
	return arg2;
    }

    if (!FIXNUM_P(arg1) && rb_range_beg_len(arg1, &pos, &len, dbst->len, 1)) {
	goto delete_pos_len;
    }

    pos = NUM2LONG(arg1);
    if (pos >= dbst->len) return Qnil;
    if (pos < 0) pos += dbst->len;
    if (pos < 0) return Qnil;

    arg1 = INT2NUM(pos);
    arg2 = bdb_sary_at(obj, arg1);
    if (bdb_del(obj, arg1) != Qnil) dbst->len--;
    return arg2;
}
Esempio n. 5
0
/*
 * call-seq:
 *     db[nth]
 *     db[start..end]
 *     db[start, length]
 *
 * Element reference - with the following syntax:
 *
 * * db[nth]
 *
 *     Retrieves the +nth+ item from an array.  Index starts from
 *     zero.  If index is the negative, counts backward from the end
 *     of the array.  The index of the last element is -1. Returns
 *     +nil+, if the +nth+ element does not exist in the array.
 *
 * * db[start..end]
 *
 *     Returns an array containing the objects from +start+ to +end+,
 *     including both ends. if end is larger than the length of the
 *     array, it will be rounded to the length.  If +start+ is out of
 *     an array range , returns +nil+.  And if +start+ is larger than
 *     end with in array range, returns empty array ([]).
 *
 * * db[start, length]
 *
 *     Returns an array containing +length+ items from +start+.
 *     Returns +nil+ if +length+ is negative.
 */
static VALUE
bdb_sary_aref(int argc, VALUE *argv, VALUE obj)
{
    VALUE arg1, arg2;
    long beg, len;
    bdb_DB *dbst;

    GetDB(obj, dbst);
    if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
	beg = NUM2LONG(arg1);
	len = NUM2LONG(arg2);
	if (beg < 0) {
	    beg = dbst->len + beg;
	}
	return bdb_sary_subseq(obj, beg, len);
    }

    if (FIXNUM_P(arg1)) {
	return bdb_sary_entry(obj, arg1);
    }
    else if (TYPE(arg1) == T_BIGNUM) {
	rb_raise(rb_eIndexError, "index too big");
    }
    else {
	switch (rb_range_beg_len(arg1, &beg, &len, dbst->len, 0)) {
	  case Qfalse:
	    break;
	  case Qnil:
	    return Qnil;
	  default:
	    return bdb_sary_subseq(obj, beg, len);
	}
    }
    return bdb_sary_entry(obj, arg1);
}
Esempio n. 6
0
static VALUE
bdb_sary_delete(VALUE obj, VALUE item)
{
    bdb_DB *dbst;
    long i1, i2;
    VALUE tmp, a;

    GetDB(obj, dbst);
    i2 = dbst->len;
    for (i1 = 0; i1 < dbst->len;) {
	tmp = INT2NUM(i1);
	a = bdb_get(1, &tmp, obj);
	if (rb_equal(a, item)) {
	    bdb_del(obj, INT2NUM(i1));
	    dbst->len--;
	}
	else {
	    i1++;
	}
    }
    if (dbst->len == i2) {
	if (rb_block_given_p()) {
	    return rb_yield(item);
	}
	return Qnil;
    }
    return item;
}
Esempio n. 7
0
static VALUE
bdb_sary_reverse_bang(VALUE obj)
{
    long i, j;
    bdb_DB *dbst;
    VALUE tmp[2], interm;

    GetDB(obj, dbst);
    if (dbst->len <= 1) return obj;
    i = 0;
    j = dbst->len - 1;
    while (i < j) {
	tmp[0] = INT2NUM(i);
	interm = bdb_get(1, tmp, obj);
	tmp[0] = INT2NUM(j);
	tmp[1] = bdb_get(1, tmp, obj);
	tmp[0] = INT2NUM(i);
	bdb_put(2, tmp, obj);
	tmp[0] = INT2NUM(j);
	tmp[1] = interm;
	bdb_put(2, tmp, obj);
	i++; j--;
    }
    return obj;
}
Esempio n. 8
0
static VALUE
bdb_sary_unshift_m(int argc, VALUE *argv, VALUE obj)
{
    bdb_DB *dbst;
    VALUE tmp[2];
    long i;

    if (argc == 0) {
	rb_raise(rb_eArgError, "wrong # of arguments(at least 1)");
    }
    if (argc > 0) {
/* ++ */
	GetDB(obj, dbst);
	for (i = dbst->len - 1; i >= 0; i++) {
	    tmp[0] = INT2NUM(i);
	    tmp[1] = bdb_get(1, tmp, obj);
	    tmp[0] = INT2NUM(i + argc);
	    bdb_put(2, tmp, obj);
	}
	for (i = 0; i < argc; i++) {
	    tmp[0] = INT2NUM(i);
	    tmp[1] = argv[i];
	    bdb_put(2, tmp, obj);
	    dbst->len++;
	}
    }
    return obj;
}
Esempio n. 9
0
void Pfml2::Test()
{
	CPFMDatabase *pDB = GetDB();
	CModAutoLocker locker(this);
	pDB->Test();

};
Esempio n. 10
0
void Pfml2::RegisterPMIF(SPMHAL *pstPMThreshold,UINT nLen)
{
	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		pDB->RegisterPMIF(pstPMThreshold,nLen);
	return ;

};
Esempio n. 11
0
void ContrastDialog::OnGetForegroundDB( wxCommandEvent &event )
{
   SetStartTime(mForegroundStartT->GetTimeValue());
   SetEndTime(mForegroundEndT->GetTimeValue());
   foregrounddB = GetDB();
   m_pButton_UseCurrentF->SetFocus();
   results();
}
Esempio n. 12
0
		Configure::~Configure()
		{
			Database::Typed<Entry> &db = GetDB();
			if (mPrev)
				db.Put(mTagId, mPrev);
			else
				db.Delete(mTagId);
		}
Esempio n. 13
0
int Pfml2::InnerAlmReport(TBlkAttr *pAboObj,UINT nID,UINT nStatus)
{

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->AlmReport(pAboObj,nID,nStatus);
	return SDB_RET_FAILED ;
};
Esempio n. 14
0
int  Pfml2::AlmGetAll(list<SAlmDataItem> &listAlm)
{
	CModAutoLocker locker(this);
	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->AlmGetAll(listAlm);
	return SDB_RET_FAILED ;
}
Esempio n. 15
0
		Deactivate::~Deactivate()
		{
			Database::Typed<Entry> &db = GetDB();
			if (mPrev)
				db.Put(mDatabaseId, mPrev);
			else
				db.Delete(mDatabaseId);
		}
Esempio n. 16
0
int     Pfml2::EventGetNum(list<SAlmDataItem> &listEvt,UINT nMaxNum,UINT &nRetNum)
{
	CModAutoLocker locker(this);
	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->EventGetNum(listEvt,nMaxNum,nRetNum);
	return SDB_RET_FAILED ;
};
Esempio n. 17
0
bool BaseIndex::WriteBestBlock(const CBlockIndex* block_index)
{
    LOCK(cs_main);
    if (!GetDB().WriteBestBlock(chainActive.GetLocator(block_index))) {
        return error("%s: Failed to write locator to disk", __func__);
    }
    return true;
}
Esempio n. 18
0
void ContrastDialog::OnGetBackgroundDB( wxCommandEvent & WXUNUSED(event))
{
   SetStartTime(mBackgroundStartT->GetTimeValue());
   SetEndTime(mBackgroundEndT->GetTimeValue());
   backgrounddB = GetDB();
   m_pButton_UseCurrentB->SetFocus();
   results();
}
Esempio n. 19
0
int  Pfml2::AddAboObj(TBlkAttr *pAboObj)
{
	CModAutoLocker locker(this);  //ok

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->AddAboObj(pAboObj);
	return SDB_RET_FAILED ;
};
Esempio n. 20
0
void  Pfml2::PMSetTime(UINT nTimeMode)
{
	CModAutoLocker locker(this);

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->PMSetTime(nTimeMode);
	return ;
};
Esempio n. 21
0
int  Pfml2::PMGetAll(list<SPMDataItem> &listPM,UINT nType)
{
	CModAutoLocker locker(this);

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->PMGetAll(listPM,nType);
	return SDB_RET_FAILED ;
};
Esempio n. 22
0
void  Pfml2::RemoveBlkObjs(UINT nBlkType,PFN_IF_REMOVE pfn,void *pvParam)
{
	CModAutoLocker locker(this);//2011 ok

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		pDB->RemoveBlkObjs(nBlkType,pfn,pvParam);
	return ;
};
Esempio n. 23
0
void  Pfml2::PMClear(UINT nClearMode)
{
	CModAutoLocker locker(this);

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		pDB->PMClear(nClearMode);

};
Esempio n. 24
0
void  Pfml2::PMClearObj(TBlkAttr *pAboObj,UINT nClearMode)
{
	CModAutoLocker locker(this);

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		pDB->PMClearObj(pAboObj,nClearMode);
	return ;
};
Esempio n. 25
0
int  Pfml2::PMGetOrgTCA(TBlkAttr *pAboObj,UINT nIdx,ULong64 & nllOn,ULong64  & ullOFF)
{
	CModAutoLocker locker(this);

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->PMGetOrgTCA(pAboObj,nIdx,nllOn,ullOFF);
	return SDB_RET_FAILED ;
};
Esempio n. 26
0
int  Pfml2::PMSetTypeTCA(UINT nType,UINT nIdx,ULong64 ullOn,ULong64 ullOFF)
{
	CModAutoLocker locker(this);//2011 1  * ok

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->PMSetTypeTCA(nType,nIdx,ullOn,ullOFF);
	return SDB_RET_FAILED ;
};
Esempio n. 27
0
Boolean  Pfml2::PMGetSwitch(TBlkAttr *pAboObj)
{
	CModAutoLocker locker(this);//2011   ok

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->PMGetSwitch(pAboObj);
	return SDB_RET_FAILED ;
};
Esempio n. 28
0
void  Pfml2::PMNotifyTimeOut(UINT nTimeType)
{
	CModAutoLocker locker(this);

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		pDB->PMNotifyTimeOut(nTimeType);

};
Esempio n. 29
0
int  Pfml2::PMSetTypeSwitch(UINT nType,LONG ulCollectEnable,Boolean bNotify)
{
	CModAutoLocker locker(this);//2011   ok 

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		return pDB->PMSetTypeSwitch(nType,ulCollectEnable,bNotify);
	return SDB_RET_FAILED ;
};
Esempio n. 30
0
void   Pfml2::RemoveAboObj(TBlkAttr *pAboObj)
{
	CModAutoLocker locker(this);///2011  ok

	CPFMDatabase  *pDB = GetDB();
	if (NULL !=pDB)
		pDB->RemoveAboObj(pAboObj);
	return ;
};