Adding GMail CSV support to the backend
[gc-dialer] / src / backends / gvoice.py
index ca26737..88035ba 100755 (executable)
@@ -188,6 +188,7 @@ class GVoiceBackend(object):
                self._XML_ACCOUNT_URL = SECURE_URL_BASE + "contacts/"
                # HACK really this redirects to the main pge and we are grabbing some javascript
                self._XML_CONTACTS_URL = "http://www.google.com/voice/inbox/search/contact"
+               self._CSV_CONTACTS_URL = "http://mail.google.com/mail/contacts/data/export"
                self._XML_RECENT_URL = SECURE_URL_BASE + "inbox/recent/"
 
                self.XML_FEEDS = (
@@ -511,6 +512,15 @@ class GVoiceBackend(object):
                                        contactDetails["name"] = unescape(contactDetails["name"])
                                yield contactId, contactDetails
 
+       def get_csv_contacts(self):
+               data = {
+                       "groupToExport": "mine",
+                       "exportType": "ALL",
+                       "out": "OUTLOOK_CSV",
+               }
+               contacts = self._get_page(self._CSV_CONTACTS_URL, data)
+               return contacts
+
        def get_voicemails(self):
                """
                @blocks
@@ -961,6 +971,7 @@ def grab_debug_info(username, password):
                ("isdnd", backend._isDndURL),
                ("account", backend._XML_ACCOUNT_URL),
                ("contacts", backend._XML_CONTACTS_URL),
+               ("csv", backend._CSV_CONTACTS_URL),
 
                ("voicemail", backend._XML_VOICEMAIL_URL),
                ("sms", backend._XML_SMS_URL),