aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-01-05 01:02:57 +0800
committerDan Winship <danw@src.gnome.org>2001-01-05 01:02:57 +0800
commitf9f6c398725a2e0969e23753106edfb896ea5930 (patch)
tree669c0a196ef914fac5261bc8d7380bfcacc4f601 /shell
parent349554fff69003e2cb426d68092f6ed33b6eb1ff (diff)
downloadgsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar.gz
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar.zst
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.zip
New function to update a folder given its URI. Plus associated changes to
* evolution-storage.c (evolution_storage_update_folder_by_uri): New function to update a folder given its URI. Plus associated changes to other functions to keep track of the path<->URI mappings. svn path=/trunk/; revision=7248
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog7
-rw-r--r--shell/evolution-storage.c64
-rw-r--r--shell/evolution-storage.h38
3 files changed, 82 insertions, 27 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index df579059bd..c6befcb49b 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,10 @@
+2001-01-04 Dan Winship <danw@helixcode.com>
+
+ * evolution-storage.c (evolution_storage_update_folder_by_uri):
+ New function to update a folder given its URI. Plus associated
+ changes to other functions to keep track of the path<->URI
+ mappings.
+
2000-12-28 Ettore Perazzoli <ettore@helixcode.com>
* evolution-shell-client.c (user_select_folder): Make sure the
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 5ad51472a3..c87c031cd0 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -54,6 +54,9 @@ struct _EvolutionStoragePrivate {
/* The set of folders we have in this storage. */
EFolderTree *folder_tree;
+ /* Mappings from URIs to folder tree paths. */
+ GHashTable *uri_to_path;
+
/* The listener registered on this storage. */
GList *corba_storage_listeners;
};
@@ -271,6 +274,13 @@ impl_Storage_remove_listener (PortableServer_Servant servant,
/* GtkObject methods. */
static void
+free_mapping (gpointer key, gpointer value, gpointer user_data)
+{
+ g_free (key);
+ g_free (value);
+}
+
+static void
destroy (GtkObject *object)
{
EvolutionStorage *storage;
@@ -286,6 +296,10 @@ destroy (GtkObject *object)
g_free (priv->toplevel_node_type);
if (priv->folder_tree != NULL)
e_folder_tree_destroy (priv->folder_tree);
+ if (priv->uri_to_path != NULL) {
+ g_hash_table_foreach (priv->uri_to_path, free_mapping, NULL);
+ g_hash_table_destroy (priv->uri_to_path);
+ }
CORBA_exception_init (&ev);
@@ -351,6 +365,7 @@ init (EvolutionStorage *storage)
priv->toplevel_node_uri = NULL;
priv->toplevel_node_type = NULL;
priv->folder_tree = e_folder_tree_new (folder_destroy_notify, storage);
+ priv->uri_to_path = g_hash_table_new (g_str_hash, g_str_equal);
priv->corba_storage_listeners = NULL;
storage->priv = priv;
@@ -544,6 +559,12 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
corba_folder->physical_uri = CORBA_string_dup (physical_uri);
corba_folder->highlighted = highlighted;
+ if (! e_folder_tree_add (priv->folder_tree, path, corba_folder)) {
+ CORBA_free (corba_folder);
+ return EVOLUTION_STORAGE_ERROR_EXISTS;
+ }
+ g_hash_table_insert (priv->uri_to_path, g_strdup (physical_uri), g_strdup (path));
+
result = EVOLUTION_STORAGE_OK;
for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
@@ -567,11 +588,6 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
CORBA_exception_free (&ev);
- if (result == EVOLUTION_STORAGE_OK) {
- if (! e_folder_tree_add (priv->folder_tree, path, corba_folder))
- result = EVOLUTION_STORAGE_ERROR_EXISTS;
- }
-
return result;
}
@@ -637,12 +653,35 @@ evolution_storage_update_folder (EvolutionStorage *evolution_storage,
}
EvolutionStorageResult
+evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage,
+ const char *physical_uri,
+ const char *display_name,
+ gboolean highlighted)
+{
+ EvolutionStoragePrivate *priv;
+ char *path;
+
+ g_return_val_if_fail (evolution_storage != NULL,
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+ g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+ g_return_val_if_fail (physical_uri != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+
+ priv = evolution_storage->priv;
+
+ path = g_hash_table_lookup (priv->uri_to_path, physical_uri);
+ return evolution_storage_update_folder (evolution_storage, path, display_name, highlighted);
+}
+
+EvolutionStorageResult
evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
const char *path)
{
EvolutionStorageResult result;
EvolutionStoragePrivate *priv;
CORBA_Environment ev;
+ GNOME_Evolution_Folder *corba_folder;
+ gpointer key, value;
GList *p;
g_return_val_if_fail (evolution_storage != NULL,
@@ -657,6 +696,16 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
if (priv->corba_storage_listeners == NULL)
return EVOLUTION_STORAGE_ERROR_NOTREGISTERED;
+ corba_folder = e_folder_tree_get_folder (priv->folder_tree, path);
+ if (corba_folder == NULL)
+ return EVOLUTION_STORAGE_ERROR_NOTFOUND;
+ if (g_hash_table_lookup_extended (priv->uri_to_path, corba_folder->physical_uri, &key, &value)) {
+ g_hash_table_remove (priv->uri_to_path, key);
+ g_free (key);
+ g_free (value);
+ }
+ e_folder_tree_remove (priv->folder_tree, path);
+
CORBA_exception_init (&ev);
result = EVOLUTION_STORAGE_OK;
@@ -682,11 +731,6 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
CORBA_exception_free (&ev);
- if (result == EVOLUTION_STORAGE_OK) {
- if (! e_folder_tree_remove (priv->folder_tree, path))
- result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
- }
-
return result;
}
diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h
index 4457d9f9b8..824c7ea12a 100644
--- a/shell/evolution-storage.h
+++ b/shell/evolution-storage.h
@@ -84,23 +84,27 @@ EvolutionStorage *evolution_storage_new (const char *name,
const char *toplevel_node_uri,
const char *toplevel_node_type);
-EvolutionStorageResult evolution_storage_register (EvolutionStorage *storage,
- GNOME_Evolution_StorageRegistry corba_registry);
-EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
- GNOME_Evolution_Shell corba_shell);
-EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage *evolution_storage,
- const char *path,
- const char *display_name,
- const char *type,
- const char *physical_uri,
- const char *description,
- gboolean highlighted);
-EvolutionStorageResult evolution_storage_update_folder (EvolutionStorage *evolution_storage,
- const char *path,
- const char *display_name,
- gboolean highlighted);
-EvolutionStorageResult evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
- const char *path);
+EvolutionStorageResult evolution_storage_register (EvolutionStorage *storage,
+ GNOME_Evolution_StorageRegistry corba_registry);
+EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
+ GNOME_Evolution_Shell corba_shell);
+EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage *evolution_storage,
+ const char *path,
+ const char *display_name,
+ const char *type,
+ const char *physical_uri,
+ const char *description,
+ gboolean highlighted);
+EvolutionStorageResult evolution_storage_update_folder (EvolutionStorage *evolution_storage,
+ const char *path,
+ const char *display_name,
+ gboolean highlighted);
+EvolutionStorageResult evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage,
+ const char *physical_uri,
+ const char *display_name,
+ gboolean highlighted);
+EvolutionStorageResult evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
+ const char *path);
#ifdef __cplusplus
}
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836