Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r4246 - trunk/src/target/opkg ([EMAIL PROTECTED])
   2. r4247 - trunk/src/target/opkg ([EMAIL PROTECTED])
   3. r4248 - trunk/src/target/u-boot/patches ([EMAIL PROTECTED])
   4. r4249 - in trunk/src/host/qemu-neo1973: hw openmoko
      ([EMAIL PROTECTED])
   5. r4250 - in
      trunk/src/target/OM-2007.2/applications/openmoko-dialer2: .
      src/dialer ([EMAIL PROTECTED])
   6. r4251 - in
      trunk/src/target/OM-2007.2/applications/openmoko-dialer2: .
      src/dialer ([EMAIL PROTECTED])
--- Begin Message ---
Author: thomas
Date: 2008-03-25 13:36:47 +0100 (Tue, 25 Mar 2008)
New Revision: 4246

Modified:
   trunk/src/target/opkg/configure.ac
Log:
opkg: fix configure check for big-endian systems


Modified: trunk/src/target/opkg/configure.ac
===================================================================
--- trunk/src/target/opkg/configure.ac  2008-03-25 10:33:45 UTC (rev 4245)
+++ trunk/src/target/opkg/configure.ac  2008-03-25 12:36:47 UTC (rev 4246)
@@ -94,7 +94,7 @@
 AC_CHECK_MEMBERS([struct stat.st_rdev])
 
 # Checks endianness
-AC_C_BIGENDIAN(ENDIAN_CFLAGS="-DWORDS_BIGENDIAN=1",)
+AC_C_BIGENDIAN(BIGENDIAN_CFLAGS="-DWORDS_BIGENDIAN=1",)
 AC_SUBST(BIGENDIAN_CFLAGS)
 
 # Don't do annoying tests that don't work when cross-compiling, just trust 
them.




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2008-03-25 13:39:50 +0100 (Tue, 25 Mar 2008)
New Revision: 4247

Modified:
   trunk/src/target/opkg/README
Log:
opkg: add README content, including website and mailing list details


Modified: trunk/src/target/opkg/README
===================================================================
--- trunk/src/target/opkg/README        2008-03-25 12:36:47 UTC (rev 4246)
+++ trunk/src/target/opkg/README        2008-03-25 12:39:50 UTC (rev 4247)
@@ -0,0 +1,7 @@
+OPKG Package Management System
+==============================
+
+Opkg is a lightweight package management system based on Ipkg.
+
+Website: http://wiki.openmoko.org/wiki/Opkg
+Mailing list: http://lists.openmoko.org/mailman/listinfo/opkg-devel




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-03-25 22:06:51 +0100 (Tue, 25 Mar 2008)
New Revision: 4248

Added:
   trunk/src/target/u-boot/patches/remap-vec.patch
Modified:
   trunk/src/target/u-boot/patches/series
Log:
remap-vec.patch: remap the vectors instead of copy them. This avoids having
  to wait for AUX release in NOR boot and it also solves the same problem for
  NAND boot.



Added: trunk/src/target/u-boot/patches/remap-vec.patch
===================================================================
--- trunk/src/target/u-boot/patches/remap-vec.patch     2008-03-25 12:39:50 UTC 
(rev 4247)
+++ trunk/src/target/u-boot/patches/remap-vec.patch     2008-03-25 21:06:51 UTC 
(rev 4248)
@@ -0,0 +1,89 @@
+This patch changes how we avoid getting killed by an interrupt if the vectors
+at address zero and the u-boot we're running don't agree.
+
+Instead of copying the vectors to SteppingStone, which introduced the very
+ugly need to wait until AUX was released, and didn't work for NAND, we copy
+the vectors to the beginning of our DRAM and map the address range 0x0...
+to 0x3...
+
+This obsoletes nor-irqvec.patch
+
+We could probably also use the same logic to replace
+uboot-s3c2410-norelocate_irqvec_cpy.patch
+but then, never change a running system ;-)
+
+Note: this is still experimental. Please give it a solid beating.
+
+- Werner
+
+Index: u-boot/board/neo1973/gta02/gta02.c
+===================================================================
+--- u-boot.orig/board/neo1973/gta02/gta02.c
++++ u-boot/board/neo1973/gta02/gta02.c
+@@ -220,17 +220,26 @@
+       dcache_enable();
+ 
+       /*
+-       * Since the NOR is replaced by SteppingStone when the AUX button is
+-       * released, we have to wait for this and copy our exception vectors
+-       * before we can let u-boot enable interrupts.
++       * Since the NOR at address 0 is replaced by SteppingStone when the AUX
++       * button is released, we would crash when an interrupt arrives (e.g.,
++       * on USB insertion).
++       *
++       * We solve this as follows: we copy the vector table to RAM at address
++       * 0x30000000 and then use the PID feature in the 920T MMU to map all
++       * addresses in the range 0x0....... to 0x3....... without actually
++       * setting up page mappings in the MMU. Thus, vectors are then
++       * retrieved from their location in RAM.
++       *
++       * Note that the mapping is done in lib_arm/interrupts.c, so that it
++       * automatically tracks whether we allow interrupts or not. This is
++       * particularly necessary when we boot, since the operating system may
++       * not expect to find this sort of mapping to be active.
+        */
+       if (booted_from_nor) {
+               extern char _start;
+ 
+-              while (neo1973_aux_key_pressed());
+-              memcpy((void *) 0, &_start, 0x40);
++              memcpy((void *) 0x30000000, &_start, 0x40);
+       }
+-
+       return 0;
+ }
+ 
+Index: u-boot/lib_arm/interrupts.c
+===================================================================
+--- u-boot.orig/lib_arm/interrupts.c
++++ u-boot/lib_arm/interrupts.c
+@@ -43,9 +43,14 @@
+ void enable_interrupts (void)
+ {
+       unsigned long temp;
+-      __asm__ __volatile__("mrs %0, cpsr\n"
++      __asm__ __volatile__(
++#ifdef CONFIG_GTA02_REVISION
++                           "mov %0, #0x30000000\n"
++                           "mcr p15, 0, %0, c13, c0\n"
++#endif
++                           "mrs %0, cpsr\n"
+                            "bic %0, %0, #0x80\n"
+-                           "msr cpsr_c, %0"
++                           "msr cpsr_c, %0\n"
+                            : "=r" (temp)
+                            :
+                            : "memory");
+@@ -61,7 +66,11 @@
+       unsigned long old,temp;
+       __asm__ __volatile__("mrs %0, cpsr\n"
+                            "orr %1, %0, #0xc0\n"
+-                           "msr cpsr_c, %1"
++                           "msr cpsr_c, %1\n"
++#ifdef CONFIG_GTA02_REVISION
++                           "mov %1, #0\n"
++                           "mcr p15, 0, %1, c13, c0\n"
++#endif
+                            : "=r" (old), "=r" (temp)
+                            :
+                            : "memory");

Modified: trunk/src/target/u-boot/patches/series
===================================================================
--- trunk/src/target/u-boot/patches/series      2008-03-25 12:39:50 UTC (rev 
4247)
+++ trunk/src/target/u-boot/patches/series      2008-03-25 21:06:51 UTC (rev 
4248)
@@ -95,3 +95,9 @@
 
 # fix and improve power management
 dont-smoke.patch
+
+# Experimental. Not intended for general use.
+###wait-for-power-DONTUSE.patch
+
+# Experimental. Please test.
+remap-vec.patch




--- End Message ---
--- Begin Message ---
Author: andrew
Date: 2008-03-25 23:12:32 +0100 (Tue, 25 Mar 2008)
New Revision: 4249

Modified:
   trunk/src/host/qemu-neo1973/hw/neo1973.c
   trunk/src/host/qemu-neo1973/openmoko/README
Log:
Implement basic LIS302DL accelerometer logic.


Modified: trunk/src/host/qemu-neo1973/hw/neo1973.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/neo1973.c    2008-03-25 21:06:51 UTC (rev 
4248)
+++ trunk/src/host/qemu-neo1973/hw/neo1973.c    2008-03-25 22:12:32 UTC (rev 
4249)
@@ -355,6 +355,9 @@
     uint8_t regs[0x40];
     int reg;
 
+    int enable;
+    uint64_t interval;
+
     QEMUTimer *sample;
 };
 
@@ -367,24 +370,88 @@
     s->regs[0x20] = 0x07;      /* Ctrl_Reg1 */
 }
 
-static void piccolo_sample_sched(struct piccolo_s *s)
+static void piccolo_data_update(struct piccolo_s *s, int mask)
 {
-    int rate = (s->regs[0x20] & (1 << 7)) ? 400 : 100; /* DR */
+    /* TODO: poll the Qemu SDL window position to find 2d acceleration */
 
-    qemu_mod_timer(s->sample,
-                    qemu_get_clock(vm_clock) + ticks_per_sec / rate);
+    /* 1G */
+    int x = 0x00, y = 0x00, z = 0x10;
+
+    if (mask & (1 << 0))
+        s->regs[0x29] = x;
+    if (mask & (1 << 1))
+        s->regs[0x2b] = y;
+    if (mask & (1 << 2))
+        s->regs[0x2d] = z;
 }
 
+static void piccolo_intr_update(struct piccolo_s *s)
+{
+    int inv = (s->regs[0x22] >> 7) & 1;
+    int level;
+    int i;
+
+    for (i = 0; i < 6; i += 3) {
+        switch ((s->regs[0x22] >> i) & 7) {
+        case 0:
+        default:
+            level = 0;
+            break;
+        case 1:
+            level = (s->regs[0x31] >> 6) & 1;
+            break;
+        case 2:
+            level = (s->regs[0x35] >> 6) & 1;
+            break;
+        case 3:
+            level = ((s->regs[0x31] | s->regs[0x35]) >> 6) & 1;
+            break;
+        case 4:
+            level = !!s->regs[0x27];
+            break;
+        }
+
+        qemu_set_irq(s->intr[!!i], level ^ inv);
+    }
+}
+
+static void piccolo_ff_wu_update(struct piccolo_s *s)
+{
+    /* TODO: update high and low interrupts */
+    /* TODO: also update the counter and check treshold */
+}
+
+static void piccolo_sample_sched(struct piccolo_s *s)
+{
+    qemu_mod_timer(s->sample, qemu_get_clock(vm_clock) + s->interval);
+}
+
 static void piccolo_sample_tick(void *opaque)
 {
     struct piccolo_s *s = (struct piccolo_s *) opaque;
+    int nu_data = s->regs[0x20] & 7;
 
-    /* TODO */
+    if (nu_data == 7)
+        nu_data |= 8;
+    s->regs[0x27] |= nu_data | ((s->regs[0x27] & nu_data) << 4);
+
+    piccolo_data_update(s, nu_data & 7);
+    piccolo_ff_wu_update(s);
+    piccolo_intr_update(s);
     piccolo_sample_sched(s);
 }
 
 static void piccolo_sample_update(struct piccolo_s *s)
 {
+    int rate = (s->regs[0x20] & (1 << 7)) ? 400 : 100; /* DR */
+
+    s->enable = (s->regs[0x20] >> 6) & 1;              /* PD */
+    if (!s->enable) {
+        qemu_del_timer(s->sample);
+        return;
+    }
+
+    s->interval = ticks_per_sec / rate;
     if (!(s->regs[0x20] & 7))                          /* Xen | Yen | Zen */
         qemu_del_timer(s->sample);
     else if (!qemu_timer_pending(s->sample))
@@ -403,6 +470,7 @@
 {
     struct piccolo_s *s = (struct piccolo_s *) i2c;
     int reg = s->reg;
+    int ret;
 
     if (reg >= 0x80) {
         reg -= 0x80;
@@ -424,13 +492,22 @@
     case 0x2b: /* OutY */
     case 0x2d: /* OutZ */
     case 0x30: /* FF_WU_CFG_1 */
-    case 0x31: /* FF_WU_SRC_1 */
     case 0x32: /* FF_WU_THS_1 */
     case 0x33: /* FF_WU_DURATION_1 */
     case 0x34: /* FF_WU_CFG_2 */
-    case 0x35: /* FF_WU_SRC_2 */
     case 0x36: /* FF_WU_THS_2 */
     case 0x37: /* FF_WU_DURATION_2 */
+        break;
+
+    case 0x31: /* FF_WU_SRC_1 */
+    case 0x35: /* FF_WU_SRC_2 */
+        ret = s->regs[reg];
+        if ((s->regs[reg - 1] >> 6) & 1) {                     /* LIR */
+            s->regs[reg] = 0;
+            piccolo_intr_update(s);
+        }
+        return ret;
+
     case 0x38: /* CLICK_CFG */
     case 0x39: /* CLICK_SRC */
     case 0x3b: /* CLICK_THSY_X */
@@ -438,7 +515,6 @@
     case 0x3d: /* CLICK_timelimit */
     case 0x3e: /* CLICK_latency */
     case 0x3f: /* CLICK_window */
-        break;
     default:
         fprintf(stderr, "%s: unknown register %02x\n", __FUNCTION__, reg);
         return 0x00;
@@ -470,8 +546,8 @@
         fprintf(stderr, "%s: write to a \"do not modify\" register %02x\n",
                         __FUNCTION__, s->reg);
         fprintf(stderr, "%s: may cause permanent damage!\n", __FUNCTION__);
-        s->regs[reg] = data;
         break;
+
     case 0x20: /* Ctrl_Reg1 */
         s->regs[reg] = data;
         if (data & (3 << 3))
@@ -480,13 +556,24 @@
         break;
 
     case 0x21: /* Ctrl_Reg2 */
+        if (data & (1 << 6)) {
+            /* Memory reboot */
+            data &= ~(1 << 6);
+        }
+        break;
+
     case 0x22: /* Ctrl_Reg3 */
+        piccolo_intr_update(s);
+        break;
+
     case 0x30: /* FF_WU_CFG_1 */
     case 0x32: /* FF_WU_THS_1 */
     case 0x33: /* FF_WU_DURATION_1 */
     case 0x34: /* FF_WU_CFG_2 */
     case 0x36: /* FF_WU_THS_2 */
     case 0x37: /* FF_WU_DURATION_2 */
+        break;
+
     case 0x38: /* CLICK_CFG */
     case 0x39: /* CLICK_SRC */
     case 0x3b: /* CLICK_THSY_X */
@@ -494,15 +581,12 @@
     case 0x3d: /* CLICK_timelimit */
     case 0x3e: /* CLICK_latency */
     case 0x3f: /* CLICK_window */
-        /* TODO */
-        s->regs[reg] = data;
-        break;
-
     default:
         fprintf(stderr, "%s: unknown register %02x\n", __FUNCTION__, reg);
         return 1;
     }
 
+    s->regs[reg] = data;
     return 0;
 }
 
@@ -520,6 +604,8 @@
 
     qemu_get_buffer(f, s->regs, sizeof(s->regs));
     i2c_slave_load(f, &s->i2c);
+
+    piccolo_sample_update(s);
     return 0;
 }
 

Modified: trunk/src/host/qemu-neo1973/openmoko/README
===================================================================
--- trunk/src/host/qemu-neo1973/openmoko/README 2008-03-25 21:06:51 UTC (rev 
4248)
+++ trunk/src/host/qemu-neo1973/openmoko/README 2008-03-25 22:12:32 UTC (rev 
4249)
@@ -2,15 +2,14 @@
 code but are in some way related or useful to have at hand.
 
 The kernel patch with GTA02fake support is based on:
- * kernel 2.6.22.5
+ * kernel 2.6.24
  * OpenMoko patchset revision 3610 from
-   http://svn.openmoko.org/trunk/src/target/kernel/patches/
- * Samuel's Atheros WLAN driver revision 3610 from
-   http://svn.openmoko.org/developers/sameo/patches/ar6k-atheros/
+   http://svn.openmoko.org/branches/src/target/kernel/2.6.24.x/patches/
 
 The following sequence can be used to obtain a working tree on which the
 patch can be applied:
 
+cg-clone git://source.mvista.com/git/linux-omap-2.6.git
 tar -xvjf linux-2.6.22.5.tar.bz2
 cd linux-2.6.22.5
 cg-init




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2008-03-26 00:11:39 +0100 (Wed, 26 Mar 2008)
New Revision: 4250

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
Log:
2008-03-25  Thomas Wood  <[EMAIL PROTECTED]>

        * src/dialog/moko-history.c: Implement "Create New Contact" from call
        log


Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2008-03-25 22:12:32 UTC (rev 4249)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2008-03-25 23:11:39 UTC (rev 4250)
@@ -1,3 +1,8 @@
+2008-03-25  Thomas Wood  <[EMAIL PROTECTED]>
+
+       * src/dialog/moko-history.c: Implement "Create New Contact" from call
+       log
+
 2008-03-20  Thomas Wood  <[EMAIL PROTECTED]>
 
        * Makefile.am:

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
  2008-03-25 22:12:32 UTC (rev 4249)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
  2008-03-25 23:11:39 UTC (rev 4250)
@@ -220,6 +220,48 @@
 }
 
 static void
+create_new_contact_from_number (gchar *number)
+{
+  GtkWidget *dialog, *name, *label;
+
+  dialog = gtk_dialog_new_with_buttons ("Save as Contact",
+             NULL, GTK_DIALOG_MODAL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+            GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
+
+  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+
+  label = gtk_label_new ("Enter a name for the contact");
+  name = gtk_entry_new ();
+
+  gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG(dialog)->vbox), label);
+  gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG(dialog)->vbox), name);
+
+  gtk_widget_show (label);
+  gtk_widget_show (name);
+
+  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+  {
+    EContact *contact;
+    EBook *book;
+
+    /* create contact */
+    contact = e_contact_new ();
+    e_contact_set (contact, E_CONTACT_FULL_NAME, gtk_entry_get_text (GTK_ENTRY 
(name)));
+    e_contact_set (contact, E_CONTACT_PHONE_OTHER, number);
+
+    /* open address book */
+    book = e_book_new_system_addressbook (NULL);
+    e_book_open (book, FALSE, NULL);
+
+    /* add contact to address book, and close */
+    e_book_add_contact (book, contact, NULL);
+    g_object_unref (book);
+    g_object_unref (contact);
+  }
+  gtk_widget_destroy (dialog);
+}
+
+static void
 on_btn_save_clicked (GtkWidget *button, SaveButtonInfo *info)
 {
   gint action = info->response_id;
@@ -229,7 +271,10 @@
   gtk_widget_destroy (info->dialog);
   
   if (action == 1)
-  { /* create new contact */ }
+  {
+    /* create new contact */
+    create_new_contact_from_number (number);
+  }
   else
   {
     EBook *book;




--- End Message ---
--- Begin Message ---
Author: thomas
Date: 2008-03-26 01:49:00 +0100 (Wed, 26 Mar 2008)
New Revision: 4251

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
Log:
2008-03-26  Thomas Wood  <[EMAIL PROTECTED]>

        * src/dialer/moko-history.c: (create_new_contact_from_number),
        (add_number_to_contact), (on_btn_save_clicked),
        (btn_save_info_weak_notify), (on_save_clicked):

        Implement "Add to Contact" from call log feature


Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2008-03-25 23:11:39 UTC (rev 4250)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2008-03-26 00:49:00 UTC (rev 4251)
@@ -1,3 +1,11 @@
+2008-03-26  Thomas Wood  <[EMAIL PROTECTED]>
+
+       * src/dialer/moko-history.c: (create_new_contact_from_number),
+       (add_number_to_contact), (on_btn_save_clicked),
+       (btn_save_info_weak_notify), (on_save_clicked):
+
+       Implement "Add to Contact" from call log feature
+
 2008-03-25  Thomas Wood  <[EMAIL PROTECTED]>
 
        * src/dialog/moko-history.c: Implement "Create New Contact" from call

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
  2008-03-25 23:11:39 UTC (rev 4250)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/moko-history.c
  2008-03-26 00:49:00 UTC (rev 4251)
@@ -34,6 +34,13 @@
 
 #include "hito-contact-view.h"
 #include "hito-contact-store.h"
+#include "hito-group-store.h"
+#include "hito-group-combo.h"
+#include "hito-all-group.h"
+#include "hito-separator-group.h"
+#include "hito-group.h"
+#include "hito-no-category-group.h"
+#include "hito-vcard-util.h"
 
 #include "moko-contacts.h"
 #include "moko-history.h"
@@ -71,6 +78,7 @@
   GtkWidget *dialog;
   gint response_id;
   gchar *number;
+  MokoHistory *history;
 };
 
 typedef struct _SaveButtonInfo SaveButtonInfo;
@@ -243,18 +251,25 @@
   {
     EContact *contact;
     EBook *book;
+    EVCardAttribute *attr;
 
     /* create contact */
     contact = e_contact_new ();
+    /* add name */
     e_contact_set (contact, E_CONTACT_FULL_NAME, gtk_entry_get_text (GTK_ENTRY 
(name)));
-    e_contact_set (contact, E_CONTACT_PHONE_OTHER, number);
+    /* add number */
+    attr = e_vcard_attribute_new ("", EVC_TEL);
+    e_vcard_add_attribute_with_value (E_VCARD (contact), attr, number);
+    hito_vcard_attribute_set_type (attr, "Other");
 
     /* open address book */
+    /* TODO: check GErrors */
     book = e_book_new_system_addressbook (NULL);
     e_book_open (book, FALSE, NULL);
 
     /* add contact to address book, and close */
     e_book_add_contact (book, contact, NULL);
+
     g_object_unref (book);
     g_object_unref (contact);
   }
@@ -262,26 +277,13 @@
 }
 
 static void
-on_btn_save_clicked (GtkWidget *button, SaveButtonInfo *info)
+add_number_to_contact (gchar *number)
 {
-  gint action = info->response_id;
-  gchar *number = g_strdup (info->number);
-    
-  /* this also destroys info data */
-  gtk_widget_destroy (info->dialog);
-  
-  if (action == 1)
-  {
-    /* create new contact */
-    create_new_contact_from_number (number);
-  }
-  else
-  {
     EBook *book;
     EBookQuery *query;
     EBookView *view;
-    GtkWidget *window, *contacts_treeview, *scroll;
-    GtkTreeModel *store;
+    GtkWidget *window, *contacts_treeview, *scroll, *groups_combo;
+    GtkTreeModel *store, *group_store, *contact_filter;
     GError *err = NULL;
     
     window = gtk_dialog_new_with_buttons ("Add to Contact", NULL, 0,
@@ -302,21 +304,84 @@
 
     e_book_query_unref (query);  
     e_book_view_start (view);
-    
+
+
     store = hito_contact_store_new (view);
-    contacts_treeview = hito_contact_view_new (HITO_CONTACT_STORE (store), 
NULL);
+
+    group_store = hito_group_store_new ();
+    hito_group_store_set_view (HITO_GROUP_STORE (group_store), view);
+    hito_group_store_add_group (HITO_GROUP_STORE (group_store), 
hito_all_group_new ());
+    hito_group_store_add_group (HITO_GROUP_STORE (group_store), 
hito_separator_group_new (-99));
+    hito_group_store_add_group (HITO_GROUP_STORE (group_store), 
hito_separator_group_new (99));
+    hito_group_store_add_group (HITO_GROUP_STORE (group_store), 
hito_no_category_group_new ());
+
+    contact_filter = hito_contact_model_filter_new (HITO_CONTACT_STORE 
(store));
+
+    groups_combo = hito_group_combo_new (HITO_GROUP_STORE (group_store));
+    hito_group_combo_connect_filter (HITO_GROUP_COMBO (groups_combo),
+                                   HITO_CONTACT_MODEL_FILTER (contact_filter));
+    gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (window)->vbox), 
groups_combo);
+
+
     
+    contacts_treeview = hito_contact_view_new (HITO_CONTACT_STORE (store), 
HITO_CONTACT_MODEL_FILTER (contact_filter));
+    
     scroll = moko_finger_scroll_new ();
+    gtk_widget_set_size_request (scroll, -1, 300);
     gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (window)->vbox), scroll);
     
     gtk_container_add (GTK_CONTAINER (scroll), contacts_treeview);
     
     gtk_widget_show_all (scroll);
+    gtk_widget_show_all (groups_combo);
     
-    gtk_dialog_run (GTK_DIALOG (window));
+    if (gtk_dialog_run (GTK_DIALOG (window)) == GTK_RESPONSE_OK)
+    {
+      GtkTreeIter iter;
+      EContact *contact;
+      EVCardAttribute *attr;
+      GtkTreeModel *model;
+      GtkTreeSelection *selection;
+
+      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW 
(contacts_treeview));
+
+      if (gtk_tree_selection_get_selected (selection, &model, &iter))
+      {
+        gtk_tree_model_get (model, &iter, COLUMN_CONTACT, &contact, -1);
+        if (contact)
+        {
+          attr = e_vcard_attribute_new ("", EVC_TEL);
+          e_vcard_add_attribute_with_value (E_VCARD (contact), attr, number);
+          hito_vcard_attribute_set_type (attr, "Other");
+          e_book_async_commit_contact (book, contact, NULL, NULL);
+          g_object_unref (contact);
+        }
+      }
+    }
+
     gtk_widget_destroy (window);
+    g_object_unref (book);
+}
+
+static void
+on_btn_save_clicked (GtkWidget *button, SaveButtonInfo *info)
+{
+  gint action = info->response_id;
+  gchar *number = g_strdup (info->number);
+  MokoHistory *history = info->history;
+    
+  /* this also destroys info data */
+  gtk_widget_destroy (info->dialog);
+  
+  if (action == 1)
+  {
+    /* create new contact */
+    create_new_contact_from_number (number);
   }
-  
+  else
+  {
+    add_number_to_contact (number);
+  }
   g_free (number);
 }
 
@@ -365,6 +430,7 @@
   btn_info = g_new0 (SaveButtonInfo, 1);
   btn_info->dialog = window;
   btn_info->response_id = 1;
+  btn_info->history = history;
   btn_info->number = g_strdup (number);
   g_signal_connect (btn, "clicked", G_CALLBACK (on_btn_save_clicked), 
btn_info);
   g_object_weak_ref (G_OBJECT (btn), (GWeakNotify) btn_save_info_weak_notify, 
btn_info);
@@ -374,6 +440,7 @@
   btn_info = g_new0 (SaveButtonInfo, 1);
   btn_info->dialog = window;
   btn_info->response_id = 2;
+  btn_info->history = history;
   btn_info->number = g_strdup (number);
   g_signal_connect (btn, "clicked", G_CALLBACK (on_btn_save_clicked), 
btn_info);
   g_object_weak_ref (G_OBJECT (btn), (GWeakNotify) btn_save_info_weak_notify, 
btn_info);




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to