UI_SF_dbmenu.c File Reference


Detailed Description

This module provides idle state handle.

REVISION

Definition in file UI_SF_dbmenu.c.

#include "../SYSTEM/sys_clock.h"
#include "../SYSTEM/sys_main.h"
#include "../SYSTEM/sys_hardware.h"
#include "ui.h"
#include "ui_assert.h"
#include "xim.h"
#include "../AUDIO/audio.h"
#include "../ear/ear.h"
#include "playQ.h"
#include "m3u.h"

Include dependency graph for UI_SF_dbmenu.c:

Include dependency graph

Go to the source code of this file.

Functions

STATE UI_SF_dbmenu (st_MSG *msgIN)
 Function serves as the DB menu state handle.


Function Documentation

STATE UI_SF_dbmenu st_MSG msgIN  ) 
 

Function serves as the DB menu state handle.

Parameters:
msgIN Input message.
Returns:
Next state.

Definition at line 104 of file UI_SF_dbmenu.c.

References st_DBNAV::audio, BTN_NEUROS, BTN_PCDELETE, BTN_YES, DB_getSaiByMdb(), MENU_2NEXT, MENU_2PREV, MENU_action(), MENU_buf, MENU_CLOSE, MENU_JUMPDN, MENU_JUMPUP, MENU_SELECT, MENU_TNEXT, MENU_TPREV, MENU_TSELECT, MENU_TXTSCROLL, MSG_send(), st_DBNAV::pcaudio, SMENUBROWSE, SMSGBOX_EXIT, SRESUMEPLAY, SSTART2PLAY, SSTATE_END, SSTATE_START, SXIM_CREATE, SXIM_EXIT, UI_isPresetValid(), UI_m3uActvItem(), UI_m3uEntryNum(), UI_msgbxCreate(), and UI_presetAudio().

00105 {   
00106     MSG_ID          id = msgIN->id;     
00107     MSG_DATA        d1 = msgIN->d1; 
00108     MSG_DATA        d2 = msgIN->d2;
00109     USHORT          ii;
00110 
00111     switch(id)
00112     {
00113     case SYS_MSG_ID:
00114         switch(d1)
00115         {
00116             case SSTATE_START:
00117             {
00118                 // +-------------+
00119                 // | dbID        |
00120                 // +-------------+
00121                 // | fldIdx      |
00122                 // +-------------+
00123                 // | fldEntry    |
00124                 // +-------------+
00125                 // | actvItem    |
00126                 // +-------------+
00127                 // +-------------+
00128                 // | Invalid dbID|
00129                 // +-------------+
00130                 // | Caller State|
00131                 // +-------------+
00132                 DB_id       =   GEN_popStack();
00133                 DB_fldIdx =     GEN_popStack();
00134                 DB_fldEntry =   GEN_popStack();                     
00135                 DB_actvItem =   GEN_popStack();
00136                                         
00137                 if(_validateDB() == 0 )
00138                 {
00139                     UI_msgbxCreate(MSGBX_DBRECORDNA);
00140                     return(_dbStateEnd());
00141                     
00142                 }
00143                 else menu = mMENU_create((void*)&MENU_buf[0]);
00144                 return S_DBMENU;
00145             }
00146             case SSTATE_END:
00147             {
00148                 return(_dbStateEnd());
00149             }
00150             case SXIM_EXIT: 
00151             {
00152                 return(_ximAction(d2));
00153             }
00154             case SMSGBOX_EXIT:
00155             {
00156                 switch(MENU_curMsgbx())
00157                 {
00158                     case MSGBX_DELETEHISICLIP:
00159                     {
00160                         if(BTN_YES == d2)
00161                         {
00162                             mMENU_action(menu, MENU_CLOSE);
00163                             _deleteHisiClip();
00164                             if(_validateDB() == 0 )
00165                             {
00166                                 return(_dbStateEnd());
00167                             }
00168                             menu = mMENU_create((void*)&MENU_buf[0]);
00169                         }
00170                         break;
00171                     }
00172                     case MSGBX_DELETERECORD:
00173                     {
00174                         if(BTN_NEUROS == d2)
00175                         {
00176                             mMENU_action(menu, MENU_CLOSE);
00177                             _deleteRecord();
00178                             if(_validateDB() == 0 )
00179                             {
00180                                 return(_dbStateEnd());
00181                             }
00182                             menu = mMENU_create((void*)&MENU_buf[0]);
00183                         }
00184                         else if(BTN_PCDELETE == d2)
00185                         {
00186                             mMENU_action(menu, MENU_CLOSE);
00187                             _pcdeleteRecord();
00188                             if(_validateDB() == 0 )
00189                             {
00190                                 return(_dbStateEnd());
00191                             }
00192                             menu = mMENU_create((void*)&MENU_buf[0]);
00193                         }
00194                         break;
00195                     }
00196                     case MSGBX_DELETEONSYNC:
00197                     {
00198                         if(BTN_YES == d2)
00199                         {
00200                             _deleteOnsync();
00201                         }
00202                         break;
00203                     }
00204                     case MSGBX_REMOVERECORD:
00205                     {
00206                         if(BTN_YES == d2)
00207                         {   
00208                             mMENU_action(menu, MENU_CLOSE);
00209                             _removeRecord();
00210                             if(_validateDB() == 0 )
00211                             {
00212                                 return(_dbStateEnd());
00213                             }
00214                             menu = mMENU_create((void*)&MENU_buf[0]);
00215                         }
00216                         break;
00217                     }                   
00218                 }
00219                 return S_DBMENU;
00220             }
00221 //DeepB
00222 #ifdef USE_DATABASE_HACKS
00223             case SSTART2PLAY:
00224             {
00225                 mMENU_action(menu, MENU_SELECT);            
00226                 mMENU_action(menu, MENU_CLOSE);
00227 
00228                 GEN_pushStack(DB_actvItem); // actvItem
00229                 GEN_pushStack(DB_fldEntry); // fldEntry
00230                 GEN_pushStack(DB_fldIdx); // fldIdx
00231                 GEN_pushStack(DB_id);               
00232                 GEN_pushStack(S_DBMENU);
00233                 
00234                 SYS_notUseSavedRandomPattern();
00235                 
00236                 // Set up to play.
00237                 if( (DB_rootID(DB_id) == DBnav.pcaudio) )
00238                 {
00239                     // Play all if no history available and queue is empty.   
00240                     if( (FALSE == UI_isPresetValid(0))||(PRESET_RADIO == UI_presetType(0)) )
00241                     {
00242                         #ifdef M3U_SUPPORT
00243                         if(UI_m3uEntryNum(0))
00244                         {
00245                             UI_presetAudio(0, 0x1234, UI_m3uActvItem(0), DONTCARE, DONTCARE, 0);
00246                         }
00247                         else
00248                         #endif
00249                         {
00250                             UI_presetAudio(0, DBnav.audio, DONTCARE, 0, -1, 0);
00251                         }
00252                     }
00253                     else
00254                     {
00255                         SYS_useSavedRandomPattern();
00256                     }                   
00257                 }
00258                 else
00259                 {
00260                     // If nothing is specifically selected here, play all instead.
00261                     if(0 == DB_selected)
00262                     {
00263                         UI_presetAudio(0, DBnav.audio, DONTCARE, 0, -1, 0);
00264                     }
00265                 
00266                     else
00267                     {
00268                         if(DB_id == DB_rootID(DB_id))
00269                         {
00270                             UI_presetAudio(0, DB_id, DB_actvItem, DB_fldEntry, DB_fldIdx, 0);
00271                         }
00272                         else
00273                         {
00274                             DB_ENTRY fldEntry;
00275                             
00276                             // Hard-coded to support artist under album, in which case always play
00277                             // the first available album.
00278                             if(6 == DB_id)
00279                             {
00280                                 _navDB();
00281                                 {
00282                                     menu = mMENU_create((void*)&MENU_buf[0]);
00283                                     mMENU_action(menu, MENU_SELECT);
00284                                     mMENU_action(menu, MENU_CLOSE);
00285                                 }
00286                             }
00287                             
00288                             fldEntry = DB_getSaiByMdb(((ULONG)dbBUF[0]<<16)|dbBUF[1], DB_id);
00289                             
00290                 
00291                             //UI_presetAudio(0, DB_rootID(DB_id), DONTCARE, DB_actvItem, DB_fieldIndex(DB_id), 0);
00292                             UI_presetAudio(0, DB_rootID(DB_id), DONTCARE, fldEntry, DB_fieldIndex(DB_id), 0);
00293                         }
00294                     }
00295                 }
00296 
00297                 GEN_pushStack(DONTCARE);
00298                 mMSG_send(uiParentMsgQ, SYS_MSG_ID, SSTART2PLAY, 0, SYS_FOREVER);
00299                 return S_NULL;
00300             }
00301 #else // #ifdef USE_DATABASE_HACKS
00302 // I like this KISS approach better
00303             case SSTART2PLAY:
00304             {
00305                 mMENU_action(menu, MENU_SELECT);            
00306                 mMENU_action(menu, MENU_CLOSE);
00307                 
00308                 GEN_pushStack(DB_actvItem); // actvItem
00309                 GEN_pushStack(DB_fldEntry); // fldEntry
00310                 GEN_pushStack(DB_fldIdx); // fldIdx
00311                 GEN_pushStack(DB_id);               
00312                 GEN_pushStack(S_DBMENU);
00313 
00314                 if (_navDB())
00315                     UI_presetAudio(0, DB_id, DB_actvItem, DB_fldEntry, DB_fldIdx, 0);
00316                 else
00317                     UI_presetAudio(0, DBnav.audio, DONTCARE, 0, -1, 0);
00318                 
00319                 GEN_pushStack(DONTCARE);
00320                 mMSG_send(uiParentMsgQ, SYS_MSG_ID, SSTART2PLAY, 0, SYS_FOREVER);
00321                 return S_NULL;
00322             }
00323 #endif // #ifdef USE_DATABASE_HACKS
00324             case SRESUMEPLAY:
00325             {
00326                 mMENU_action(menu, MENU_SELECT);
00327                 mMENU_action(menu, MENU_CLOSE);
00328 
00329                 GEN_pushStack(DB_actvItem); // actvItem
00330                 GEN_pushStack(DB_fldEntry); // fldEntry
00331                 GEN_pushStack(DB_fldIdx); // fldIdx
00332                 GEN_pushStack(DB_id);
00333                 
00334                 GEN_pushStack(S_DBMENU);
00335                 
00336                 GEN_pushStack(DONTCARE);                
00337                 MSG_send(uiParentMsgQ, msgIN, SYS_FOREVER);
00338                 return S_NULL;
00339             }
00340             case SMENUBROWSE:
00341             {
00342                 UINT * pD = (UINT*)d2;
00343                 GEN_pushStack(S_NULL);
00344                             
00345                 GEN_pushStack(*pD++);
00346                 if(*pD != DONTCARE) GEN_pushStack(*pD);
00347                 pD++;
00348                 
00349                 GEN_pushStack(S_NULL);
00350                 GEN_pushStack(MENU_NULL);
00351                 GEN_pushStack(*pD);
00352                 return S_MENU;          
00353             }
00354         }                           
00355         break;
00356         
00357     case KBD_MSG_ID:
00358         switch(d1)
00359         {
00360         case KEY_PLAY:
00361             if(SYS_isAudioActive())
00362             {
00363                 mMSG_send(uiParentMsgQ, SYS_MSG_ID, SSTATE_END, DONTCARE, SYS_FOREVER); 
00364             }
00365             MSG_send(uiParentMsgQ, msgIN, SYS_FOREVER);
00366             return S_DBMENU;
00367                                 
00368         case KEY_DOWN:
00369         case KEY_HDOWN:
00370             mMENU_action(menu, MENU_2NEXT);
00371             return S_DBMENU;
00372         
00373         case KEY_RDOWN:
00374             ii = (d2/(KDOWN_HOLD_TIME>>1)) - 2;
00375             ii = (ii > 6)? 6 : ii;
00376             mMENU_action(menu, MENU_JUMPDN|(2<<ii));
00377             return S_DBMENU;
00378             
00379         case KEY_UP:
00380         case KEY_HUP:
00381             mMENU_action(menu, MENU_2PREV);
00382             return S_DBMENU;
00383 
00384         case KEY_RUP:
00385             ii = (d2/(KDOWN_HOLD_TIME>>1)) - 2;
00386             ii = (ii > 6)? 6 : ii;
00387             mMENU_action(menu, MENU_JUMPUP|(2<<ii));
00388             return S_DBMENU;
00389 
00390         case KEY_FORWARD:
00391         {
00392 //DeepB
00393 // Here is where i should check 
00394 // if the leading char is not a letter.
00395             unsigned char  curLeadCh = toupper(dbBUF[3]>>8);
00396             unsigned short curItem;
00397             
00398             mMENU_action(menu, MENU_2NEXT);
00399             mMENU_action(menu, MENU_SELECT);
00400             curItem = DB_actvItem;
00401             while(1)
00402             {
00403                 if(toupper(dbBUF[3]>>8) != curLeadCh) break;
00404                 mMENU_action(menu, MENU_TNEXT);
00405                 mMENU_action(menu, MENU_TSELECT);
00406                 if(DB_actvItem == curItem) break;
00407             }
00408             MENU_action(menu, MENU_JUMPDN);
00409             return S_DBMENU;
00410         }   
00411 
00412         case KEY_REWIND:
00413         {
00414             unsigned char  curLeadCh = toupper(dbBUF[3]>>8);
00415             unsigned short curItem;
00416             
00417             mMENU_action(menu, MENU_2PREV);
00418             mMENU_action(menu, MENU_SELECT);
00419             curItem = DB_actvItem;
00420             while(1)
00421             {
00422                 if(toupper(dbBUF[3]>>8) != curLeadCh) break;
00423                 mMENU_action(menu, MENU_TPREV);
00424                 mMENU_action(menu, MENU_TSELECT);
00425                 if(DB_actvItem == curItem) break;
00426             }
00427             MENU_action(menu, MENU_JUMPUP);
00428             return S_DBMENU;
00429         }   
00430 
00431 //DeepB
00432 // Creates Xi Menu for folders too.
00433 // Broken right now.
00434         case KEY_HSELECT:       
00435         {
00436             UI_msgbxCreate(MSGBX_NOTIMPLEMENTED);   
00437 //          mMENU_action(menu, MENU_SELECT);            
00438 //          _navDB();
00439 //          _setupDBxim(dbHdl);
00440 //          mMSG_send(uiChildMsgQ, SYS_MSG_ID, SXIM_CREATE, XIMWIN_DB|dbHdl, SYS_FOREVER);  
00441 //          return S_DBMENU;
00442         }
00443         break;
00444         case KEY_SELECT:        
00445         {
00446             int     navRet;
00447             DB_ID   _id;
00448             int     _fldIdx;
00449             int     _actvItem;
00450             int     _fldEntry;
00451 
00452             mMENU_action(menu, MENU_SELECT);            
00453 
00454             // Save a copy of controls.
00455             _actvItem = DB_actvItem;
00456             _fldEntry = DB_fldEntry;
00457             _fldIdx   = DB_fldIdx;
00458             _id       = DB_id;
00459                                     
00460             navRet =_navDB();
00461             if( 0 == navRet )
00462             {
00463                 // No record available, restore the original DB controls.
00464                 DB_id       = _id;
00465                 DB_fldIdx   = _fldIdx;
00466                 DB_fldEntry = _fldEntry;
00467                 DB_actvItem = _actvItem;
00468                 _validateDB();
00469                 
00470                 UI_msgbxCreate(MSGBX_DBRECORDNA);
00471             }
00472             else if( -1 == navRet )
00473             {
00474                 mMENU_action(menu, MENU_CLOSE);
00475                 // Nav forward, save history on stack.
00476                 GEN_pushStack(_actvItem); // actvItem
00477                 GEN_pushStack(_fldEntry); // fldEntry
00478                 GEN_pushStack(_fldIdx); // fldIdx
00479                 GEN_pushStack(_id);
00480                 menu = mMENU_create((void*)&MENU_buf[0]);
00481             }
00482             else
00483             {
00484                 _setupDBxim(dbHdl);
00485                 mMSG_send(uiChildMsgQ, SYS_MSG_ID, SXIM_CREATE, XIMWIN_DB|dbHdl, SYS_FOREVER);  
00486             } 
00487             return S_DBMENU;
00488         }
00489         case KEY_BACK: return(_dbStateEnd());
00490             
00491         }
00492         break;
00493         
00494     case TMR_MSG_ID:
00495         switch(d1)
00496         {
00497             case TTXTSCROLL:
00498                 mMENU_action(menu, MENU_TXTSCROLL);
00499                 return S_DBMENU;
00500         
00501         }
00502         break;
00503     }
00504     
00505     MSG_send(uiParentMsgQ, msgIN, SYS_FOREVER);
00506     return S_DBMENU;
00507 }

Here is the call graph for this function:


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