void show_nandroid_restore_menu()
{
    const char* sdcard_path;
    char* backup_path[PATH_MAX];

    if (target_sdcard == TARGET_INTERNAL_SDCARD) {
        sdcard_path = INTERNAL_SDCARD_PATH;
    } else {
        sdcard_path = EXTERNAL_SDCARD_PATH;
    }

    if (ensure_path_mounted(sdcard_path) != 0) {
        LOGE ("Can't mount %s\n", sdcard_path);
        return;
    }

    static char* headers[] = {  "Choose an image to restore",
                                "",
                                NULL
    };

    sprintf(backup_path, "%s/clockworkmod/backup/", sdcard_path);
    char* file = choose_file_menu(backup_path, NULL, headers);
    if (file == NULL)
        return;

    if (confirm_selection("Confirm restore?", "Yes - Restore"))
        nandroid_restore(file, 1, 1, 1, 1, 1, 0);
}
void show_nandroid_restore_menu(const char* volume)
{
    if (ensure_path_mounted(volume) != 0) {
        LOGE ("Can't mount %s\n", volume);
        return;
    }

    int restore_webtop = 1;
    static char* headers[] = {  "Choose an image to restore",
                                "",
                                NULL
    };

    char backup_path[PATH_MAX];
    sprintf(backup_path, "%s/clockworkmod/backup/", volume);
    char* file = choose_file_menu(backup_path, NULL, headers);
    if (file == NULL)
        return;

#ifdef BOARD_HAS_WEBTOP
    static char* header[] = {  "Include webtop in restore?",
                               "",
                               NULL
    };

    static char* list[] = {  "Yes",
                             "No",
                             NULL
    };

    switch (get_menu_selection(header, list, 0, 0))
    {
        case 0:
            restore_webtop = 1;
            break;
        case 1:
            restore_webtop = 0;
            break;
        default:
            return;
    }
#endif

    if (confirm_selection("Confirm restore?", "Yes - Restore"))
        nandroid_restore(file, 1, 1, 1, 1, restore_webtop, 0, restore_webtop, 0);
}
void show_nandroid_restore_menu()
{
    if (ensure_path_mounted("/sdcard") != 0) {
        LOGE ("Can't mount /sdcard\n");
        return;
    }

    static char* headers[] = {  "Choose an image to restore",
                                "",
                                NULL
    };

    char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, headers);
    if (file == NULL)
        return;

    if (confirm_selection("Confirm restore?", "Yes - Restore"))
        nandroid_restore(file, 1, 1, 1, 1, 1, 0);
}
void show_choose_zip_menu(const char *mount_point)
{
    if (ensure_path_mounted(mount_point) != 0) {
        LOGE ("Can't mount %s\n", mount_point);
        return;
    }

    static char* headers[] = {  "Choose a zip to apply",
                                "",
                                NULL
    };

    char* file = choose_file_menu(mount_point, ".zip", headers);
    if (file == NULL)
        return;
    static char* confirm_install  = "Confirm install?";
    static char confirm[PATH_MAX];
    sprintf(confirm, "Yes - Install %s", basename(file));
    if (confirm_selection(confirm_install, confirm))
        install_zip(file);
}
void show_nandroid_restore_menu(const char* path)
{
    if (ensure_path_mounted(path) != 0) {
        LOGE("Can't mount %s\n", path);
        return;
    }

    static char* headers[] = {  "Choose an image to restore",
                                "",
                                NULL
    };

    char tmp[PATH_MAX];
    sprintf(tmp, "%s/clockworkmod/backup/", path);
    char* file = choose_file_menu(tmp, NULL, headers);
    if (file == NULL)
        return;

    if (confirm_selection("Confirm restore?", "Yes - Restore"))
        nandroid_restore(file, 1, 1, 1, 1, 1, 0);
}
void show_nandroid_restore_menu(const char* path)
{
    if (ensure_path_mounted(path) != 0) {
        LOGE("无法挂载 %s\n", path);
        return;
    }

    static char* headers[] = {  "选择恢复镜像",
                                "",
                                NULL
    };

    char tmp[PATH_MAX];
    sprintf(tmp, "%s/clockworkmod/backup/", path);
    char* file = choose_file_menu(tmp, NULL, headers);
    if (file == NULL)
        return;

    if (confirm_selection("确认恢复?", "是 - 恢复"))
        nandroid_restore(file, 1, 1, 1, 1, 1, 0);
}
void show_choose_zip_menu(const char *mount_point)
{
    if (ensure_path_mounted(mount_point) != 0) {
        LOGE ("无法挂载 %s\n", mount_point);
        return;
    }

    static char* headers[] = {  "选择一个ZIP格式刷机包",
                                "",
                                NULL
    };

    char* file = choose_file_menu(mount_point, ".zip", headers);
    if (file == NULL)
        return;
    static char* confirm_install  = "确认安装?";
    static char confirm[PATH_MAX];
    sprintf(confirm, "是-刷入%s", basename(file));
    if (confirm_selection(confirm_install, confirm))
        install_zip(file);
}
void show_nandroid_delete_menu(const char* path)
{
    if (ensure_path_mounted(path) != 0) {
        LOGE("无法挂载 %s\n", path);
        return;
    }

    static char* headers[] = {  "选择删除镜像",
                                "",
                                NULL
    };

    char tmp[PATH_MAX];
    sprintf(tmp, "%s/clockworkmod/backup/", path);
    char* file = choose_file_menu(tmp, NULL, headers);
    if (file == NULL)
        return;

    if (confirm_selection("确认删除?", "是 - 删除")) {
        // nandroid_restore(file, 1, 1, 1, 1, 1, 0);
        sprintf(tmp, "rm -rf %s", file);
        __system(tmp);
    }
}
void show_choose_zip_menu()
{
    if (ensure_root_path_mounted("SDCARD:") != 0) {
        LOGE ("Can't mount /sdcard\n");
        return;
    }

    static char* headers[] = {  "Choose a zip to apply",
                                "",
                                NULL 
    };
    
    char* file = choose_file_menu("/sdcard/", ".zip", headers);
    if (file == NULL)
        return;
    char sdcard_package_file[1024];
    strcpy(sdcard_package_file, "SDCARD:");
    strcat(sdcard_package_file,  file + strlen("/sdcard/"));
    static char* confirm_install  = "Confirm install?";
    static char confirm[PATH_MAX];
    sprintf(confirm, "Yes - Install %s", basename(file));
    if (confirm_selection(confirm_install, confirm))
        install_zip(sdcard_package_file);
}
void show_nandroid_advanced_restore_menu(const char* path)
{
    if (ensure_path_mounted(path) != 0) {
        LOGE ("Can't mount sdcard\n");
        return;
    }

    static char* advancedheaders[] = {  "Choose an image to restore",
                                "",
                                "Choose an image to restore",
                                "first. The next menu will",
                                "show you more options.",
                                "",
                                NULL
    };

    char tmp[PATH_MAX];
    sprintf(tmp, "%s/clockworkmod/backup/", path);
    char* file = choose_file_menu(tmp, NULL, advancedheaders);
    if (file == NULL)
        return;

    static char* headers[] = {  "Advanced Restore",
                                "",
                                NULL
    };

    static char* list[] = { "Restore boot",
                            "Restore system",
                            "Restore data",
                            "Restore cache",
                            "Restore sd-ext",
                            "Restore wimax",
                            NULL
    };
    
    if (0 != get_partition_device("wimax", tmp)) {
        // disable wimax restore option
        list[5] = NULL;
    }

    static char* confirm_restore  = "Confirm restore?";

    int chosen_item = get_menu_selection(headers, list, 0, 0);
    switch (chosen_item)
    {
        case 0:
            if (confirm_selection(confirm_restore, "Yes - Restore boot"))
                nandroid_restore(file, 1, 0, 0, 0, 0, 0);
            break;
        case 1:
            if (confirm_selection(confirm_restore, "Yes - Restore system"))
                nandroid_restore(file, 0, 1, 0, 0, 0, 0);
            break;
        case 2:
            if (confirm_selection(confirm_restore, "Yes - Restore data"))
                nandroid_restore(file, 0, 0, 1, 0, 0, 0);
            break;
        case 3:
            if (confirm_selection(confirm_restore, "Yes - Restore cache"))
                nandroid_restore(file, 0, 0, 0, 1, 0, 0);
            break;
        case 4:
            if (confirm_selection(confirm_restore, "Yes - Restore sd-ext"))
                nandroid_restore(file, 0, 0, 0, 0, 1, 0);
            break;
        case 5:
            if (confirm_selection(confirm_restore, "Yes - Restore wimax"))
                nandroid_restore(file, 0, 0, 0, 0, 0, 1);
            break;
    }
}
void show_nandroid_advanced_restore_menu()
{
    const char* sdcard_path;
    char* backup_path[PATH_MAX];

    if (target_sdcard == TARGET_INTERNAL_SDCARD) {
        sdcard_path = INTERNAL_SDCARD_PATH;
    } else {
        sdcard_path = EXTERNAL_SDCARD_PATH;
    }

    if (ensure_path_mounted(sdcard_path) != 0) {
        LOGE ("Can't mount %s\n", sdcard_path);
        return;
    }

    static char* advancedheaders[] = {  "Choose an image to restore",
                                "",
                                "Choose an image to restore",
                                "first. The next menu will",
                                "you more options.",
                                "",
                                NULL
    };

    sprintf(backup_path, "%s/clockworkmod/backup/", sdcard_path);
    char* file = choose_file_menu(backup_path, NULL, advancedheaders);
    if (file == NULL)
        return;

    static char* headers[] = {  "Nandroid Advanced Restore",
                                "",
                                NULL
    };

    static char* list[] = { "Restore boot",
                            "Restore system",
                            "Restore data",
                            "Restore cache",
#ifdef RECOVERY_HAVE_SD_EXT
                            "Restore sd-ext",
#endif
                            "Restore wimax",
                            NULL
    };
    
    char tmp[PATH_MAX];
    if (0 != get_partition_device("wimax", tmp)) {
        // disable wimax restore option
        list[5] = NULL;
    }

    static char* confirm_restore  = "Confirm restore?";

    int chosen_item = get_menu_selection(headers, list, 0, 0);
    switch (chosen_item)
    {
        case 0:
            if (confirm_selection(confirm_restore, "Yes - Restore boot"))
                nandroid_restore(file, 1, 0, 0, 0, 0, 0);
            break;
        case 1:
            if (confirm_selection(confirm_restore, "Yes - Restore system"))
                nandroid_restore(file, 0, 1, 0, 0, 0, 0);
            break;
        case 2:
            if (confirm_selection(confirm_restore, "Yes - Restore data"))
                nandroid_restore(file, 0, 0, 1, 0, 0, 0);
            break;
        case 3:
            if (confirm_selection(confirm_restore, "Yes - Restore cache"))
                nandroid_restore(file, 0, 0, 0, 1, 0, 0);
            break;
#ifdef RECOVERY_HAVE_SD_EXT
        case 4:
            if (confirm_selection(confirm_restore, "Yes - Restore sd-ext"))
                nandroid_restore(file, 0, 0, 0, 0, 1, 0);
            break;
        case 5:
#else
		case 4:
#endif
            if (confirm_selection(confirm_restore, "Yes - Restore wimax"))
                nandroid_restore(file, 0, 0, 0, 0, 0, 1);
            break;
    }
}
void show_nandroid_advanced_restore_menu(const char* path)
{
    if (ensure_path_mounted(path) != 0) {
        LOGE ("无法挂载 sdcard\n");
        return;
    }

    static char* advancedheaders[] = {  "选择恢复镜像",
                                "",
                                "先选择一个需要恢复的镜像",
                                "下级菜单",
                                "将会显示更多选项",
                                "",
                                NULL
    };

    char tmp[PATH_MAX];
    sprintf(tmp, "%s/clockworkmod/backup/", path);
    char* file = choose_file_menu(tmp, NULL, advancedheaders);
    if (file == NULL)
        return;

    static char* headers[] = {  "高级恢复",
                                "",
                                NULL
    };

    static char* list[] = { "恢复 boot",
                            "恢复 system",
                            "恢复 data",
                            "恢复 cache",
                            "恢复 sd-ext",
                            "恢复 wimax",
                            NULL
    };
    
    if (0 != get_partition_device("wimax", tmp)) {
        // disable wimax restore option
        list[5] = NULL;
    }

    static char* confirm_restore  = "确认恢复?";

    int chosen_item = get_menu_selection(headers, list, 0, 0);
    switch (chosen_item)
    {
        case 0:
            if (confirm_selection(confirm_restore, "是 - 恢复 boot"))
                nandroid_restore(file, 1, 0, 0, 0, 0, 0);
            break;
        case 1:
            if (confirm_selection(confirm_restore, "是 - 恢复 system"))
                nandroid_restore(file, 0, 1, 0, 0, 0, 0);
            break;
        case 2:
            if (confirm_selection(confirm_restore, "是 - 恢复 data"))
                nandroid_restore(file, 0, 0, 1, 0, 0, 0);
            break;
        case 3:
            if (confirm_selection(confirm_restore, "是 - 恢复 cache"))
                nandroid_restore(file, 0, 0, 0, 1, 0, 0);
            break;
        case 4:
            if (confirm_selection(confirm_restore, "是 - 恢复 sd-ext"))
                nandroid_restore(file, 0, 0, 0, 0, 1, 0);
            break;
        case 5:
            if (confirm_selection(confirm_restore, "是 - 恢复 wimax"))
                nandroid_restore(file, 0, 0, 0, 0, 0, 1);
            break;
    }
}
// pass in NULL for fileExtensionOrDirectory and you will get a directory chooser
char* choose_file_menu(const char* directory, const char* fileExtensionOrDirectory, const char* headers[])
{
    char path[PATH_MAX] = "";
    DIR *dir;
    struct dirent *de;
    int numFiles = 0;
    int numDirs = 0;
    int i;
    char* return_value = NULL;
    int dir_len = strlen(directory);

    i = 0;
    while (headers[i]) {
        i++;
    }
    const char** fixed_headers = (const char*)malloc((i + 3) * sizeof(char*));
    i = 0;
    while (headers[i]) {
        fixed_headers[i] = headers[i];
        i++;
    }
    fixed_headers[i] = directory;
    fixed_headers[i + 1] = "";
    fixed_headers[i + 2 ] = NULL;

    char** files = gather_files(directory, fileExtensionOrDirectory, &numFiles);
    char** dirs = NULL;
    if (fileExtensionOrDirectory != NULL)
        dirs = gather_files(directory, NULL, &numDirs);
    int total = numDirs + numFiles;
    if (total == 0)
    {
        ui_print("No files found.\n");
    }
    else
    {
        char** list = (char**) malloc((total + 1) * sizeof(char*));
        list[total] = NULL;


        for (i = 0 ; i < numDirs; i++)
        {
            list[i] = strdup(dirs[i] + dir_len);
        }

        for (i = 0 ; i < numFiles; i++)
        {
            list[numDirs + i] = strdup(files[i] + dir_len);
        }

        for (;;)
        {
            int chosen_item = get_menu_selection(fixed_headers, list, 0, 0);
            if (chosen_item == GO_BACK)
                break;
            static char ret[PATH_MAX];
            if (chosen_item < numDirs)
            {
                char* subret = choose_file_menu(dirs[chosen_item], fileExtensionOrDirectory, headers);
                if (subret != NULL)
                {
                    strcpy(ret, subret);
                    return_value = ret;
                    break;
                }
                continue;
            }
            strcpy(ret, files[chosen_item - numDirs]);
            return_value = ret;
            break;
        }
        free_string_array(list);
    }

    free_string_array(files);
    free_string_array(dirs);
    free(fixed_headers);
    return return_value;
}
Exemple #14
0
void choose_file_menu(char* sdpath) {
    static char* headers[] = { "Choose item or press POWER to return",
			       "",
			       NULL };
    
    char path[PATH_MAX] = "";
    DIR *dir;
    struct dirent *de;
    int total = 0;
	int ftotal = 0;
	int dtotal = 0;
	int i;
	int j;
    char** flist;
	char** dlist;
    char** list; 
    if (ensure_root_path_mounted("SDCARD:") != 0) {
	LOGE ("Can't mount /sdcard\n");
	return;
    }

    dir = opendir(sdpath);
    if (dir == NULL) {
		LOGE("Couldn't open directory");
		LOGE("Please make sure it exists!");
		return;
    }
    //count the number of valid files:
    while ((de=readdir(dir)) != NULL) {
		if (de->d_type == DT_DIR && strcmp(de->d_name,".") != 0 && strcmp(de->d_name,"nandroid") != 0) {
				dtotal++;
		} else {
			if (strcmp(de->d_name+strlen(de->d_name)-4,".zip")==0) {
				ftotal++;
			}
			if (strcmp(de->d_name+strlen(de->d_name)-4,".tar")==0) {
				ftotal++;
			}
			if (strcmp(de->d_name+strlen(de->d_name)-4,".tgz")==0) {
				ftotal++;
			}
			if (strcmp(de->d_name+strlen(de->d_name)-7,"rec.img")==0) {
				ftotal++;
			}
			if (strcmp(de->d_name+strlen(de->d_name)-8,"boot.img")==0) {
				ftotal++;
			}
		}
	}
	total = ftotal + dtotal;
    if (total==0) {
		ui_print("\nNo valid files found!\n");
    } else {
		flist = (char**) malloc((ftotal+1)*sizeof(char*));
		flist[ftotal]=NULL;

		dlist = (char**) malloc((dtotal+1)*sizeof(char*));
		dlist[dtotal]=NULL;

		list = (char**) malloc((total+1)*sizeof(char*));
		list[total]=NULL;
	
		rewinddir(dir);

		i = 0; //dir iterator
		j = 0; //file iterator
		while ((de = readdir(dir)) != NULL) {
			//create dirs list
			if (de->d_type == DT_DIR && strcmp(de->d_name,".") != 0 && strcmp(de->d_name,"nandroid") != 0) {
				dlist[i] = (char*) malloc(strlen(sdpath)+strlen(de->d_name)+1);
				strcpy(dlist[i], sdpath);
				strcat(dlist[i], de->d_name);
				dlist[i] = (char*) malloc(strlen(de->d_name)+2); //need one extra byte for the termnitaing char
				strcat(de->d_name, "/\0"); //add "/" followed by terminating character since these are dirs
				strcpy(dlist[i], de->d_name);				
					i++;				
			}
			//create files list
			if ((de->d_type == DT_REG && (strcmp(de->d_name+strlen(de->d_name)-4,".zip")==0 || strcmp(de->d_name+strlen(de->d_name)-4,".tar")==0 || strcmp(de->d_name+strlen(de->d_name)-4,".tgz")==0 || strcmp(de->d_name+strlen(de->d_name)-7,"rec.img")==0 || strcmp(de->d_name+strlen(de->d_name)-8,"boot.img")==0))) {			
				flist[j] = (char*) malloc(strlen(sdpath)+strlen(de->d_name)+1);
				strcpy(flist[j], sdpath);
				strcat(flist[j], de->d_name);
				flist[j] = (char*) malloc(strlen(de->d_name)+1);
				strcpy(flist[j], de->d_name);				
					j++;		
			}
		}
		
		

		if (closedir(dir) <0) {
			LOGE("Failure closing directory\n");
			return;
		}
		//sort lists
		sortlist(flist, ftotal);
		sortlist(dlist, dtotal);
		
		//join the file and dir list, with dirs on top - thanks cvpcs
		i = 0;
		j = 0;
		int k;
		for(k = 0; k < total; k++) {
			if(i < dtotal) {
				list[k] = strdup(dlist[i++]);
			} else {
				list[k] = strdup(flist[j++]);
			}
		}
		
		int chosen_item = -1;
		while (chosen_item < 0) {
			chosen_item = get_menu_selection(headers, list, 1, chosen_item<0?0:chosen_item);
			if (chosen_item >= 0 && chosen_item != ITEM_BACK ) {
			
				char install_string[PATH_MAX]; //create real path from selection
				strcpy(install_string, sdpath);
				strcat(install_string, list[chosen_item]);
				
				if (opendir(install_string) == NULL) { //handle selection
					preinstall_menu(install_string);
				} else {						
					choose_file_menu(install_string);					
				}
				if (ui_key_pressed(32)) { //D = 32
					remove(install_string);
					ui_print(install_string);
					ui_print(" removed.");
					choose_file_menu(sdpath);
				}
			}
		} 
	}
}
void show_nandroid_advanced_restore_menu(const char* volume)
{
    if (ensure_path_mounted(volume) != 0) {
        LOGE ("Can't mount %s\n", volume);
        return;
    }

    static char* advancedheaders[] = {  "Choose an image to restore",
                                "",
                                "Choose an image to restore",
                                "first. The next menu will",
                                "give you more options.",
                                "",
                                NULL
    };

    char backup_path[PATH_MAX];
    sprintf(backup_path, "%s/clockworkmod/backup/", volume);
    char* file = choose_file_menu(backup_path, NULL, advancedheaders);
    if (file == NULL)
        return;

    static char* headers[] = {  "Nandroid Advanced Restore",
                                "",
                                NULL
    };

    char* list[] = { "Restore boot",
                     "Restore system",
                     "Restore data",
                     "Restore cache",
                     "Restore sd-ext",
                     "Restore wimax",
                     "Restore webtop",
                     "Restore PDS",
                     NULL
    };
    int num_menu_items = 8;
    int webtop = 6, pds = 7;
    int webtop_offset = 0, pds_offset = 0;
    int i;

    char tmp[PATH_MAX];
    if (0 != get_partition_device("wimax", tmp)) {
        // disable wimax restore option
        list[5] = NULL;
        webtop_offset--;
        pds_offset--;
    }
    if (volume_for_path("/osh") == NULL) {
        // disable webtop restore option
        list[6] = NULL;
        pds_offset--;
    }
    if (volume_for_path("/pds") == NULL) {
        // disable PDS restore option
        list[7] = NULL;
    }
    for (i = 5; i < num_menu_items; i++)
        if ((list[i] == NULL) && (list[i+1] != NULL)) {
            list[i] = list[i+1];
            list[i+1] = NULL;
        }

    static char* confirm_restore  = "Confirm restore?";

    int chosen_item = get_menu_selection(headers, list, 0, 0);
    if ((chosen_item >= 0) && (chosen_item <= 4)) {
        switch (chosen_item)
        {
            case 0:
                if (confirm_selection(confirm_restore, "Yes - Restore boot"))
                    nandroid_restore(file, 1, 0, 0, 0, 0, 0, 0, 0);
                break;
            case 1:
                if (confirm_selection(confirm_restore, "Yes - Restore system"))
                    nandroid_restore(file, 0, 1, 0, 0, 0, 0, 0, 0);
                break;
            case 2:
                if (confirm_selection(confirm_restore, "Yes - Restore data"))
                    nandroid_restore(file, 0, 0, 1, 0, 0, 0, 0, 0);
                break;
            case 3:
                if (confirm_selection(confirm_restore, "Yes - Restore cache"))
                    nandroid_restore(file, 0, 0, 0, 1, 0, 0, 0, 0);
                break;
            case 4:
                if (confirm_selection(confirm_restore, "Yes - Restore sd-ext"))
                    nandroid_restore(file, 0, 0, 0, 0, 1, 0, 0, 0);
                break;
        }
    } else if ((webtop_offset == 0) && (pds_offset == 0) && (chosen_item >= 5) && (chosen_item <= 7)) {
        switch (chosen_item)
        {
            case 5:
                if (confirm_selection(confirm_restore, "Yes - Restore wimax"))
                    nandroid_restore(file, 0, 0, 0, 0, 0, 1, 0, 0);
                break;
            case 6:
                if (confirm_selection(confirm_restore, "Yes - Restore webtop"))
                    nandroid_restore(file, 0, 0, 0, 0, 0, 0, 1, 0);
                break;
            case 7:
                if (confirm_selection(confirm_restore, "Yes - Restore PDS"))
                    nandroid_restore(file, 0, 0, 0, 0, 0, 0, 0, 1);
                break;
        }
     } else if ((chosen_item >= 5) && (chosen_item < 7)) {
        if (chosen_item == (pds + pds_offset)) {
            if (confirm_selection(confirm_restore, "Yes - Restore PDS"))
                nandroid_restore(file, 0, 0, 0, 0, 0, 0, 0, 1);
        } else if (chosen_item == (webtop + webtop_offset)) {
            if (confirm_selection(confirm_restore, "Yes - Restore webtop"))
                nandroid_restore(file, 0, 0, 0, 0, 0, 0, 1, 0);
        }
    }
}
Exemple #16
0
void show_multi_boot_menu()
{
    static char* headers[] = {  "MultiBoot Menu",
                                "",
                                NULL
    };

    static char* list[] = { "~~~> Go Back <~~~",
			    "Switch ROM",
                            "Backup Current ROM",
			    "Switch Kernel",
			    "Backup Data",
			    "Restore Data",
                            NULL
    };

    for (;;)
    {	
	create_rom_dirs();
        int chosen_item = get_menu_selection(headers, list, 0);
	if (chosen_item == GO_BACK)
            break;
        switch (chosen_item)
        {
		case 0:
		{
		return;
		break;
		}
            
		case 1:
                {
		if (ensure_root_path_mounted("SDCARD:") != 0) {
		LOGE ("Can't mount /sdcard\n");
		return;
		}
		
   		static char* advancedheaders1[] = {  "Choose Which ROM to Activate",
                                			NULL
   						 };
  		char* file = choose_file_menu("/sdcard/Android/data/g3mod/roms/", NULL, advancedheaders1);
   		 if (file == NULL)
     		   return;

    		static char* headers[] = {  "Activating ROM",
                           		     "",
                            		    NULL
  					  };

    		static char* confirm_restore  = "Confirm activate?";
       	        if (confirm_selection(confirm_restore, "Yes - Activate ROM"))
		{		
		nandroid_restore_system(file,1);
		
		}
		
		if (0 != ensure_root_path_mounted("DATA:"))
                    break;
                ensure_root_path_mounted("SDEXT:");
                ensure_root_path_mounted("CACHE:");
                    __system("rm -r /data/dalvik-cache");
                    __system("rm -r /cache/dalvik-cache");
                    __system("rm -r /sd-ext/dalvik-cache");
                ensure_root_path_unmounted("DATA:");
                ui_print("Dalvik Cache wiped.\n");

		show_choose_kernel_menu();
		
                break;
	}
            case 2:
            {
                backup_rom();
                break;
            }
	case 3:
                {
		show_choose_kernel_menu();
                break;
	}
	case 4:
                {
		backup_data();
                break;
	}
	case 5:
                {
		if (ensure_root_path_mounted("SDCARD:") != 0) {
		LOGE ("Can't mount /sdcard\n");
		return;
		}
		
   		static char* advancedheaders1[] = {  "Choose Which Data to Restore",
                                			NULL
   						 };
  		char* file = choose_file_menu("/sdcard/Android/data/g3mod/data/", NULL, advancedheaders1);
   		 if (file == NULL)
     		   return;

    		static char* headers[] = {  "Restoring Data",
                           		     "",
                            		    NULL
  					  };

    		static char* confirm_restore  = "Confirm restore?";
       	        if (confirm_selection(confirm_restore, "Yes - Restore Data"))
		{		
			nandroid_restore_data(file,1);
			nandroid_restore_sd(file,1);
			nandroid_restore_androidSecure(file,1);
		}
                break;
	}
        }
    }
}
void show_nandroid_advanced_restore_menu(int f_nandroid)
{
    if (ensure_root_path_mounted("SDCARD:") != 0) {
        LOGE ("Can't mount /sdcard\n");
        return;
    }

    static char* advancedheaders[] = {  "Choose an image to restore",
                                "",
                                "Choose an image to restore",
                                "first. The next menu will",
                                "you more options.",
                                "",
                                NULL
    };

    char* file = choose_file_menu(f_nandroid?"/sdcard/ebrecovery/backup/":"/sdcard/ebrecovery/backup/", NULL, advancedheaders);
    if (file == NULL)
        return;

    static char* headers[] = {  "Nandroid Advanced Restore",
                                "",
                                NULL
    };

    static char* list[] = { "Restore system",
                            "Restore data",
                            "Restore cache",
                            "Restore sd-ext",
                            NULL
    };


    static char* confirm_restore  = "Confirm restore?";

    int chosen_item = get_menu_selection(headers, list, 0);
    switch (chosen_item)
    {
        case 0:
            if (confirm_selection(confirm_restore, "Yes - Restore system")) {
                if (f_nandroid)
                	nandroid_restore(file, 0, 1, 0, 0, 0);
                else
                	tarbackup_restore(file, 1, 0, 0, 0);
            }
            break;
        case 1:
            if (confirm_selection(confirm_restore, "Yes - Restore data")) {
                if (f_nandroid)
                	nandroid_restore(file, 0, 0, 1, 0, 0);
                else
                	tarbackup_restore(file, 0, 1, 0, 0);
            }
            break;
        case 2:
            if (confirm_selection(confirm_restore, "Yes - Restore cache")) {
                if (f_nandroid)
                	nandroid_restore(file, 0, 0, 0, 1, 0);
                else
                	tarbackup_restore(file, 0, 0, 1, 0);
            }
            break;
        case 3:
            if (confirm_selection(confirm_restore, "Yes - Restore sd-ext")) {
                if (f_nandroid)
                	nandroid_restore(file, 0, 0, 0, 0, 1);
                else
                	tarbackup_restore(file, 0, 0, 0, 1);
            }
            break;
    }
}