void contact_list_editor_select_button_clicked_cb (GtkWidget *widget) { EContactListEditor *editor; EContactListModel *model; ENameSelectorDialog *dialog; EDestinationStore *store; GList *list, *iter; editor = contact_list_editor_extract (widget); model = E_CONTACT_LIST_MODEL (editor->priv->model); dialog = e_name_selector_peek_dialog (editor->priv->name_selector); gtk_window_set_title (GTK_WINDOW (dialog), _("Contact List Members")); /* We need to empty out the destination store, since we copy its * contents every time. This sucks, we should really be wired * directly to the EDestinationStore that the name selector uses * in true MVC fashion. */ e_name_selector_model_peek_section ( e_name_selector_peek_model (editor->priv->name_selector), "Members", NULL, &store); list = e_destination_store_list_destinations (store); for (iter = list; iter != NULL; iter = iter->next) e_destination_store_remove_destination (store, iter->data); g_list_free (list); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_hide (GTK_WIDGET (dialog)); list = e_destination_store_list_destinations (store); for (iter = list; iter != NULL; iter = iter->next) { EDestination *destination = iter->data; const gchar *email = e_destination_get_email (destination); if (email == NULL) continue; if (!contact_list_editor_contact_exists (model, email)) e_contact_list_model_add_destination ( model, destination); } g_list_free (list); editor->priv->changed = TRUE; contact_list_editor_update (editor); }
GList * e_select_names_editable_get_emails (ESelectNamesEditable *esne) { EDestinationStore *destination_store; GList *destinations; EDestination *destination; GList *result = NULL; g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (esne)); destinations = e_destination_store_list_destinations (destination_store); if (!destinations) return NULL; destination = destinations->data; if (e_destination_is_evolution_list (destination)) { const GList *list_dests, *l; list_dests = e_destination_list_get_dests (destination); for (l = list_dests; l != NULL; l = g_list_next (l)) { result = g_list_append (result, g_strdup (e_destination_get_email (l->data))); } } else { /* check if the contact is contact list, it does not contain all the email ids */ /* we dont expand it currently, TODO do we need to expand it by getting it from addressbook*/ if (e_destination_get_contact (destination) && e_contact_get (e_destination_get_contact (destination), E_CONTACT_IS_LIST)) { /* If its a contact_list which is not expanded, it wont have a email id, so we can use the name as the email id */ result = g_list_append (result, g_strdup (e_destination_get_name (destination))); } else result = g_list_append (result, g_strdup (e_destination_get_email (destination))); } g_list_free (destinations); return result; }
gchar * e_select_names_editable_get_email (ESelectNamesEditable *esne) { EDestinationStore *destination_store; GList *destinations; EDestination *destination; gchar *result = NULL; g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (esne)); destinations = e_destination_store_list_destinations (destination_store); if (!destinations) return NULL; destination = destinations->data; result = g_strdup (e_destination_get_email (destination)); g_list_free (destinations); return result; }
/* Fills the mail alarm data with the values from the widgets */ static void malarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { gchar *str; ECalComponentText description; GSList *attendee_list = NULL; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; ENameSelectorModel *name_selector_model; EDestinationStore *destination_store; GList *destinations; icalcomponent *icalcomp; icalproperty *icalprop; GList *l; /* Attendees */ name_selector_model = e_name_selector_peek_model (dialog->name_selector); e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); destinations = e_destination_store_list_destinations (destination_store); for (l = destinations; l; l = g_list_next (l)) { EDestination *dest; ECalComponentAttendee *a; dest = l->data; a = g_new0 (ECalComponentAttendee, 1); a->value = e_destination_get_email (dest); a->cn = e_destination_get_name (dest); a->cutype = ICAL_CUTYPE_INDIVIDUAL; a->status = ICAL_PARTSTAT_NEEDSACTION; a->role = ICAL_ROLE_REQPARTICIPANT; attendee_list = g_slist_append (attendee_list, a); } e_cal_component_alarm_set_attendee_list (alarm, attendee_list); e_cal_component_free_attendee_list (attendee_list); g_list_free (destinations); if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->malarm_message))) return; /* Description */ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description)); gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start); gtk_text_buffer_get_end_iter (text_buffer, &text_iter_end); str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE); description.value = str; description.altrep = NULL; e_cal_component_alarm_set_description (alarm, &description); g_free (str); /* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that * we don't re-set the alarm's description */ icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); while (icalprop) { const gchar *x_name; x_name = icalproperty_get_x_name (icalprop); if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) { icalcomponent_remove_property (icalcomp, icalprop); break; } icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY); } }
static void subscribe_to_folder (GtkWidget *dialog, gint response, gpointer data) { SubscriptionInfo *subscription_info = data; gchar *user_email_address = NULL, *folder_name = NULL, *path = NULL; gchar *subscriber_email; EFolder *folder = NULL; EDestinationStore *destination_store; GList *destinations; EDestination *destination; ExchangeAccountFolderResult result; if (response == GTK_RESPONSE_CANCEL) { gtk_widget_destroy (dialog); destroy_subscription_info (subscription_info); } else if (response == GTK_RESPONSE_OK) { while (TRUE) { destination_store = e_name_selector_entry_peek_destination_store ( E_NAME_SELECTOR_ENTRY (GTK_ENTRY (subscription_info->name_selector_widget))); destinations = e_destination_store_list_destinations (destination_store); if (!destinations) break; destination = destinations->data; user_email_address = g_strdup (e_destination_get_email (destination)); g_list_free (destinations); if (user_email_address != NULL && *user_email_address != '\0') break; /* check if user is trying to subscribe to his own folder */ subscriber_email = exchange_account_get_email_id (subscription_info->account); if (subscriber_email != NULL && *subscriber_email != '\0') { if (g_str_equal (subscriber_email, user_email_address)) { e_alert_run_dialog_for_args (GTK_WINDOW (dialog), ERROR_DOMAIN ":folder-exists-error", NULL); g_free (user_email_address); gtk_widget_destroy (dialog); destroy_subscription_info (subscription_info); return; } } /* It would be nice to insensitivize the OK button appropriately instead of doing this, but unfortunately we can't do this for the control. */ e_alert_run_dialog_for_args (GTK_WINDOW (dialog), ERROR_DOMAIN ":select-user", NULL); } folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (subscription_info->folder_name_entry))); if (user_email_address && folder_name) { const gchar *err_msg = NULL; result = exchange_account_discover_shared_folder (subscription_info->account, user_email_address, folder_name, &folder); g_free (folder_name); gtk_widget_hide (dialog); switch (result) { case EXCHANGE_ACCOUNT_FOLDER_OK: exchange_account_rescan_tree (subscription_info->account); if (!g_ascii_strcasecmp (e_folder_get_type_string (folder), "mail")) err_msg = ERROR_DOMAIN ":folder-restart-evo"; break; case EXCHANGE_ACCOUNT_FOLDER_ALREADY_EXISTS: err_msg = ERROR_DOMAIN ":folder-exists-error"; break; case EXCHANGE_ACCOUNT_FOLDER_DOES_NOT_EXIST: err_msg = ERROR_DOMAIN ":folder-doesnt-exist-error"; break; case EXCHANGE_ACCOUNT_FOLDER_UNKNOWN_TYPE: err_msg = ERROR_DOMAIN ":folder-unknown-type"; break; case EXCHANGE_ACCOUNT_FOLDER_PERMISSION_DENIED: err_msg = ERROR_DOMAIN ":folder-perm-error"; break; case EXCHANGE_ACCOUNT_FOLDER_OFFLINE: err_msg = ERROR_DOMAIN ":folder-offline-error"; break; case EXCHANGE_ACCOUNT_FOLDER_UNSUPPORTED_OPERATION: err_msg = ERROR_DOMAIN ":folder-unsupported-error"; break; case EXCHANGE_ACCOUNT_FOLDER_GC_NOTREACHABLE: err_msg = ERROR_DOMAIN ":folder-no-gc-error"; break; case EXCHANGE_ACCOUNT_FOLDER_NO_SUCH_USER: e_alert_run_dialog_for_args (GTK_WINDOW (dialog), ERROR_DOMAIN ":no-user-error", user_email_address, NULL); break; case EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR: err_msg = ERROR_DOMAIN ":folder-generic-error"; break; default: break; } if (err_msg) e_alert_run_dialog_for_args (GTK_WINDOW (dialog), err_msg, NULL); } if (!folder) { g_free (user_email_address); gtk_widget_destroy (dialog); return; } g_object_unref (folder); path = g_strdup_printf ("/%s", user_email_address); exchange_account_open_folder (subscription_info->account, path); g_free (path); g_free (user_email_address); gtk_widget_destroy (dialog); destroy_subscription_info (subscription_info); } }