Subversion Repositories freemyipod

Rev

Rev 808 | Rev 833 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
808 theseven 1
//
2
//
3
//    Copyright 2011 TheSeven
4
//
5
//
6
//    This file is part of emCORE.
7
//
8
//    emCORE is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emCORE is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "emcoreapp.h"
25
#include "libmkfat32.h"
26
#include "tools.h"
27
#include "util.h"
28
#include "main.h"
830 theseven 29
#include "confirmchooser.h"
808 theseven 30
 
31
 
32
void run_clearcfg(void** firmware, void** app, int* size)
33
{
830 theseven 34
    if (!run_confirmchooser("Really clear Rockbox config?")) return;
808 theseven 35
    remove("/.rockbox/config.cfg");
36
    memcpy(framebuf, bg, 320 * 240 * 3);
37
    message(97, "Rockbox configuration", "  has been cleared.  ");
38
}
39
 
40
void run_cleardb(void** firmware, void** app, int* size)
41
{
830 theseven 42
    if (!run_confirmchooser("Really clear Rockbox database?")) return;
808 theseven 43
    remove("/.rockbox/database_0.tcd");
44
    remove("/.rockbox/database_1.tcd");
45
    remove("/.rockbox/database_2.tcd");
46
    remove("/.rockbox/database_3.tcd");
47
    remove("/.rockbox/database_4.tcd");
48
    remove("/.rockbox/database_5.tcd");
49
    remove("/.rockbox/database_6.tcd");
50
    remove("/.rockbox/database_7.tcd");
51
    remove("/.rockbox/database_8.tcd");
52
    remove("/.rockbox/database_9.tcd");
53
    remove("/.rockbox/database_idx.tcd");
54
    remove("/.rockbox/database_tmp.tcd");
55
    remove("/.rockbox/database_state.tcd");
56
    remove("/.rockbox/database_changelog.txt");
57
    memcpy(framebuf, bg, 320 * 240 * 3);
58
    message(109, "Rockbox  database", "has been cleared.");
59
}
60
 
61
static void fat32_progressbar_init(void* user, int max)
62
{
63
    progressbar_init((struct progressbar_state*)user,
64
                     15, 304, 135, 159, 0x77ff, 0xe8, 0x125f, 0, max);
65
}
66
 
67
static void fat32_progressbar_update(void* user, int current)
68
{
69
    progressbar_setpos((struct progressbar_state*)user, current, false);
70
}
71
 
72
void run_reformat(void** firmware, void** app, int* size)
73
{
830 theseven 74
    if (!run_confirmchooser("Really reformat data partition?")) return;
808 theseven 75
    memcpy(framebuf, bg, 320 * 240 * 3);
76
    rendertext(framebuf, 70, 125, 320, 0xff7fffff, 0, "Reformatting data partition...");
77
    update_display(NULL);
78
    displaylcd(0, 0, 320, 240, framebuf, 0, 0, 320);
79
    struct emcorelib_header* libmkfat32 = loadlib(LIBMKFAT32_IDENTIFIER,
80
                                                  LIBMKFAT32_API_VERSION, "libmkf32");
81
    struct libmkfat32_api* mf32 = (struct libmkfat32_api*)libmkfat32->api;
82
    struct storage_info storageinfo;
83
    storage_get_info(0, &storageinfo);
84
    struct progressbar_state progressbar;
85
    int rc = mf32->mkfat32(0, 0, storageinfo.num_sectors, 4096, 1, "iPodClassic",
86
                           &progressbar, fat32_progressbar_init, fat32_progressbar_update);
87
    if (rc < 0) panicf(PANIC_KILLTHREAD, "Error formatting hard drive: %08X", rc);
88
    release_library(libmkfat32);
89
    library_unload(libmkfat32);
90
    memcpy(framebuf, bg, 320 * 240 * 3);
91
    message(106, "Data partition has", "been  reformatted.");
92
}