/** * get ICalendar VTIMEZONE block from ECalComponentWithTZ * * @param ectz * An evolution event/task/note type which may contain a time zone. * * @return the ICalendar VTIMEZONE block */ static gchar* get_vtimezone (const ECalComponentWithTZ *ectz) { icalcomponent *icc = NULL; icalcomponent *cloned_icc = NULL; icalproperty *dtstamp = NULL; icalproperty *uid = NULL; gchar *ical_str = NULL; if (ectz == NULL || ectz->maincomp == NULL || ectz->timezone == NULL) return NULL; icc = e_cal_component_get_icalcomponent (ectz->timezone); cloned_icc = icalcomponent_new_clone (icc); /* uid and dtstamp are not needed (nor wanted) in timezone block */ uid = icalcomponent_get_first_property(cloned_icc, ICAL_UID_PROPERTY); icalcomponent_remove_property (cloned_icc, uid); free(uid); dtstamp = icalcomponent_get_first_property(cloned_icc, ICAL_DTSTAMP_PROPERTY); icalcomponent_remove_property (cloned_icc, dtstamp); free(dtstamp); /* memory returned by *_as_ical_string() is owned by libical */ ical_str = g_strdup (icalcomponent_as_ical_string (cloned_icc)); icalcomponent_free (cloned_icc); return ical_str; }
/** Gets the LOCATION or X-LIC-LOCATION property from a VTIMEZONE. */ static char* icaltimezone_get_location_from_vtimezone (icalcomponent *component) { icalproperty *prop; const char *location; const char *name; prop = icalcomponent_get_first_property (component, ICAL_LOCATION_PROPERTY); if (prop) { location = icalproperty_get_location (prop); if (location) return strdup (location); } prop = icalcomponent_get_first_property (component, ICAL_X_PROPERTY); while (prop) { name = icalproperty_get_x_name (prop); if (name && !strcasecmp (name, "X-LIC-LOCATION")) { location = icalproperty_get_x (prop); if (location) return strdup (location); } prop = icalcomponent_get_next_property (component, ICAL_X_PROPERTY); } return NULL; }
void create_simple_component(void) { icalcomponent* calendar; icalproperty *version, *bogus; /* Create calendar and add properties */ calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); ok("create vcalendar component", (calendar!=NULL)); icalcomponent_add_property( calendar, icalproperty_new_version("2.0") ); version = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); ok("version property added", (version!=NULL)); bogus = icalcomponent_get_first_property(calendar,ICAL_DTSTART_PROPERTY); ok("bogus dtstart not found", (bogus == NULL)); if (VERBOSE && calendar) printf("%s\n",icalcomponent_as_ical_string(calendar)); icalcomponent_free(calendar); }
icalproperty *icallangbind_get_first_property(icalcomponent *c, const char *prop) { icalproperty_kind kind = icalproperty_string_to_kind(prop); icalproperty *p; if (kind == ICAL_NO_PROPERTY) { return 0; } if (kind == ICAL_X_PROPERTY) { for (p = icalcomponent_get_first_property(c, kind); p != 0; p = icalcomponent_get_next_property(c, kind)) { if (strcmp(icalproperty_get_x_name(p), prop) == 0) { return p; } } } else { p = icalcomponent_get_first_property(c, kind); return p; } return 0; }
/** * e_cal_util_construct_instance: * @icalcomp: A recurring #icalcomponent * @rid: The RECURRENCE-ID to construct a component for * * This checks that @rid indicates a valid recurrence of @icalcomp, and * if so, generates a copy of @comp containing a RECURRENCE-ID of @rid. * * Returns: the instance, or %NULL. **/ icalcomponent * e_cal_util_construct_instance (icalcomponent *icalcomp, struct icaltimetype rid) { struct instance_data instance; struct icaltimetype start, end; g_return_val_if_fail (icalcomp != NULL, NULL); /* Make sure this is really recurring */ if (!icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY) && !icalcomponent_get_first_property (icalcomp, ICAL_RDATE_PROPERTY)) return NULL; /* Make sure the specified instance really exists */ start = icaltime_convert_to_zone (rid, icaltimezone_get_utc_timezone ()); end = start; icaltime_adjust (&end, 0, 0, 0, 1); instance.start = icaltime_as_timet (start); instance.found = FALSE; icalcomponent_foreach_recurrence (icalcomp, start, end, check_instance, &instance); if (!instance.found) return NULL; /* Make the instance */ icalcomp = icalcomponent_new_clone (icalcomp); icalcomponent_set_recurrenceid (icalcomp, rid); return icalcomp; }
static icalproperty * find_attendee (icalcomponent *ical_comp, const char *address) { icalproperty *prop; if (address == NULL) return NULL; for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY); prop != NULL; prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) { icalvalue *value; const char *attendee; char *text; value = icalproperty_get_value (prop); if (!value) continue; attendee = icalvalue_get_string (value); text = g_strdup (itip_strip_mailto (attendee)); text = g_strstrip (text); if (!g_ascii_strcasecmp (address, text)) { g_free (text); break; } g_free (text); } return prop; }
static icalproperty *icalmessage_find_attendee(icalcomponent *comp, const char *user) { icalcomponent *inner = icalmessage_get_inner(comp); icalproperty *p, *attendee = 0; char *luser = lowercase(user); for (p = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY); p != 0; p = icalcomponent_get_next_property(inner, ICAL_ATTENDEE_PROPERTY)) { char *lattendee; lattendee = lowercase(icalproperty_get_attendee(p)); if (strstr(lattendee, user) != 0) { free(lattendee); attendee = p; break; } free(lattendee); } free(luser); return attendee; }
icalcomponent *icalmessage_new_delegate_request(icalcomponent *c, const char *user, const char *delegatee, const char *msg) { icalcomponent *reply; icalproperty *attendee; icalcomponent *inner; icalparameter *delegateeParam; icalerror_check_arg_rz(c, "c"); reply = icalmessage_new_reply_base(c, user, msg); inner = icalmessage_get_inner(reply); if (reply == 0) { return 0; } icalcomponent_set_method(reply, ICAL_METHOD_REQUEST); attendee = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY); icalproperty_set_parameter(attendee, icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED)); icalproperty_set_parameter(attendee, icalparameter_new_delegatedto(delegatee)); delegateeParam = icalparameter_new_delegatedfrom(icalproperty_get_attendee(attendee)); icalcomponent_add_property( inner, icalproperty_vanew_attendee(delegatee, delegateeParam, 0)); icalparameter_free(delegateeParam); return reply; }
/** Set icalcomponent X-* property. * * @param comp iCal component. * @param key Property name (i.e. X-EEE-WHATEVER). * @param value Property value. */ static void icomp_x_prop_set(icalcomponent *comp, const char *key, const char *value) { icalproperty *iter; g_return_if_fail(comp != NULL); g_return_if_fail(key != NULL); again: for (iter = icalcomponent_get_first_property(comp, ICAL_X_PROPERTY); iter; iter = icalcomponent_get_next_property(comp, ICAL_X_PROPERTY)) { const char *str = icalproperty_get_x_name(iter); if (str && !g_strcmp0(str, key)) { icalcomponent_remove_property(comp, iter); icalproperty_free(iter); goto again; } } if (value) { iter = icalproperty_new_x(value); icalproperty_set_x_name(iter, key); icalcomponent_add_property(comp, iter); } }
static void icaldirset_add_uid(icalcomponent *comp) { char uidstring[MAXPATHLEN] = { 0 }; icalproperty *uid; #if defined(HAVE_SYS_UTSNAME_H) struct utsname unamebuf; #endif icalerror_check_arg_rv((comp != 0), "comp"); uid = icalcomponent_get_first_property(comp, ICAL_UID_PROPERTY); if (uid == 0) { #if defined(HAVE_SYS_UTSNAME_H) uname(&unamebuf); snprintf(uidstring, sizeof(uidstring), "%d-%s", (int)getpid(), unamebuf.nodename); #else /* FIXME: There must be an easy get the system name */ snprintf(uidstring, sizeof(uidstring), "%d-%s", (int)getpid(), "WINDOWS"); #endif uid = icalproperty_new_uid(uidstring); icalcomponent_add_property(comp, uid); } else { strncpy(uidstring, icalproperty_get_uid(uid), MAXPATHLEN - 1); uidstring[MAXPATHLEN - 1] = '\0'; } }
icalproperty *icalcomponent_get_first_invitee(icalcomponent *comp) { icalproperty *prop; if (icalcomponent_isa(comp) == ICAL_VPOLL_COMPONENT) { icalcomponent *vvoter = icalcomponent_get_first_component(comp, ICAL_VVOTER_COMPONENT); prop = icalcomponent_get_first_property(vvoter, ICAL_VOTER_PROPERTY); } else { prop = icalcomponent_get_first_property(comp, ICAL_ATTENDEE_PROPERTY); } return prop; }
static gboolean update_objects (ECal *client, icalcomponent *icalcomp) { icalcomponent_kind kind; icalcomponent *vcal; gboolean success = TRUE; kind = icalcomponent_isa (icalcomp); if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) { vcal = e_cal_util_new_top_level (); if (icalcomponent_get_method (icalcomp) == ICAL_METHOD_CANCEL) icalcomponent_set_method (vcal, ICAL_METHOD_CANCEL); else icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH); icalcomponent_add_component (vcal, icalcomponent_new_clone (icalcomp)); } else if (kind == ICAL_VCALENDAR_COMPONENT) { vcal = icalcomponent_new_clone (icalcomp); if (!icalcomponent_get_first_property (vcal, ICAL_METHOD_PROPERTY)) icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH); } else return FALSE; if (!e_cal_receive_objects (client, vcal, NULL)) success = FALSE; icalcomponent_free (vcal); return success; }
void view_event(icalcomponent* calendar) { //Ask user if they want null fields in addition to filled ones bool show_null_fields_too = yes_no_prompt("Do you want to view empty fields? (y/n)"); icalcomponent* event = find_event(calendar); if (event == NULL) { append_action_to_closed_log("View event", false); } //Once user selects desired one, displays all needed fields icalproperty* p; for(p = icalcomponent_get_first_property(event,ICAL_ANY_PROPERTY); p != 0; p = icalcomponent_get_next_property(event,ICAL_ANY_PROPERTY)) { if ((icalproperty_get_comment(p) != NULL) || (show_null_fields_too)) { cout << icalproperty_get_x_name(p) << ": "; cout << icalproperty_get_comment(p) << endl; } } append_action_to_closed_log("View event", true); }
static void icaldirset_add_uid(icalcomponent* comp) { char uidstring[ICAL_PATH_MAX]; icalproperty *uid; #ifndef WIN32 struct utsname unamebuf; #endif icalerror_check_arg_rv( (comp!=0), "comp"); uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY); if (uid == 0) { #ifndef WIN32 uname(&unamebuf); snprintf(uidstring,sizeof(uidstring),"%d-%s",(int)getpid(),unamebuf.nodename); #else snprintf(uidstring,sizeof(uidstring),"%d-%s",(int)getpid(),"WINDOWS"); /* FIX: There must be an easy get the system name */ #endif uid = icalproperty_new_uid(uidstring); icalcomponent_add_property(comp,uid); } else { strcpy(uidstring,icalproperty_get_uid(uid)); } }
gboolean scalix_appointment_get (ScalixAppointment * comp, const char *key, char **value) { icalcomponent *icomp; icalproperty *icalprop; const char *x_val; icomp = e_cal_component_get_icalcomponent (E_CAL_COMPONENT (comp)); icalprop = icalcomponent_get_first_property (icomp, ICAL_X_PROPERTY); while (icalprop) { const char *x_name; x_name = icalproperty_get_x_name (icalprop); x_val = icalproperty_get_x (icalprop); if (!strcmp (x_name, key)) { break; } icalprop = icalcomponent_get_next_property (icomp, ICAL_X_PROPERTY); } if (icalprop) { *value = g_strdup (x_val); return TRUE; } *value = NULL; return FALSE; }
void scalix_appointment_unset (ScalixAppointment * comp, const char *key) { icalcomponent *icomp; icalproperty *icalprop; const char *x_val; GSList *list, *iter; list = NULL; icomp = e_cal_component_get_icalcomponent (E_CAL_COMPONENT (comp)); icalprop = icalcomponent_get_first_property (icomp, ICAL_X_PROPERTY); while (icalprop) { const char *x_name; x_name = icalproperty_get_x_name (icalprop); x_val = icalproperty_get_x (icalprop); if (!strcmp (x_name, key)) { list = g_slist_prepend (list, icalprop); } icalprop = icalcomponent_get_next_property (icomp, ICAL_X_PROPERTY); } for (iter = list; iter; iter = iter->next) { icalprop = iter->data; icalcomponent_remove_property (icomp, icalprop); icalproperty_free (icalprop); } return; }
static void action_calendar_taskpad_open_url_cb (GtkAction *action, ECalShellView *cal_shell_view) { EShellView *shell_view; EShellWindow *shell_window; ECalShellContent *cal_shell_content; ECalModelComponent *comp_data; ETaskTable *task_table; icalproperty *prop; const gchar *uri; GSList *list; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); cal_shell_content = cal_shell_view->priv->cal_shell_content; task_table = e_cal_shell_content_get_task_table (cal_shell_content); list = e_task_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; /* XXX We only open the URI of the first selected task. */ prop = icalcomponent_get_first_property ( comp_data->icalcomp, ICAL_URL_PROPERTY); g_return_if_fail (prop != NULL); uri = icalproperty_get_url (prop); e_show_uri (GTK_WINDOW (shell_window), uri); }
static gboolean check_first_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end, gpointer user_data) { CheckFirstInstanceData *ifs = user_data; icalcomponent *icalcomp; struct icaltimetype rid; g_return_val_if_fail (ifs != NULL, FALSE); icalcomp = e_cal_component_get_icalcomponent (comp); if (icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY) != NULL) { rid = icalcomponent_get_recurrenceid (icalcomp); } else { struct icaltimetype dtstart; dtstart = icalcomponent_get_dtstart (icalcomp); if (dtstart.zone) { rid = icaltime_from_timet_with_zone (instance_start, dtstart.is_date, dtstart.zone); } else { rid = icaltime_from_timet (instance_start, dtstart.is_date); } } ifs->matches = icaltime_compare (ifs->rid, rid) == 0; return FALSE; }
int cond_ICalHaveItem(StrBuf *Target, WCTemplputParams *TP) { icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL); icalproperty *p; icalproperty_kind Kind; Kind = (icalproperty_kind) GetTemplateTokenNumber(Target, TP, 2, ICAL_ANY_PROPERTY); p = icalcomponent_get_first_property(cal, Kind); if (p != NULL) { WCTemplputParams *DynamicTP; DynamicTP = (WCTemplputParams*) malloc(sizeof(WCTemplputParams)); StackDynamicContext (TP, DynamicTP, p, CTX_ICALPROPERTY, 0, TP->Tokens, ReleaseIcalSubCtx, TP->Tokens->Params[1]->lvalue); return 1; } return 0; }
static time_t get_time_from_property (icalcomponent *ical, icalproperty_kind prop_kind, struct icaltimetype (* get_prop_func) (const icalproperty *prop), icaltimezone *default_zone) { icalproperty *prop; struct icaltimetype ical_time; icalparameter *param; icaltimezone *timezone = NULL; prop = icalcomponent_get_first_property (ical, prop_kind); if (!prop) return 0; ical_time = get_prop_func (prop); param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); if (param) timezone = icaltimezone_get_builtin_timezone_from_tzid (icalparameter_get_tzid (param)); else if (icaltime_is_utc (ical_time)) timezone = icaltimezone_get_utc_timezone (); else timezone = default_zone; return icaltime_as_timet_with_zone (ical_time, timezone); }
static gboolean get_ical_is_all_day (icalcomponent *ical, time_t start_time, icaltimezone *default_zone) { icalproperty *prop; struct tm *start_tm; time_t end_time; struct icaldurationtype duration; struct icaltimetype start_icaltime; start_icaltime = icalcomponent_get_dtstart (ical); if (start_icaltime.is_date) return TRUE; start_tm = gmtime (&start_time); if (start_tm->tm_sec != 0 || start_tm->tm_min != 0 || start_tm->tm_hour != 0) return FALSE; if ((end_time = get_ical_end_time (ical, default_zone))) return (end_time - start_time) % 86400 == 0; prop = icalcomponent_get_first_property (ical, ICAL_DURATION_PROPERTY); if (!prop) return FALSE; duration = icalproperty_get_duration (prop); return icaldurationtype_as_int (duration) % 86400 == 0; }
/* read the entry identified by id from the vcal file f and write it to the phone */ static int gn_ical2todo_real(icalcomponent *comp, gn_todo *ctodo, int id) { icalcomponent *compresult = NULL; if (id < 1) id = 1; /* iterate through the component */ iterate_cal(comp, 0, &id, &compresult, ICAL_VTODO_COMPONENT); if (!compresult) { dprintf("No component found.\n"); return GN_ERR_EMPTYLOCATION; } else { icalproperty *priority = icalcomponent_get_first_property(compresult, ICAL_PRIORITY_PROPERTY); /* summary goes into text */ /* TODO: UTF8 --> ascii */ snprintf(ctodo->text, GN_TODO_MAX_LENGTH-1, "%s", icalcomponent_get_summary(compresult)); /* priority */ ctodo->priority = icalproperty_get_priority((const icalproperty *)priority); dprintf("Component found\n%s\n", icalcomponent_as_ical_string(compresult)); } icalcomponent_free(compresult); return GN_ERR_NONE; }
void MainWindow::loadFromIcsFile() { char* line; icalcomponent *c; icalparser *parser = icalparser_new(); FILE* stream = fopen("/home/quentin/Public/test.ics", "r"); icalparser_set_gen_data(parser, stream); do { line = icalparser_get_line(parser, read_stream); c = icalparser_add_line(parser, line); if (c != 0) { icalcomponent *inner = icalcomponent_get_first_component(c, ICAL_ANY_COMPONENT); while (inner != NULL) { if (icalcomponent_isa(inner) == ICAL_VTODO_COMPONENT) { const char* name = icalcomponent_get_summary(inner); const char* uid = icalcomponent_get_uid(inner); icalproperty *p = icalcomponent_get_first_property(inner, ICAL_RELATEDTO_PROPERTY); const char* parent = icalproperty_get_relatedto(p); addTask(name, uid, parent); } if (icalcomponent_isa(inner) == ICAL_VEVENT_COMPONENT) { const char* name = icalcomponent_get_summary(inner); const char* uid = icalcomponent_get_uid(inner); icalproperty *p = icalcomponent_get_first_property(inner, ICAL_RELATEDTO_PROPERTY); const char* parent = icalproperty_get_relatedto(p); p = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY); icaltimetype start = icalproperty_get_dtstart(p); p = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY); icaltimetype end = icalproperty_get_dtend(p); Task* task = findTask(parent); addEvent(task, uid, name, start, end); } inner = icalcomponent_get_next_component(c, ICAL_ANY_COMPONENT); } } } while (line != 0); }
void e_cal_shell_view_memopad_actions_update (ECalShellView *cal_shell_view) { ECalShellContent *cal_shell_content; EShellWindow *shell_window; EShellView *shell_view; EMemoTable *memo_table; GtkAction *action; GSList *list, *iter; gboolean editable = TRUE; gboolean has_url = FALSE; gboolean sensitive; gint n_selected; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); cal_shell_content = cal_shell_view->priv->cal_shell_content; memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); n_selected = e_table_selected_count (E_TABLE (memo_table)); list = e_memo_table_get_selected (memo_table); for (iter = list; iter != NULL; iter = iter->next) { ECalModelComponent *comp_data = iter->data; icalproperty *prop; gboolean read_only; read_only = e_client_is_readonly (E_CLIENT (comp_data->client)); editable &= !read_only; prop = icalcomponent_get_first_property ( comp_data->icalcomp, ICAL_URL_PROPERTY); has_url |= (prop != NULL); } g_slist_free (list); action = ACTION (CALENDAR_MEMOPAD_FORWARD); sensitive = (n_selected == 1); gtk_action_set_sensitive (action, sensitive); action = ACTION (CALENDAR_MEMOPAD_OPEN); sensitive = (n_selected == 1); gtk_action_set_sensitive (action, sensitive); action = ACTION (CALENDAR_MEMOPAD_OPEN_URL); sensitive = (n_selected == 1) && has_url; gtk_action_set_sensitive (action, sensitive); action = ACTION (CALENDAR_MEMOPAD_PRINT); sensitive = (n_selected == 1); gtk_action_set_sensitive (action, sensitive); action = ACTION (CALENDAR_MEMOPAD_SAVE_AS); sensitive = (n_selected == 1); gtk_action_set_sensitive (action, sensitive); }
nsresult calIcalComponent::GetIntProperty(icalproperty_kind kind, int32_t *valp) { icalproperty *prop = icalcomponent_get_first_property(mComponent, kind); if (!prop) *valp = calIIcalComponent::INVALID_VALUE; else *valp = (int32_t)icalvalue_get_integer(icalproperty_get_value(prop)); return NS_OK; }
/* * Construct a JSON array for an iCalendar component. */ static json_t *icalcomponent_as_json_array(icalcomponent *comp) { icalcomponent *c; icalproperty *p; icalcomponent_kind kind; const char* kind_string; json_t *jcomp, *jprops, *jsubs; if (!comp) return NULL; kind = icalcomponent_isa(comp); switch (kind) { case ICAL_NO_COMPONENT: return NULL; break; case ICAL_X_COMPONENT: kind_string = ""; //comp->x_name; break; default: kind_string = icalcomponent_kind_to_string(kind); } /* Create component array */ jcomp = json_array(); /* Add component name */ json_array_append_new(jcomp, json_string(lcase(icalmemory_tmp_copy(kind_string)))); /* Add properties */ jprops = json_array(); for (p = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY); p; p = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) { json_array_append_new(jprops, icalproperty_as_json_array(p)); } json_array_append_new(jcomp, jprops); /* Add sub-components */ jsubs = json_array(); for (c = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT); c; c = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) { json_array_append_new(jsubs, icalcomponent_as_json_array(c)); } json_array_append_new(jcomp, jsubs); return jcomp; }
void e_task_shell_view_open_task (ETaskShellView *task_shell_view, ECalModelComponent *comp_data) { EShell *shell; EShellView *shell_view; EShellWindow *shell_window; ESourceRegistry *registry; CompEditor *editor; CompEditorFlags flags = 0; ECalComponent *comp; icalcomponent *clone; icalproperty *prop; const gchar *uid; g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view)); g_return_if_fail (E_IS_CAL_MODEL_COMPONENT (comp_data)); shell_view = E_SHELL_VIEW (task_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell = e_shell_window_get_shell (shell_window); registry = e_shell_get_registry (shell); uid = icalcomponent_get_uid (comp_data->icalcomp); editor = comp_editor_find_instance (uid); if (editor != NULL) goto exit; comp = e_cal_component_new (); clone = icalcomponent_new_clone (comp_data->icalcomp); e_cal_component_set_icalcomponent (comp, clone); prop = icalcomponent_get_first_property ( comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY); if (prop != NULL) flags |= COMP_EDITOR_IS_ASSIGNED; if (itip_organizer_is_user (registry, comp, comp_data->client)) flags |= COMP_EDITOR_USER_ORG; if (!e_cal_component_has_attendees (comp)) flags |= COMP_EDITOR_USER_ORG; editor = task_editor_new (comp_data->client, shell, flags); comp_editor_edit_comp (editor, comp); g_object_unref (comp); if (flags & COMP_EDITOR_IS_ASSIGNED) task_editor_show_assignment (TASK_EDITOR (editor)); exit: gtk_window_present (GTK_WINDOW (editor)); }
void calIcalComponent::ClearAllProperties(icalproperty_kind kind) { for (icalproperty *prop = icalcomponent_get_first_property(mComponent, kind), *next; prop; prop = next) { next = icalcomponent_get_next_property(mComponent, kind); icalcomponent_remove_property(mComponent, prop); icalproperty_free(prop); } }
static void icalmessage_copy_properties(icalcomponent *to, icalcomponent *from, icalproperty_kind kind) { icalcomponent *to_inner = icalmessage_get_inner(to); icalcomponent *from_inner = icalmessage_get_inner(from); if (to_inner == 0 && from_inner == 0) { icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); return; } if (!icalcomponent_get_first_property(from_inner, kind)) { return; } icalcomponent_add_property( to_inner, icalproperty_new_clone(icalcomponent_get_first_property(from_inner, kind))); }
/* * Construct a XML element for an iCalendar component. */ static xmlNodePtr icalcomponent_as_xml_element(icalcomponent *comp) { icalcomponent *c; icalproperty *p; icalcomponent_kind kind; const char* kind_string; xmlNodePtr xcomp, xprops = NULL, xsubs = NULL; if (!comp) return NULL; kind = icalcomponent_isa(comp); switch (kind) { case ICAL_NO_COMPONENT: return NULL; break; case ICAL_X_COMPONENT: kind_string = ""; //comp->x_name; break; default: kind_string = icalcomponent_kind_to_string(kind); } /* Create component */ xcomp = xmlNewNode(NULL, BAD_CAST lcase(icalmemory_tmp_copy(kind_string))); /* Add properties */ for (p = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY); p; p = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) { if (!xprops) xprops = xmlNewChild(xcomp, NULL, BAD_CAST "properties", NULL); xmlAddChild(xprops, icalproperty_as_xml_element(p)); } /* Add sub-components */ for (c = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT); c; c = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) { if (!xsubs) xsubs = xmlNewChild(xcomp, NULL, BAD_CAST "components", NULL); xmlAddChild(xsubs, icalcomponent_as_xml_element(c)); } return xcomp; }