summaryrefslogtreecommitdiff
path: root/apps/codecs/SOURCES
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2006-08-28 22:03:16 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2006-08-28 22:03:16 +0000
commit65c2c58b3aa26164bd919665e4d710efa2fa7c79 (patch)
tree49e07980a0ab655331632beeec02b39118dc1bb1 /apps/codecs/SOURCES
parent5ec380514baacbbdaf7ed022f2a5a1c82bafd0d5 (diff)
downloadrockbox-65c2c58b3aa26164bd919665e4d710efa2fa7c79.zip
rockbox-65c2c58b3aa26164bd919665e4d710efa2fa7c79.tar.gz
rockbox-65c2c58b3aa26164bd919665e4d710efa2fa7c79.tar.bz2
rockbox-65c2c58b3aa26164bd919665e4d710efa2fa7c79.tar.xz
Improve the quick start section a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10788 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/SOURCES')
0 files changed, 0 insertions, 0 deletions
id='n131' href='#n131'>131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2005 Jonas Haggqvist
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#include "plugin.h"
#include "lib/pluginlib_actions.h"


static int files, dirs, audiofiles, m3ufiles, imagefiles, videofiles, largestdir;
static int lasttick;
static bool cancel;


/* we use PLA */
#define STATS_STOP PLA_EXIT
#define STATS_STOP2 PLA_CANCEL
/* this set the context to use with PLA */
static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };

/* we don't have yet a filetype attribute for image files */
static const char *image_exts[] = {"bmp","jpg","jpe","jpeg","png","ppm"};

/* neither for video ones */
static const char *video_exts[] = {"mpg","mpeg","mpv","m2v"};

static void prn(const char *str, int y)
{
    rb->lcd_puts(0,y,str);
#ifdef HAVE_REMOTE_LCD
    rb->lcd_remote_puts(0,y,str);
#endif
}

static void update_screen(void)
{
    char buf[32];

    rb->lcd_clear_display();
#ifdef HAVE_REMOTE_LCD
    rb->lcd_remote_clear_display();
#endif

#ifdef HAVE_LCD_BITMAP
    rb->snprintf(buf, sizeof(buf), "Total Files: %d", files);
    prn(buf,0);
    rb->snprintf(buf, sizeof(buf), "Audio: %d", audiofiles);
    prn(buf,1);
    rb->snprintf(buf, sizeof(buf), "Playlists: %d", m3ufiles);
    prn(buf,2);
    rb->snprintf(buf, sizeof(buf), "Images: %d", imagefiles);
    prn(buf,3);
    rb->snprintf(buf, sizeof(buf), "Videos: %d", videofiles);
    prn(buf,4);
    rb->snprintf(buf, sizeof(buf), "Directories: %d", dirs);
    prn(buf,5);
    rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d", largestdir);
    prn(buf,6);
#else
    rb->snprintf(buf, sizeof(buf), "Files:%5d", files);
    prn(buf,0);
    rb->snprintf(buf, sizeof(buf), "Dirs: %5d", dirs);
    prn(buf,1);
#endif

    rb->lcd_update();
#ifdef HAVE_REMOTE_LCD
    rb->lcd_remote_update();
#endif
}

static void traversedir(char* location, char* name)
{
    int button;
    struct dirent *entry;
    DIR* dir;
    char fullpath[MAX_PATH];
    int files_in_dir = 0;

    rb->snprintf(fullpath, sizeof(fullpath), "%s/%s", location, name);
    dir = rb->opendir(fullpath);
    if (dir) {
        entry = rb->readdir(dir);
        while (entry) {
            if (cancel)
                break;
            /* Skip .. and . */
            if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, ".."))
            {
                struct dirinfo info = rb->dir_get_info(dir, entry);
                if (info.attribute & ATTR_DIRECTORY) {
                    traversedir(fullpath, entry->d_name);
                    dirs++;
                }
                else {
                    files_in_dir++; files++;

                    /* get the filetype from the filename */
                    int attr = rb->filetype_get_attr(entry->d_name);
                    switch (attr & FILE_ATTR_MASK)
                    {
                    case FILE_ATTR_AUDIO:
                        audiofiles++;
                        break;

                    case FILE_ATTR_M3U:
                        m3ufiles++;
                        break;
 
                    default:
                    {
                        /* use hardcoded filetype_exts to count
                         * image and video files until we get
                         * new attributes added to filetypes.h */
                        char *ptr = rb->strrchr(entry->d_name,'.');
                        if(ptr) {
                            unsigned i;
                            ptr++;
                            for(i=0;i<ARRAYLEN(image_exts);i++) {
                                if(!rb->strcasecmp(ptr,image_exts[i])) {
                                    imagefiles++; break;
                                }
                            }

                            if (i >= ARRAYLEN(image_exts)) {
                                /* not found above - try video files */
                                for(i=0;i<ARRAYLEN(video_exts);i++) {
                                    if(!rb->strcasecmp(ptr,video_exts[i])) {
                                        videofiles++; break;