Exemple #1
0
extern Boolean
dssw_form_flags_to_appt(DSSW *dssw, Dtcm_appointment *a, char *name, Tick t, int *flagsP)
{
	time_t		start_tick, stop_tick;
	char		ampm_buf[BUFSIZ], buf[BUFSIZ];
	Props		*p = (Props *)dssw->cal->properties;
	Props_pu	*pu = (Props_pu *)dssw->cal->properties_pu;
	DisplayType	dt = get_int_prop(p, CP_DEFAULTDISP);
	int		flags = 0;

	if (flagsP == (int *)NULL)
	  flagsP = &flags;

	/*
	**  If neither start nor end times exist, then the start time is set
	**  to 3:41am (magic time) and the end time to 3:41 plus one minute.
	*/
	get_dssw_vals(dssw, t);
	if (blank_buf(dssw->date_val)) {
		editor_err_msg(dssw->parent, name, MISSING_DATE,
			       pu->xm_error_pixmap);
		return False;
	}

	if (!blank_buf(dssw->start_val.val)) {
		if (!valid_time(p, dssw->start_val.val)) {
			if (a->type->value->item.sint32_value == CSA_TYPE_TODO)
				editor_err_msg(dssw->parent, name, 
					       INVALID_TIME_DUE,
					       pu->xm_error_pixmap);
			else
				editor_err_msg(dssw->parent, name, 
					       INVALID_START,
					       pu->xm_error_pixmap);
			return False;
		}

		if (dt == HOUR12) {
			/* am and pm should not be translated.  They are only
			 * used in the date parsing code and never shown to
			 * the user.
			 */
			if (dssw->start_val.block == TIME_AM)
				sprintf(ampm_buf, "am");
			else
				sprintf(ampm_buf, "pm");
		} else
			ampm_buf[0] = '\0';

		sprintf(buf, "%s %s%s",
			dssw->date_val, dssw->start_val.val, ampm_buf); 

		if (!blank_buf(dssw->stop_val.val)
			&& !valid_time(p, dssw->stop_val.val)) {
			editor_err_msg(dssw->parent, name, INVALID_STOP,
				pu->xm_error_pixmap);
               		return False;
		}
	} else if (!blank_buf(dssw->stop_val.val)) {
		editor_err_msg(dssw->parent, name, MISSING_START,
			pu->xm_error_pixmap);
		return False;
	} else
		sprintf(buf, "%s 3:41am", dssw->date_val);

	start_tick = cm_getdate(buf, NULL);
	if(start_tick < 0) {
		editor_err_msg(dssw->parent, name, INVALID_DATE,
			pu->xm_error_pixmap);
		return False;
	}

	if (blank_buf(dssw->what_val) && blank_buf(dssw->start_val.val)
		&& blank_buf(dssw->stop_val.val)) {
		editor_err_msg(dssw->parent, name, INVALID_NOTIME_APPT,
			pu->xm_error_pixmap);
		return False;
	}

	a->time->value->item.date_time_value = (char *) malloc(BUFSIZ);
	_csa_tick_to_iso8601(start_tick, a->time->value->item.date_time_value);
	a->what->value->item.string_value = (char *)cm_strdup(dssw->what_val);
	a->show_time->value->item.sint32_value = True;

	if (!blank_buf(dssw->stop_val.val)) {
		if (dt == HOUR12) {
			/* am and pm should not be translated.  They are only
			 * used in the date parsing code and never shown to
			 * the user.
			 */
			if (dssw->stop_val.block == TIME_AM)
				sprintf(ampm_buf, "am");
			else
				sprintf(ampm_buf, "pm");
		} else
			ampm_buf[0] = '\0';

		sprintf(buf, "%s %s%s", dssw->date_val,
			dssw->stop_val.val, ampm_buf); 
		if ((stop_tick = cm_getdate(buf, NULL)) <= 0) {
			editor_err_msg(dssw->parent, name, INVALID_DATE,
				       pu->xm_error_pixmap);
			return False;
		}
		if (stop_tick < start_tick) {
		    if (*flagsP == 0)
		    {
		  	char *title = XtNewString(catgets(calendar->DT_catd, 1, 248,
					"Calendar : Schedule Appointment"));
		  	char *ident1 = XtNewString(catgets(calendar->DT_catd, 1,
					923, "Cancel"));
		  	char *ident2 = XtNewString(catgets(calendar->DT_catd, 1,
					250, "Next Day"));
			sprintf(buf, "%s", catgets(calendar->DT_catd, 1, 247,
				"This appointment has an end time earlier than\nits begin time.  Do you want to\nschedule it into the next day?"));
			*flagsP = dialog_popup(dssw->parent,
				DIALOG_TITLE, title,
				DIALOG_TEXT, buf,
				BUTTON_IDENT, -1, ident1,
				BUTTON_IDENT, DSSW_NEXT_DAY, ident2,
				DIALOG_IMAGE, pu->xm_question_pixmap,
				NULL);
			XtFree(ident2);
			XtFree(ident1);
			XtFree(title);
		    }
		    switch (*flagsP) {
		    case DSSW_NEXT_DAY:
			stop_tick += daysec;
			break;

		    default:
			*flagsP = 0;
		        return False;
		    }
		}

		a->end_time->value->item.date_time_value = (char *) malloc(BUFSIZ);
		_csa_tick_to_iso8601(stop_tick, a->end_time->value->item.date_time_value);
	} else if (blank_buf(dssw->start_val.val)) {
		a->end_time->value->item.date_time_value = (char *) malloc(BUFSIZ);
		_csa_tick_to_iso8601(start_tick + minsec, a->end_time->value->item.date_time_value);
		a->show_time->value->item.sint32_value = False;
	} else {
		free(a->end_time->value);
		a->end_time->value = NULL;
	}

	return True;
}
Exemple #2
0
void show_main_help(Widget w, XtPointer clientData, XtPointer cbs)
{
        int 		ac;
        Arg 		al[10];
        Calendar 	*c = calendar;
	Props_pu       	*p = (Props_pu *) c->properties_pu;
        Widget 		selWidget = NULL;
        int 		status = DtHELP_SELECT_ERROR;
 
        ac = 0;
        XtSetArg(al[ac], DtNhelpType, DtHELP_TYPE_TOPIC); ac++;
        switch ((int)clientData) {
            case HELP_OVERVIEW:
        	XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
                XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
                break;
            case HELP_USINGHELP:
        	XtSetArg(al[ac], DtNhelpVolume, "Help4Help"); ac++;
                XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
                break;
            case HELP_TASKS:
        	XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
                XtSetArg(al[ac], DtNlocationId, "TASKS"); ac++;
                break;
            case HELP_REFERENCE:
        	XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
                XtSetArg(al[ac], DtNlocationId, "REFERENCE"); ac++;
                break;
            case HELP_ABOUTCALENDAR:
        	XtSetArg(al[ac], DtNhelpVolume, "Help4Help"); ac++;
                XtSetArg(al[ac], DtNlocationId, "_COPYRIGHT"); ac++;
                break;
            case HELP_TOC:
        	XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
                XtSetArg(al[ac], DtNlocationId, "TOC"); ac++;
                break;
            case HELP_ONITEM:
               while (!XtIsSubclass(w, applicationShellWidgetClass))
                   w = XtParent(w);
 
               status = DtHelpReturnSelectedWidgetId(w, NULL, &selWidget);     
               switch ((int)status)
                  {
                    case DtHELP_SELECT_ERROR:
                      printf(catgets(c->DT_catd, 1, 350, "Selection Error, cannot continue\n"));
                    break;
                    case DtHELP_SELECT_VALID:
                      while (selWidget != NULL)
                        {
                          if ((XtHasCallbacks(selWidget, XmNhelpCallback)                                            == XtCallbackHasSome))
                            {
                               XtCallCallbacks((Widget)selWidget,
                                               XmNhelpCallback,NULL);
                               break;
                            }
                          else
                           selWidget = XtParent(selWidget);
                        }
                    break;
                    case DtHELP_SELECT_ABORT:
                      return;

                    case DtHELP_SELECT_INVALID:
		      {
			char *title = XtNewString(catgets(c->DT_catd, 1, 110, "Calendar : Error - Help"));
			char *text = XtNewString(catgets(c->DT_catd, 1, 352, "You must select a component within your application."));
			char *ident1 = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
			dialog_popup(c->frame,
				     DIALOG_TITLE, title,
				     DIALOG_TEXT, text,
				     BUTTON_IDENT, 1, ident1,
				     DIALOG_IMAGE, p->xm_error_pixmap,
				     NULL);
			XtFree(ident1);
			XtFree(text);
			XtFree(title);
			return;
		      }
                  }
 
               break;
 
            default:
        	XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
                XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
                break;
        }

	display_help(c, al, ac);
}
Exemple #3
0
/*
 * Call the routines in file_parse (in libDtCm) to read the appointments!
 */
extern int 
drag_load_proc(char *filename, Calendar *c) {
	int			ret_val, i = 1;
	char			buf[MAXNAMELEN * 2];
	CmDataList		*list = CmDataListCreate();
	Props			*p = (Props *)c->properties;
	Props_pu		*pu = (Props_pu *)c->properties_pu;
	Validate_op		op;
	Dtcm_appointment	*a;
	char			*msg;

	if (!filename || *filename == '\0')
		return -1;

	op = parse_appt_from_file(c->DT_catd, filename, list, p, query_user, 
				  (void *)c, c->general->version);
	if (list->count <= 0) {
		op = CANCEL_APPT;
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 842, 
	     "The information transferred did not\ncontain any appointments."));
	}

	switch(op) {
	case COULD_NOT_OPEN_FILE:
	  	msg = XtNewString(catgets(c->DT_catd, 1, 843, 
					"Drag and Drop operation failed."));
		sprintf(buf, "%s\n%s",
			msg,
			catgets(c->DT_catd, 1, 844, 
			      "Unable to locate the transferred information."));
		XtFree(msg);
		break;
	case INVALID_DATE:
		sprintf(buf, "%s",
			catgets(c->DT_catd, 1, 218, "Invalid DATE specified"));
		break;
	case INVALID_START:
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 219,
					   "Invalid START time specified"));
		break;
	case INVALID_STOP:
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 220,
					   "Invalid END time specified"));
		break;
	case MISSING_DATE:
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 221,
					   "Empty or missing DATE field"));
		break;
	case MISSING_START:
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 222,
					   "Empty or missing START field"));
		break;
	case MISSING_WHAT:
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 223,
					   "Empty or missing WHAT field"));
		break;
	case REPEAT_FOR_MISMATCH:
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 224,
					   "REPEAT and FOR field mismatch"));
		break;
	case VALID_APPT:
		break;
	case CANCEL_APPT:
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 225,
					   "Schedule appointment was cancelled."));
		break;
	default:
		op = CANCEL_APPT;
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 225,
					   "Schedule appointment was cancelled."));
		break;
	}

	while (op == VALID_APPT && i <= list->count) {
		extern void scrub_attr_list(Dtcm_appointment *); 

		a = (Dtcm_appointment *)CmDataListGetData(list, i);

		scrub_attr_list(a);

		ret_val = schedule_appt(c, a);
		if (ret_val < 0) {
			op = CANCEL_APPT;
			sprintf(buf, "%s", catgets(c->DT_catd, 1, 226,
				"Internal error scheduling appointment."));
		} else if (ret_val == 0) {
			op = CANCEL_APPT;
			sprintf(buf, "%s", catgets(c->DT_catd, 1, 225,
				"Schedule appointment was cancelled."));
		}
		++i;
	}

	for (i = 1; i <= list->count; i++)
		if (a = (Dtcm_appointment *)CmDataListGetData(list, i))
			free_appt_struct(&a);
	CmDataListDestroy(list, B_FALSE);

	if (op != VALID_APPT) {
	  	char *title = XtNewString(catgets(c->DT_catd, 1, 1073,
					  "Calendar : Error - Drag and Drop"));
		char *ident = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
		dialog_popup(c->frame,
			DIALOG_TITLE, title,
			DIALOG_TEXT, buf,
			BUTTON_IDENT, 1, ident,
			BUTTON_HELP, DND_ERROR_HELP,
			DIALOG_IMAGE, pu->xm_error_pixmap,
			NULL);
		XtFree(ident);
		XtFree(title);
		return -1;
	}

	return 0;
}
Exemple #4
0
CSA_entry_handle
get_appt_struct(DragContext *context) {
	int             *item_list = NULL, item_cnt = 0, answer;
	char		buf[MAXNAMELEN];
	Widget 		list;
	Calendar 	*c = context->calendar;
	Props_pu	*pr;
	CSA_entry_handle	entry;
	Access_data	*ad;

	pr = (Props_pu *)(c->properties_pu);

	if (context->editor_type == SingleEditorList)
		list = ((Editor *) context->editor)->appt_list;
	else if (context->editor_type == GroupEditorList)
		list = ((GEditor *) context->editor)->appt_list;
	else if (context->editor_type == TodoEditorList)
		list = ((ToDo *) context->editor)->todo_list;

        if (!XmListGetSelectedPos(list, &item_list, &item_cnt)) {
	  	char *title = XtNewString(catgets(c->DT_catd, 1, 230, 
				"Calendar : Error - Drag Appointment"));
		char *text = XtNewString(catgets(c->DT_catd, 1, 231, "Select an appointment and DRAG again."));
		char *ident = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
                answer = dialog_popup(c->frame,
                        DIALOG_TITLE, title,
                        DIALOG_TEXT, text,
                        BUTTON_IDENT, 1, ident,
			BUTTON_HELP, RESELECT_ERROR_HELP,
                        DIALOG_IMAGE, pr->xm_error_pixmap,
                        NULL);
		XtFree(ident);
		XtFree(text);
		XtFree(title);
                return(NULL);
        }
 

	if (context->editor_type == SingleEditorList)
		entry = editor_nth_appt((Editor *)context->editor,
					item_list[0] - 1);
	else if (context->editor_type == GroupEditorList)
		entry = geditor_nth_appt((GEditor *)context->editor,
					 item_list[0] - 1, &ad);
	else if (context->editor_type == TodoEditorList)
		entry = t_nth_appt((ToDo *)context->editor,
					 item_list[0] - 1);


        if (!entry) {
	  	char *title = XtNewString(catgets(c->DT_catd, 1, 230, 
					"Calendar : Error - Drag Appointment"));
		char *ident = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 845,
		"Drag and Drop operation Failed\nInternal consistency error."));
                answer = dialog_popup(c->frame,
                        DIALOG_TITLE, title,
                        DIALOG_TEXT, buf,
                        BUTTON_IDENT, 1, ident,
                        DIALOG_IMAGE, pr->xm_error_pixmap,
                        NULL);
		XtFree(ident);
		XtFree(title);
                XtFree((XtPointer)item_list);
                return(NULL);
        }

	return entry;
}
Exemple #5
0
/*
 * Insert the appointment into the calendar.
 *
 * Returns:
 *		1	Success
 *		0	User overuled.  Appointment not inserted.
 *		-1	Failure
 */
static int
schedule_appt(Calendar *c, Dtcm_appointment *a) {
	char		date_buf[MAXNAMELEN], buf[BUFSIZ], buf2[BUFSIZ];
	int		answer;
	Editor		*e = (Editor *)c->editor;
	ToDo		*t = (ToDo *)c->todo;
	Props		*p = (Props *)c->properties;
	CSA_entry_handle	entry;
	OrderingType	ot = get_int_prop(p, CP_DATEORDERING);
	SeparatorType	st = get_int_prop(p, CP_DATESEPARATOR);
	Tick		tick;
	int		rc;

	if (strcmp(c->calname, c->view->current_calendar) != 0) {
		/*
		 * Make sure user really meant to insert appointment
		 * into somebody elses calendar.
		 */
		char *ident = XtNewString(catgets(c->DT_catd, 1, 923, "Cancel"));
	  	char *title = XtNewString(catgets(c->DT_catd, 1, 212,
				"Calendar : Schedule Appointment"));
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 210, "The appointment will be scheduled in the calendar\nyou are currently browsing.  Do you still want to schedule it?"));
		sprintf(buf2, "%s %s", catgets(c->DT_catd, 1, 211, "Schedule in"),
			c->view->current_calendar);
		answer = dialog_popup(c->frame,
			DIALOG_TITLE, title,
			DIALOG_TEXT, buf,
			BUTTON_IDENT, 1, ident,
			BUTTON_IDENT, 2, buf2,
			NULL);
		XtFree(title);
		XtFree(ident);
		if (answer == 1)
			return 0;
	}

	if (a->end_time) {
        if (!editor_created(e))
	{
                e_make_editor(c);
		XtUnmanageChild(e->base_form_mgr);
		e->editor_is_up = False;
	}
	if ((rc = editor_insert(a, &entry, c)) == True) {

		_csa_iso8601_to_tick(a->time->value->item.string_value, &tick);
		format_tick(tick, ot, st, date_buf);
		sprintf(buf, catgets(c->DT_catd, 1, 214,
				     "Appointment scheduled: %s"), date_buf);
		set_message(c->message_text, buf);
		return 1;
	} else {
		set_message(c->message_text, "");
		if ( rc == 2)
			return 0;
			return -1;
	}
	} else {
	if (!t->frame)
	{
		t_make_todo(c);
		XtUnmanageChild(t->frame);
		t->todo_is_up = False;
	}
	if (todo_insert(a, &entry, c)) {
		/*
		 * No messages displayed on calendar for todo.
		 */
		return 1;
	} else {
		/*
		 * No messages displayed on calendar for todo.
		 */
		return -1;
	}
	}
}