1 /* 2 * 3 * Evolution calendar - Data model for ETable 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU Lesser General Public License as published by 7 * the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this program; if not, see <http://www.gnu.org/licenses/>. 16 * 17 * 18 * Authors: 19 * Rodrigo Moya <rodrigo@ximian.com> 20 * 21 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 22 * 23 */ 24 25 #ifndef E_CAL_MODEL_H 26 #define E_CAL_MODEL_H 27 28 #include <libecal/libecal.h> 29 30 #include <e-util/e-util.h> 31 #include <shell/e-shell.h> 32 #include <calendar/gui/e-cal-data-model.h> 33 34 #include "e-cell-date-edit-text.h" 35 36 /* Standard GObject macros */ 37 #define E_TYPE_CAL_MODEL \ 38 (e_cal_model_get_type ()) 39 #define E_CAL_MODEL(obj) \ 40 (G_TYPE_CHECK_INSTANCE_CAST \ 41 ((obj), E_TYPE_CAL_MODEL, ECalModel)) 42 #define E_CAL_MODEL_CLASS(cls) \ 43 (G_TYPE_CHECK_CLASS_CAST \ 44 ((cls), E_TYPE_CAL_MODEL, ECalModelClass)) 45 #define E_IS_CAL_MODEL(obj) \ 46 (G_TYPE_CHECK_INSTANCE_TYPE \ 47 ((obj), E_TYPE_CAL_MODEL)) 48 #define E_IS_CAL_MODEL_CLASS(cls) \ 49 (G_TYPE_CHECK_CLASS_TYPE \ 50 ((cls), E_TYPE_CAL_MODEL)) 51 #define E_CAL_MODEL_GET_CLASS(obj) \ 52 (G_TYPE_INSTANCE_GET_CLASS \ 53 ((obj), E_TYPE_CAL_MODEL, ECalModelClass)) 54 55 /* Standard GObject macros */ 56 #define E_TYPE_CAL_MODEL_COMPONENT \ 57 (e_cal_model_component_get_type ()) 58 #define E_CAL_MODEL_COMPONENT(obj) \ 59 (G_TYPE_CHECK_INSTANCE_CAST \ 60 ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponent)) 61 #define E_CAL_MODEL_COMPONENT_CLASS(cls) \ 62 (G_TYPE_CHECK_CLASS_CAST \ 63 ((cls), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentClass)) 64 #define E_IS_CAL_MODEL_COMPONENT(obj) \ 65 (G_TYPE_CHECK_INSTANCE_TYPE \ 66 ((obj), E_TYPE_CAL_MODEL_COMPONENT)) 67 #define E_IS_CAL_MODEL_COMPONENT_CLASS(cls) \ 68 (G_TYPE_CHECK_CLASS_TYPE \ 69 ((cls), E_TYPE_CAL_MODEL_COMPONENT)) 70 #define E_CAL_MODEL_COMPONENT_GET_CLASS(obj) \ 71 (G_TYPE_INSTANCE_GET_CLASS \ 72 ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentClass)) 73 74 G_BEGIN_DECLS 75 76 typedef enum { 77 /* If you add new items here or reorder them, you have to update the 78 * .etspec files for the tables using this model */ 79 E_CAL_MODEL_FIELD_CATEGORIES, 80 E_CAL_MODEL_FIELD_CLASSIFICATION, 81 E_CAL_MODEL_FIELD_COLOR, /* not a real field */ 82 E_CAL_MODEL_FIELD_COMPONENT, /* not a real field */ 83 E_CAL_MODEL_FIELD_DESCRIPTION, 84 E_CAL_MODEL_FIELD_DTSTART, 85 E_CAL_MODEL_FIELD_HAS_ALARMS, /* not a real field */ 86 E_CAL_MODEL_FIELD_ICON, /* not a real field */ 87 E_CAL_MODEL_FIELD_SUMMARY, 88 E_CAL_MODEL_FIELD_UID, 89 E_CAL_MODEL_FIELD_CREATED, 90 E_CAL_MODEL_FIELD_LASTMODIFIED, 91 E_CAL_MODEL_FIELD_SOURCE, /* not a real field */ 92 E_CAL_MODEL_FIELD_CANCELLED, /* not a real field */ 93 E_CAL_MODEL_FIELD_LAST 94 } ECalModelField; 95 96 typedef struct _ECalModel ECalModel; 97 typedef struct _ECalModelClass ECalModelClass; 98 typedef struct _ECalModelPrivate ECalModelPrivate; 99 100 typedef struct _ECalModelComponent ECalModelComponent; 101 typedef struct _ECalModelComponentClass ECalModelComponentClass; 102 typedef struct _ECalModelComponentPrivate ECalModelComponentPrivate; 103 104 struct _ECalModelComponent { 105 GObject object; 106 107 ECalClient *client; 108 ICalComponent *icalcomp; 109 time_t instance_start; 110 time_t instance_end; 111 gboolean is_new_component; 112 113 /* Private data used by ECalModelCalendar and ECalModelTasks */ 114 /* keep these public to avoid many accessor functions */ 115 ECellDateEditValue *dtstart; 116 ECellDateEditValue *dtend; 117 ECellDateEditValue *due; 118 ECellDateEditValue *completed; 119 ECellDateEditValue *created; 120 ECellDateEditValue *lastmodified; 121 gchar *color; 122 123 ECalModelComponentPrivate *priv; 124 }; 125 126 struct _ECalModelComponentClass { 127 GObjectClass parent_class; 128 }; 129 130 typedef struct { 131 ECalModelComponent *comp_data; 132 gpointer cb_data; 133 } ECalModelGenerateInstancesData; 134 135 struct _ECalModel { 136 GObject parent; 137 ECalModelPrivate *priv; 138 }; 139 140 struct _ECalModelClass { 141 GObjectClass parent_class; 142 143 /* virtual methods */ 144 const gchar * (*get_color_for_component) 145 (ECalModel *model, 146 ECalModelComponent *comp_data); 147 void (*store_values_from_model) 148 (ECalModel *model, 149 ETableModel *source_model, 150 gint row, 151 GHashTable *values); /* column ID ~> value */ 152 void (*fill_component_from_values) 153 (ECalModel *model, 154 ECalModelComponent *comp_data, 155 GHashTable *values); /* column ID ~> value, populated by store_values_from_model() */ 156 157 /* Signals */ 158 void (*time_range_changed) (ECalModel *model, 159 gint64 start, /* time_t */ 160 gint64 end); /* time_t */ 161 void (*row_appended) (ECalModel *model); 162 void (*comps_deleted) (ECalModel *model, 163 gpointer list); 164 void (*timezone_changed) (ECalModel *model, 165 ICalTimezone *old_zone, 166 ICalTimezone *new_zone); 167 void (*object_created) (ECalModel *model, 168 ECalClient *where); 169 }; 170 171 typedef time_t (*ECalModelDefaultTimeFunc) (ECalModel *model, gpointer user_data); 172 173 GType e_cal_model_get_type (void); 174 GType e_cal_model_component_get_type (void); 175 ECalDataModel * e_cal_model_get_data_model (ECalModel *model); 176 ESourceRegistry * 177 e_cal_model_get_registry (ECalModel *model); 178 EShell * e_cal_model_get_shell (ECalModel *model); 179 EClientCache * e_cal_model_get_client_cache (ECalModel *model); 180 ICalComponentKind 181 e_cal_model_get_component_kind (ECalModel *model); 182 void e_cal_model_set_component_kind (ECalModel *model, 183 ICalComponentKind kind); 184 gboolean e_cal_model_get_confirm_delete (ECalModel *model); 185 void e_cal_model_set_confirm_delete (ECalModel *model, 186 gboolean confirm_delete); 187 ICalTimezone * e_cal_model_get_timezone (ECalModel *model); 188 void e_cal_model_set_timezone (ECalModel *model, 189 const ICalTimezone *zone); 190 gboolean e_cal_model_get_compress_weekend 191 (ECalModel *model); 192 void e_cal_model_set_compress_weekend 193 (ECalModel *model, 194 gboolean compress_weekend); 195 void e_cal_model_set_default_category 196 (ECalModel *model, 197 const gchar *default_cat); 198 gint e_cal_model_get_default_reminder_interval 199 (ECalModel *model); 200 void e_cal_model_set_default_reminder_interval 201 (ECalModel *model, 202 gint def_reminder_interval); 203 EDurationType e_cal_model_get_default_reminder_units 204 (ECalModel *model); 205 void e_cal_model_set_default_reminder_units 206 (ECalModel *model, 207 EDurationType def_reminder_units); 208 gboolean e_cal_model_get_use_24_hour_format 209 (ECalModel *model); 210 void e_cal_model_set_use_24_hour_format 211 (ECalModel *model, 212 gboolean use24); 213 gboolean e_cal_model_get_use_default_reminder 214 (ECalModel *model); 215 void e_cal_model_set_use_default_reminder 216 (ECalModel *model, 217 gboolean use_def_reminder); 218 GDateWeekday e_cal_model_get_week_start_day (ECalModel *model); 219 void e_cal_model_set_week_start_day (ECalModel *model, 220 GDateWeekday week_start_day); 221 gboolean e_cal_model_get_work_day (ECalModel *model, 222 GDateWeekday weekday); 223 void e_cal_model_set_work_day (ECalModel *model, 224 GDateWeekday weekday, 225 gboolean work_day); 226 GDateWeekday e_cal_model_get_work_day_first (ECalModel *model); 227 GDateWeekday e_cal_model_get_work_day_last (ECalModel *model); 228 gint e_cal_model_get_work_day_end_hour 229 (ECalModel *model); 230 void e_cal_model_set_work_day_end_hour 231 (ECalModel *model, 232 gint work_day_end_hour); 233 gint e_cal_model_get_work_day_end_minute 234 (ECalModel *model); 235 void e_cal_model_set_work_day_end_minute 236 (ECalModel *model, 237 gint work_day_end_minute); 238 gint e_cal_model_get_work_day_start_hour 239 (ECalModel *model); 240 void e_cal_model_set_work_day_start_hour 241 (ECalModel *model, 242 gint work_day_start_hour); 243 gint e_cal_model_get_work_day_start_minute 244 (ECalModel *model); 245 void e_cal_model_set_work_day_start_minute 246 (ECalModel *model, 247 gint work_day_start_minute); 248 gint e_cal_model_get_work_day_start_mon 249 (ECalModel *model); 250 void e_cal_model_set_work_day_start_mon 251 (ECalModel *model, 252 gint work_day_start); 253 gint e_cal_model_get_work_day_end_mon 254 (ECalModel *model); 255 void e_cal_model_set_work_day_end_mon 256 (ECalModel *model, 257 gint work_day_end); 258 gint e_cal_model_get_work_day_start_tue 259 (ECalModel *model); 260 void e_cal_model_set_work_day_start_tue 261 (ECalModel *model, 262 gint work_day_start); 263 gint e_cal_model_get_work_day_end_tue 264 (ECalModel *model); 265 void e_cal_model_set_work_day_end_tue 266 (ECalModel *model, 267 gint work_day_end); 268 gint e_cal_model_get_work_day_start_wed 269 (ECalModel *model); 270 void e_cal_model_set_work_day_start_wed 271 (ECalModel *model, 272 gint work_day_start); 273 gint e_cal_model_get_work_day_end_wed 274 (ECalModel *model); 275 void e_cal_model_set_work_day_end_wed 276 (ECalModel *model, 277 gint work_day_end); 278 gint e_cal_model_get_work_day_start_thu 279 (ECalModel *model); 280 void e_cal_model_set_work_day_start_thu 281 (ECalModel *model, 282 gint work_day_start); 283 gint e_cal_model_get_work_day_end_thu 284 (ECalModel *model); 285 void e_cal_model_set_work_day_end_thu 286 (ECalModel *model, 287 gint work_day_end); 288 gint e_cal_model_get_work_day_start_fri 289 (ECalModel *model); 290 void e_cal_model_set_work_day_start_fri 291 (ECalModel *model, 292 gint work_day_start); 293 gint e_cal_model_get_work_day_end_fri 294 (ECalModel *model); 295 void e_cal_model_set_work_day_end_fri 296 (ECalModel *model, 297 gint work_day_end); 298 gint e_cal_model_get_work_day_start_sat 299 (ECalModel *model); 300 void e_cal_model_set_work_day_start_sat 301 (ECalModel *model, 302 gint work_day_start); 303 gint e_cal_model_get_work_day_end_sat 304 (ECalModel *model); 305 void e_cal_model_set_work_day_end_sat 306 (ECalModel *model, 307 gint work_day_end); 308 gint e_cal_model_get_work_day_start_sun 309 (ECalModel *model); 310 void e_cal_model_set_work_day_start_sun 311 (ECalModel *model, 312 gint work_day_start); 313 gint e_cal_model_get_work_day_end_sun 314 (ECalModel *model); 315 void e_cal_model_set_work_day_end_sun 316 (ECalModel *model, 317 gint work_day_end); 318 void e_cal_model_get_work_day_range_for 319 (ECalModel *model, 320 GDateWeekday weekday, 321 gint *start_hour, 322 gint *start_minute, 323 gint *end_hour, 324 gint *end_minute); 325 const gchar * e_cal_model_get_default_source_uid 326 (ECalModel *model); 327 void e_cal_model_set_default_source_uid 328 (ECalModel *model, 329 const gchar *source_uid); 330 void e_cal_model_remove_all_objects (ECalModel *model); 331 void e_cal_model_get_time_range (ECalModel *model, 332 time_t *start, 333 time_t *end); 334 void e_cal_model_set_time_range (ECalModel *model, 335 time_t start, 336 time_t end); 337 ICalComponent * e_cal_model_create_component_with_defaults_sync 338 (ECalModel *model, 339 ECalClient *client, 340 gboolean all_day, 341 GCancellable *cancellable, 342 GError **error); 343 gchar * e_cal_model_get_attendees_status_info 344 (ECalModel *model, 345 ECalComponent *comp, 346 ECalClient *cal_client); 347 const gchar * e_cal_model_get_color_for_component 348 (ECalModel *model, 349 ECalModelComponent *comp_data); 350 gboolean e_cal_model_get_rgba_for_component 351 (ECalModel *model, 352 ECalModelComponent *comp_data, 353 GdkRGBA *rgba); 354 gboolean e_cal_model_get_rgb_color_for_component 355 (ECalModel *model, 356 ECalModelComponent *comp_data, 357 gdouble *red, 358 gdouble *green, 359 gdouble *blue); 360 ECalModelComponent * 361 e_cal_model_get_component_at (ECalModel *model, 362 gint row); 363 ECalModelComponent * 364 e_cal_model_get_component_for_client_and_uid 365 (ECalModel *model, 366 ECalClient *client, 367 const ECalComponentId *id); 368 gchar * e_cal_model_date_value_to_string (ECalModel *model, 369 gconstpointer value); 370 void e_cal_model_generate_instances_sync 371 (ECalModel *model, 372 time_t start, 373 time_t end, 374 GCancellable *cancellable, 375 ECalRecurInstanceCb cb, 376 gpointer cb_data); 377 GPtrArray * e_cal_model_get_object_array (ECalModel *model); 378 void e_cal_model_set_instance_times (ECalModelComponent *comp_data, 379 const ICalTimezone *zone); 380 gboolean e_cal_model_test_row_editable (ECalModel *model, 381 gint row); 382 void e_cal_model_set_default_time_func 383 (ECalModel *model, 384 ECalModelDefaultTimeFunc func, 385 gpointer user_data); 386 387 void e_cal_model_update_comp_time (ECalModel *model, 388 ECalModelComponent *comp_data, 389 gconstpointer time_value, 390 ICalPropertyKind kind, 391 void (*set_func) (ICalProperty *prop, 392 ICalTime *v), 393 ICalProperty * (*new_func) (ICalTime *v)); 394 395 void e_cal_model_emit_object_created (ECalModel *model, 396 ECalClient *where); 397 398 void e_cal_model_modify_component (ECalModel *model, 399 ECalModelComponent *comp_data, 400 ECalObjModType mod); 401 402 void e_cal_model_util_set_value (GHashTable *values, 403 ETableModel *table_model, 404 gint column, 405 gint row); 406 gpointer e_cal_model_util_get_value (GHashTable *values, 407 gint column); 408 gpointer e_cal_model_util_get_status (ECalModelComponent *comp_data); 409 ICalPropertyStatus 410 e_cal_model_util_set_status (ECalModelComponent *comp_data, 411 gconstpointer value); 412 gint e_cal_model_util_status_compare_cb 413 (gconstpointer a, 414 gconstpointer b, 415 gpointer cmp_cache); 416 ECellDateEditValue * 417 e_cal_model_util_get_datetime_value 418 (ECalModel *model, 419 ECalModelComponent *comp_data, 420 ICalPropertyKind kind, 421 ICalTime * (*get_time_func) (ICalProperty *prop)); 422 void e_cal_model_until_sanitize_text_value 423 (gchar *value, 424 gint value_length); 425 426 G_END_DECLS 427 428 #endif /* E_CAL_MODEL_H */ 429