gmime r1405 - in trunk: . docs/reference gmime tests tools
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1405 - in trunk: . docs/reference gmime tests tools
- Date: Mon, 18 Aug 2008 15:16:11 +0000 (UTC)
Author: fejj
Date: Mon Aug 18 15:16:11 2008
New Revision: 1405
URL: http://svn.gnome.org/viewvc/gmime?rev=1405&view=rev
Log:
2008-08-18 Jeffrey Stedfast <fejj novell com>
* tools/gmime-port-2-2-to-2-4.sh: Updated.
* gmime/internet-address.c (internet_address_new_mailbox): Renamed
from internet_address_new_name() to make it less ambiguous (and to
use the terminology used in the RFC's).
(internet_address_get_type): Now takes a const InternetAddress
argument.
(internet_address_get_name): Same.
(internet_address_get_addr): Same.
(internet_address_get_members): Same, but now returns a ref'd
InternetAddressList rather than a const InternetAddressList.
(internet_address_list_ref): InternetAddressLists are now
reffable.
(internet_address_list_unref): Same.
(internet_address_list_get_address): Now returns a ref'd copy of
the InternetAddress at the index specified.
Modified:
trunk/ChangeLog
trunk/docs/reference/gmime-sections.txt
trunk/gmime/gmime-message.c
trunk/gmime/internet-address.c
trunk/gmime/internet-address.h
trunk/tests/test-mime.c
trunk/tools/gmime-port-2-2-to-2-4.sh
Modified: trunk/docs/reference/gmime-sections.txt
==============================================================================
--- trunk/docs/reference/gmime-sections.txt (original)
+++ trunk/docs/reference/gmime-sections.txt Mon Aug 18 15:16:11 2008
@@ -937,7 +937,7 @@
InternetAddressList
InternetAddress
internet_address_new
-internet_address_new_name
+internet_address_new_mailbox
internet_address_new_group
internet_address_ref
internet_address_unref
@@ -951,7 +951,8 @@
internet_address_get_members
internet_address_to_string
internet_address_list_new
-internet_address_list_destroy
+internet_address_list_ref
+internet_address_list_unref
internet_address_list_length
internet_address_list_clear
internet_address_list_add
Modified: trunk/gmime/gmime-message.c
==============================================================================
--- trunk/gmime/gmime-message.c (original)
+++ trunk/gmime/gmime-message.c Mon Aug 18 15:16:11 2008
@@ -170,7 +170,7 @@
InternetAddressList *recipients = value;
if (recipients)
- internet_address_list_destroy (recipients);
+ internet_address_list_unref (recipients);
return TRUE;
}
@@ -584,7 +584,7 @@
if (value && (addrlist = internet_address_list_parse_string (value))) {
internet_address_list_writer (addrlist, str);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
}
g_string_append_c (str, '\n');
@@ -637,7 +637,7 @@
g_free (message->from);
if ((addrlist = internet_address_list_parse_string (value))) {
message->from = internet_address_list_to_string (addrlist, FALSE);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
} else {
message->from = NULL;
}
@@ -646,7 +646,7 @@
g_free (message->reply_to);
if ((addrlist = internet_address_list_parse_string (value))) {
message->reply_to = internet_address_list_to_string (addrlist, FALSE);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
} else {
message->reply_to = NULL;
}
@@ -804,19 +804,19 @@
type = recipient_types[GMIME_RECIPIENT_TYPE_TO];
addrlist = g_hash_table_lookup (message->recipients, type);
g_hash_table_remove (message->recipients, type);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
break;
case HEADER_CC:
type = recipient_types[GMIME_RECIPIENT_TYPE_CC];
addrlist = g_hash_table_lookup (message->recipients, type);
g_hash_table_remove (message->recipients, type);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
break;
case HEADER_BCC:
type = recipient_types[GMIME_RECIPIENT_TYPE_BCC];
addrlist = g_hash_table_lookup (message->recipients, type);
g_hash_table_remove (message->recipients, type);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
break;
case HEADER_SUBJECT:
g_free (message->subject);
@@ -964,7 +964,7 @@
addrlist = internet_address_list_parse_string (sender);
message->from = internet_address_list_to_string (addrlist, FALSE);
encoded = internet_address_list_to_string (addrlist, TRUE);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
g_mime_header_list_set (GMIME_OBJECT (message)->headers, "From", encoded);
g_free (encoded);
@@ -1062,7 +1062,7 @@
g_return_if_fail (name != NULL);
g_return_if_fail (address != NULL);
- ia = internet_address_new_name (name, address);
+ ia = internet_address_new_mailbox (name, address);
if ((recipients = g_hash_table_lookup (message->recipients, recipient_types[type])))
g_hash_table_remove (message->recipients, recipient_types[type]);
@@ -1088,7 +1088,7 @@
if ((addrlist = internet_address_list_parse_string (str))) {
if (recipients != NULL) {
internet_address_list_concat (recipients, addrlist);
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
} else {
recipients = addrlist;
}
Modified: trunk/gmime/internet-address.c
==============================================================================
--- trunk/gmime/internet-address.c (original)
+++ trunk/gmime/internet-address.c Mon Aug 18 15:16:11 2008
@@ -55,11 +55,6 @@
**/
-struct _InternetAddressList {
- GPtrArray *array;
-};
-
-
/**
* internet_address_new:
*
@@ -84,7 +79,7 @@
/**
* internet_address_destroy:
- * @ia: internet address
+ * @ia: a #InternetAddress
*
* Destroy the #InternetAddress object pointed to by @ia.
**/
@@ -94,7 +89,7 @@
g_free (ia->name);
if (ia->type == INTERNET_ADDRESS_GROUP) {
- internet_address_list_destroy (ia->value.members);
+ internet_address_list_unref (ia->value.members);
} else {
g_free (ia->value.addr);
}
@@ -105,26 +100,30 @@
/**
* internet_address_ref:
- * @ia: internet address
+ * @ia: a #InternetAddress
*
* Ref's the internet address.
**/
void
internet_address_ref (InternetAddress *ia)
{
+ g_return_if_fail (ia != NULL);
+
ia->refcount++;
}
/**
* internet_address_unref:
- * @ia: internet address
+ * @ia: a #InternetAddress
*
* Unref's the internet address.
**/
void
internet_address_unref (InternetAddress *ia)
{
+ g_return_if_fail (ia != NULL);
+
if (ia->refcount <= 1) {
internet_address_destroy (ia);
} else {
@@ -134,7 +133,7 @@
/**
- * internet_address_new_name:
+ * internet_address_new_mailbox:
* @name: person's name
* @addr: person's address
*
@@ -144,14 +143,14 @@
* Returns: a new #InternetAddress object.
**/
InternetAddress *
-internet_address_new_name (const char *name, const char *addr)
+internet_address_new_mailbox (const char *name, const char *addr)
{
InternetAddress *ia;
g_return_val_if_fail (addr != NULL, NULL);
ia = internet_address_new ();
- ia->type = INTERNET_ADDRESS_NAME;
+ ia->type = INTERNET_ADDRESS_MAILBOX;
if (name) {
ia->name = g_mime_utils_header_decode_phrase (name);
g_mime_utils_unquote_string (ia->name);
@@ -221,7 +220,7 @@
g_return_if_fail (ia != NULL);
g_return_if_fail (ia->type != INTERNET_ADDRESS_GROUP);
- ia->type = INTERNET_ADDRESS_NAME;
+ ia->type = INTERNET_ADDRESS_MAILBOX;
g_free (ia->value.addr);
ia->value.addr = g_strdup (addr);
}
@@ -238,10 +237,16 @@
internet_address_set_group (InternetAddress *ia, InternetAddressList *group)
{
g_return_if_fail (ia != NULL);
- g_return_if_fail (ia->type != INTERNET_ADDRESS_NAME);
+ g_return_if_fail (ia->type != INTERNET_ADDRESS_MAILBOX);
ia->type = INTERNET_ADDRESS_GROUP;
- internet_address_list_destroy (ia->value.members);
+
+ if (group)
+ internet_address_list_ref (group);
+
+ if (ia->value.members)
+ internet_address_list_unref (ia->value.members);
+
ia->value.members = group;
}
@@ -257,7 +262,7 @@
internet_address_add_member (InternetAddress *ia, InternetAddress *member)
{
g_return_if_fail (ia != NULL);
- g_return_if_fail (ia->type != INTERNET_ADDRESS_NAME);
+ g_return_if_fail (ia->type != INTERNET_ADDRESS_MAILBOX);
g_return_if_fail (member != NULL);
ia->type = INTERNET_ADDRESS_GROUP;
@@ -273,12 +278,12 @@
* @ia: internet address
*
* Gets the type of the internet address, which will either be
- * #INTERNET_ADDRESS_NAME or #INTERNET_ADDRESS_GROUP.
+ * #INTERNET_ADDRESS_MAILBOX or #INTERNET_ADDRESS_GROUP.
*
* Returns: the type of @ia.
**/
InternetAddressType
-internet_address_get_type (InternetAddress *ia)
+internet_address_get_type (const InternetAddress *ia)
{
g_return_val_if_fail (ia != NULL, INTERNET_ADDRESS_NONE);
@@ -296,7 +301,7 @@
* Returns: the name of @ia.
**/
const char *
-internet_address_get_name (InternetAddress *ia)
+internet_address_get_name (const InternetAddress *ia)
{
g_return_val_if_fail (ia != NULL, NULL);
@@ -306,14 +311,14 @@
/**
* internet_address_get_addr:
- * @ia: internet address
+ * @ia: a #InternetAddress of type #INTERNET_ADDRESS_MAILBOX
*
* Gets the addr-spec of the internet address.
*
* Returns: the address of @ia.
**/
const char *
-internet_address_get_addr (InternetAddress *ia)
+internet_address_get_addr (const InternetAddress *ia)
{
g_return_val_if_fail (ia != NULL, NULL);
g_return_val_if_fail (ia->type != INTERNET_ADDRESS_GROUP, NULL);
@@ -324,24 +329,27 @@
/**
* internet_address_get_members:
- * @ia: internet address
+ * @ia: a #InternetAddress of type #INTERNET_ADDRESS_GROUP
*
* Gets the #InternetAddressList containing the group members of an
* rfc822 group address.
*
- * Returns: the members of @ia.
+ * Returns: a ref'd #InternetAddressList containing the members of
+ * @ia.
**/
-const InternetAddressList *
-internet_address_get_members (InternetAddress *ia)
+InternetAddressList *
+internet_address_get_members (const InternetAddress *ia)
{
g_return_val_if_fail (ia != NULL, NULL);
- g_return_val_if_fail (ia->type != INTERNET_ADDRESS_NAME, NULL);
+ g_return_val_if_fail (ia->type != INTERNET_ADDRESS_MAILBOX, NULL);
+
+ if (ia->value.members)
+ internet_address_list_ref (ia->value.members);
return ia->value.members;
}
-
/**
* internet_address_list_new:
*
@@ -356,6 +364,7 @@
list = g_new (InternetAddressList, 1);
list->array = g_ptr_array_new ();
+ list->refcount = 1;
return list;
}
@@ -367,14 +376,11 @@
*
* Destroys the list of #InternetAddress objects.
**/
-void
+static void
internet_address_list_destroy (InternetAddressList *list)
{
guint i;
- if (list == NULL)
- return;
-
for (i = 0; i < list->array->len; i++)
internet_address_unref (list->array->pdata[i]);
@@ -384,6 +390,40 @@
/**
+ * internet_address_list_ref:
+ * @list: a #InternetAddressList
+ *
+ * Ref's the internet address list.
+ **/
+void
+internet_address_list_ref (InternetAddressList *list)
+{
+ g_return_if_fail (list != NULL);
+
+ list->refcount++;
+}
+
+
+/**
+ * internet_address_list_unref:
+ * @list: a #InternetAddressList
+ *
+ * Unref's the internet address list.
+ **/
+void
+internet_address_list_unref (InternetAddressList *list)
+{
+ g_return_if_fail (list != NULL);
+
+ if (list->refcount <= 1) {
+ internet_address_list_destroy (list);
+ } else {
+ list->refcount--;
+ }
+}
+
+
+/**
* internet_address_list_length:
* @list: a #InternetAddressList
*
@@ -616,16 +656,21 @@
* Returns: the #InternetAddress at the specified index or %NULL if
* the index is out of range.
**/
-const InternetAddress *
+InternetAddress *
internet_address_list_get_address (const InternetAddressList *list, int index)
{
+ InternetAddress *ia;
+
g_return_val_if_fail (list != NULL, NULL);
g_return_val_if_fail (index < 0, NULL);
if ((guint) index >= list->array->len)
return NULL;
- return list->array->pdata[index];
+ ia = list->array->pdata[index];
+ internet_address_ref (ia);
+
+ return ia;
}
@@ -752,7 +797,7 @@
char *name;
size_t len;
- if (ia->type == INTERNET_ADDRESS_NAME) {
+ if (ia->type == INTERNET_ADDRESS_MAILBOX) {
if (ia->name && *ia->name) {
name = encoded_name (ia->name, encode);
len = strlen (name);
@@ -1076,7 +1121,7 @@
g_free (utf8);
}
- mailbox = internet_address_new_name (name ? name->str : NULL, addr->str);
+ mailbox = internet_address_new_mailbox (name ? name->str : NULL, addr->str);
}
g_string_free (addr, TRUE);
@@ -1195,7 +1240,7 @@
}
if (addrlist->array->len == 0) {
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
addrlist = NULL;
}
Modified: trunk/gmime/internet-address.h
==============================================================================
--- trunk/gmime/internet-address.h (original)
+++ trunk/gmime/internet-address.h Mon Aug 18 15:16:11 2008
@@ -27,31 +27,24 @@
G_BEGIN_DECLS
+
+
/**
* InternetAddressType:
* @INTERNET_ADDRESS_NONE: No type.
- * @INTERNET_ADDRESS_NAME: A typical internet address type.
- * @INTERNET_ADDRESS_GROUP: An rfc822 group type address.
+ * @INTERNET_ADDRESS_MAILBOX: A typical internet address type.
+ * @INTERNET_ADDRESS_GROUP: An rfc2822 group type address.
*
* The type of #InternetAddress.
**/
typedef enum {
INTERNET_ADDRESS_NONE,
- INTERNET_ADDRESS_NAME,
+ INTERNET_ADDRESS_MAILBOX,
INTERNET_ADDRESS_GROUP
} InternetAddressType;
-typedef struct _InternetAddress InternetAddress;
-
-
-/**
- * InternetAddressList:
- * @next: Pointer to the next item in the list.
- * @address: The #InternetAddress.
- *
- * A collection of #InternetAddresses.
- **/
typedef struct _InternetAddressList InternetAddressList;
+typedef struct _InternetAddress InternetAddress;
/**
@@ -60,7 +53,7 @@
* @refcount: The reference count.
* @name: The name component of the internet address.
*
- * A structure representing an rfc822 address.
+ * A structure representing an rfc2822 address.
**/
struct _InternetAddress {
InternetAddressType type;
@@ -74,7 +67,7 @@
InternetAddress *internet_address_new (void);
-InternetAddress *internet_address_new_name (const char *name, const char *addr);
+InternetAddress *internet_address_new_mailbox (const char *name, const char *addr);
InternetAddress *internet_address_new_group (const char *name);
void internet_address_ref (InternetAddress *ia);
@@ -85,13 +78,31 @@
void internet_address_set_group (InternetAddress *ia, InternetAddressList *group);
void internet_address_add_member (InternetAddress *ia, InternetAddress *member);
-InternetAddressType internet_address_get_type (InternetAddress *ia);
-const char *internet_address_get_name (InternetAddress *ia);
-const char *internet_address_get_addr (InternetAddress *ia);
-const InternetAddressList *internet_address_get_members (InternetAddress *ia);
+InternetAddressType internet_address_get_type (const InternetAddress *ia);
+const char *internet_address_get_name (const InternetAddress *ia);
+const char *internet_address_get_addr (const InternetAddress *ia);
+InternetAddressList *internet_address_get_members (const InternetAddress *ia);
+
+char *internet_address_to_string (const InternetAddress *ia, gboolean encode);
+
+
+/**
+ * InternetAddressList:
+ * @refcount: The reference count.
+ * @array: The array of #InternetAddress objects.
+ *
+ * A collection of #InternetAddress objects.
+ **/
+struct _InternetAddressList {
+ unsigned int refcount;
+ GPtrArray *array;
+};
+
InternetAddressList *internet_address_list_new (void);
-void internet_address_list_destroy (InternetAddressList *list);
+
+void internet_address_list_ref (InternetAddressList *list);
+void internet_address_list_unref (InternetAddressList *list);
int internet_address_list_length (const InternetAddressList *list);
@@ -106,12 +117,11 @@
gboolean internet_address_list_contains (const InternetAddressList *list, const InternetAddress *ia);
int internet_address_list_index_of (const InternetAddressList *list, const InternetAddress *ia);
-const InternetAddress *internet_address_list_get_address (const InternetAddressList *list, int index);
+InternetAddress *internet_address_list_get_address (const InternetAddressList *list, int index);
void internet_address_list_set_address (InternetAddressList *list, int index, InternetAddress *ia);
InternetAddressList *internet_address_list_parse_string (const char *str);
-char *internet_address_to_string (const InternetAddress *ia, gboolean encode);
char *internet_address_list_to_string (const InternetAddressList *list, gboolean encode);
void internet_address_list_writer (const InternetAddressList *list, GString *str);
Modified: trunk/tests/test-mime.c
==============================================================================
--- trunk/tests/test-mime.c (original)
+++ trunk/tests/test-mime.c Mon Aug 18 15:16:11 2008
@@ -193,7 +193,7 @@
g_free (str);
if (addrlist)
- internet_address_list_destroy (addrlist);
+ internet_address_list_unref (addrlist);
}
}
Modified: trunk/tools/gmime-port-2-2-to-2-4.sh
==============================================================================
--- trunk/tools/gmime-port-2-2-to-2-4.sh (original)
+++ trunk/tools/gmime-port-2-2-to-2-4.sh Mon Aug 18 15:16:11 2008
@@ -85,7 +85,10 @@
-e "s/g_mime_object_ref/g_object_ref/g" \
-e "s/g_mime_stream_unref/g_object_unref/g" \
-e "s/g_mime_stream_ref/g_object_ref/g" \
+ -e "s/INTERNET_ADDRESS_NAME/INTERNET_ADDRESS?MAILBOX/g" \
+ -e "s/internet_address_new_name/internet_address_new_mailbox/g" \
-e "s/internet_address_parse_string/internet_address_list_parse_string/g" \
+ -e "s/internet_address_list_destroy/internet_address_list_unref/g" \
-e "s/internet_address_list_append/internet_address_list_add/g" \
< "$src" > "$src.tmp"
mv "$src.tmp" "$src"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]