static CamelFolder *
vee_store_get_folder_sync (CamelStore *store,
                           const gchar *folder_name,
                           CamelStoreGetFolderFlags flags,
                           GCancellable *cancellable,
                           GError **error)
{
	CamelVeeFolder *vf;
	CamelFolder *folder;
	gchar *name, *p;
	gsize name_len;

	vf = (CamelVeeFolder *) camel_vee_folder_new (store, folder_name, flags);
	if (vf && ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0)) {
		const gchar *full_name;

		full_name = camel_folder_get_full_name (CAMEL_FOLDER (vf));

		/* Check that parents exist, if not, create dummy ones */
		name_len = strlen (full_name) + 1;
		name = alloca (name_len);
		g_strlcpy (name, full_name, name_len);
		p = name;
		while ( (p = strchr (p, '/'))) {
			*p = 0;

			folder = camel_object_bag_reserve (store->folders, name);
			if (folder == NULL) {
				/* create a dummy vFolder for this, makes get_folder_info simpler */
				folder = camel_vee_folder_new (store, name, flags);
				camel_object_bag_add (store->folders, name, folder);
				change_folder (store, name, CHANGE_ADD | CHANGE_NOSELECT, 0);
				/* FIXME: this sort of leaks folder, nobody owns a ref to it but us */
			} else {
				g_object_unref (folder);
			}
			*p++='/';
		}

		change_folder (store, full_name, CHANGE_ADD, camel_folder_get_message_count ((CamelFolder *) vf));
	}

	return (CamelFolder *) vf;
}
static gboolean
vee_store_delete_folder_sync (CamelStore *store,
                              const gchar *folder_name,
                              GCancellable *cancellable,
                              GError **error)
{
	CamelFolder *folder;

	if (strcmp (folder_name, CAMEL_UNMATCHED_NAME) == 0) {
		g_set_error (
			error, CAMEL_STORE_ERROR,
			CAMEL_STORE_ERROR_NO_FOLDER,
			_("Cannot delete folder: %s: Invalid operation"),
			folder_name);
		return FALSE;
	}

	folder = camel_object_bag_get (store->folders, folder_name);
	if (folder) {
		CamelObject *object = CAMEL_OBJECT (folder);
		const gchar *state_filename;

		state_filename = camel_object_get_state_filename (object);
		if (state_filename != NULL) {
			g_unlink (state_filename);
			camel_object_set_state_filename (object, NULL);
		}

		if ((((CamelVeeFolder *) folder)->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
			/* what about now-empty parents?  ignore? */
			change_folder (store, folder_name, CHANGE_DELETE, -1);
		}

		g_object_unref (folder);
	} else {
		g_set_error (
			error, CAMEL_STORE_ERROR,
			CAMEL_STORE_ERROR_NO_FOLDER,
			_("Cannot delete folder: %s: No such folder"),
			folder_name);
		return FALSE;
	}

	return TRUE;
}
示例#3
0
void control(void)
{
	uint16_t work_slice;
	char c = 0;

	while(c != 27)
	{
		c = getch();
		if(c == 80)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->next_slice != 0)
			{
				cursor.ID_slice = opt_slice->next_slice;
				opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
				cursor.ID_file = opt_slice->ID_file;
				cursor.ID_folder = opt_slice->ID_folder;
			}
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 72)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->prev_slice != 0)
			{
				prev_opt_slice = (opt_slice_init*) &mem[(opt_slice->prev_slice - 1)*32]; 
				if(prev_opt_slice->ID_folder == opt_slice->ID_folder)
				{
					cursor.ID_slice = opt_slice->prev_slice;
					opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
					cursor.ID_file = opt_slice->ID_file;
					cursor.ID_folder = opt_slice->ID_folder;	
				}				
			}
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 13)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->safe == 3)
			{
				cursor.ID_slice = opt_slice->next_slice_folder;
				opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
				cursor.ID_file = opt_slice->ID_file;
				cursor.ID_folder = opt_slice->ID_folder;
			}
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 8)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->ID_folder != 1)
			{
				work_slice = find_first_file_in_folder(cursor.ID_slice);			
				opt_slice = (opt_slice_init*) &mem[(work_slice - 1)*32];
				prev_opt_slice = (opt_slice_init*) &mem[(opt_slice->prev_slice - 1)*32]; 								
				
				work_slice = find_first_file_in_folder(opt_slice->prev_slice_folder);
				opt_slice = (opt_slice_init*) &mem[(work_slice - 1)*32];
				cursor.ID_slice = opt_slice->ID_slice;
				cursor.ID_file = opt_slice->ID_file;
				cursor.ID_folder = opt_slice->ID_folder;

				system("cls");
				output_PC();
				//cursor(output_PC)
			}
		}
		if(c == 32)
		{
			system("cls");
			printf("Enter name temporary and value: \n");
			scanf("%s %u", &name_file, &val_temp);
			//getch();
			//printf("Enter value temporary \n");
			//scanf("/u", &val_temp);
			
			create_file(&name_file[0], val_temp);
			system("cls");
			output_PC();
			//cursor(output_PC)	
		}
		if(c == 57)
		{
			system("cls");
			printf("Enter name folder, name first temporary in folder\n and her value: \n ");
			scanf("%s %s %u", &name_folder, &name_file, &val_temp);
			//getch();
			//printf("Enter value temporary \n");
			//scanf("/u", &val_temp);
			
			create_folder(&name_folder[0], &name_file[0], val_temp);
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 56)
		{
			system("cls");
			printf("Enter name temporary and value: \n");
			scanf("%s %u", &name_file, &val_temp);

			change_file(&name_file[0], val_temp);
			system("cls");
			output_PC();
		}
		if(c == 55)
		{
			system("cls");
			printf("Enter name folder: \n");
			scanf("%s", &name_folder);

			change_folder(&name_folder[0]);
			system("cls");
			output_PC();
		}
	}	
}