~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-client-gnome/src/contacts/addressbook.c

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <addressbook-config.h>
35
35
 
36
36
static void
37
 
handler_async_search(GList *, gpointer);
 
37
handler_async_search (GList *, gpointer);
38
38
 
39
39
/**
40
40
 * Perform a search on address book
41
41
 */
42
42
void
43
 
addressbook_search(GtkEntry* entry)
 
43
addressbook_search (GtkEntry* entry)
44
44
{
45
45
 
46
 
    const gchar* query = gtk_entry_get_text(GTK_ENTRY (entry));
47
 
    if (strlen(query) >= 3) {
48
 
 
49
 
        AddressBook_Config *addressbook_config;
50
 
        
51
 
        // Activate waiting layer
52
 
        activateWaitingLayer();
53
 
 
54
 
        // Load the address book parameters
55
 
        addressbook_config_load_parameters(&addressbook_config);
56
 
      
57
 
        // Start the asynchronous search as soon as we have an entry */
58
 
        search_async(gtk_entry_get_text(GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config);
59
 
 
60
 
    }
 
46
    const gchar* query = gtk_entry_get_text (GTK_ENTRY (entry));
 
47
    DEBUG ("Addressbook: Search %s", query);
 
48
 
 
49
 
 
50
    AddressBook_Config *addressbook_config;
 
51
 
 
52
    activateWaitingLayer();
 
53
 
 
54
    addressbook_config_load_parameters (&addressbook_config);
 
55
 
 
56
 
 
57
    search_async_by_contacts (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config);
 
58
 
61
59
}
62
60
 
63
61
/**
66
64
gboolean
67
65
addressbook_is_enabled()
68
66
{
69
 
  AddressBook_Config *addressbook_config;
70
 
  
71
 
  // Load the address book parameters
72
 
  addressbook_config_load_parameters(&addressbook_config);
73
 
 
74
 
  return (guint)addressbook_config->enable;
 
67
    AddressBook_Config *addressbook_config;
 
68
 
 
69
    // Load the address book parameters
 
70
    addressbook_config_load_parameters (&addressbook_config);
 
71
 
 
72
    return (guint) addressbook_config->enable;
75
73
}
76
74
 
77
75
/**
80
78
gboolean
81
79
addressbook_is_ready()
82
80
{
83
 
  return books_ready();
 
81
    return books_ready();
84
82
}
85
83
 
86
84
/**
89
87
gboolean
90
88
addressbook_is_active()
91
89
{
92
 
  return books_active();
 
90
    return books_active();
93
91
}
94
92
 
95
93
/**
96
 
 * Asynchronous open callback.
97
 
 * Used to handle activation of books.
 
94
 * Get active addressbook from config.
98
95
 */
99
96
static void
100
97
addressbook_config_books()
101
98
{
102
99
 
103
 
  gchar **config_book_uid;
104
 
  book_data_t *book_data;
105
 
  gchar **list;
106
 
 
107
 
  // Retrieve list of books
108
 
  list = (gchar **) dbus_get_addressbook_list();
109
 
 
110
 
  if (list) {
111
 
 
112
 
      for (config_book_uid = list; *config_book_uid; config_book_uid++) {
113
 
 
114
 
          // Get corresponding book data
115
 
          book_data = books_get_book_data_by_uid(*config_book_uid);
116
 
 
117
 
          // If book_data exists
118
 
          if (book_data != NULL) {
119
 
 
120
 
              book_data->active = TRUE;
121
 
          }
122
 
      }
123
 
      g_strfreev(list);
124
 
  }
125
 
 
126
 
  // Update buttons
127
 
  update_actions ();
 
100
    gchar **config_book_uid;
 
101
    book_data_t *book_data;
 
102
    gchar **list;
 
103
 
 
104
    // Retrieve list of books
 
105
    list = (gchar **) dbus_get_addressbook_list();
 
106
 
 
107
    if (list) {
 
108
 
 
109
        for (config_book_uid = list; *config_book_uid; config_book_uid++) {
 
110
 
 
111
            // Get corresponding book data
 
112
            book_data = books_get_book_data_by_uid (*config_book_uid);
 
113
 
 
114
            // If book_data exists
 
115
            if (!book_data) {
 
116
                ERROR ("Addressbook: Error: Could not open book (%s:%d)", __FILE__, __LINE__);
 
117
                continue;
 
118
            }
 
119
 
 
120
            book_data->active = TRUE;
 
121
        }
 
122
 
 
123
        g_strfreev (list);
 
124
    }
 
125
 
 
126
    // Update buttons
 
127
    // update_actions ();
128
128
}
129
129
 
130
130
/**
133
133
GSList *
134
134
addressbook_get_books_data()
135
135
{
136
 
  addressbook_config_books();
137
 
  return books_data;
 
136
    DEBUG ("Addressboook: Get books data");
 
137
 
 
138
    fill_books_data();
 
139
    addressbook_config_books();
 
140
 
 
141
    return books_data;
138
142
}
139
143
 
140
144
/**
144
148
void
145
149
addressbook_init()
146
150
{
147
 
  // Call books initialization
148
 
  init(&addressbook_config_books);
 
151
    DEBUG ("Addressbook: Initialize addressbook");
 
152
 
 
153
    fill_books_data();
 
154
    addressbook_config_books();
 
155
 
 
156
    // Call books initialization
 
157
    init ();
149
158
}
150
159
 
151
160
/**
152
161
 * Callback called after all book have been processed
153
162
 */
154
163
static void
155
 
handler_async_search(GList *hits, gpointer user_data)
 
164
handler_async_search (GList *hits, gpointer user_data)
156
165
{
157
166
 
158
 
  GList *i;
159
 
  GdkPixbuf *photo = NULL;
160
 
  AddressBook_Config *addressbook_config;
161
 
  callable_obj_t *j;
162
 
 
163
 
  // freeing calls
164
 
  while ((j = (callable_obj_t *) g_queue_pop_tail(contacts->callQueue)) != NULL)
165
 
    {
166
 
      free_callable_obj_t(j);
 
167
    GList *i;
 
168
    GdkPixbuf *photo = NULL;
 
169
    AddressBook_Config *addressbook_config;
 
170
    callable_obj_t *j;
 
171
 
 
172
    DEBUG ("Addressbook: callback async search");
 
173
 
 
174
    // freeing calls
 
175
    while ( (j = (callable_obj_t *) g_queue_pop_tail (contacts->callQueue)) != NULL) {
 
176
        free_callable_obj_t (j);
167
177
    }
168
178
 
169
 
  // Retrieve the address book parameters
170
 
  addressbook_config = (AddressBook_Config*) user_data;
171
 
 
172
 
  // reset previous results
173
 
  calltree_reset(contacts);
174
 
  calllist_reset(contacts);
175
 
 
176
 
  for (i = hits; i != NULL; i = i->next)
177
 
    {
178
 
      Hit *entry;
179
 
      entry = i->data;
180
 
      if (entry)
181
 
        {
182
 
          // Get the photo
183
 
          if (addressbook_display(addressbook_config,
184
 
              ADDRESSBOOK_DISPLAY_CONTACT_PHOTO))
185
 
            photo = entry->photo;
186
 
          // Create entry for business phone information
187
 
          if (addressbook_display(addressbook_config,
188
 
              ADDRESSBOOK_DISPLAY_PHONE_BUSINESS))
189
 
            calllist_add_contact(entry->name, entry->phone_business,
190
 
                CONTACT_PHONE_BUSINESS, photo);
191
 
          // Create entry for home phone information
192
 
          if (addressbook_display(addressbook_config,
193
 
              ADDRESSBOOK_DISPLAY_PHONE_HOME))
194
 
            calllist_add_contact(entry->name, entry->phone_home,
195
 
                CONTACT_PHONE_HOME, photo);
196
 
          // Create entry for mobile phone information
197
 
          if (addressbook_display(addressbook_config,
198
 
              ADDRESSBOOK_DISPLAY_PHONE_MOBILE))
199
 
            calllist_add_contact(entry->name, entry->phone_mobile,
200
 
                CONTACT_PHONE_MOBILE, photo);
 
179
    // Retrieve the address book parameters
 
180
    addressbook_config = (AddressBook_Config*) user_data;
 
181
 
 
182
    // reset previous results
 
183
    calltree_reset (contacts);
 
184
    calllist_reset (contacts);
 
185
 
 
186
    for (i = hits; i != NULL; i = i->next) {
 
187
 
 
188
        Hit *entry;
 
189
        entry = i->data;
 
190
 
 
191
        if (entry) {
 
192
            // Get the photo
 
193
            if (addressbook_display (addressbook_config,
 
194
                                     ADDRESSBOOK_DISPLAY_CONTACT_PHOTO))
 
195
                photo = entry->photo;
 
196
 
 
197
            // Create entry for business phone information
 
198
            if (addressbook_display (addressbook_config,
 
199
                                     ADDRESSBOOK_DISPLAY_PHONE_BUSINESS))
 
200
                calllist_add_contact (entry->name, entry->phone_business,
 
201
                                      CONTACT_PHONE_BUSINESS, photo);
 
202
 
 
203
            // Create entry for home phone information
 
204
            if (addressbook_display (addressbook_config,
 
205
                                     ADDRESSBOOK_DISPLAY_PHONE_HOME))
 
206
                calllist_add_contact (entry->name, entry->phone_home,
 
207
                                      CONTACT_PHONE_HOME, photo);
 
208
 
 
209
            // Create entry for mobile phone information
 
210
            if (addressbook_display (addressbook_config,
 
211
                                     ADDRESSBOOK_DISPLAY_PHONE_MOBILE))
 
212
                calllist_add_contact (entry->name, entry->phone_mobile,
 
213
                                      CONTACT_PHONE_MOBILE, photo);
201
214
        }
202
 
      free_hit(entry);
 
215
 
 
216
        free_hit (entry);
203
217
    }
204
 
  g_list_free(hits);
205
 
 
206
 
  // Deactivate waiting image
207
 
  deactivateWaitingLayer();
 
218
 
 
219
    g_list_free (hits);
 
220
 
 
221
    // Deactivate waiting image
 
222
    deactivateWaitingLayer();
 
223
 
 
224
 
 
225
    gtk_widget_grab_focus (GTK_WIDGET (contacts->view));
208
226
}
209
227