implemented phone calls
authorMax Usachev <maxusachev@gmail.com>
Tue, 22 Jun 2010 09:05:51 +0000 (12:05 +0300)
committerMax Usachev <maxusachev@gmail.com>
Tue, 22 Jun 2010 09:05:51 +0000 (12:05 +0300)
constants.py
controller.py
ui/hildon_ui.py

index 57af873..e3ec0cb 100644 (file)
@@ -6,3 +6,7 @@ TYPE_FILE = 'f'
 FIELD_TOPLEVEL = 'o'
 FIELD_MIDDLELEVEL = 'ou'
 FIELD_LOWLEVEL = 'cn'
+FIELD_PHONE_HOME = 'homePhone'
+FIELD_PHONE_GENERAL = 'telephoneNumber'
+FIELD_PHONE_INTERNAL = 'internalPhone'
+FIELD_PHONE_MOBILE = 'mobile'
index 54f579d..a451a30 100644 (file)
@@ -3,12 +3,14 @@ Meabook controller class
 """
 
 from meabook.constants import *
+from meabook.caller import PhoneCaller
 from gettext import gettext as _
 
 
 class MeabookController:
     def __init__(self, model, view_class, renderer_class, config):
         self.config = config
+        self.caller = PhoneCaller()
         self.model = model
         self.view = view_class(self, renderer_class(), self.config)
         self.view.start()
@@ -19,6 +21,11 @@ class MeabookController:
         self.config.save()
         self.model.close()
 
+    def call(self, number):
+        """Make a phone call."""
+
+        self.caller.call(number)
+
     def get_items(self, parent=0):
         """Gets from model items with selected level."""
 
index c21b5a9..c280dd7 100644 (file)
@@ -7,6 +7,7 @@ import hildon
 import gobject
 from gettext import gettext as _
 from meabook.constants import *
+from meabook.caller import PhoneCaller
 from meabook.ui.ui import MeabookUI
 
 
@@ -50,6 +51,8 @@ def set_box_content(box, handler, items=[]):
 
     def on_button_click(widget):
         handler(widget.get_title(), widget.get_data('iname'))
+        #caller = PhoneCaller()
+        #caller.call(widget.get_value())
 
     for child in box.get_children():
         box.remove(child)
@@ -197,6 +200,9 @@ class HildonMeabook(MeabookUI):
                 if fname == 'image':
                     continue
                 button = self.renderer.render_button(_(fname) , fvalue, fname)
+                if fname in (FIELD_PHONE_HOME, FIELD_PHONE_GENERAL, \
+                    FIELD_PHONE_INTERNAL, FIELD_PHONE_MOBILE):
+                    button.connect('clicked', self.call_cb)
                 info_box.pack_start(button, expand=False)
             # pack widgets
             image_box.pack_start(image, expand=False)
@@ -347,6 +353,11 @@ class HildonMeabook(MeabookUI):
         self.search_entry.set_text('')
         set_box_content(self.box, None)
 
+    def call_cb(self, widget):
+        """Nake a phone call."""
+
+        self.controller.call(widget.get_value())
+
 
 
 class AboutDialog(hildon.Dialog):