################################
# VoiceOne Vo-tools Methods
#  
# @package voiceone_webservices
# @subpackage Moh
################################
###
# getMohDir: return AST_MOH_DIR
###
getMohDir () {
  echo "$AST_MOH_DIR";
}
###
# mohMakeSongsList: make a songs list in webservices's sandbox
###
mohMakeSongsList () {
  if [ -e $2/moh/songsList.txt ]; then
    rm -rf $2/moh/songsList.txt
  fi
  if [ -d "$AST_MOH_DIR/$1" ]; then
    if [ ! -d "$2/moh/" ]; then
         mkdir $2/moh
    fi
    ls -l $AST_MOH_DIR/$1 >> $2/moh/songsList.txt
   fi  
}
###
# mohSetSong: create a symbolic link in class folder
###
mohSetSong () {
  if [ ! -d "$AST_MOH_DIR/voiceone/$1" ]; then
    mkdir "$AST_MOH_DIR/voiceone/$1"
  fi
  if [ -e "$AST_MOH_DIR/voiceone/$2" ]; then
    ln -s "$AST_MOH_DIR/voiceone/$2" "$AST_MOH_DIR/voiceone/$1/$3"
  fi
}    
###
# mohDelFolder: delete a class folder
###
mohDelFolder () {
  if [ -d "$AST_MOH_DIR/voiceone/$1" ]; then
    rm -rf "$AST_MOH_DIR/voiceone/$1"
  fi
} 
###
# mohMoveSong: move an audio file from sandbox to moh/voiceone folder
###
mohMoveSong () {
  if [ -d "$AST_MOH_DIR/voiceone" ]; then
    cp "$1" "$AST_MOH_DIR/voiceone/$2"
  fi
} 
###
# mohDelSong: delete an audio file and its symbolic links
###
mohDelSong () {
  if [ -e "$AST_MOH_DIR/voiceone/$1" ]; then
    rm -f "$AST_MOH_DIR/voiceone/$1"
    if [ $(find /var/lib/asterisk/mohmp3/voiceone/ -lname "$1" -o -lname "*/$1" | wc -l) -ne "0" ]; then
      rm `find /var/lib/asterisk/mohmp3/voiceone/ -lname "$1" -o -lname "*/$1"`
    fi
  fi
}
