Re: Google Contacts Problem



I'm running your latest patch, and everything is working.
I get another patch on the list, for the phone numbers, and made some
fixes for that to work properly. 
I tested using folder and evolution contacts, and it's working
properly. 
I'll try to fix the Instant Messenger piece of code when I have more
time. Please check this patch and make your comments. 
It has your previous patches on it. If it's a problem, let me know and I
make another patch
Thanks

Regards

Em Qui, 2008-09-04 às 16:12 +0100, John Carr escreveu:
> On Thu, Sep 4, 2008 at 3:57 PM, Fabio Rafael da Rosa
> <fabiorafael rosa gmail com> wrote:
> > Sorry for the delay, I was without internet connection (work problems).
> > I tried your patch and it didn't work.
> > I made some changes and got it to work better, but it still is not 100%
> > I had some problems at work this week, so I didn't have much time to
> > check on that. Problably I'll be able to take a look tonigh and I hope I
> > can finish that :) .
> > I'll add you second patch to my changes and let you know :).
> >
> > Thanks
> >
> > Regards
> 
> Can you try the third patch? It combines the first 2 and fixes some
> stupid errors...
> 
> John
diff --recursive -uBb conduit-trunk/conduit/datatypes/Contact.py conduit-new/conduit/datatypes/Contact.py
--- conduit-trunk/conduit/datatypes/Contact.py	2008-09-01 21:30:37.000000000 -0300
+++ conduit-new/conduit/datatypes/Contact.py	2008-09-04 23:47:38.000000000 -0300
@@ -73,6 +74,15 @@
             email.value = address
             email.type_param = 'INTERNET'
         
+    def set_phones(self, args):
+        for number,rel in args: 
+            tel = self.vcard.add('tel')
+            tel.value = number
+            if rel != 'MOBILE':
+                tel.type_param = [rel, u"VOICE"]            
+            else:            
+                tel.type_param = [u'CELL', u'VOICE']
+
     def __getstate__(self):
         data = DataType.DataType.__getstate__(self)
         data['vcard'] = self.get_vcard_string()
diff --recursive -uBb conduit-trunk/conduit/datatypes/File.py conduit-new/conduit/datatypes/File.py
--- conduit-trunk/conduit/datatypes/File.py	2008-09-01 21:30:37.000000000 -0300
+++ conduit-new/conduit/datatypes/File.py	2008-09-04 12:24:29.000000000 -0300
@@ -454,9 +454,9 @@
     """
     Creates a file in the system temp directory with the given contents.
     """
-    def __init__(self, contents, **kwargs):
+    def __init__(self, contents, suffix=None, **kwargs):
         #create the file containing contents
-        fd, name = tempfile.mkstemp(prefix="conduit")
+        fd, name = tempfile.mkstemp(prefix="conduit", suffix=suffix)
         os.write(fd, contents)
         os.close(fd)
         File.__init__(self, name, **kwargs)
diff --recursive -uBb conduit-trunk/conduit/modules/ConverterModule.py conduit-new/conduit/modules/ConverterModule.py
--- conduit-trunk/conduit/modules/ConverterModule.py	2008-09-01 21:30:40.000000000 -0300
+++ conduit-new/conduit/modules/ConverterModule.py	2008-09-04 12:24:29.000000000 -0300
@@ -112,7 +112,7 @@
                             
     def contact_to_file(self, contact, **kwargs):
         #get vcard data
-        f = Utils.new_tempfile(contact.get_vcard_string())
+        f = Utils.new_tempfile(contact.get_vcard_string(), suffix=".vcf")
         return f
 
     def contact_to_text(self, contact, **kwargs):
diff --recursive -uBb conduit-trunk/conduit/modules/GoogleModule/GoogleModule.py conduit-new/conduit/modules/GoogleModule/GoogleModule.py
--- conduit-trunk/conduit/modules/GoogleModule/GoogleModule.py	2008-09-01 21:30:40.000000000 -0300
+++ conduit-new/conduit/modules/GoogleModule/GoogleModule.py	2008-09-04 23:42:24.000000000 -0300
@@ -847,6 +847,7 @@
         #notes = contact.get_notes()
         #if notes: gc.content = atom.Content(text=notes)
         
+        #trying to import phone numbers
         return gc
 
         
@@ -860,6 +861,9 @@
         emails = [str(e.address) for e in gc.email]
         c.set_emails(*emails)
         
+        phones = [(phone.text,phone.rel.split('#')[1].upper()) for phone in gc.phone_number]
+        c.set_phones(phones)
+
         #ee_names = map(operator.attrgetter('tag'),gc.extension_elements)
         #if len(gc.extension_elements) >0:
         #    for e in [e for e in ee_names if e == 'phoneNumber']:
@@ -933,7 +937,19 @@
         feed = self.service.GetContactsFeed()
         if not feed.entry:
             return []
-        return [str(contact.id.text) for contact in feed.entry]
+
+        # the only examples of GetNextLink do this, don't know if we need it
+        # contacts_service.auth_token = authsub_token
+        # contacts_service.UpgradeToSessionToken()
+
+	contacts = []
+	contacts.extend([str(contact.id.text) for contact in feed.entry])
+	next = feed.GetNextLink()
+	while next:
+            feed = self.service.GetContactsFeed(uri=next.href)
+	    contacts.extend([str(contact.id.text) for contact in feed.entry])
+	    next = feed.GetNextLink()
+        return contacts
         
     def refresh(self):
         DataProvider.TwoWay.refresh(self)


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