summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Hertzfeld <andy@src.gnome.org>2001-03-29 10:04:32 +0000
committerAndy Hertzfeld <andy@src.gnome.org>2001-03-29 10:04:32 +0000
commit9ebbce2b7df674831a6e612db3622522cf943e2e (patch)
tree71060cfb1801a44e800cf29c4af2226ae7d7f67b
parentac9ee8d442abffb3779e870fe1b5917498ff21f3 (diff)
downloadnautilus-9ebbce2b7df674831a6e612db3622522cf943e2e.tar.gz
partially implemented add_annotation
* libnautilus-extensions/nautilus-annotation.c: (nautilus_annotation_add_annotation): * libnautilus-extensions/nautilus-annotation.h: partially implemented add_annotation
-rw-r--r--ChangeLog7
-rw-r--r--libnautilus-extensions/nautilus-annotation.c54
-rw-r--r--libnautilus-extensions/nautilus-annotation.h6
-rw-r--r--libnautilus-private/nautilus-annotation.c54
-rw-r--r--libnautilus-private/nautilus-annotation.h6
5 files changed, 123 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4203b1aa3..f1d10df51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-03-29 Andy Hertzfeld <andy@eazel.com>
+
+ * libnautilus-extensions/nautilus-annotation.c:
+ (nautilus_annotation_add_annotation):
+ * libnautilus-extensions/nautilus-annotation.h:
+ partially implemented add_annotation
+
2001-03-28 Andy Hertzfeld <andy@eazel.com>
made the annotation edit field display existing annotation text,
diff --git a/libnautilus-extensions/nautilus-annotation.c b/libnautilus-extensions/nautilus-annotation.c
index fdae7fe9a..9c02348e5 100644
--- a/libnautilus-extensions/nautilus-annotation.c
+++ b/libnautilus-extensions/nautilus-annotation.c
@@ -1023,8 +1023,60 @@ int nautilus_annotation_has_annotation (NautilusFile *file)
}
/* add an annotation to a file */
-void nautilus_annotation_add_annotation (NautilusFile *file, const char *new_annotation)
+void nautilus_annotation_add_annotation (NautilusFile *file,
+ const char *annotation_type,
+ const char *annotation_text,
+ const char *access)
{
+ char *digest;
+ char *annotations;
+ xmlDocPtr xml_document;
+
+ /* we can't handle directories yet, so just return. */
+ if (nautilus_file_is_directory (file)) {
+ return;
+ }
+
+ /* fetch the local annotation, if one exists */
+ digest = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_FILE_DIGEST, NULL);
+
+ /* there isn't a digest, so start a request for one going, and return */
+ /* this shouldn't happen in practice, since the annotation window will have
+ * already created a digest
+ */
+ if (digest == NULL) {
+ queue_file_digest_request (file);
+ return;
+ }
+
+ /* there's a digest, so we if we have the annotations for the file cached locally */
+ annotations = look_up_local_annotation (file, digest);
+
+ /* no annotation exists, so create the initial xml document from scratch */
+ if (annotations == NULL || strlen (annotations) == 0) {
+ xml_document = xmlNewDoc ("1.0");
+ /* create the header node, with the digest attribute */
+ } else {
+ /* open the existing annotation and load it */
+ xml_document = xmlParseMemory (annotations, strlen (annotations));
+ }
+
+ /* add the new entry. For now, we only support one entry per file, so we replace the old
+ * one, if it exists, but this will change soon as we support multiple notes per file
+ */
+
+ /* save the modified xml document back to the local repository */
+
+ /* update the metadata date and count */
+
+ /* issue file changed symbol to update the emblem */
+
+ /* if the access is global, send it to the server */
+
+ /* clean up and we're done */
+ xmlFreeDoc (xml_document);
+ g_free (digest);
+ g_free (annotations);
}
/* remove an annotation from a file */
diff --git a/libnautilus-extensions/nautilus-annotation.h b/libnautilus-extensions/nautilus-annotation.h
index 5c5a6ef96..712b276f8 100644
--- a/libnautilus-extensions/nautilus-annotation.h
+++ b/libnautilus-extensions/nautilus-annotation.h
@@ -35,7 +35,11 @@ char * nautilus_annotation_get_display_text (const char* annotation_text);
char * nautilus_annotation_get_annotation_for_display (NautilusFile *file);
int nautilus_annotation_has_annotation (NautilusFile *file);
-void nautilus_annotation_add_annotation (NautilusFile *file, const char *new_annotation);
+
+void nautilus_annotation_add_annotation (NautilusFile *file,
+ const char *annotation_type,
+ const char *annotation_text,
+ const char *access);
void nautilus_annotation_remove_annotation (NautilusFile *file, int which_annotation);
#endif /* NAUTILUS_ANNOTATION_H */
diff --git a/libnautilus-private/nautilus-annotation.c b/libnautilus-private/nautilus-annotation.c
index fdae7fe9a..9c02348e5 100644
--- a/libnautilus-private/nautilus-annotation.c
+++ b/libnautilus-private/nautilus-annotation.c
@@ -1023,8 +1023,60 @@ int nautilus_annotation_has_annotation (NautilusFile *file)
}
/* add an annotation to a file */
-void nautilus_annotation_add_annotation (NautilusFile *file, const char *new_annotation)
+void nautilus_annotation_add_annotation (NautilusFile *file,
+ const char *annotation_type,
+ const char *annotation_text,
+ const char *access)
{
+ char *digest;
+ char *annotations;
+ xmlDocPtr xml_document;
+
+ /* we can't handle directories yet, so just return. */
+ if (nautilus_file_is_directory (file)) {
+ return;
+ }
+
+ /* fetch the local annotation, if one exists */
+ digest = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_FILE_DIGEST, NULL);
+
+ /* there isn't a digest, so start a request for one going, and return */
+ /* this shouldn't happen in practice, since the annotation window will have
+ * already created a digest
+ */
+ if (digest == NULL) {
+ queue_file_digest_request (file);
+ return;
+ }
+
+ /* there's a digest, so we if we have the annotations for the file cached locally */
+ annotations = look_up_local_annotation (file, digest);
+
+ /* no annotation exists, so create the initial xml document from scratch */
+ if (annotations == NULL || strlen (annotations) == 0) {
+ xml_document = xmlNewDoc ("1.0");
+ /* create the header node, with the digest attribute */
+ } else {
+ /* open the existing annotation and load it */
+ xml_document = xmlParseMemory (annotations, strlen (annotations));
+ }
+
+ /* add the new entry. For now, we only support one entry per file, so we replace the old
+ * one, if it exists, but this will change soon as we support multiple notes per file
+ */
+
+ /* save the modified xml document back to the local repository */
+
+ /* update the metadata date and count */
+
+ /* issue file changed symbol to update the emblem */
+
+ /* if the access is global, send it to the server */
+
+ /* clean up and we're done */
+ xmlFreeDoc (xml_document);
+ g_free (digest);
+ g_free (annotations);
}
/* remove an annotation from a file */
diff --git a/libnautilus-private/nautilus-annotation.h b/libnautilus-private/nautilus-annotation.h
index 5c5a6ef96..712b276f8 100644
--- a/libnautilus-private/nautilus-annotation.h
+++ b/libnautilus-private/nautilus-annotation.h
@@ -35,7 +35,11 @@ char * nautilus_annotation_get_display_text (const char* annotation_text);
char * nautilus_annotation_get_annotation_for_display (NautilusFile *file);
int nautilus_annotation_has_annotation (NautilusFile *file);
-void nautilus_annotation_add_annotation (NautilusFile *file, const char *new_annotation);
+
+void nautilus_annotation_add_annotation (NautilusFile *file,
+ const char *annotation_type,
+ const char *annotation_text,
+ const char *access);
void nautilus_annotation_remove_annotation (NautilusFile *file, int which_annotation);
#endif /* NAUTILUS_ANNOTATION_H */