add every folder to the sequence except the root folder
2002-05-07 JP Rosevear <jpr@ximian.com> * evolution-storage.c (get_folder_list_foreach): add every folder to the sequence except the root folder (impl_Storage_get_folder_list): implement corba method (evolution_storage_get_epv): set new method implementation * evolution-folder-selector-button.h: fix signal prototype * e-folder-tree.h: new proto * e-folder-tree.c (e_folder_tree_get_count): count nodes (count_nodes): bump count foreach path * e-corba-storage-registry.c (impl_StorageRegistry_getStorageList): implement idl method (corba_class_init): set epv method * Evolution-Storage.idl: add getStorageList and getFolderList methods svn path=/trunk/; revision=16708
This commit is contained in:
@ -1,3 +1,24 @@
|
||||
2002-05-07 JP Rosevear <jpr@ximian.com>
|
||||
|
||||
* evolution-storage.c (get_folder_list_foreach): add every folder
|
||||
to the sequence except the root folder
|
||||
(impl_Storage_get_folder_list): implement corba method
|
||||
(evolution_storage_get_epv): set new method implementation
|
||||
|
||||
* evolution-folder-selector-button.h: fix signal prototype
|
||||
|
||||
* e-folder-tree.h: new proto
|
||||
|
||||
* e-folder-tree.c (e_folder_tree_get_count): count nodes
|
||||
(count_nodes): bump count foreach path
|
||||
|
||||
* e-corba-storage-registry.c
|
||||
(impl_StorageRegistry_getStorageList): implement idl method
|
||||
(corba_class_init): set epv method
|
||||
|
||||
* Evolution-Storage.idl: add getStorageList and getFolderList
|
||||
methods
|
||||
|
||||
2002-05-07 Ettore Perazzoli <ettore@ximian.com>
|
||||
|
||||
* evolution-test-component.c (create_new_folder_selector): Use the
|
||||
|
||||
@ -21,6 +21,8 @@ module Evolution {
|
||||
|
||||
attribute string name;
|
||||
|
||||
typedef sequence<Folder> FolderList;
|
||||
|
||||
enum Result {
|
||||
OK,
|
||||
UNSUPPORTED_OPERATION,
|
||||
@ -39,6 +41,8 @@ module Evolution {
|
||||
string path;
|
||||
};
|
||||
|
||||
FolderList getFolderList ();
|
||||
|
||||
void asyncCreateFolder (in string path,
|
||||
in string type,
|
||||
in string description,
|
||||
@ -95,6 +99,8 @@ module Evolution {
|
||||
exception NotFound {};
|
||||
exception AlreadyListening {};
|
||||
|
||||
typedef sequence<Storage> StorageList;
|
||||
|
||||
enum MessageType {
|
||||
STORAGE_CREATED,
|
||||
STORAGE_DESTROYED
|
||||
@ -108,6 +114,8 @@ module Evolution {
|
||||
StorageListener addStorage (in Storage storage,
|
||||
in string name)
|
||||
raises (Exists);
|
||||
|
||||
StorageList getStorageList ();
|
||||
|
||||
Storage getStorageByName (in string name)
|
||||
raises (NotFound);
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "e-local-storage.h"
|
||||
#include "e-corba-storage.h"
|
||||
#include "e-corba-storage-registry.h"
|
||||
#include "e-shell-constants.h"
|
||||
@ -130,6 +131,54 @@ impl_StorageRegistry_addStorage (PortableServer_Servant servant,
|
||||
return listener_interface;
|
||||
}
|
||||
|
||||
static GNOME_Evolution_StorageRegistry_StorageList *
|
||||
impl_StorageRegistry_getStorageList (PortableServer_Servant servant,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
BonoboObject *bonobo_object;
|
||||
ECorbaStorageRegistry *storage_registry;
|
||||
ECorbaStorageRegistryPrivate *priv;
|
||||
GNOME_Evolution_StorageRegistry_StorageList *storage_list;
|
||||
GList *sl, *l;
|
||||
|
||||
bonobo_object = bonobo_object_from_servant (servant);
|
||||
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
|
||||
priv = storage_registry->priv;
|
||||
|
||||
sl = e_storage_set_get_storage_list (priv->storage_set);
|
||||
|
||||
storage_list = GNOME_Evolution_StorageRegistry_StorageList__alloc ();
|
||||
storage_list->_maximum = g_list_length (sl);
|
||||
storage_list->_length = 0;
|
||||
storage_list->_buffer = CORBA_sequence_GNOME_Evolution_Storage_allocbuf (storage_list->_maximum);
|
||||
for (l = sl; l != NULL; l = l->next) {
|
||||
EStorage *storage;
|
||||
GNOME_Evolution_Storage corba_storage;
|
||||
CORBA_Environment ev2;
|
||||
|
||||
CORBA_exception_init (&ev2);
|
||||
|
||||
storage = l->data;
|
||||
if (E_IS_LOCAL_STORAGE (storage)) {
|
||||
corba_storage = e_local_storage_get_corba_interface (E_LOCAL_STORAGE (storage));
|
||||
} else if (E_IS_CORBA_STORAGE (storage)) {
|
||||
corba_storage = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
corba_storage = CORBA_Object_duplicate (corba_storage, &ev2);
|
||||
if (BONOBO_EX (&ev2)) {
|
||||
CORBA_exception_free (&ev2);
|
||||
continue;
|
||||
}
|
||||
storage_list->_buffer[storage_list->_length] = corba_storage;
|
||||
storage_list->_length++;
|
||||
}
|
||||
|
||||
return storage_list;
|
||||
}
|
||||
|
||||
static GNOME_Evolution_Storage
|
||||
impl_StorageRegistry_getStorageByName (PortableServer_Servant servant,
|
||||
const CORBA_char *name,
|
||||
@ -384,6 +433,7 @@ corba_class_init (void)
|
||||
|
||||
epv = g_new0 (POA_GNOME_Evolution_StorageRegistry__epv, 1);
|
||||
epv->addStorage = impl_StorageRegistry_addStorage;
|
||||
epv->getStorageList = impl_StorageRegistry_getStorageList;
|
||||
epv->getStorageByName = impl_StorageRegistry_getStorageByName;
|
||||
epv->removeStorageByName = impl_StorageRegistry_removeStorageByName;
|
||||
epv->addListener = impl_StorageRegistry_addListener;
|
||||
|
||||
@ -315,6 +315,35 @@ e_folder_tree_remove (EFolderTree *folder_tree,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
count_nodes (EFolderTree *tree,
|
||||
const char *path,
|
||||
void *data,
|
||||
void *closure)
|
||||
{
|
||||
int *count = closure;
|
||||
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
/**
|
||||
* e_folder_tree_get_count:
|
||||
* @folder_tree: A pointer to an EFolderTree
|
||||
*
|
||||
* Gets the number of folders in the tree
|
||||
*
|
||||
* Return value: The number of folders in the tree
|
||||
**/
|
||||
int
|
||||
e_folder_tree_get_count (EFolderTree *folder_tree)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
e_folder_tree_foreach (folder_tree, count_nodes, &count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* e_folder_tree_get_folder:
|
||||
* @folder_tree: A pointer to an EFolderTree
|
||||
|
||||
@ -42,7 +42,9 @@ gboolean e_folder_tree_add (EFolderTree *folder_tre
|
||||
void *data);
|
||||
gboolean e_folder_tree_remove (EFolderTree *folder_tree,
|
||||
const char *path);
|
||||
|
||||
|
||||
int e_folder_tree_get_count (EFolderTree *folder_tree);
|
||||
|
||||
void *e_folder_tree_get_folder (EFolderTree *folder_tree,
|
||||
const char *path);
|
||||
GList *e_folder_tree_get_subfolders (EFolderTree *folder_tree,
|
||||
|
||||
@ -52,7 +52,7 @@ struct _EvolutionFolderSelectorButtonClass {
|
||||
GtkButtonClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (*selected) (GNOME_Evolution_Folder *folder);
|
||||
void (*selected) (EvolutionFolderSelectorButton *button, GNOME_Evolution_Folder *folder);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <bonobo/bonobo-exception.h>
|
||||
|
||||
#include <gal/util/e-util.h>
|
||||
|
||||
@ -249,6 +250,57 @@ impl_Storage__get_name (PortableServer_Servant servant,
|
||||
return CORBA_string_dup (priv->name);
|
||||
}
|
||||
|
||||
static void
|
||||
get_folder_list_foreach (EFolderTree *tree,
|
||||
const char *path,
|
||||
void *data,
|
||||
void *closure)
|
||||
{
|
||||
const GNOME_Evolution_Folder *corba_folder;
|
||||
GNOME_Evolution_Folder *new_corba_folder;
|
||||
GNOME_Evolution_FolderList *folder_list;
|
||||
|
||||
corba_folder = (GNOME_Evolution_Folder *) data;
|
||||
folder_list = (GNOME_Evolution_FolderList *) closure;
|
||||
|
||||
/* The root folder has no data. */
|
||||
if (corba_folder == NULL)
|
||||
return;
|
||||
|
||||
new_corba_folder = folder_list->_buffer + folder_list->_length;
|
||||
new_corba_folder->displayName = CORBA_string_dup (corba_folder->displayName);
|
||||
new_corba_folder->description = CORBA_string_dup (corba_folder->description);
|
||||
new_corba_folder->type = CORBA_string_dup (corba_folder->type);
|
||||
new_corba_folder->physicalUri = CORBA_string_dup (corba_folder->physicalUri);
|
||||
new_corba_folder->evolutionUri = CORBA_string_dup (corba_folder->evolutionUri);
|
||||
new_corba_folder->unreadCount = corba_folder->unreadCount;
|
||||
|
||||
folder_list->_length++;
|
||||
}
|
||||
|
||||
static GNOME_Evolution_FolderList *
|
||||
impl_Storage_get_folder_list (PortableServer_Servant servant,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
BonoboObject *bonobo_object;
|
||||
EvolutionStorage *storage;
|
||||
EvolutionStoragePrivate *priv;
|
||||
GNOME_Evolution_FolderList *folder_list;
|
||||
|
||||
bonobo_object = bonobo_object_from_servant (servant);
|
||||
storage = EVOLUTION_STORAGE (bonobo_object);
|
||||
priv = storage->priv;
|
||||
|
||||
folder_list = GNOME_Evolution_FolderList__alloc ();
|
||||
folder_list->_maximum = e_folder_tree_get_count (priv->folder_tree) - 1;
|
||||
folder_list->_length = 0;
|
||||
folder_list->_buffer = CORBA_sequence_GNOME_Evolution_Folder_allocbuf (folder_list->_maximum);
|
||||
|
||||
e_folder_tree_foreach (priv->folder_tree, get_folder_list_foreach, folder_list);
|
||||
|
||||
return folder_list;
|
||||
}
|
||||
|
||||
static void
|
||||
impl_Storage_async_create_folder (PortableServer_Servant servant,
|
||||
const CORBA_char *path,
|
||||
@ -603,6 +655,7 @@ evolution_storage_get_epv (void)
|
||||
|
||||
epv = g_new0 (POA_GNOME_Evolution_Storage__epv, 1);
|
||||
epv->_get_name = impl_Storage__get_name;
|
||||
epv->getFolderList = impl_Storage_get_folder_list;
|
||||
epv->asyncCreateFolder = impl_Storage_async_create_folder;
|
||||
epv->asyncRemoveFolder = impl_Storage_async_remove_folder;
|
||||
epv->asyncXferFolder = impl_Storage_async_xfer_folder;
|
||||
|
||||
Reference in New Issue
Block a user