Changeset 885

Show
Ignore:
Timestamp:
07/26/08 16:41:51 (4 months ago)
Author:
michux
Message:

added command functions

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugin_mpd.c

    r864 r885  
    5757 *               -> uses less ressources 
    5858 * 
    59  * changelog v0.8 (30.01.2007): 
     59 * changelog v0.8 (30.01.2008): 
    6060 *  changed:  -libmpd is not needed anymore, use libmpdclient.c instead 
    6161 *  fixed:    -getMpdUptime() 
     
    6464 *  added:    -mpd::getSamplerateHz 
    6565 *            -getAudioChannels 
     66 * 
     67 * changelog v0.83 (26.07.2008): 
     68 *  added:    -mpd::cmd* commands 
     69 * 
    6670 */ 
    6771 
     
    529533 
    530534 
     535static void nextSong() 
     536{ 
     537    mpd_update(); 
     538    if (currentSong != NULL) { 
     539  mpd_sendNextCommand(conn); 
     540  mpd_finishCommand(conn); 
     541  if (conn->error) { 
     542      error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     543  } 
     544    } 
     545} 
     546 
     547static void prevSong() 
     548{ 
     549    mpd_update(); 
     550    if (currentSong != NULL) { 
     551        mpd_sendPrevCommand(conn); 
     552  mpd_finishCommand(conn); 
     553        if (conn->error) { 
     554          error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     555  } 
     556    } 
     557} 
     558 
     559static void stopSong() 
     560{ 
     561    mpd_update(); 
     562    if (currentSong != NULL) { 
     563  mpd_sendStopCommand(conn); 
     564        mpd_finishCommand(conn); 
     565  if (conn->error) { 
     566      error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     567  } 
     568    } 
     569} 
     570 
     571static void pauseSong() 
     572{ 
     573    mpd_update(); 
     574    if (currentSong != NULL) { 
     575  if (l_state == MPD_STATUS_STATE_PAUSE) { 
     576      mpd_sendPauseCommand(conn, 0); 
     577  } else { 
     578      mpd_sendPauseCommand(conn, 1); 
     579  } 
     580           
     581        mpd_finishCommand(conn); 
     582  if (conn->error) { 
     583      error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     584  } 
     585    } 
     586} 
     587 
     588static void volUp() 
     589{ 
     590    mpd_update(); 
     591    if (currentSong != NULL) { 
     592  l_volume += 5; 
     593  if (l_volume > 100)  
     594      l_volume=100; 
     595  mpd_sendSetvolCommand(conn, l_volume); 
     596        mpd_finishCommand(conn); 
     597  if (conn->error) { 
     598      error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     599  } 
     600    } 
     601} 
     602 
     603static void volDown() 
     604{ 
     605    mpd_update(); 
     606    if (currentSong != NULL) { 
     607  if (l_volume > 5)  
     608      l_volume -= 5; 
     609  else 
     610      l_volume = 0; 
     611  mpd_sendSetvolCommand(conn, l_volume); 
     612        mpd_finishCommand(conn); 
     613  if (conn->error) { 
     614      error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     615  } 
     616    } 
     617} 
     618 
     619static void toggleRepeat() 
     620{ 
     621    mpd_update(); 
     622    if (currentSong != NULL) { 
     623     
     624  l_repeatEnabled = !l_repeatEnabled; 
     625  mpd_sendRepeatCommand(conn, l_repeatEnabled); 
     626           
     627        mpd_finishCommand(conn); 
     628  if (conn->error) { 
     629      error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     630  } 
     631    } 
     632} 
     633 
     634 
     635static void toggleRandom() 
     636{ 
     637    mpd_update(); 
     638    if (currentSong != NULL) { 
     639     
     640  l_randomEnabled = !l_randomEnabled; 
     641  mpd_sendRandomCommand(conn, l_randomEnabled); 
     642           
     643        mpd_finishCommand(conn); 
     644  if (conn->error) { 
     645      error("[MPD] error mpd_finishCommand: %s", conn->errorStr); 
     646  } 
     647    } 
     648} 
     649 
    531650 
    532651static void formatTimeMMSS(RESULT * result, RESULT * param) 
     
    574693{ 
    575694    int check; 
    576     debug("[MPD] v0.82, check lcd4linux configuration file..."); 
     695    debug("[MPD] v0.83, check lcd4linux configuration file..."); 
    577696 
    578697    check = configure_mpd(); 
     
    609728    AddFunction("mpd::getMpdPlaylistGetCurrentId", 0, getCurrentSongPos); 
    610729 
     730    AddFunction("mpd::cmdNextSong", 0, nextSong); 
     731    AddFunction("mpd::cmdPrevSong", 0, prevSong); 
     732    AddFunction("mpd::cmdStopSong", 0, stopSong); 
     733    AddFunction("mpd::cmdTogglePauseSong", 0, pauseSong); 
     734    AddFunction("mpd::cmdVolUp", 0, volUp); 
     735    AddFunction("mpd::cmdVolDown", 0, volDown); 
     736    AddFunction("mpd::cmdToggleRandom", 0, toggleRandom); 
     737    AddFunction("mpd::cmdToggleRepeat", 0, toggleRepeat); 
     738     
    611739    AddFunction("mpd::formatTimeMMSS", 1, formatTimeMMSS); 
    612740    AddFunction("mpd::formatTimeDDHHMM", 1, formatTimeDDHHMM);