0
  "   ˆl–Ü4ý(&ÔËm
�ÆŸ¸ÓêbÑ¿ÄƒtÂÁ •    # gnokii(1) completion                                     -*- shell-script -*-

_gnokii_memory_type()
{
    # TODO: reduce the number of choices
    COMPREPLY=($(compgen -W "IN OU SM ME MT" -- "$cur"))
}

_gnokii()
{
    local cur prev words cword pprev tprev fprev
    _init_completion || return

    case $prev in
        --config)
            _filedir
            return
            ;;
        --phone)
            local config_file
            for config_file in "$XDG_CONFIG_HOME/gnokii/config" \
                "$HOME/.config/gnokii/config" "$HOME/.gnokiirc" \
                "$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc; do
                [[ -f $config_file ]] && break
            done
            [[ ! -f $config_file ]] && return
            COMPREPLY=($(compgen -W \
                "$(command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \
                -- "$cur"))
            return
            ;;
        --help)
            COMPREPLY=($(compgen -W 'all monitor sms mms phonebook calendar
                todo dial profile settings wap logo ringtone security file
                other' -- "$cur"))
            return
            ;;
        --version | --shell | ping)
            return
            ;;

        # MONITOR
        --monitor)
            COMPREPLY=($(compgen -W 'delay once' -- "$cur"))
            return
            ;;
        --getdisplaystatus | --displayoutput)
            return
            ;;
        --netmonitor)
            COMPREPLY=($(compgen -W 'reset off field devel next nr' \
                -- "$cur"))
            return
            ;;

        # SMS
        --sendsms)
            # (how)TODO ?
            return
            ;;
        --savesms)
            COMPREPLY=($(compgen -W '--sender --smsc --smscno --folder
                --location --sent --read --deliver --datetime' -- "$cur"))
            return
            ;;
        --memory-type | --memory | --getsms | --deletesms | --getmms | --deletemms | \
            --getphonebook | --deletephonebook)
            _gnokii_memory_type
            return
            ;;
        --getsmsc | --getcalendarnote | --deletecalendarnote | --gettodo | \
            --getspeeddial)
            # TODO: grab a specific entry ID
            return
            ;;
        --setsmsc | --smsreader | --createsmsfolder | --deletealltodos | \
            --showsmsfolderstatus)
            return
            ;;
        --deletesmsfolder | --folder)
            # TODO: folderid
            return
            ;;
        --writephonebook)
            COMPREPLY=($(compgen -W '--overwrite --find-free --memory-type
                --location --vcard --ldif' -- "$cur"))
            return
            ;;
        --writecalendarnote | --writetodo)
            _filedir vcf
            return
            ;;

        # DIAL
        --setspeeddial | --dialvoice | --senddtmf | --answercall | --hangup)
            # TODO
            return
            ;;
        --divert)
            COMPREPLY=($(compgen -W '--op' -- "$cur"))
            return
            ;;

        # PROFILE
        --getprofile | --setactiveprofile)
            # TODO
            return
            ;;
        --setprofile | --getactiveprofile)
            return
            ;;

        # SETTINGS
        --reset)
            COMPREPLY=($(compgen -W 'soft hard' -- "$cur"))
            return
            ;;
        --setdatetime | --setalarm)
            # TODO
            return
            ;;
        --getdatetime | --getalarm)
            return
            ;;

        # WAP
        --getwapbookmark | --writewapbookmark | --deletewapbookmark | \
            --getwapsetting | --writewapsetting | --activatewapsetting)
            return
            ;;

        # LOGOS
        --sendlogo)
            COMPREPLY=($(compgen -W 'caller op picture' -- "$cur"))
            return
            ;;
        --setlogo | --getlogo)
            COMPREPLY=($(compgen -W 'op startup caller dealer text' \
                -- "$cur"))
            return
            ;;
