[evolution-patches] Patch for ... adding three new important function for EContact...



Hi all,

Am a OOo hacker, my application(OpenOffice.org: "mail merge") required
all the "synthetic structured field " in plain "char *" just like 
e_contact_name_to_string(EContactName) or 
e_contact_date_to_string(EContactDate)

I have added three function
1> e_contact_address_to_string(EContactAddress) 
2> e_contact_address_to_string_with_separator(EContactAddress,char)
3> e_contact_address_equal(EContactAddress,EContactAddress);

Attached with this mail is diff's for the same.

There is one more thing missing though E_TYPE_CONTACT_ADDRESS is defined
but E_IS_ADDRESS(obj) is not defined. Actually it seems like e_contact_get
(contact,E_CONTACT_ADDRESS_HOME) does not return "Object" but a pointer
to struct EContactAddress !!! Please let me know if my guess is correct
so that i can go ahead and write the function for same(if it is
required :) ).


Thanks,
(aZEN_JM)
-- 
Jayant Madavi <mjayant novell com>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.182
diff -u -p -r1.182 ChangeLog
--- ChangeLog	3 Aug 2004 23:46:39 -0000	1.182
+++ ChangeLog	5 Aug 2004 13:10:11 -0000
@@ -1,3 +1,10 @@
+2004-08-05  Jayant Madavi <mjayant novell com>
+
+	*  libebook/e-contact.[ch] : added new functions
+	e_contact_address_to_string, 
+	e_contact_address_to_string_with_separator, 
+	e_contact_address_equal
+
 2004-08-03  Chris Toshok  <toshok ximian com>
 
 	* tests/vcard/Makefile.am (EXTRA_DIST): add 11.vcf.
Index: libebook/e-contact.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-contact.h,v
retrieving revision 1.15
diff -u -p -r1.15 e-contact.h
--- libebook/e-contact.h	20 May 2004 00:44:15 -0000	1.15
+++ libebook/e-contact.h	5 Aug 2004 13:10:11 -0000
@@ -294,7 +294,9 @@ void                    e_contact_cert_f
 
 GType                   e_contact_address_get_type (void);
 void                    e_contact_address_free     (EContactAddress *address);
-
+char 		       *e_contact_address_to_string(EContactAddress *address);
+char 		       *e_contact_address_to_string_with_separator(EContactAddress *address,char separator);
+gboolean		e_contact_address_equal	   (EContactAddress *ad1,EContactAddress *ad2);
 
 const char*             e_contact_field_name       (EContactField field_id);
 const char*             e_contact_pretty_name      (EContactField field_id);
Index: libebook/e-contact.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-contact.c,v
retrieving revision 1.37
diff -u -p -r1.37 e-contact.c
--- libebook/e-contact.c	22 Jun 2004 01:27:53 -0000	1.37
+++ libebook/e-contact.c	5 Aug 2004 13:10:11 -0000
@@ -1,5 +1,5 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-contact.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- *n
+ * e-contact.c
  *
  * Copyright (C) 2003 Ximian, Inc.
  *
@@ -1723,6 +1723,76 @@ e_contact_address_free (EContactAddress 
 	g_free (address);
 }
 
+/**
+ * e_contact_address_equal:
+ * @ad1: First address for comparision
+ * @ad2: Second address for comparision
+ * returns TRUE is they are equal else FALSE
+ *
+ * Info for developer: Though address format is used for comparision
+ * but it is not actually used adr_setter does not even get the value of it
+ * the address_format is put as "".
+ */
+
+gboolean
+e_contact_address_equal(EContactAddress *ad1, EContactAddress *ad2) {
+	if (ad1 && ad2) 
+	{
+		if ((0==strcmp(ad1->address_format, ad2->address_format)) &&
+			(0==strcmp(ad1->po,       ad2->po)) &&
+			(0==strcmp(ad1->ext,      ad2->ext)) &&
+			(0==strcmp(ad1->street,   ad2->street)) &&
+			(0==strcmp(ad1->locality, ad2->locality)) &&
+			(0==strcmp(ad1->region,   ad2->region)) &&
+			(0==strcmp(ad1->code,     ad2->code)) &&
+			(0==strcmp(ad1->country,  ad2->country)) 
+			)
+		return TRUE;
+	}
+		
+	return FALSE;
+}
+
+/**
+ * e_contact_address_to_string_with_separator:
+ * @address: The contact for which a contains the actual data
+ * @separator: a char which is a separator between 2 attributes of address
+ * returns string array of combined name.
+ *
+ * Info for Developer: the address_format field is still not used, b'se the
+ * adr_setter is not putting any value into it.
+ */
+char *                    
+e_contact_address_to_string_with_separator(EContactAddress *address,char separator)
+{
+	char *addr_string=NULL;
+	
+	if (address) 
+	{
+		addr_string = g_strdup_printf ("%s%c%s%c%s%c%s%c%s%c%s%c%s",
+				address->po, separator ,	
+				address->ext, separator ,	
+				address->street, separator ,	
+				address->locality, separator ,	
+				address->region, separator ,	
+				address->code, 	separator ,	
+				address->country 
+				);
+	}
+	return addr_string;
+}
+
+/**
+ * Same as e_contact_address_to_string_with_separator.
+ * The only thing different is the DEFAULT separator ie single space
+ */
+
+char *
+e_contact_address_to_string(EContactAddress *address) 
+{
+	return e_contact_address_to_string_with_separator (address,' ');
+}
+
 static EContactAddress *
 e_contact_address_copy (EContactAddress *address)
 {


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