Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | 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"
29
 
30
 
31
void run_clearcfg(void** firmware, void** app, int* size)
32
{
33
    remove("/.rockbox/config.cfg");
34
    memcpy(framebuf, bg, 320 * 240 * 3);
35
    message(97, "Rockbox configuration", "  has been cleared.  ");
36
}
37
 
38
void run_cleardb(void** firmware, void** app, int* size)
39
{
40
    remove("/.rockbox/database_0.tcd");
41
    remove("/.rockbox/database_1.tcd");
42
    remove("/.rockbox/database_2.tcd");
43
    remove("/.rockbox/database_3.tcd");
44
    remove("/.rockbox/database_4.tcd");
45
    remove("/.rockbox/database_5.tcd");
46
    remove("/.rockbox/database_6.tcd");
47
    remove("/.rockbox/database_7.tcd");
48
    remove("/.rockbox/database_8.tcd");
49
    remove("/.rockbox/database_9.tcd");
50
    remove("/.rockbox/database_idx.tcd");
51
    remove("/.rockbox/database_tmp.tcd");
52
    remove("/.rockbox/database_state.tcd");
53
    remove("/.rockbox/database_changelog.txt");
54
    memcpy(framebuf, bg, 320 * 240 * 3);
55
    message(109, "Rockbox  database", "has been cleared.");
56
}
57
 
58
static void fat32_progressbar_init(void* user, int max)
59
{
60
    progressbar_init((struct progressbar_state*)user,
61
                     15, 304, 135, 159, 0x77ff, 0xe8, 0x125f, 0, max);
62
}
63
 
64
static void fat32_progressbar_update(void* user, int current)
65
{
66
    progressbar_setpos((struct progressbar_state*)user, current, false);
67
}
68
 
69
void run_reformat(void** firmware, void** app, int* size)
70
{
71
    memcpy(framebuf, bg, 320 * 240 * 3);
72
    rendertext(framebuf, 70, 125, 320, 0xff7fffff, 0, "Reformatting data partition...");
73
    update_display(NULL);
74
    displaylcd(0, 0, 320, 240, framebuf, 0, 0, 320);
75
    struct emcorelib_header* libmkfat32 = loadlib(LIBMKFAT32_IDENTIFIER,
76
                                                  LIBMKFAT32_API_VERSION, "libmkf32");
77
    struct libmkfat32_api* mf32 = (struct libmkfat32_api*)libmkfat32->api;
78
    struct storage_info storageinfo;
79
    storage_get_info(0, &storageinfo);
80
    struct progressbar_state progressbar;
81
    int rc = mf32->mkfat32(0, 0, storageinfo.num_sectors, 4096, 1, "iPodClassic",
82
                           &progressbar, fat32_progressbar_init, fat32_progressbar_update);
83
    if (rc < 0) panicf(PANIC_KILLTHREAD, "Error formatting hard drive: %08X", rc);
84
    release_library(libmkfat32);
85
    library_unload(libmkfat32);
86
    memcpy(framebuf, bg, 320 * 240 * 3);
87
    message(106, "Data partition has", "been  reformatted.");
88
}