[seahorse: 2/3] Remove unused functions.



commit 30b03db09d4a97de46456da557f5a8f1b8e5c401
Author: Stef Walter <stefw collabora co uk>
Date:   Thu Jul 28 16:07:40 2011 +0200

    Remove unused functions.
    
     * Remove a bunch of unused or little used functions from
       seahorse-util.[ch]

 libseahorse/seahorse-transfer-operation.c |    2 +-
 libseahorse/seahorse-util.c               |  311 +----------------------------
 libseahorse/seahorse-util.h               |   42 +----
 src/seahorse-key-manager-store.c          |    2 +-
 src/seahorse-key-manager.c                |    3 +-
 src/seahorse-viewer.c                     |    4 +-
 6 files changed, 13 insertions(+), 351 deletions(-)
---
diff --git a/libseahorse/seahorse-transfer-operation.c b/libseahorse/seahorse-transfer-operation.c
index 1338c09..f213a3a 100644
--- a/libseahorse/seahorse-transfer-operation.c
+++ b/libseahorse/seahorse-transfer-operation.c
@@ -178,7 +178,7 @@ export_done (SeahorseOperation *op, SeahorseTransferOperation *top)
 
 	/* Build an input stream for this */
 	data = g_memory_output_stream_get_data (pv->output);
-	size = seahorse_util_memory_output_length (pv->output);
+	size = g_memory_output_stream_get_data_size (pv->output);
 	
 	if(!size) {
 		seahorse_operation_mark_done (SEAHORSE_OPERATION (top), FALSE, NULL);
diff --git a/libseahorse/seahorse-util.c b/libseahorse/seahorse-util.c
index 015c98a..0e9ca88 100644
--- a/libseahorse/seahorse-util.c
+++ b/libseahorse/seahorse-util.c
@@ -379,58 +379,6 @@ seahorse_util_read_data_block (GString *buf, GInputStream *input,
     return copied;
 }
 
-/**
- * seahorse_util_memory_input_string:
- * @string: The string to create the stream from
- * @length: The length of this string
- *
- * Returns: The new input stream of type #GMemoryInputStream
- */
-GMemoryInputStream*
-seahorse_util_memory_input_string (const gchar *string, gsize length)
-{
-	g_return_val_if_fail (string, NULL);
-	return G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (g_strndup (string, length), length, g_free));
-}
-
-/**
- * seahorse_util_memory_output_length:
- * @output: a stream
- *
- * A replacement for #g_memory_output_stream_get_data_size (since 2.18)
- *
- * Returns: The length of the stream
- */
-gsize
-seahorse_util_memory_output_length (GMemoryOutputStream *output)
-{
-	GSeekable *seekable;
-	goffset offset, end;
-	
-	/* 
-	 * This is a replacement for g_memory_output_stream_get_data_size()
-	 * which is not available in current version of glib.
-	 */
-	
-	g_return_val_if_fail (G_IS_MEMORY_OUTPUT_STREAM (output), 0);
-	g_return_val_if_fail (G_IS_SEEKABLE (output), 0);
-	
-	seekable = G_SEEKABLE (output);
-	offset = g_seekable_tell (seekable);
-	
-	if (!g_seekable_seek (seekable, 0, G_SEEK_END, NULL, NULL))
-		g_return_val_if_reached (0);
-	
-	end = g_seekable_tell (seekable);
-	
-	if (offset != end) {
-		if (!g_seekable_seek (seekable, offset, G_SEEK_SET, NULL, NULL))
-			g_return_val_if_reached (0);
-	}
-	
-	return (gsize)end;
-}
-
 /** 
  * seahorse_util_print_fd:
  * @fd: The file descriptor to write to
@@ -555,28 +503,6 @@ seahorse_util_uri_get_last (const gchar* uri)
 }    
 
 /**
- * seahorse_util_uri_split_last:
- * @uri: The uri to split
- * 
- * Splits the uri in two at it's last component. The result
- * is still part of the same string, so don't free it. This 
- * modifies the @uri argument.
- * 
- * Returns: The last component
- **/
-const gchar* 
-seahorse_util_uri_split_last (gchar* uri)
-{
-    gchar* t;
-    
-    t = (gchar*)seahorse_util_uri_get_last (uri);
-    if(t != uri)
-        *(t - 1) = 0;
-        
-    return t;
-}
-
-/**
  * seahorse_util_uri_exists:
  * @uri: The uri to check
  * 
@@ -659,135 +585,6 @@ seahorse_util_uri_unique (const gchar* uri)
 }
 
 /**
- * seahorse_util_uri_replace_ext:
- * @uri: The uri with old extension
- * @ext: The new extension
- *
- * Replaces the extension on @uri
- *
- * Returns: Newly allocated URI string with new extension. The returned string
- * should be freed with #g_free when no longer needed.
- **/
-gchar* 
-seahorse_util_uri_replace_ext (const gchar *uri, const gchar *ext)
-{
-    gchar* ret;
-    gchar* dot;
-    gchar* slash;
-    guint len;
-    
-    len = strlen (uri);
-    ret = g_new0 (gchar, len + strlen(ext) + 16);
-    strcpy (ret, uri);
- 
-    /* Always take off a slash at end */
-    g_return_val_if_fail (len > 1, ret);
-    if (ret[len - 1] == '/')
-        ret[len - 1] = 0;
-        
-    dot = strrchr (ret, '.');
-    if (dot != NULL) {
-        slash = strrchr (ret, '/');
-        if (slash == NULL || dot > slash)
-            *dot = 0;
-    }
- 
-    /* Only begin extension with . if provided extension doesn't start with
-       one already. */
-    if(ext[0] != '.')
-        strcat (ret, ".");
-
-    /* Finally append the caller's provided extension. */
-    strcat (ret, ext);
-    return ret;
-}
-
-/**
- * seahorse_util_uris_package:
- * @package: Package uri
- * @uris: null-terminated array of uris to package 
- * 
- * Package uris into an archive. The uris must be local.
- * 
- * Returns: TRUE on success or FALSE on failure
- */
-gboolean
-seahorse_util_uris_package (const gchar* package, const char** uris)
-{
-    GError* err = NULL;
-    gchar *out = NULL;
-    gint status;
-    gboolean r;
-    GString *str;
-    gchar *cmd;
-    gchar *t;
-    gchar *x;
-    GFile *file, *fpackage;
-    
-    	fpackage = g_file_new_for_uri (package);
-    	t = g_file_get_path (fpackage);
-    	x = g_shell_quote (t);
-    	g_free (t);
-    
-    	/* create execution */
-    	str = g_string_new ("");
-    	g_string_printf (str, "file-roller --add-to=%s", x);
-    	g_free (x);
-    
-    	while(*uris) {
-    		/* We should never be passed any remote uris at this point */
-    		x = g_uri_parse_scheme (*uris);
-    		if (x) 
-    			file = g_file_new_for_uri (*uris);
-    		else
-    			file = g_file_new_for_path (*uris);
-    		g_free (x);
-    		
-    		t = g_file_get_path (file);
-    		g_object_unref (file);
-    		g_return_val_if_fail (t != NULL, FALSE);
-
-    		x = g_shell_quote (t);
-    		g_free (t);
-
-    		g_string_append_printf (str, " %s", x);
-    		g_free (x);
-        
-    		uris++;
-    	}
-        
-    	/* Execute the command */
-    	cmd = g_string_free (str, FALSE);
-    	r = g_spawn_command_line_sync (cmd, &out, NULL, &status, &err);
-    	g_free (cmd); 
-    
-    	/* TODO: This won't work for remote packages if we support them in the future */
-    	t = g_file_get_path (fpackage);
-	g_chmod (t, S_IRUSR | S_IWUSR);
-	g_free (t);
-    	g_object_unref (fpackage);
-
-    if (out) {
-        g_print ("%s", out);
-        g_free (out);
-    }
-    
-    if (!r) {
-        seahorse_util_handle_error (err, _("Couldn't run file-roller"));
-        g_clear_error (&err);
-        return FALSE;
-    }
-    
-    if(!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) {
-        seahorse_util_show_error(NULL, _("Couldn't package files"), 
-                                 _("The file-roller process did not complete successfully"));
-        return FALSE;
-    }
-    
-    return TRUE;
-}
-
-/**
  * seahorse_util_detect_mime_type:
  * @mime: The mime string
  *
@@ -1122,112 +919,6 @@ seahorse_util_chooser_open_prompt (GtkDialog *dialog)
 }
 
 /**
- * seahorse_util_check_suffix:
- * @path: Path of file to check
- * @suffix: Suffix type to check for.
- *
- * Checks that @path has a suffix specified by @suffix.
- *
- * Returns: TRUE if the file has a correct suffix, FALSE otherwise
- **/
-gboolean
-seahorse_util_check_suffix (const gchar *path, SeahorseSuffix suffix)
-{
-	if (suffix == SEAHORSE_SIG_SUFFIX)
-        return g_str_has_suffix (path, SEAHORSE_EXT_SIG) || 
-               g_str_has_suffix (path, SEAHORSE_EXT_ASC);
-	else
-        return g_str_has_suffix (path, SEAHORSE_EXT_PGP) ||
-               g_str_has_suffix (path, SEAHORSE_EXT_GPG) ||
-               g_str_has_suffix (path, SEAHORSE_EXT_ASC);
-}
-
-/**
- * seahorse_util_add_suffix:
- * @path: Path of an existing file
- * @suffix: Suffix type
- * @prompt: Overwrite prompt text
- *
- * Constructs a new path for a file based on @path plus a suffix determined by
- * @suffix. If ASCII Armor is enabled, the suffix will be '.asc'. Otherwise the 
- * suffix will be '.pgp' if @suffix is %SEAHORSE_CRYPT_SUFFIX or '.sig' if 
- * @suffix is %SEAHORSE_SIG_SUFFIX.
- *
- * Returns: A new path with the suffix appended to @path. NULL if prompt cancelled
- **/
-gchar*
-seahorse_util_add_suffix (const gchar *path, SeahorseSuffix suffix, const gchar *prompt)
-{
-    GtkDialog *dialog;
-    const gchar *ext;
-    gchar *uri;
-    gchar *t;
-    
-    if (suffix == SEAHORSE_CRYPT_SUFFIX)
-        ext = SEAHORSE_EXT_PGP;
-    else
-        ext = SEAHORSE_EXT_SIG;
-    
-    uri = g_strdup_printf ("%s%s", path, ext);
-    
-    if (prompt && uri && seahorse_util_uri_exists (uri)) {
-            
-        t = g_strdup_printf (prompt, seahorse_util_uri_get_last (uri));
-        dialog = seahorse_util_chooser_save_new (t, NULL);
-        g_free (t);
-
-        seahorse_util_chooser_show_key_files (dialog);
-        gtk_file_chooser_select_uri (GTK_FILE_CHOOSER (dialog), uri);
-
-        g_free (uri);                
-        uri = NULL;
-            
-        uri = seahorse_util_chooser_save_prompt (dialog);
-        gtk_widget_destroy (GTK_WIDGET (dialog));
-    }
-
-    return uri;         
-}
-
-/**
- * seahorse_util_remove_suffix:
- * @path: Path with a suffix
- * @prompt:Overwrite prompt text
- *
- * Removes a suffix from @path. Does not check if @path actually has a suffix.
- *
- * Returns: @path without a suffix. NULL if prompt cancelled
- **/
-gchar*
-seahorse_util_remove_suffix (const gchar *path, const gchar *prompt)
-{
-    GtkDialog *dialog;
-    gchar *uri;
-    gchar *t;
-    
-    g_return_val_if_fail (path != NULL, NULL);
-    uri =  g_strndup (path, strlen (path) - 4);
-   
-    if (prompt && uri && seahorse_util_uri_exists (uri)) {
-            
-        t = g_strdup_printf (prompt, seahorse_util_uri_get_last (uri));
-        dialog = seahorse_util_chooser_save_new (t, NULL);
-        g_free (t);
-
-        seahorse_util_chooser_show_key_files (dialog);
-		gtk_file_chooser_select_uri (GTK_FILE_CHOOSER (dialog), uri);
-		
-        g_free (uri);                
-        uri = NULL;
-            
-        uri = seahorse_util_chooser_save_prompt (dialog);
-        gtk_widget_destroy (GTK_WIDGET (dialog));
-    }   
-    
-    return uri;
-}
-
-/**
  * sort_objects_by_source:
  * @k1: the first seahorse object
  * @k2: The second seahorse object
@@ -1520,7 +1211,7 @@ free_avahi ()
 }
 
 const AvahiPoll*
-seahorse_util_dns_sd_get_poll ()
+seahorse_util_dns_sd_get_poll (void)
 {
     if (!avahi_poll) {
         
diff --git a/libseahorse/seahorse-util.h b/libseahorse/seahorse-util.h
index 82f1b7b..b27c66c 100644
--- a/libseahorse/seahorse-util.h
+++ b/libseahorse/seahorse-util.h
@@ -34,35 +34,28 @@
 
 #ifdef WITH_SHARING
 #include <avahi-client/client.h>
-const AvahiPoll* seahorse_util_dns_sd_get_poll ();
+const AvahiPoll* seahorse_util_dns_sd_get_poll (void);
 #endif
 
 struct _SeahorseObject;
 
-typedef enum {
-    SEAHORSE_CRYPT_SUFFIX,
-    SEAHORSE_SIG_SUFFIX,
-} SeahorseSuffix;
-
 typedef guint64 SeahorseVersion;
 
 #define SEAHORSE_EXT_ASC ".asc"
-#define SEAHORSE_EXT_SIG ".sig"
-#define SEAHORSE_EXT_PGP ".pgp"
 #define SEAHORSE_EXT_GPG ".gpg"
 
-gchar*		seahorse_util_get_date_string		    (const time_t		time);
-gchar*		seahorse_util_get_display_date_string   (const time_t		time);
+gchar*      seahorse_util_get_date_string           (const time_t time);
+gchar*      seahorse_util_get_display_date_string   (const time_t time);
 
 
-#define SEAHORSE_ERROR  (seahorse_util_error_domain ())
+#define     SEAHORSE_ERROR                      (seahorse_util_error_domain ())
 
-GQuark      seahorse_util_error_domain ();
+GQuark      seahorse_util_error_domain          (void);
 
 void        seahorse_util_show_error            (GtkWidget          *parent,
                                                  const gchar        *heading,
                                                  const gchar        *message);
-                                                 
+
 void        seahorse_util_handle_error          (GError*            err,
                                                  const char*        desc, ...);
 
@@ -77,11 +70,6 @@ guint       seahorse_util_read_data_block       (GString            *buf,
                                                  const gchar        *start, 
                                                  const gchar*       end);
 
-GMemoryInputStream*
-            seahorse_util_memory_input_string   (const gchar *string, gsize length);
-
-gsize       seahorse_util_memory_output_length  (GMemoryOutputStream *output);
-
 gboolean    seahorse_util_print_fd          (int fd, 
                                              const char* data);
 
@@ -94,16 +82,8 @@ gboolean    seahorse_util_uri_exists        (const gchar* uri);
 
 gchar*      seahorse_util_uri_unique        (const gchar* uri);
 
-gchar*      seahorse_util_uri_replace_ext   (const gchar *uri, 
-                                             const gchar *ext);
-
 const gchar* seahorse_util_uri_get_last     (const gchar* uri);
 
-const gchar* seahorse_util_uri_split_last   (gchar* uri);
-
-gboolean    seahorse_util_uris_package      (const gchar* package, 
-                                             const gchar** uris);
-
 GQuark      seahorse_util_detect_mime_type   (const gchar *mime);
 
 GQuark      seahorse_util_detect_data_type   (const gchar *data,
@@ -135,16 +115,6 @@ gchar*      seahorse_util_chooser_open_prompt           (GtkDialog *dialog);
 
 gchar*      seahorse_util_chooser_save_prompt           (GtkDialog *dialog);
 
-gboolean	seahorse_util_check_suffix		(const gchar		*path,
-                                             SeahorseSuffix     suffix);
-
-gchar*		seahorse_util_add_suffix		(const gchar        *path,
-                                             SeahorseSuffix     suffix,
-                                             const gchar        *prompt);
-
-gchar*      seahorse_util_remove_suffix     (const gchar        *path,
-                                             const gchar        *prompt);
-
 GList*      seahorse_util_objects_sort       (GList *objects);
 
 GList*      seahorse_util_objects_splice     (GList *objects);
diff --git a/src/seahorse-key-manager-store.c b/src/seahorse-key-manager-store.c
index 5e64a76..8a4d90c 100644
--- a/src/seahorse-key-manager-store.c
+++ b/src/seahorse-key-manager-store.c
@@ -576,7 +576,7 @@ export_to_text (SeahorseKeyManagerStore *skstore, GtkSelectionData *selection_da
 		seahorse_debug ("setting selection text");
 		gtk_selection_data_set_text (selection_data, 
 		                             g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (output)), 
-		                             seahorse_util_memory_output_length (G_MEMORY_OUTPUT_STREAM (output)));
+		                             g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (output)));
 	} else {
 		g_message ("error occurred on export: %s", 
 		           skstore->priv->drag_error && skstore->priv->drag_error->message ? 
diff --git a/src/seahorse-key-manager.c b/src/seahorse-key-manager.c
index 151cda5..197f897 100644
--- a/src/seahorse-key-manager.c
+++ b/src/seahorse-key-manager.c
@@ -538,7 +538,8 @@ import_text (SeahorseKeyManager* self, const char* text)
 	sksrc = seahorse_context_find_source (seahorse_context_instance (), ktype, SEAHORSE_LOCATION_LOCAL);
 	g_return_if_fail (sksrc != NULL);
 
-	input = seahorse_util_memory_input_string (text, len);
+	input = G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (g_strndup (text, len),
+	                                                                    len, g_free));
 	op = seahorse_source_import (sksrc, G_INPUT_STREAM (input));
 	
 	seahorse_progress_show (op, _("Importing Keys"), TRUE);
diff --git a/src/seahorse-viewer.c b/src/seahorse-viewer.c
index 9cbf220..9f4a35d 100644
--- a/src/seahorse-viewer.c
+++ b/src/seahorse-viewer.c
@@ -329,8 +329,8 @@ on_copy_complete (SeahorseOperation* op, SeahorseViewer* self)
 	
 	text = g_memory_output_stream_get_data (output);
 	g_return_if_fail (text != NULL);
-	
-	size = seahorse_util_memory_output_length (output);
+
+	size = g_memory_output_stream_get_data_size (output);
 	g_return_if_fail (size >= 0);
 	
 	atom = gdk_atom_intern ("CLIPBOARD", FALSE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]