Merge gv_support changes r243:251 into the trunk
authorepage <eopage@byu.net>
Thu, 26 Mar 2009 02:33:34 +0000 (02:33 +0000)
committerepage <eopage@byu.net>
Thu, 26 Mar 2009 02:33:34 +0000 (02:33 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@252 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

Makefile
src/dc_glade.py
src/dialcentral.glade
src/gc_backend.py
src/gc_views.py
src/gdata_backend.py
src/gtk_toolbox.py
src/gv_backend.py
src/null_backend.py [new file with mode: 0644]
src/null_views.py
support/builddeb.py

index cb4cb18..1edb00e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,7 @@ test: $(SOURCE)
        $(UNIT_TEST)
 
 build:
+       @# @todo Add a PYC generation step
        rm -Rf $(BUILD_PATH)
        mkdir $(BUILD_PATH)
        cp $(SOURCE_PATH)/$(PROJECT_NAME).py  $(BUILD_PATH)
index 8e7c205..1229cdc 100755 (executable)
@@ -40,6 +40,13 @@ except ImportError:
 import gtk_toolbox
 
 
+def getmtime_nothrow(path):
+       try:
+               return os.path.getmtime(path)
+       except StandardError:
+               return 0
+
+
 class Dialcentral(object):
 
        __pretty_app_name__ = "DialCentral"
@@ -53,17 +60,22 @@ class Dialcentral(object):
                os.path.join(os.path.dirname(__file__), "../lib/dialcentral.glade"),
        ]
 
+       NULL_BACKEND = 0
+       GC_BACKEND = 1
+       GV_BACKEND = 2
+       BACKENDS = (NULL_BACKEND, GC_BACKEND, GV_BACKEND)
+
        _data_path = os.path.join(os.path.expanduser("~"), ".dialcentral")
 
        def __init__(self):
                self._connection = None
                self._osso = None
-               self._phoneBackends = []
-               self._phoneBackend = None
                self._clipboard = gtk.clipboard_get()
 
                self._deviceIsOnline = True
-               self._isLoggedIn = False
+               self._selectedBackendId = self.NULL_BACKEND
+               self._defaultBackendId = self.GC_BACKEND
+               self._phoneBackends = None
                self._dialpads = None
                self._accountViews = None
                self._recentViews = None
@@ -130,6 +142,26 @@ class Dialcentral(object):
                """
                If something can be done after the UI loads, push it here so it's not blocking the UI
                """
+               # Barebones UI handlers
+               import null_backend
+               import null_views
+
+               self._phoneBackends = {self.NULL_BACKEND: null_backend.NullDialer()}
+               gtk.gdk.threads_enter()
+               try:
+                       self._dialpads = {self.NULL_BACKEND: null_views.Dialpad(self._widgetTree)}
+                       self._accountViews = {self.NULL_BACKEND: null_views.AccountInfo(self._widgetTree)}
+                       self._recentViews = {self.NULL_BACKEND: null_views.RecentCallsView(self._widgetTree)}
+                       self._contactsViews = {self.NULL_BACKEND: null_views.ContactsView(self._widgetTree)}
+
+                       self._dialpads[self._selectedBackendId].enable()
+                       self._accountViews[self._selectedBackendId].enable()
+                       self._recentViews[self._selectedBackendId].enable()
+                       self._contactsViews[self._selectedBackendId].enable()
+               finally:
+                       gtk.gdk.threads_leave()
+
+               # Setup maemo specifics
                try:
                        import osso
                except ImportError:
@@ -154,11 +186,11 @@ class Dialcentral(object):
                else:
                        pass # warnings.warn("No Internet Connectivity API ", UserWarning)
 
+               # Setup costly backends
                import gv_backend
                import gc_backend
                import file_backend
                import evo_backend
-               import null_views
                import gc_views
 
                try:
@@ -166,61 +198,69 @@ class Dialcentral(object):
                except OSError, e:
                        if e.errno != 17:
                                raise
-               self._phoneBackends = [
-                       (gc_backend.GCDialer, os.path.join(self._data_path, "gc_cookies.txt")),
-                       (gv_backend.GVDialer, os.path.join(self._data_path, "gv_cookies.txt")),
-               ]
-               backendFactory, cookieFile = None, None
-               for backendFactory, cookieFile in self._phoneBackends:
-                       if os.path.exists(cookieFile):
-                               break
-               else:
-                       backendFactory, cookieFile = self._phoneBackends[0]
-               self._phoneBackend = backendFactory(cookieFile)
+               gcCookiePath = os.path.join(self._data_path, "gc_cookies.txt")
+               gvCookiePath = os.path.join(self._data_path, "gv_cookies.txt")
+               self._defaultBackendId = self._guess_preferred_backend((
+                       (self.GC_BACKEND, gcCookiePath),
+                       (self.GV_BACKEND, gvCookiePath),
+               ))
+
+               self._phoneBackends.update({
+                       self.GC_BACKEND: gc_backend.GCDialer(gcCookiePath),
+                       self.GV_BACKEND: gv_backend.GVDialer(gvCookiePath),
+               })
                gtk.gdk.threads_enter()
                try:
-                       self._dialpads = {
-                               True: gc_views.Dialpad(self._widgetTree, self._errorDisplay),
-                               False: null_views.Dialpad(self._widgetTree),
-                       }
-                       self._dialpads[True].set_number("")
-                       self._accountViews = {
-                               True: gc_views.AccountInfo(self._widgetTree, self._phoneBackend, self._errorDisplay),
-                               False: null_views.AccountInfo(self._widgetTree),
-                       }
-                       self._recentViews = {
-                               True: gc_views.RecentCallsView(self._widgetTree, self._phoneBackend, self._errorDisplay),
-                               False: null_views.RecentCallsView(self._widgetTree),
-                       }
-                       self._contactsViews = {
-                               True: gc_views.ContactsView(self._widgetTree, self._phoneBackend, self._errorDisplay),
-                               False: null_views.ContactsView(self._widgetTree),
-                       }
+                       unifiedDialpad = gc_views.Dialpad(self._widgetTree, self._errorDisplay)
+                       unifiedDialpad.set_number("")
+                       self._dialpads.update({
+                               self.GC_BACKEND: unifiedDialpad,
+                               self.GV_BACKEND: unifiedDialpad,
+                       })
+                       self._accountViews.update({
+                               self.GC_BACKEND: gc_views.AccountInfo(
+                                       self._widgetTree, self._phoneBackends[self.GC_BACKEND], self._errorDisplay
+                               ),
+                               self.GV_BACKEND: gc_views.AccountInfo(
+                                       self._widgetTree, self._phoneBackends[self.GV_BACKEND], self._errorDisplay
+                               ),
+                       })
+                       self._recentViews.update({
+                               self.GC_BACKEND: gc_views.RecentCallsView(
+                                       self._widgetTree, self._phoneBackends[self.GC_BACKEND], self._errorDisplay
+                               ),
+                               self.GV_BACKEND: gc_views.RecentCallsView(
+                                       self._widgetTree, self._phoneBackends[self.GV_BACKEND], self._errorDisplay
+                               ),
+                       })
+                       self._contactsViews.update({
+                               self.GC_BACKEND: gc_views.ContactsView(
+                                       self._widgetTree, self._phoneBackends[self.GC_BACKEND], self._errorDisplay
+                               ),
+                               self.GV_BACKEND: gc_views.ContactsView(
+                                       self._widgetTree, self._phoneBackends[self.GV_BACKEND], self._errorDisplay
+                               ),
+                       })
                finally:
                        gtk.gdk.threads_leave()
 
-               self._dialpads[True].dial = self._on_dial_clicked
-               self._recentViews[True].number_selected = self._on_number_selected
-               self._contactsViews[True].number_selected = self._on_number_selected
-
+               evoBackend = evo_backend.EvolutionAddressBook()
                fsContactsPath = os.path.join(self._data_path, "contacts")
-               addressBooks = [
-                       self._phoneBackend,
-                       evo_backend.EvolutionAddressBook(),
-                       file_backend.FilesystemAddressBookFactory(fsContactsPath),
-               ]
-               mergedBook = gc_views.MergedAddressBook(addressBooks, gc_views.MergedAddressBook.advanced_lastname_sorter)
-               self._contactsViews[True].append(mergedBook)
-               self._contactsViews[True].extend(addressBooks)
-               self._contactsViews[True].open_addressbook(*self._contactsViews[True].get_addressbooks().next()[0][0:2])
-               gtk.gdk.threads_enter()
-               try:
-                       self._dialpads[self._isLoggedIn].enable()
-                       self._accountViews[self._isLoggedIn].enable()
-                       self._recentViews[self._isLoggedIn].enable()
-                       self._contactsViews[self._isLoggedIn].enable()
-               finally:
-                       gtk.gdk.threads_leave()
+               fileBackend = file_backend.FilesystemAddressBookFactory(fsContactsPath)
+               for backendId in (self.GV_BACKEND, self.GC_BACKEND):
+                       self._dialpads[backendId].dial = self._on_dial_clicked
+                       self._recentViews[backendId].number_selected = self._on_number_selected
+                       self._contactsViews[backendId].number_selected = self._on_number_selected
+
+                       addressBooks = [
+                               self._phoneBackends[backendId],
+                               evoBackend,
+                               fileBackend,
+                       ]
+                       mergedBook = gc_views.MergedAddressBook(addressBooks, gc_views.MergedAddressBook.advanced_lastname_sorter)
+                       self._contactsViews[backendId].append(mergedBook)
+                       self._contactsViews[backendId].extend(addressBooks)
+                       self._contactsViews[backendId].open_addressbook(*self._contactsViews[backendId].get_addressbooks().next()[0][0:2])
 
                callbackMapping = {
                        "on_paste": self._on_paste,
@@ -234,7 +274,7 @@ class Dialcentral(object):
 
                return False
 
-       def attempt_login(self, numOfAttempts = 1):
+       def attempt_login(self, numOfAttempts = 10):
                """
                @todo Handle user notification better like attempting to login and failed login
 
@@ -245,7 +285,7 @@ class Dialcentral(object):
                if not self._deviceIsOnline:
                        warnings.warn("Attempted to login while device was offline")
                        return False
-               elif self._phoneBackend is None:
+               elif self._phoneBackends is None:
                        warnings.warn(
                                "Attempted to login before initialization is complete, did an event fire early?"
                        )
@@ -253,32 +293,33 @@ class Dialcentral(object):
 
                loggedIn = False
                try:
-                       if self._phoneBackend.is_authed():
+                       if self._phoneBackends[self._defaultBackendId].is_authed():
+                               serviceId = self._defaultBackendId
                                loggedIn = True
-                       else:
-                               for x in xrange(numOfAttempts):
-                                       gtk.gdk.threads_enter()
-                                       try:
-                                               username, password = self._credentials.request_credentials()
-                                       finally:
-                                               gtk.gdk.threads_leave()
-
-                                       loggedIn = self._phoneBackend.login(username, password)
-                                       if loggedIn:
-                                               break
+                       for x in xrange(numOfAttempts):
+                               if loggedIn:
+                                       break
+                               gtk.gdk.threads_enter()
+                               try:
+                                       availableServices = {
+                                               self.GV_BACKEND: "Google Voice",
+                                               self.GC_BACKEND: "Grand Central",
+                                       }
+                                       credentials = self._credentials.request_credentials_from(availableServices)
+                                       serviceId, username, password = credentials
+                               finally:
+                                       gtk.gdk.threads_leave()
+
+                               loggedIn = self._phoneBackends[serviceId].login(username, password)
                except RuntimeError, e:
                        warnings.warn(traceback.format_exc())
-                       gtk.gdk.threads_enter()
-                       try:
-                               self._errorDisplay.push_message(e.message)
-                       finally:
-                               gtk.gdk.threads_leave()
+                       self._errorDisplay.push_message_with_lock(e.message)
 
                gtk.gdk.threads_enter()
                try:
                        if not loggedIn:
                                self._errorDisplay.push_message("Login Failed")
-                       self._change_loggedin_status(loggedIn)
+                       self._change_loggedin_status(serviceId if loggedIn else self.NULL_BACKEND)
                finally:
                        gtk.gdk.threads_leave()
                return loggedIn
@@ -297,7 +338,9 @@ class Dialcentral(object):
                gtk.main_quit()
 
        def _change_loggedin_status(self, newStatus):
-               oldStatus = self._isLoggedIn
+               oldStatus = self._selectedBackendId
+               if oldStatus == newStatus:
+                       return
 
                self._dialpads[oldStatus].disable()
                self._accountViews[oldStatus].disable()
@@ -309,12 +352,19 @@ class Dialcentral(object):
                self._recentViews[newStatus].enable()
                self._contactsViews[newStatus].enable()
 
-               if newStatus:
-                       if self._phoneBackend.get_callback_number() is None:
-                               self._phoneBackend.set_sane_callback()
-                       self._accountViews[True].update()
+               if self._phoneBackends[self._selectedBackendId].get_callback_number() is None:
+                       self._phoneBackends[self._selectedBackendId].set_sane_callback()
+               self._accountViews[self._selectedBackendId].update()
+
+               self._selectedBackendId = newStatus
 
-               self._isLoggedIn = newStatus
+       def _guess_preferred_backend(self, backendAndCookiePaths):
+               modTimeAndPath = [
+                       (getmtime_nothrow(path), backendId, path)
+                       for backendId, path in backendAndCookiePaths
+               ]
+               modTimeAndPath.sort()
+               return modTimeAndPath[-1][1]
 
        def _on_device_state_change(self, shutdown, save_unsaved_data, memory_low, system_inactivity, message, userData):
                """
@@ -324,8 +374,9 @@ class Dialcentral(object):
                @note Hildon specific
                """
                if memory_low:
-                       self._phoneBackend.clear_caches()
-                       self._contactsViews[True].clear_caches()
+                       for backendId in self.BACKENDS:
+                               self._phoneBackends[backendId].clear_caches()
+                       self._contactsViews[self._selectedBackendId].clear_caches()
                        gc.collect()
 
        def _on_connection_change(self, connection, event, magicIdentifier):
@@ -342,14 +393,14 @@ class Dialcentral(object):
                if status == conic.STATUS_CONNECTED:
                        self._window.set_sensitive(True)
                        self._deviceIsOnline = True
-                       self._isLoggedIn = False
                        backgroundLogin = threading.Thread(target=self.attempt_login, args=[2])
                        backgroundLogin.setDaemon(True)
                        backgroundLogin.start()
                elif status == conic.STATUS_DISCONNECTED:
                        self._window.set_sensitive(False)
                        self._deviceIsOnline = False
-                       self._isLoggedIn = False
+                       self._defaultBackendId = self._selectedBackendId
+                       self._change_loggedin_status(self.NULL_BACKEND)
 
        def _on_window_state_change(self, widget, event, *args):
                """
@@ -371,21 +422,21 @@ class Dialcentral(object):
                                self._window.fullscreen()
 
        def _on_clearcookies_clicked(self, *args):
-               self._phoneBackend.logout()
-               self._accountViews[True].clear()
-               self._recentViews[True].clear()
-               self._contactsViews[True].clear()
+               self._phoneBackends[self._selectedBackendId].logout()
+               self._accountViews[self._selectedBackendId].clear()
+               self._recentViews[self._selectedBackendId].clear()
+               self._contactsViews[self._selectedBackendId].clear()
+               self._change_loggedin_status(self.NULL_BACKEND)
 
-               # re-run the inital grandcentral setup
                backgroundLogin = threading.Thread(target=self.attempt_login, args=[2])
                backgroundLogin.setDaemon(True)
                backgroundLogin.start()
 
        def _on_notebook_switch_page(self, notebook, page, page_num):
                if page_num == 1:
-                       self._contactsViews[self._isLoggedIn].update()
+                       self._contactsViews[self._selectedBackendId].update()
                elif page_num == 3:
-                       self._recentViews[self._isLoggedIn].update()
+                       self._recentViews[self._selectedBackendId].update()
 
                tabTitle = self._notebook.get_tab_label(self._notebook.get_nth_page(page_num)).get_text()
                if hildon is not None:
@@ -394,7 +445,7 @@ class Dialcentral(object):
                        self._window.set_title("%s - %s" % (self.__pretty_app_name__, tabTitle))
 
        def _on_number_selected(self, number):
-               self._dialpads[True].set_number(number)
+               self._dialpads[self._selectedBackendId].set_number(number)
                self._notebook.set_current_page(0)
 
        def _on_dial_clicked(self, number):
@@ -402,7 +453,7 @@ class Dialcentral(object):
                @todo Potential blocking on web access, maybe we should defer parts of this or put up a dialog?
                """
                try:
-                       loggedIn = self._phoneBackend.is_authed()
+                       loggedIn = self._phoneBackends[self._selectedBackendId].is_authed()
                except RuntimeError, e:
                        warnings.warn(traceback.format_exc())
                        loggedIn = False
@@ -417,8 +468,8 @@ class Dialcentral(object):
 
                dialed = False
                try:
-                       assert self._phoneBackend.get_callback_number() != ""
-                       self._phoneBackend.dial(number)
+                       assert self._phoneBackends[self._selectedBackendId].get_callback_number() != ""
+                       self._phoneBackends[self._selectedBackendId].dial(number)
                        dialed = True
                except RuntimeError, e:
                        warnings.warn(traceback.format_exc())
@@ -428,12 +479,12 @@ class Dialcentral(object):
                        self._errorDisplay.push_message(e.message)
 
                if dialed:
-                       self._dialpads[True].clear()
-                       self._recentViews[True].clear()
+                       self._dialpads[self._selectedBackendId].clear()
+                       self._recentViews[self._selectedBackendId].clear()
 
        def _on_paste(self, *args):
                contents = self._clipboard.wait_for_text()
-               self._dialpads[True].set_number(contents)
+               self._dialpads[self._selectedBackendId].set_number(contents)
 
        def _on_about_activate(self, *args):
                dlg = gtk.AboutDialog()
index d200d93..9baf5f1 100644 (file)
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Wed Mar  4 20:08:42 2009 -->
+<!--Generated with glade3 3.4.5 on Fri Mar 20 21:35:31 2009 -->
 <glade-interface>
   <widget class="GtkWindow" id="mainWindow">
+    <property name="title" translatable="yes">Dialer</property>
     <property name="default_width">800</property>
     <property name="default_height">480</property>
-    <property name="title" translatable="yes">Dialer</property>
     <child>
       <widget class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
                     <property name="n_columns">3</property>
                     <property name="homogeneous">True</property>
                     <child>
-                      <widget class="GtkButton" id="dial">
+                      <widget class="GtkButton" id="digit1">
                         <property name="visible">True</property>
-                        <property name="has_default">True</property>
+                        <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
-                        <signal name="clicked" handler="on_dial_clicked"/>
-                        <accelerator key="Return" modifiers="" signal="clicked"/>
+                        <signal name="clicked" handler="on_digit_clicked"/>
+                        <accelerator key="1" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkHBox" id="hbox1">
+                          <widget class="GtkLabel" id="label12">
                             <property name="visible">True</property>
-                            <child>
-                              <widget class="GtkImage" id="image1">
-                                <property name="visible">True</property>
-                                <property name="xalign">1</property>
-                                <property name="stock">gtk-yes</property>
-                              </widget>
-                            </child>
-                            <child>
-                              <widget class="GtkLabel" id="label8">
-                                <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="xpad">5</property>
-                                <property name="label" translatable="yes">&lt;span size="17000" weight="bold"&gt;Dial&lt;/span&gt;</property>
-                                <property name="use_markup">True</property>
-                              </widget>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
+                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;1&lt;/span&gt;
+&lt;span size="9000"&gt;  &lt;/span&gt;</property>
+                            <property name="use_markup">True</property>
                           </widget>
                         </child>
                       </widget>
-                      <packing>
-                        <property name="left_attach">2</property>
-                        <property name="right_attach">3</property>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
-                      </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit0">
+                      <widget class="GtkButton" id="digit2">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="0" modifiers="" signal="clicked"/>
+                        <accelerator key="2" modifiers="" signal="clicked"/>
+                        <accelerator key="a" modifiers="" signal="clicked"/>
+                        <accelerator key="b" modifiers="" signal="clicked"/>
+                        <accelerator key="c" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label19">
+                          <widget class="GtkLabel" id="label10">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;0&lt;/span&gt;
-&lt;span size="9000"&gt;&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;2&lt;/span&gt;
+&lt;span size="12000"&gt;ABC&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="GtkButton" id="back">
-                        <property name="visible">True</property>
-                        <property name="focus_on_click">False</property>
-                        <property name="response_id">0</property>
-                        <signal name="pressed" handler="on_back_pressed"/>
-                        <signal name="clicked" handler="on_back_clicked"/>
-                        <signal name="released" handler="on_back_released"/>
-                        <accelerator key="BackSpace" modifiers="" signal="clicked"/>
-                        <child>
-                          <widget class="GtkHBox" id="hbox2">
-                            <property name="visible">True</property>
-                            <child>
-                              <widget class="GtkImage" id="image2">
-                                <property name="visible">True</property>
-                                <property name="xalign">1</property>
-                                <property name="stock">gtk-no</property>
-                              </widget>
-                            </child>
-                            <child>
-                              <widget class="GtkLabel" id="label9">
-                                <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="xpad">5</property>
-                                <property name="label" translatable="yes">&lt;span size="17000" weight="Bold"&gt;Back&lt;/span&gt;</property>
-                                <property name="use_markup">True</property>
-                              </widget>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                          </widget>
-                        </child>
-                      </widget>
-                      <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit9">
+                      <widget class="GtkButton" id="digit3">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="z" modifiers="" signal="clicked"/>
-                        <accelerator key="y" modifiers="" signal="clicked"/>
-                        <accelerator key="x" modifiers="" signal="clicked"/>
-                        <accelerator key="w" modifiers="" signal="clicked"/>
-                        <accelerator key="9" modifiers="" signal="clicked"/>
+                        <accelerator key="3" modifiers="" signal="clicked"/>
+                        <accelerator key="d" modifiers="" signal="clicked"/>
+                        <accelerator key="e" modifiers="" signal="clicked"/>
+                        <accelerator key="f" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label18">
+                          <widget class="GtkLabel" id="label11">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;9&lt;/span&gt;
-&lt;span size="12000"&gt;WXYZ&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold" stretch="ultraexpanded"&gt;3&lt;/span&gt;
+&lt;span size="12000"&gt;DEF&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">2</property>
                         <property name="right_attach">3</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit8">
+                      <widget class="GtkButton" id="digit4">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="v" modifiers="" signal="clicked"/>
-                        <accelerator key="u" modifiers="" signal="clicked"/>
-                        <accelerator key="t" modifiers="" signal="clicked"/>
-                        <accelerator key="8" modifiers="" signal="clicked"/>
+                        <accelerator key="4" modifiers="" signal="clicked"/>
+                        <accelerator key="g" modifiers="" signal="clicked"/>
+                        <accelerator key="h" modifiers="" signal="clicked"/>
+                        <accelerator key="i" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label17">
+                          <widget class="GtkLabel" id="label13">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;8&lt;/span&gt;
-&lt;span size="12000"&gt;TUV&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;4&lt;/span&gt;
+&lt;span size="12000"&gt;GHI&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit7">
+                      <widget class="GtkButton" id="digit5">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="s" modifiers="" signal="clicked"/>
-                        <accelerator key="r" modifiers="" signal="clicked"/>
-                        <accelerator key="q" modifiers="" signal="clicked"/>
-                        <accelerator key="p" modifiers="" signal="clicked"/>
-                        <accelerator key="7" modifiers="" signal="clicked"/>
+                        <accelerator key="5" modifiers="" signal="clicked"/>
+                        <accelerator key="j" modifiers="" signal="clicked"/>
+                        <accelerator key="k" modifiers="" signal="clicked"/>
+                        <accelerator key="l" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label16">
+                          <widget class="GtkLabel" id="label14">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;7&lt;/span&gt;
-&lt;span size="12000"&gt;PQRS&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;5&lt;/span&gt;
+&lt;span size="12000"&gt;JKL&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
                       </packing>
                     </child>
                     <child>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="o" modifiers="" signal="clicked"/>
-                        <accelerator key="n" modifiers="" signal="clicked"/>
-                        <accelerator key="m" modifiers="" signal="clicked"/>
                         <accelerator key="6" modifiers="" signal="clicked"/>
+                        <accelerator key="m" modifiers="" signal="clicked"/>
+                        <accelerator key="n" modifiers="" signal="clicked"/>
+                        <accelerator key="o" modifiers="" signal="clicked"/>
                         <child>
                           <widget class="GtkLabel" id="label15">
                             <property name="visible">True</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit5">
+                      <widget class="GtkButton" id="digit7">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="l" modifiers="" signal="clicked"/>
-                        <accelerator key="k" modifiers="" signal="clicked"/>
-                        <accelerator key="j" modifiers="" signal="clicked"/>
-                        <accelerator key="5" modifiers="" signal="clicked"/>
+                        <accelerator key="7" modifiers="" signal="clicked"/>
+                        <accelerator key="p" modifiers="" signal="clicked"/>
+                        <accelerator key="q" modifiers="" signal="clicked"/>
+                        <accelerator key="r" modifiers="" signal="clicked"/>
+                        <accelerator key="s" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label14">
+                          <widget class="GtkLabel" id="label16">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;5&lt;/span&gt;
-&lt;span size="12000"&gt;JKL&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;7&lt;/span&gt;
+&lt;span size="12000"&gt;PQRS&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit4">
+                      <widget class="GtkButton" id="digit8">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="i" modifiers="" signal="clicked"/>
-                        <accelerator key="h" modifiers="" signal="clicked"/>
-                        <accelerator key="g" modifiers="" signal="clicked"/>
-                        <accelerator key="4" modifiers="" signal="clicked"/>
+                        <accelerator key="8" modifiers="" signal="clicked"/>
+                        <accelerator key="t" modifiers="" signal="clicked"/>
+                        <accelerator key="u" modifiers="" signal="clicked"/>
+                        <accelerator key="v" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label13">
+                          <widget class="GtkLabel" id="label17">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;4&lt;/span&gt;
-&lt;span size="12000"&gt;GHI&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;8&lt;/span&gt;
+&lt;span size="12000"&gt;TUV&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                         </child>
                       </widget>
                       <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit3">
+                      <widget class="GtkButton" id="digit9">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="f" modifiers="" signal="clicked"/>
-                        <accelerator key="e" modifiers="" signal="clicked"/>
-                        <accelerator key="d" modifiers="" signal="clicked"/>
-                        <accelerator key="3" modifiers="" signal="clicked"/>
+                        <accelerator key="9" modifiers="" signal="clicked"/>
+                        <accelerator key="w" modifiers="" signal="clicked"/>
+                        <accelerator key="x" modifiers="" signal="clicked"/>
+                        <accelerator key="y" modifiers="" signal="clicked"/>
+                        <accelerator key="z" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label11">
+                          <widget class="GtkLabel" id="label18">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold" stretch="ultraexpanded"&gt;3&lt;/span&gt;
-&lt;span size="12000"&gt;DEF&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;9&lt;/span&gt;
+&lt;span size="12000"&gt;WXYZ&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">2</property>
                         <property name="right_attach">3</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit2">
+                      <widget class="GtkButton" id="back">
+                        <property name="visible">True</property>
+                        <property name="focus_on_click">False</property>
+                        <property name="response_id">0</property>
+                        <signal name="pressed" handler="on_back_pressed"/>
+                        <signal name="clicked" handler="on_back_clicked"/>
+                        <signal name="released" handler="on_back_released"/>
+                        <accelerator key="BackSpace" modifiers="" signal="clicked"/>
+                        <child>
+                          <widget class="GtkHBox" id="hbox2">
+                            <property name="visible">True</property>
+                            <child>
+                              <widget class="GtkImage" id="image2">
+                                <property name="visible">True</property>
+                                <property name="xalign">1</property>
+                                <property name="stock">gtk-no</property>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label9">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xpad">5</property>
+                                <property name="label" translatable="yes">&lt;span size="17000" weight="Bold"&gt;Back&lt;/span&gt;</property>
+                                <property name="use_markup">True</property>
+                              </widget>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </widget>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkButton" id="digit0">
                         <property name="visible">True</property>
                         <property name="focus_on_click">False</property>
                         <property name="response_id">0</property>
                         <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="c" modifiers="" signal="clicked"/>
-                        <accelerator key="b" modifiers="" signal="clicked"/>
-                        <accelerator key="a" modifiers="" signal="clicked"/>
-                        <accelerator key="2" modifiers="" signal="clicked"/>
+                        <accelerator key="0" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label10">
+                          <widget class="GtkLabel" id="label19">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="30000" weight="bold"&gt;2&lt;/span&gt;
-&lt;span size="12000"&gt;ABC&lt;/span&gt;</property>
+                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;0&lt;/span&gt;
+&lt;span size="9000"&gt;&lt;/span&gt;</property>
                             <property name="use_markup">True</property>
                             <property name="justify">GTK_JUSTIFY_CENTER</property>
                           </widget>
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="digit1">
+                      <widget class="GtkButton" id="dial">
                         <property name="visible">True</property>
-                        <property name="focus_on_click">False</property>
+                        <property name="has_default">True</property>
                         <property name="response_id">0</property>
-                        <signal name="clicked" handler="on_digit_clicked"/>
-                        <accelerator key="1" modifiers="" signal="clicked"/>
+                        <signal name="clicked" handler="on_dial_clicked"/>
+                        <accelerator key="Return" modifiers="" signal="clicked"/>
                         <child>
-                          <widget class="GtkLabel" id="label12">
+                          <widget class="GtkHBox" id="hbox1">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;span size="33000" weight="bold"&gt;1&lt;/span&gt;
-&lt;span size="9000"&gt;  &lt;/span&gt;</property>
-                            <property name="use_markup">True</property>
+                            <child>
+                              <widget class="GtkImage" id="image1">
+                                <property name="visible">True</property>
+                                <property name="xalign">1</property>
+                                <property name="stock">gtk-yes</property>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label8">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xpad">5</property>
+                                <property name="label" translatable="yes">&lt;span size="17000" weight="bold"&gt;Dial&lt;/span&gt;</property>
+                                <property name="use_markup">True</property>
+                              </widget>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </widget>
                         </child>
                       </widget>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
                     </child>
                   </widget>
                   <packing>
                 <property name="visible">True</property>
                 <property name="n_rows">2</property>
                 <child>
+                  <widget class="GtkComboBox" id="addressbook_combo">
+                    <property name="visible">True</property>
+                    <signal name="changed" handler="on_addressbook_combo_changed"/>
+                  </widget>
+                  <packing>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
                   <widget class="GtkScrolledWindow" id="contacts_scrolledwindow">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="bottom_attach">2</property>
                   </packing>
                 </child>
-                <child>
-                  <widget class="GtkComboBox" id="addressbook_combo">
-                    <property name="visible">True</property>
-                    <signal name="changed" handler="on_addressbook_combo_changed"/>
-                  </widget>
-                  <packing>
-                    <property name="y_options">GTK_FILL</property>
-                  </packing>
-                </child>
               </widget>
               <packing>
                 <property name="position">1</property>
                   <placeholder/>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="gcnumber_label">
+                  <widget class="GtkComboBoxEntry" id="callbackcombo">
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
-                    <property name="xpad">5</property>
-                    <property name="label" translatable="yes">GrandCentral
-Number:</property>
-                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                    <child internal-child="entry">
+                      <widget class="GtkEntry" id="callback_comboboxentry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <signal name="changed" handler="on_callbackentry_changed"/>
+                      </widget>
+                    </child>
                   </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="gcnumber_display">
+                  <widget class="GtkLabel" id="callback_number_label">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;span size="15000" weight="bold"&gt;(518) 555-1212&lt;/span&gt;</property>
-                    <property name="use_markup">True</property>
+                    <property name="xalign">1</property>
+                    <property name="xpad">5</property>
+                    <property name="label" translatable="yes">Callback Number:</property>
                   </widget>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"></property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
                   </packing>
                 </child>
                 <child>
@@ -629,36 +639,26 @@ Number:</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="callback_number_label">
+                  <widget class="GtkLabel" id="gcnumber_display">
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
-                    <property name="xpad">5</property>
-                    <property name="label" translatable="yes">Callback Number:</property>
+                    <property name="label" translatable="yes">&lt;span size="15000" weight="bold"&gt;(518) 555-1212&lt;/span&gt;</property>
+                    <property name="use_markup">True</property>
                   </widget>
                   <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBoxEntry" id="callbackcombo">
+                  <widget class="GtkLabel" id="gcnumber_label">
                     <property name="visible">True</property>
-                    <child internal-child="entry">
-                      <widget class="GtkEntry" id="callback_comboboxentry">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <signal name="changed" handler="on_callbackentry_changed"/>
-                      </widget>
-                    </child>
+                    <property name="xalign">1</property>
+                    <property name="xpad">5</property>
+                    <property name="label" translatable="yes">GrandCentral
+Number:</property>
+                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
                   </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
                 </child>
               </widget>
               <packing>
@@ -742,6 +742,16 @@ Number:</property>
         <property name="visible">True</property>
         <property name="spacing">2</property>
         <child>
+          <widget class="GtkComboBox" id="serviceCombo">
+            <property name="visible">True</property>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
           <widget class="GtkTable" id="table1">
             <property name="visible">True</property>
             <property name="n_rows">2</property>
@@ -787,7 +797,7 @@ Number:</property>
             </child>
           </widget>
           <packing>
-            <property name="position">1</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child internal-child="action_area">
@@ -841,7 +851,6 @@ Number:</property>
     <property name="skip_taskbar_hint">True</property>
     <property name="skip_pager_hint">True</property>
     <property name="deletable">False</property>
-    <property name="transient_for">Dialpad</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
       <widget class="GtkVBox" id="dialog-vbox3">
index ed77913..ef851e7 100644 (file)
@@ -70,8 +70,8 @@ class GCDialer(object):
 
                self._accessToken = None
                self._accountNum = None
-               self._callbackNumbers = {}
                self._lastAuthed = 0.0
+               self._callbackNumbers = {}
 
                self.__contacts = None
 
@@ -89,13 +89,18 @@ class GCDialer(object):
                        forwardSelectionPage = self._browser.download(self._forwardselectURL)
                except urllib2.URLError, e:
                        warnings.warn(traceback.format_exc())
-                       raise RuntimeError("%s is not accesible" % self._forwardselectURL)
+                       return False
 
-               self._browser.cookies.save()
                if self._isLoginPageRe.search(forwardSelectionPage) is not None:
                        return False
 
-               self._grab_token(forwardSelectionPage)
+               try:
+                       self._grab_token(forwardSelectionPage)
+               except StandardError, e:
+                       warnings.warn(traceback.format_exc())
+                       return False
+
+               self._browser.cookies.save()
                self._lastAuthed = time.time()
                return True
 
@@ -334,7 +339,7 @@ def test_backend(username, password):
        print "Authenticated: ", backend.is_authed()
        print "Login?: ", backend.login(username, password)
        print "Authenticated: ", backend.is_authed()
-       print "Token: ", backend._token
+       print "Token: ", backend._accessToken
        print "Account: ", backend.get_account_number()
        print "Callback: ", backend.get_callback_number()
        # print "All Callback: ",
index f605e1e..672b870 100644 (file)
@@ -283,7 +283,7 @@ class MergedAddressBook(object):
                        return name.rsplit(" ", 1)[-1]
 
        @classmethod
-       def advanced_firtname_sorter(cls, contacts):
+       def advanced_firstname_sorter(cls, contacts):
                contactsWithKey = [
                        (cls.guess_firstname(contactName), (contactId, contactName))
                                for (contactId, contactName) in contacts
@@ -441,6 +441,7 @@ class AccountInfo(object):
                self._callbackList = gtk.ListStore(gobject.TYPE_STRING)
                self._accountViewNumberDisplay = widgetTree.get_widget("gcnumber_display")
                self._callbackCombo = widgetTree.get_widget("callbackcombo")
+               self._onCallbackentryChangedId = 0
 
        def enable(self):
                assert self._backend.is_authed()
@@ -448,10 +449,10 @@ class AccountInfo(object):
                self.set_account_number("")
                self._callbackList.clear()
                self.update()
-               self._callbackCombo.get_child().connect("changed", self._on_callbackentry_changed)
+               self._onCallbackentryChangedId = self._callbackCombo.get_child().connect("changed", self._on_callbackentry_changed)
 
        def disable(self):
-               self._callbackCombo.get_child().disconnect("changed", self._on_callbackentry_changed)
+               self._callbackCombo.get_child().disconnect(self._onCallbackentryChangedId)
                self.clear()
                self._callbackList.clear()
 
@@ -521,6 +522,7 @@ class RecentCallsView(object):
                self._recentmodel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
                self._recentview = widgetTree.get_widget("recentview")
                self._recentviewselection = None
+               self._onRecentviewRowActivatedId = 0
 
                textrenderer = gtk.CellRendererText()
                self._recentviewColumn = gtk.TreeViewColumn("Calls", textrenderer, text=1)
@@ -534,10 +536,10 @@ class RecentCallsView(object):
                self._recentviewselection = self._recentview.get_selection()
                self._recentviewselection.set_mode(gtk.SELECTION_SINGLE)
 
-               self._recentview.connect("row-activated", self._on_recentview_row_activated)
+               self._onRecentviewRowActivatedId = self._recentview.connect("row-activated", self._on_recentview_row_activated)
 
        def disable(self):
-               self._recentview.disconnect("row-activated", self._on_recentview_row_activated)
+               self._recentview.disconnect(self._onRecentviewRowActivatedId)
                self._recentview.remove_column(self._recentviewColumn)
                self._recentview.set_model(None)
 
@@ -627,6 +629,8 @@ class ContactsView(object):
                self._contactColumn.set_sort_column_id(1)
                self._contactColumn.set_visible(True)
 
+               self._onContactsviewRowActivatedId = 0
+               self._onAddressbookComboChangedId = 0
                self._phoneTypeSelector = PhoneTypeSelector(widgetTree, self._backend)
 
        def enable(self):
@@ -656,15 +660,17 @@ class ContactsView(object):
                self._booksSelectionBox.add_attribute(cell, 'text', 2)
                self._booksSelectionBox.set_active(0)
 
-               self._contactsview.connect("row-activated", self._on_contactsview_row_activated)
-               self._booksSelectionBox.connect("changed", self._on_addressbook_combo_changed)
+               self._onContactsviewRowActivatedId = self._contactsview.connect("row-activated", self._on_contactsview_row_activated)
+               self._onAddressbookComboChangedId = self._booksSelectionBox.connect("changed", self._on_addressbook_combo_changed)
 
        def disable(self):
+               self._contactsview.disconnect(self._onContactsviewRowActivatedId)
+               self._booksSelectionBox.disconnect(self._onAddressbookComboChangedId)
+
+               self._booksSelectionBox.clear()
                self._booksSelectionBox.set_model(None)
                self._contactsview.set_model(None)
                self._contactsview.remove_column(self._contactColumn)
-               self._contactsview.disconnect("row-activated", self._on_contactsview_row_activated)
-               self._booksSelectionBox.disconnect("changed", self._on_addressbook_combo_changed)
 
        def number_selected(self, number):
                """
index a1b3ca4..8560ab3 100644 (file)
@@ -83,7 +83,6 @@ class GDataAddressBookFactory(object):
        def clear_caches(self):
                if gdata is None:
                        return
-               pass
 
        def get_addressbooks(self):
                """
index 5d81d9b..195c522 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 
+import gobject
 import gtk
 
 
@@ -12,9 +13,17 @@ class LoginWindow(object):
                """
                self._dialog = widgetTree.get_widget("loginDialog")
                self._parentWindow = widgetTree.get_widget("mainWindow")
+               self._serviceCombo = widgetTree.get_widget("serviceCombo")
                self._usernameEntry = widgetTree.get_widget("usernameentry")
                self._passwordEntry = widgetTree.get_widget("passwordentry")
 
+               self._serviceList = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING)
+               self._serviceCombo.set_model(self._serviceList)
+               cell = gtk.CellRendererText()
+               self._serviceCombo.pack_start(cell, True)
+               self._serviceCombo.add_attribute(cell, 'text', 1)
+               self._serviceCombo.set_active(0)
+
                callbackMapping = {
                        "on_loginbutton_clicked": self._on_loginbutton_clicked,
                        "on_loginclose_clicked": self._on_loginclose_clicked,
@@ -27,6 +36,10 @@ class LoginWindow(object):
                """
                if parentWindow is None:
                        parentWindow = self._parentWindow
+
+               self._serviceCombo.hide()
+               self._serviceList.clear()
+
                try:
                        self._dialog.set_transient_for(parentWindow)
                        self._dialog.set_default_response(gtk.RESPONSE_OK)
@@ -39,8 +52,40 @@ class LoginWindow(object):
                        self._passwordEntry.set_text("")
                finally:
                        self._dialog.hide()
+
                return username, password
 
+       def request_credentials_from(self, services, parentWindow = None):
+               """
+               @note UI Thread
+               """
+               if parentWindow is None:
+                       parentWindow = self._parentWindow
+
+               self._serviceList.clear()
+               for serviceIdserviceName in services.iteritems():
+                       self._serviceList.append(serviceIdserviceName)
+               self._serviceCombo.set_active(0)
+               self._serviceCombo.show()
+
+               try:
+                       self._dialog.set_transient_for(parentWindow)
+                       self._dialog.set_default_response(gtk.RESPONSE_OK)
+                       response = self._dialog.run()
+                       if response != gtk.RESPONSE_OK:
+                               raise RuntimeError("Login Cancelled")
+
+                       username = self._usernameEntry.get_text()
+                       password = self._passwordEntry.get_text()
+                       self._passwordEntry.set_text("")
+               finally:
+                       self._dialog.hide()
+
+               itr = self._serviceCombo.get_active_iter()
+               serviceId = int(self._serviceList.get_value(itr, 0))
+               self._serviceList.clear()
+               return serviceId, username, password
+
        def _on_loginbutton_clicked(self, *args):
                self._dialog.response(gtk.RESPONSE_OK)
 
@@ -62,6 +107,13 @@ class ErrorDisplay(object):
                self.__messages = []
                self.__parentBox.remove(self.__errorBox)
 
+       def push_message_with_lock(self, message):
+               gtk.gdk.threads_enter()
+               try:
+                       self.push_message(message)
+               finally:
+                       gtk.gdk.threads_leave()
+
        def push_message(self, message):
                if 0 < len(self.__messages):
                        self.__messages.append(message)
index aca5b9b..d2dfedd 100644 (file)
@@ -88,7 +88,7 @@ class GVDialer(object):
        _accountNumberURL = "https://www.google.com/voice/mobile"
        _forwardURL = "https://www.google.com/voice/mobile/phones"
 
-       _inboxURL = "https://www.google.com/voice/inbox/"
+       _inboxURL = "https://www.google.com/voice/m/i"
        _recentCallsURL = "https://www.google.com/voice/inbox/recent/"
        _placedCallsURL = "https://www.google.com/voice/inbox/recent/placed/"
        _receivedCallsURL = "https://www.google.com/voice/inbox/recent/received/"
@@ -103,9 +103,9 @@ class GVDialer(object):
                if os.path.isfile(cookieFile):
                        self._browser.cookies.load()
 
+               self._token = ""
                self._accountNum = None
                self._lastAuthed = 0.0
-               self._token = ""
                self._callbackNumber = ""
                self._callbackNumbers = {}
 
@@ -125,13 +125,18 @@ class GVDialer(object):
                        inboxPage = self._browser.download(self._inboxURL)
                except urllib2.URLError, e:
                        warnings.warn(traceback.format_exc())
-                       raise RuntimeError("%s is not accesible" % self._inboxURL)
+                       return False
 
-               self._browser.cookies.save()
                if self._isNotLoginPageRe.search(inboxPage) is not None:
                        return False
 
-               self._grab_account_info()
+               try:
+                       self._grab_account_info()
+               except StandardError, e:
+                       warnings.warn(traceback.format_exc())
+                       return False
+
+               self._browser.cookies.save()
                self._lastAuthed = time.time()
                return True
 
@@ -147,6 +152,9 @@ class GVDialer(object):
                        'Email' : username,
                        'Passwd' : password,
                        'service': "grandcentral",
+                       "ltmpl": "mobile",
+                       "btmpl": "mobile",
+                       "PersistentCookie": "yes",
                })
 
                try:
diff --git a/src/null_backend.py b/src/null_backend.py
new file mode 100644 (file)
index 0000000..795a4b7
--- /dev/null
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+
+# DialCentral - Front end for Google's Grand Central service.
+# Copyright (C) 2008  Eric Warnke ericew AT gmail DOT com
+# 
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+# 
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+# 
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+class NullDialer(object):
+
+       def __init__(self):
+               pass
+
+       def is_authed(self, force = False):
+               return False
+
+       def login(self, username, password):
+               return self.is_authed()
+
+       def logout(self):
+               self.clear_caches()
+
+       def dial(self, number):
+               return True
+
+       def clear_caches(self):
+               pass
+
+       def is_valid_syntax(self, number):
+               """
+               @returns If This number be called ( syntax validation only )
+               """
+               return False
+
+       def get_account_number(self):
+               """
+               @returns The grand central phone number
+               """
+               return ""
+
+       def set_sane_callback(self):
+               pass
+
+       def get_callback_numbers(self):
+               return {}
+
+       def set_callback_number(self, callbacknumber):
+               return True
+
+       def get_callback_number(self):
+               return ""
+
+       def get_recent(self):
+               return ()
+
+       def get_addressbooks(self):
+               return ()
+
+       def open_addressbook(self, bookId):
+               return self
+
+       @staticmethod
+       def contact_source_short_name(contactId):
+               return "ERROR"
+
+       @staticmethod
+       def factory_name():
+               return "ERROR"
+
+       def get_contacts(self):
+               return ()
+
+       def get_contact_details(self, contactId):
+               return ()
index 2236906..984c5f7 100644 (file)
@@ -52,6 +52,14 @@ class AccountInfo(object):
                self._clearCookiesButton.set_sensitive(True)
                self._callbackCombo.set_sensitive(True)
 
+       @staticmethod
+       def update():
+               pass
+
+       @staticmethod
+       def clear():
+               pass
+
 
 class RecentCallsView(object):
 
@@ -67,6 +75,10 @@ class RecentCallsView(object):
        def update(self):
                pass
 
+       @staticmethod
+       def clear():
+               pass
+
 
 class ContactsView(object):
 
@@ -81,3 +93,7 @@ class ContactsView(object):
 
        def update(self):
                pass
+
+       @staticmethod
+       def clear():
+               pass
index d19a18b..e7e2321 100755 (executable)
@@ -7,9 +7,14 @@ __appname__ = "dialcentral"
 __description__ = "Simple interface to Google's GrandCentral(tm) service"
 __author__ = "Ed Page"
 __email__ = "eopage@byu.net"
-__version__ = "0.9.1"
-__build__ = 1
+__version__ = "0.9.2"
+__build__ = 0
 __changelog__ = '''\
+0.9.2 - "Two heads are better than one"
+ * Adding of UI to switch between GC and GV
+ * Minimized flashing the dial button between grayed out and not on startup
+ * Bug fixes
+
 0.9.1 - "Get your hands off that"
  * GoogleVoice Support, what a pain
  * More flexible CSV support.  It now checks the header row for what column name/number are in