Author: antonello
Date: 2006-10-08 07:00:50 -0400 (Sun, 08 Oct 2006)
New Revision: 66400

Modified:
   trunk/Deveel.Pim/Deveel.Pim/ContactConverter.cs
   trunk/Deveel.Pim/Deveel.Pim/ContactDetail.cs
   trunk/Deveel.Pim/Deveel.Pim/vCardParser.csc
Log:
Modified ContactDetail logic.

Modified: trunk/Deveel.Pim/Deveel.Pim/ContactConverter.cs
===================================================================
--- trunk/Deveel.Pim/Deveel.Pim/ContactConverter.cs     2006-10-08 11:00:44 UTC 
(rev 66399)
+++ trunk/Deveel.Pim/Deveel.Pim/ContactConverter.cs     2006-10-08 11:00:50 UTC 
(rev 66400)
@@ -307,20 +307,17 @@
                        return ("BDAY:" + birthday + "\r\n");
                }
 
-               private string composeFieldTelephone(ArrayList phones) {
+               private string ComposeFieldTelephone(PropertyCollection phones) 
{
                        if (phones == null || phones.Count == 0)
                                return String.Empty;
 
                        StringBuilder output = new StringBuilder();
                        ArrayList properties = new ArrayList();
 
-                       Phone telephone = null;
-                       string phoneType = null;
-
                        int size = phones.Count;
                        for (int i = 0; i < size; i++) {
-                               telephone = (Phone)phones[i];
-                               phoneType = 
ComposePhoneType(telephone.PhoneType);
+                               Phone telephone = (Phone)phones[i];
+                               string phoneType = 
ComposePhoneType(telephone.PhoneType);
 
                                properties.Clear();
                                properties.Insert(0, telephone);
@@ -413,7 +410,7 @@
                        return String.Empty;
                }
 
-               private string ComposeFieldEmail(ArrayList emails) {
+               private string ComposeFieldEmail(PropertyCollection emails) {
                        if (emails == null || emails.Count == 0)
                                return String.Empty;
 
@@ -460,7 +457,7 @@
                        return String.Empty;
                }
 
-               private string ComposeFieldWebPage(ArrayList webpages) {
+               private string ComposeFieldWebPage(PropertyCollection webpages) 
{
                        if (webpages == null || webpages.Count == 0)
                                return String.Empty;
 
@@ -668,7 +665,7 @@
                                
output.Append(ComposeFieldPersonalLabel(contact.PersonalDetail.Address.Label));
                                
output.Append(ComposeFieldOtherLabel(contact.PersonalDetail.OtherAddress.Label));
                                if (contact.PersonalDetail != null) {
-                                       
output.Append(composeFieldTelephone(contact.PersonalDetail.Phones));
+                                       
output.Append(ComposeFieldTelephone(contact.PersonalDetail.Phones));
                                        
output.Append(ComposeFieldEmail(contact.PersonalDetail.Emails));
                                        
output.Append(ComposeFieldWebPage(contact.PersonalDetail.WebPages));
                                }
@@ -680,7 +677,7 @@
                                
output.Append(ComposeFieldOrg(contact.BusinessDetail.Company, 
contact.BusinessDetail.Department));
                                
output.Append(ComposeFieldBusinessLabel(contact.BusinessDetail.Address.Label));
                                if (contact.BusinessDetail != null) {
-                                       
output.Append(composeFieldTelephone(contact.BusinessDetail.Phones));
+                                       
output.Append(ComposeFieldTelephone(contact.BusinessDetail.Phones));
                                        
output.Append(ComposeFieldEmail(contact.BusinessDetail.Emails));
                                        
output.Append(ComposeFieldWebPage(contact.BusinessDetail.WebPages));
                                }

Modified: trunk/Deveel.Pim/Deveel.Pim/ContactDetail.cs
===================================================================
--- trunk/Deveel.Pim/Deveel.Pim/ContactDetail.cs        2006-10-08 11:00:44 UTC 
(rev 66399)
+++ trunk/Deveel.Pim/Deveel.Pim/ContactDetail.cs        2006-10-08 11:00:50 UTC 
(rev 66400)
@@ -28,90 +28,36 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-
 using System;
-using System.Collections;
 
 namespace Deveel.Pim {
        public class ContactDetail {
                #region .ctor
                public ContactDetail() {
-                       phones = null;
-                       emails = null;
-                       webPages = null;
+                       phones = new PropertyCollection();
+                       emails = new PropertyCollection();
+                       webPages = new PropertyCollection();
                }
                #endregion
 
                #region Fields
-               private ArrayList phones;
-               private ArrayList emails;
-               private ArrayList webPages;
+               private PropertyCollection phones;
+               private PropertyCollection emails;
+               private PropertyCollection webPages;
                #endregion
 
                #region Properties
-               public ArrayList Phones {
+               public PropertyCollection Phones {
                        get { return phones; }
-                       set { phones = value; }
                }
 
-               public ArrayList Emails {
+               public PropertyCollection Emails {
                        get { return emails; }
-                       set { emails = value; }
                }
 
-               public ArrayList WebPages {
+               public PropertyCollection WebPages {
                        get { return webPages; }
-                       set { webPages = value; }
                }
-               #endregion
-
-               public void AddPhone(Phone phone) {
-                       if (phone == null)
-                               return;
-
-                       if (phones == null)
-                               phones = new ArrayList();
-
-                       int pos = phones.IndexOf(phone);
-                       if (pos < 0) {
-                               phones.Add(phone);
-                       } else {
-                               phones[pos] = phone;
-                       }
-               }
-
-               public void AddEmail(Email email) {
-                       if (email == null) {
-                               return;
-                       }
-
-                       if (emails == null) {
-                               emails = new ArrayList();
-                       }
-
-                       int pos = emails.IndexOf(email);
-                       if (pos < 0) {
-                               emails.Add(email);
-                       } else {
-                               emails[pos] = email;
-                       }
-               }
-
-               public void AddWebPage(WebPage page) {
-                       if (page == null) {
-                               return;
-                       }
-
-                       if (webPages == null) {
-                               webPages = new ArrayList();
-                       }
-
-                       int pos = webPages.IndexOf(page);
-                       if (pos < 0) {
-                               webPages.Add(page);
-                       } else {
-                               webPages[pos] = page;
-                       }
-               }
+               #endregion              
        }
 }
\ No newline at end of file

Modified: trunk/Deveel.Pim/Deveel.Pim/vCardParser.csc
===================================================================
--- trunk/Deveel.Pim/Deveel.Pim/vCardParser.csc 2006-10-08 11:00:44 UTC (rev 
66399)
+++ trunk/Deveel.Pim/Deveel.Pim/vCardParser.csc 2006-10-08 11:00:50 UTC (rev 
66400)
@@ -421,14 +421,14 @@
             Email tmpmail = new Email(text);
             SetParameters(tmpmail,plist,group);
             if (email == 0) {
-                if (emailHome == 0) {
-                    contact.PersonalDetail.Emails = new ArrayList();
-                }
+                //if (emailHome == 0) {
+                //    contact.PersonalDetail.Emails = new ArrayList();
+                //}
                 tmpmail.EmailType = "Email1Address";
             } else {
                 tmpmail.EmailType = "OtherEmail" + (email + 1) + "Address";
             }
-            contact.PersonalDetail.AddEmail(tmpmail);
+            contact.PersonalDetail.Emails.Add(tmpmail);
             email++;
         } else if (plist.ContainsKey("HOME")) {
             string text=Unfold(content);
@@ -436,14 +436,14 @@
             Email tmpmail = new Email(text);
             SetParameters(tmpmail,plist,group);
             if (emailHome == 0) {
-                if (email == 0) {
-                    contact.PersonalDetail.Emails = new ArrayList();
-                }
+                //if (email == 0) {
+                //    contact.PersonalDetail.Emails = new ArrayList();
+                //}
                 tmpmail.EmailType = "Email2Address";
             } else {
                 tmpmail.EmailType = "HomeEmail" + (emailHome + 1) + "Address";
             }
-            contact.PersonalDetail.AddEmail(tmpmail);
+            contact.PersonalDetail.Emails.Add(tmpmail);
             emailHome++;
         } else if (plist.ContainsKey("WORK")) {
             string text=Unfold(content);
@@ -451,12 +451,12 @@
             Email tmpmail = new Email(text);
             SetParameters(tmpmail,plist,group);
             if (emailWork == 0) {
-                contact.BusinessDetail.Emails = new ArrayList();
+                //contact.BusinessDetail.Emails = new ArrayList();
                 tmpmail.EmailType = "Email3Address";
             } else {
                 tmpmail.EmailType = "BusinessEmail" + (emailWork + 1) + 
"Address";
             }
-            contact.BusinessDetail.AddEmail(tmpmail);
+            contact.BusinessDetail.Emails.Add(tmpmail);
             emailWork++;
         } else {
             string text=Unfold(content);
@@ -464,14 +464,14 @@
             Email tmpmail = new Email(text);
             SetParameters(tmpmail,plist,group);
             if (email == 0) {
-                if (emailHome == 0) {
-                    contact.PersonalDetail.Emails = new ArrayList();
-        }
+                //if (emailHome == 0) {
+                //    contact.PersonalDetail.Emails = new ArrayList();
+                //}
                 tmpmail.EmailType = "Email1Address";
             } else {
                 tmpmail.EmailType = "OtherEmail" + (email + 1) + "Address";
             }
-            contact.PersonalDetail.AddEmail(tmpmail);
+            contact.PersonalDetail.Emails.Add(tmpmail);
             email++;
         
         }
@@ -493,14 +493,14 @@
             SetParameters(tmppage,plist,group);
 
             if (webPage == 0) {
-                if (webPageHome == 0) {
-                    contact.PersonalDetail.WebPages = new ArrayList();
-                }
+                //if (webPageHome == 0) {
+                //    contact.PersonalDetail.WebPages = new ArrayList();
+                //}
                 tmppage.WebPageType = "WebPage";
             } else {
                 tmppage.WebPageType = "WebPage" + (webPage + 1);
             }
-            contact.PersonalDetail.AddWebPage(tmppage);
+            contact.PersonalDetail.WebPages.Add(tmppage);
             webPage++;
         }
 
@@ -512,14 +512,14 @@
             SetParameters(tmppage,plist,group);
 
             if (webPageHome == 0) {
-                if (webPage == 0) {
-                    contact.PersonalDetail.WebPages = new ArrayList();
-                }
+                //if (webPage == 0) {
+                //    contact.PersonalDetail.WebPages = new ArrayList();
+                //}
                 tmppage.WebPageType = "HomeWebPage";
             } else {
                 tmppage.WebPageType = "Home" + (webPageHome + 1) + "WebPage";
             }
-            contact.PersonalDetail.AddWebPage(tmppage);
+            contact.PersonalDetail.WebPages.Add(tmppage);
             webPageHome++;
         }
             
@@ -531,12 +531,12 @@
             SetParameters(tmppage,plist,group);
 
             if (webPageWork == 0) {
-                contact.BusinessDetail.WebPages = new ArrayList();
+                //contact.BusinessDetail.WebPages = new ArrayList();
                 tmppage.WebPageType = "BusinessWebPage";
             } else {
                 tmppage.WebPageType = "Business" + (webPageWork + 1) + 
"WebPage";
             }
-            contact.BusinessDetail.AddWebPage(tmppage);
+            contact.BusinessDetail.WebPages.Add(tmppage);
             webPageWork++;
         }
     }
@@ -555,11 +555,11 @@
             Phone tmphone = new Phone(content);
             SetParameters(tmphone, plist, group);
             // Check if it is the very first for a business detail.
-            if ((cellWorkTel == 0) && (voiceWorkTel == 0) &&
-                (faxWork == 0) && (pager == 0) && (primary == 0) &&
-                (companyMain == 0)) {
-                contact.BusinessDetail.Phones = new ArrayList();
-            }
+            //if ((cellWorkTel == 0) && (voiceWorkTel == 0) &&
+            //    (faxWork == 0) && (pager == 0) && (primary == 0) &&
+            //    (companyMain == 0)) {
+            //    contact.BusinessDetail.Phones = new ArrayList();
+            //}
 
             if (plist.ContainsKey("CELL")) {
                 if (cellWorkTel == 0) {
@@ -567,7 +567,7 @@
                 } else {
                     tmphone.PhoneType = "MobileBusiness" + (cellWorkTel + 1) + 
"TelephoneNumber";
                 }
-                contact.BusinessDetail.AddPhone(tmphone);
+                contact.BusinessDetail.Phones.Add(tmphone);
                 cellWorkTel++;
             }
 
@@ -577,7 +577,7 @@
                 } else {
                     tmphone.PhoneType = "Business" + (voiceWorkTel + 1) + 
"TelephoneNumber";
                 }
-                contact.BusinessDetail.AddPhone(tmphone);
+                contact.BusinessDetail.Phones.Add(tmphone);
                 voiceWorkTel++;
             }
             if (plist.ContainsKey("FAX")) {
@@ -586,13 +586,13 @@
                 } else {
                     tmphone.PhoneType = "Business" + (faxWork + 1) + 
"FaxNumber";
                 }
-                contact.BusinessDetail.AddPhone(tmphone);
+                contact.BusinessDetail.Phones.Add(tmphone);
                 faxWork++;
             }
             // suppose that can exists only one voice work telephone pref.
             if (plist.ContainsKey("PREF")) {
                 tmphone.PhoneType = "CompanyMainTelephoneNumber";
-                contact.BusinessDetail.AddPhone(tmphone);
+                contact.BusinessDetail.Phones.Add(tmphone);
                 companyMain++;
             }
         } else if ((plist.ContainsKey("CELL") && plist.Count == 1) ||
@@ -601,102 +601,102 @@
             SetParameters(tmphone, plist, group);
 
             if (cellTel == 0) {
-                if ((cellHomeTel == 0) && (voiceTel == 0) && (voiceHomeTel == 
0) && (fax == 0) && (faxHome == 0) && (car == 0)) {
-                    contact.PersonalDetail.Phones = new ArrayList();
-                }
+                //if ((cellHomeTel == 0) && (voiceTel == 0) && (voiceHomeTel 
== 0) && (fax == 0) && (faxHome == 0) && (car == 0)) {
+                //    contact.PersonalDetail.Phones = new ArrayList();
+                //}
                 tmphone.PhoneType = "MobileTelephoneNumber";
             } else {
                 tmphone.PhoneType = "Mobile" + (cellTel + 1) + 
"TelephoneNumber";
             }
-            contact.PersonalDetail.AddPhone(tmphone);
+            contact.PersonalDetail.Phones.Add(tmphone);
             cellTel++;
         } else if (plist.ContainsKey("HOME") && plist.ContainsKey("CELL")) {
             Phone tmphone = new Phone(content);
             SetParameters(tmphone, plist, group);
             if (cellHomeTel == 0) {
-                if ((cellTel == 0) && (voiceTel == 0) && (voiceHomeTel == 0) 
&& (fax == 0) && (faxHome == 0) && (car == 0)) {
-                    contact.PersonalDetail.Phones = new ArrayList();
-                }
+                //if ((cellTel == 0) && (voiceTel == 0) && (voiceHomeTel == 0) 
&& (fax == 0) && (faxHome == 0) && (car == 0)) {
+                //    contact.PersonalDetail.Phones = new ArrayList();
+                //}
                 tmphone.PhoneType = "MobileHomeTelephoneNumber";
             } else {
                 tmphone.PhoneType = "MobileHome" + (cellHomeTel + 1) + 
"TelephoneNumber";
             }
-            contact.PersonalDetail.AddPhone(tmphone);
+            contact.PersonalDetail.Phones.Add(tmphone);
             cellHomeTel++;
         } else if (plist.Count == 1 && plist.ContainsKey("VOICE")) {
             Phone tmphone = new Phone(content);
             SetParameters(tmphone,plist,group);
             if (voiceTel == 0) {
-                if ((cellTel == 0) && (cellHomeTel == 0) && (voiceHomeTel == 
0) && (fax == 0) && (faxHome == 0) && (car == 0)) {
-                    contact.PersonalDetail.Phones = new ArrayList();
-                }
+                //if ((cellTel == 0) && (cellHomeTel == 0) && (voiceHomeTel == 
0) && (fax == 0) && (faxHome == 0) && (car == 0)) {
+                //    contact.PersonalDetail.Phones = new ArrayList();
+                //}
                 tmphone.PhoneType = "OtherTelephoneNumber";
             } else {
                 tmphone.PhoneType = "Other" + (voiceTel + 1) + 
"TelephoneNumber";
             }
-            contact.PersonalDetail.AddPhone(tmphone);
+            contact.PersonalDetail.Phones.Add(tmphone);
             voiceTel++;
         } else if ((plist.ContainsKey("VOICE") && plist.ContainsKey("HOME"))  
||
             (plist.Count == 1 && plist.ContainsKey("HOME"))  )       {
             Phone tmphone = new Phone(content);
             SetParameters(tmphone, plist, group);
             if (voiceHomeTel == 0) {
-                if ((cellTel == 0) && (cellHomeTel == 0) && (voiceTel == 0) && 
(fax == 0) && (faxHome == 0) && (car == 0)) {
-                    contact.PersonalDetail.Phones = new ArrayList();
-                }
+                //if ((cellTel == 0) && (cellHomeTel == 0) && (voiceTel == 0) 
&& (fax == 0) && (faxHome == 0) && (car == 0)) {
+                //    contact.PersonalDetail.Phones = new ArrayList();
+                //}
                 tmphone.PhoneType = "HomeTelephoneNumber";
             } else {
                 tmphone.PhoneType = "Home" + (voiceHomeTel + 1) + 
"TelephoneNumber";
             }
-            contact.PersonalDetail.AddPhone(tmphone);
+            contact.PersonalDetail.Phones.Add(tmphone);
             voiceHomeTel++;
         } else if (plist.Count == 1 && plist.ContainsKey("FAX")) {
             Phone tmphone = new Phone(content);
             SetParameters(tmphone, plist, group);
             if (fax == 0) {
-                if ((cellTel == 0) && (cellHomeTel == 0) && (voiceTel == 0) && 
(voiceHomeTel == 0) && (faxHome == 0) && (car == 0)) {
-                    contact.PersonalDetail.Phones = new ArrayList();
-                }
+                //if ((cellTel == 0) && (cellHomeTel == 0) && (voiceTel == 0) 
&& (voiceHomeTel == 0) && (faxHome == 0) && (car == 0)) {
+                //    contact.PersonalDetail.Phones = new ArrayList();
+                //}
                 tmphone.PhoneType = "OtherFaxNumber";
             } else {
                 tmphone.PhoneType = "Other" + (fax + 1) + "FaxNumber";
             }
-            contact.PersonalDetail.AddPhone(tmphone);
+            contact.PersonalDetail.Phones.Add(tmphone);
             fax++;
         } else if (plist.ContainsKey("HOME") && plist.ContainsKey("FAX")) {
             Phone tmphone = new Phone(content);
             SetParameters(tmphone,plist,group);
             if (faxHome == 0) {
-                if ((cellTel == 0) && (cellHomeTel == 0) && (voiceTel == 0) && 
(voiceHomeTel == 0) && (fax == 0) && (car == 0)) {
-                    contact.PersonalDetail.Phones = new ArrayList();
-                }
+                //if ((cellTel == 0) && (cellHomeTel == 0) && (voiceTel == 0) 
&& (voiceHomeTel == 0) && (fax == 0) && (car == 0)) {
+                //    contact.PersonalDetail.Phones = new ArrayList();
+                //}
                 tmphone.PhoneType = "HomeFaxNumber";
             } else {
                 tmphone.PhoneType = "Home" + (faxHome + 1) + "FaxNumber";
             }
-            contact.PersonalDetail.AddPhone(tmphone);
+            contact.PersonalDetail.Phones.Add(tmphone);
             faxHome++;
         } else if (plist.ContainsKey("CAR")) {
             Phone tmphone = new Phone(content);
             SetParameters(tmphone,plist,group);
             tmphone.PhoneType = "CarTelephoneNumber";
-            if ((car == 0) && (cellTel == 0) && (cellHomeTel == 0) && 
(voiceTel == 0) && (voiceHomeTel == 0) && (fax == 0) && (faxHome == 0)) {
-                contact.PersonalDetail.Phones = new ArrayList();
-            }
-            contact.PersonalDetail.AddPhone(tmphone);
+            //if ((car == 0) && (cellTel == 0) && (cellHomeTel == 0) && 
(voiceTel == 0) && (voiceHomeTel == 0) && (fax == 0) && (faxHome == 0)) {
+            //    contact.PersonalDetail.Phones = new ArrayList();
+            //}
+            contact.PersonalDetail.Phones.Add(tmphone);
             car++;
         } else if (plist.ContainsKey("PAGER")) {
             Phone tmphone = new Phone(content);
             SetParameters(tmphone,plist,group);
             if (pager == 0) {
-                if ((cellWorkTel == 0) && (voiceWorkTel == 0) && (faxWork == 
0) && (primary == 0) && (companyMain == 0)) {
-                    contact.BusinessDetail.Phones = new ArrayList();
-                }
+                //if ((cellWorkTel == 0) && (voiceWorkTel == 0) && (faxWork == 
0) && (primary == 0) && (companyMain == 0)) {
+                //    contact.BusinessDetail.Phones = new ArrayList();
+                //}
                 tmphone.PhoneType = "PagerNumber";
             } else {
                 tmphone.PhoneType = "PagerNumber" + (pager + 1);
             }
-            contact.BusinessDetail.AddPhone(tmphone);
+            contact.BusinessDetail.Phones.Add(tmphone);
             pager++;
         } else if ((plist.ContainsKey("PREF") && plist.ContainsKey("VOICE")) ||
             (plist.ContainsKey("PREF") && plist.Count == 1)) {
@@ -704,11 +704,11 @@
             // suppose that can exists only one voice telephone pref.
             Phone tmphone = new Phone(content);
             SetParameters(tmphone,plist,group);
-            if ((primary == 0) && (cellWorkTel == 0) && (voiceWorkTel == 0) && 
(faxWork == 0) && (pager == 0) && (companyMain == 0)) {
-                contact.BusinessDetail.Phones = new ArrayList();
-            }
+            //if ((primary == 0) && (cellWorkTel == 0) && (voiceWorkTel == 0) 
&& (faxWork == 0) && (pager == 0) && (companyMain == 0)) {
+            //    contact.BusinessDetail.Phones = new ArrayList();
+            //}
             tmphone.PhoneType = "PrimaryTelephoneNumber";
-            contact.BusinessDetail.AddPhone(tmphone);
+            contact.BusinessDetail.Phones.Add(tmphone);
             primary++;
         }
     }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to