UI_insertRecord.c File Reference


Detailed Description

This module inserts record to various DB.

REVISION

Definition in file UI_insertRecord.c.

#include "../SYSTEM/sys_main.h"
#include "../SYSTEM/sys_clock.h"
#include "../DB/db.h"
#include "ui.h"
#include "ui_assert.h"

Include dependency graph for UI_insertRecord.c:

Include dependency graph

Go to the source code of this file.

Functions

BOOL UI_insertHisiRecord (const char *pTitle, const char *pSrc, const char *pPath)
 Function inserts a HiSi clip to unidentified HiSi database.
BOOL UI_insertAudioRecord (const char *pTitle, const char *pPlaylist, const char *pArtist, const char *pAlbum, const char *pGenre, const char *pRecordings, ULONG timeLen, ULONG size, const char *pPath)
 Function inserts an audio record from the root of audio DB.


Function Documentation

BOOL UI_insertAudioRecord const char *  pTitle,
const char *  pPlaylist,
const char *  pArtist,
const char *  pAlbum,
const char *  pGenre,
const char *  pRecordings,
ULONG  timeLen,
ULONG  size,
const char *  pPath
 

Function inserts an audio record from the root of audio DB.

Note that in case the audio DB is updated future, this funciton needs to be rewritten. NOTE: pTitle and pPath are mandatory and must NOT be null pointers.

Parameters:
pTitle Audio record time.
pPlaylist Audio record playlist string.
pArtist Audio record artist string.
pAlbum Audio record album string.
pGenre Audio record genre string.
pRecordings Audio record recording source string.
timeLen Audio record duration.
size Audio file size in kilo-bytes.
pPath Audio record full path.
Returns:
TRUE if successfully inserted, otherwise FALSE.

Definition at line 129 of file UI_insertRecord.c.

References st_DBNAV::audio, DB_insertRecord(), GEN_strPack(), SYS_die(), and UI_audioPresetUpdate().

00137                                                {
00138     
00139     char *      title;
00140     char *      playlist;
00141     char *      artist;
00142     char *      album;
00143     char *      genre;
00144     char *      recordings;
00145     char *      pC;
00146     char        emptyRecord[] = {0x8000, DB_RECDLMT};
00147     //char *    record[6] = { title, playlist, artist, album, genre, recordings };
00148     char *      record[6];
00149     
00150     int         ii;
00151     int         len1, len2;
00152     BOOL        ret;
00153     BOOL        bPlaylistAllocated = TRUE;
00154     BOOL        bArtistAllocated = TRUE;
00155     BOOL        bAlbumAllocated = TRUE;
00156     BOOL        bGenreAllocated = TRUE;
00157     BOOL        bRecordingsAllocated = TRUE;
00158     
00159     UI_assert (pTitle      != NULL      , UI_INSERTAUDIORECORD);
00160     UI_assert (pPath       != NULL      , UI_INSERTAUDIORECORD2);
00161     
00162     /* Construct the primary data entry. */
00163     len1 = strlen(pTitle);
00164     len2 = strlen(pPath);
00165     
00166     ii = ( (len1 + len2)/2 ) + 30;  // 2 extra NULL holder + 15 child DB entry holder.
00167                                     // + 1 record flag + 4 timeLen + 4 size 
00168                                     // + 4 reserved for safe.
00169                                                 
00170     title = (char *)calloc(ii, sizeof(char));
00171     if(NULL == title) SYS_die(UI_INSERTAUDIORECORD3);
00172 
00173     pC = title;
00174     *pC++= 0x8000;      // Record flag.
00175     
00176     pC += GEN_strPack(pC, pTitle, len1);
00177     *pC++ = DB_FLDDLMT; // end of title field.
00178     
00179     *pC++ = 0;
00180     *pC++ = 0;
00181     *pC++ = DB_FLDDLMT; // playlist entry holder.
00182     
00183     *pC++ = 0;
00184     *pC++ = 0;
00185     *pC++ = DB_FLDDLMT; // artist entry holder.
00186 
00187     *pC++ = 0;
00188     *pC++ = 0;
00189     *pC++ = DB_FLDDLMT; // album entry holder.
00190 
00191     *pC++ = 0;
00192     *pC++ = 0;
00193     *pC++ = DB_FLDDLMT; // genre entry holder.
00194 
00195     *pC++ = 0;
00196     *pC++ = 0;
00197     *pC++ = DB_FLDDLMT; // recordings entry holder.
00198     
00199     // Let's handle the special characters.
00200     pC += _processDBchar(timeLen, pC);
00201     pC += _processDBchar(size, pC);
00202 
00203     pC += GEN_strPack(pC, pPath, len2);
00204     
00205     *pC = DB_RECDLMT;
00206     
00207     // Contruct playlist record entry. 
00208     if( (playlist = _constructRecord(pPlaylist)) == NULL ) 
00209     {
00210         playlist = emptyRecord;
00211         bPlaylistAllocated = FALSE;
00212     }
00213 
00214     // Contruct playlist record entry.
00215     if( (artist = _constructRecord(pArtist)) == NULL ) {
00216         
00217         artist = emptyRecord;
00218         bArtistAllocated = FALSE;
00219     }
00220     
00221     // Contruct Album record entry. 
00222     if( (album = _constructRecord(pAlbum)) == NULL ) 
00223     {       
00224         album = emptyRecord;
00225         bAlbumAllocated = FALSE;
00226     }
00227 
00228     // Contruct Genre record entry.
00229     if( (genre = _constructRecord(pGenre)) == NULL ) 
00230     {       
00231         genre = emptyRecord;        
00232         bGenreAllocated = FALSE;
00233     }
00234     
00235     // Contruct recordings record entry. 
00236     if( (recordings = _constructRecord(pRecordings)) == NULL ) 
00237     {       
00238         recordings = emptyRecord;       
00239         bRecordingsAllocated = FALSE;
00240     }
00241     
00242     // Initialize record.
00243     record[0] = title;
00244     record[1] = playlist;
00245     record[2] = artist;
00246     record[3] = album;
00247     record[4] = genre;
00248     record[5] = recordings;
00249 
00250     // Insert to audio DB.
00251     ret = DB_insertRecord(DBnav.audio, (DB_DATA *)record);  
00252     
00253     free(title);
00254     if(bPlaylistAllocated == TRUE) free(playlist);
00255     if(bArtistAllocated == TRUE) free(artist);
00256     if(bAlbumAllocated == TRUE) free(album);
00257     if(bGenreAllocated == TRUE) free(genre);
00258     if(bRecordingsAllocated == TRUE) free(recordings);
00259     
00260     UI_audioPresetUpdate(1);
00261     
00262     return ret;
00263 }

Here is the call graph for this function:

BOOL UI_insertHisiRecord const char *  pTitle,
const char *  pSrc,
const char *  pPath
 

Function inserts a HiSi clip to unidentified HiSi database.

Parameters:
pTitle Title string.
pSrc HiSi source string embedded with hisi source identifier.
pPath HiSi clip full path.
Returns:
TRUE if record successfully inserted, otherwise FALSE.

3 delimiter + 2 reserved for safe.

Definition at line 51 of file UI_insertRecord.c.

References DB_insertRecord(), GEN_strPack(), SYS_die(), and st_DBNAV::unidedhisi.

00054 {   
00055     char *      record;
00056     char *      pC;
00057     int         len1;
00058     int         len2;
00059     int         len3;
00060     int         ii;
00061     BOOL        ret;
00062     
00063     /* Construct the primary data entry. */
00064     len1 = strlen(pTitle);
00065     len2 = strlen(pSrc);
00066     len3 = strlen(pPath);
00067     
00068     // 3 extra NULL holder + 1 record flag + 
00070     ii = ( (len1 + len2 + len3)/2 ) + 9;    
00071 
00072     record = (char *)calloc(ii, sizeof(char));
00073     if(NULL == record) SYS_die(UI_INSERTRECORD);
00074     
00075     pC = record;
00076     
00077     *pC++= 0x8000;      // Record flag.
00078     
00079     pC += GEN_strPack(pC, pTitle, len1);
00080     
00081     *pC++ = DB_FLDDLMT; 
00082     
00083     pC += GEN_strPack(pC, pSrc, len2);
00084 
00085     *pC++ = DB_FLDDLMT; 
00086 
00087     pC += GEN_strPack(pC, pPath, len3);
00088     
00089     *pC = DB_RECDLMT;
00090     
00091     
00092     /* Insert to unidentified HiSi DB. */
00093     ret = DB_insertRecord(DBnav.unidedhisi, (DB_DATA *)&record);    
00094 
00095     free(record);   
00096     
00097     return ret;
00098 }

Here is the call graph for this function:


Generated on Wed Jan 19 01:13:25 2005 for neuros-firmware by  doxygen 1.3.9.1