示例#1
0
/*
**  The next two functions will take appointment values and stuff them into
**  a form.
*/
extern Boolean
dssw_appt_to_form(DSSW *dssw, CSA_entry_handle entry) {
	Boolean			ret_val;
	CSA_return_code		stat;
	Dtcm_appointment	*appt;

	appt = allocate_appt_struct(appt_read,
				    dssw->cal->general->version,
				    CSA_ENTRY_ATTR_START_DATE_I,
				    CSA_ENTRY_ATTR_SUMMARY_I,
				    CSA_ENTRY_ATTR_END_DATE_I,
				    CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
				    NULL);
	stat = query_appt_struct(dssw->cal->cal_handle, entry, appt);
	backend_err_msg(dssw->cal->frame, dssw->cal->view->current_calendar,
		stat, ((Props_pu *)dssw->cal->properties_pu)->xm_error_pixmap);
	if (stat != CSA_SUCCESS) {
		free_appt_struct(&appt);
		return False;
	}

	ret_val = dssw_attrs_to_form(dssw, appt);
	free_appt_struct(&appt);

	return ret_val;
}
示例#2
0
文件: weekglance.c 项目: juddy/edcde
extern int
count_multi_appts(CSA_entry_handle *list, int num_entries, Calendar *c)
{
    CSA_return_code stat;
    Dtcm_appointment *appt;
    int count = 0, i, meoval;
    Props *pr = (Props*)c->properties;
    Lines *lines, *l_ptr;

    meoval = get_int_prop(pr, CP_PRINTPRIVACY);

    appt = allocate_appt_struct(appt_read,
                                c->general->version,
                                CSA_ENTRY_ATTR_CLASSIFICATION_I,
                                CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
                                CSA_ENTRY_ATTR_SUMMARY_I,
                                NULL);
    for (i = 0; i < num_entries; i++) {

        stat = query_appt_struct(c->cal_handle, list[i], appt);

        if (stat != CSA_SUCCESS) {
            free_appt_struct(&appt);
            return 0;
        }

        if ((privacy_set(appt) == CSA_CLASS_PUBLIC) && !(meoval & PRINT_PUBLIC))
            continue;
        else if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
                 !(meoval & PRINT_SEMIPRIVATE))
            continue;
        else if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
                 !(meoval & PRINT_PRIVATE))
            continue;

        if (showtime_set(appt)) {
            count++;
        }
        l_ptr = lines = text_to_lines(appt->what->value->item.string_value, 10);
        while (lines != NULL) {
            count++;
            lines = lines->next;
        }
        destroy_lines(l_ptr);
    }
    free_appt_struct(&appt);
    return(count);
}
示例#3
0
static Boolean 
validate_dropped_appt(char *filename, Calendar *c) {
	Props			*p = (Props *)c->properties;
	Props_pu		*pu = (Props_pu *)c->properties_pu;
	CmDataList		*list = CmDataListCreate();
	Validate_op		op;
	int			i;
	Dtcm_appointment	*a;

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

	op = parse_appt_from_file(c->DT_catd, filename, list, p, query_user, 
				  (void *)c, c->general->version);

	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)
		return(True);
	else
		return(False);

}
示例#4
0
文件: alarm.c 项目: juddy/edcde
/*
**  Functions to build and popup the postup reminder
*/
extern void
postup_show_proc(Calendar *c, CSA_reminder_reference *r) {
        int			start_hr, stop_hr;
	char			text[BUFSIZ];
	time_t			st, sp = 0;
	Lines			*lines, *l = NULL;
	Props			*p = (Props *)c->properties;
	Widget			pu_frame, pu_base_form, 
				pu_text_form, separator, 
				pu_form, button_form, pu_date,
				pu_range, pu_image, pu_close, line, last_line;
	Boolean			start_am, stop_am;
	XmString		xmstr;
	CSA_return_code		stat;
	DisplayType		dis_t = get_int_prop(p, CP_DEFAULTDISP);
	OrderingType		ord_t = get_int_prop(p, CP_DATEORDERING);
	SeparatorType		sep_t = get_int_prop(p, CP_DATESEPARATOR);
	Dtcm_appointment	*appt;
	char			*title;

	if (!c->postup)
		c->postup = XtAppCreateShell("calendar_postup", "Dtcm",
			xmDialogShellWidgetClass, c->xcontext->display,
			NULL, 0);

	/*
	**  Create the Motif objects
	*/
	title = XtNewString(catgets(c->DT_catd, 1, 839, "Calendar : Reminder"));
	pu_frame = XtVaCreatePopupShell("pu_frame",
		topLevelShellWidgetClass, c->postup,
		XmNtitle, title,
		XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_CLOSE,
		XmNdeleteResponse,      XmDESTROY,
		NULL);
	XtFree(title);

	pu_base_form = XtVaCreateWidget("pu_base_form",
		xmFormWidgetClass, pu_frame,
		NULL);

	pu_text_form = XtVaCreateWidget("pu_test_form",
		xmFormWidgetClass, pu_base_form,
		XmNtopAttachment, XmATTACH_FORM,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		XmNleftOffset, 1,
		XmNrightOffset, 1,
		XmNtopOffset, 1,
		NULL);

	pu_image = XtVaCreateWidget("pu_image",
		xmLabelGadgetClass, pu_text_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		XmNtopOffset, 5,
		XmNlabelType, XmPIXMAP,
		XmNlabelPixmap, ((Props_pu *)c->properties_pu)->postup_pixmap,
		NULL);

	button_form = XtVaCreateWidget("pu_form",
		xmFormWidgetClass, pu_base_form,
		XmNbottomAttachment, XmATTACH_FORM,
		XmNbottomOffset, 2,
		XmNleftOffset, 1,
		XmNrightOffset, 1,
		XmNleftAttachment, XmATTACH_FORM,
		XmNrightAttachment, XmATTACH_FORM,
		XmNfractionBase, 3,
		NULL);

	xmstr = XmStringCreateLocalized(catgets(c->DT_catd, 1, 680, "Close"));
	pu_close = XtVaCreateManagedWidget("close", 
		xmPushButtonWidgetClass, button_form, 
                XmNtopAttachment, 	XmATTACH_FORM,
		XmNbottomAttachment, 	XmATTACH_FORM,
		XmNleftAttachment, 	XmATTACH_POSITION,
		XmNrightAttachment, 	XmATTACH_POSITION,
		XmNleftPosition,	1,
		XmNrightPosition,	2,
		XmNbottomOffset, 	1,
                XmNlabelString, 	xmstr,
                NULL);
	XmStringFree(xmstr);

	separator = XtVaCreateWidget("separator",
                xmSeparatorGadgetClass,
                pu_base_form,
                XmNleftAttachment,      XmATTACH_FORM,
                XmNrightAttachment,     XmATTACH_FORM,
                XmNbottomAttachment,   	XmATTACH_WIDGET,
                XmNbottomWidget,        button_form,
		XmNtopAttachment, XmATTACH_WIDGET,
		XmNtopWidget, pu_text_form,
		XmNtopOffset, 1,
                NULL);


	pu_form = XtVaCreateWidget("pu_form",
		xmFormWidgetClass, pu_text_form,
		XmNtopAttachment, XmATTACH_FORM,
		XmNtopOffset, 1,
		XmNleftAttachment, XmATTACH_WIDGET,
		XmNleftWidget, pu_image,
		XmNverticalSpacing, 10,
		NULL);

	pu_date = XtVaCreateWidget("pu_date",
		xmLabelGadgetClass, pu_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		NULL);

	pu_range = XtVaCreateWidget("pu_range",
		xmLabelGadgetClass, pu_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_WIDGET,
		XmNtopWidget, pu_date,
		XmNtopOffset, 8,
		NULL);

	XtAddCallback(pu_close, XmNactivateCallback, close_cb, pu_frame);

	appt = allocate_appt_struct(appt_read,
				    c->general->version,
				    CSA_ENTRY_ATTR_START_DATE_I,
				    CSA_ENTRY_ATTR_END_DATE_I,
				    CSA_ENTRY_ATTR_SUMMARY_I,
				    CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
				    NULL);
	stat = query_appt_struct(c->cal_handle, r->entry, appt);
	backend_err_msg(c->frame, c->calname, stat,
			((Props_pu *)c->properties_pu)->xm_error_pixmap);
	if (stat != CSA_SUCCESS) {
		free_appt_struct(&appt);
		return;
	}

	_csa_iso8601_to_tick(appt->time->value->item.date_time_value, &st);
	if (appt->end_time)
		_csa_iso8601_to_tick(appt->end_time->value->\
			item.date_time_value, &sp);
	l = lines = text_to_lines(appt->what->value->item.string_value, 5);
	last_line = 0;
	while (l) {
		xmstr = XmStringCreateLocalized(l->s);
		line = XtVaCreateWidget("text_line",
			xmLabelGadgetClass, pu_text_form,
			XmNlabelString, xmstr,
			XmNleftAttachment, XmATTACH_WIDGET,
			XmNleftWidget, pu_form,
			XmNleftOffset, 15,
			NULL);
		XmStringFree(xmstr);

		if (last_line)
			XtVaSetValues(line, 
				XmNtopAttachment, XmATTACH_WIDGET,
				XmNtopWidget, last_line,
				XmNtopOffset, 8,
				NULL);
		else
			XtVaSetValues(line, 
				XmNtopAttachment, XmATTACH_FORM,
				XmNtopOffset, 8,
				NULL);

		last_line = line;
		l = l->next;
	}
	if (lines)
		destroy_lines(lines);

	/*
	**  Now fill in the correct information
	*/
	set_date_in_widget(st, pu_date, ord_t, sep_t);

        if (!showtime_set(appt) || magic_time(st)) 
                text[0] = '\0';
	else {
		start_hr = hour(st);
		if (sp) stop_hr = hour(sp);
		if (dis_t == HOUR12) {
			start_am = adjust_hour(&start_hr);
			if (sp) {
				/* NL_COMMENT

				   Message 1087 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  In the C locale it would
				   look something like this:

				   ``From 11:00am to 1:00pm''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> am or pm
					$4	-> stop hour
					$5	-> stop minute
					$6	-> am or pm

				*/
			        char *am = XtNewString(catgets(c->DT_catd, 
							       1, 4, "am"));
			        char *pm = XtNewString(catgets(c->DT_catd, 
							       1, 3, "pm"));
				stop_am = adjust_hour(&stop_hr);
				sprintf(text, catgets(c->DT_catd, 1, 1087,
				   "From %1$2d:%2$02d%3$s to %4$2d:%5$02d%6$s"),
					start_hr, minute(st),
					(start_am) ? am : pm,
					stop_hr, minute(sp),
					(stop_am) ? am : pm
					);
				XtFree(am);
				XtFree(pm);
			} else {
				/* NL_COMMENT

				   Message 1088 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  It is used when an appt
				   does not have and ``end'' time.  In the 
				   C locale it would look something like this:

				   ``11:00am''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> am or pm

				*/
			        char *meridian = 
				  XtNewString ((start_am) ? 
					       catgets(c->DT_catd, 1, 4, "am"):
					       catgets(c->DT_catd, 1, 3, "pm"));
				
				sprintf(text, catgets(c->DT_catd, 1, 1088,
				   			"%1$2d:%2$02d%3$s"), 
					start_hr, minute(st), meridian
					);
				XtFree(meridian);
			}
		} else {
			if (sp) {
				/* NL_COMMENT

				   Message 1089 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  This string is used when
				   a user has asked that times be displayed
				   in 24 hour format.  In the C locale it 
				   would look something like this:

				   ``From 0100 to 1600''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> stop hour
					$4	-> stop minute

				*/
				sprintf(text, catgets(c->DT_catd, 1, 1089,
				   "From %1$02d%2$02d to %3$02d%4$02d"),
					start_hr, minute(st), stop_hr, 
					minute(sp));
			} else {
				/* NL_COMMENT

				   Message 1090 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  This string is used when
				   an appt does not have an end time and the
				   user has asked that times be displayed
				   in 24 hour format.  In the C locale it 
				   would look something like this:

				   ``1600''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute

				*/
				sprintf(text, catgets(c->DT_catd, 1, 1090,
							"%1$02d%2$02d"), 
					start_hr, minute(st));
			}
		}
	}

	free_appt_struct(&appt);
	xmstr = XmStringCreateLocalized(text);
	XtVaSetValues(pu_range, XmNlabelString, xmstr,
		NULL);
	XmStringFree(xmstr);

	ManageChildren(pu_form);
	ManageChildren(pu_base_form);
	ManageChildren(pu_text_form);
	XtManageChild(pu_base_form);
	XtVaSetValues(button_form, XmNdefaultButton, pu_close, NULL);
        XtVaSetValues(button_form, XmNcancelButton, pu_close, NULL);
	XtPopup(pu_frame, XtGrabNone);
	DtWsmOccupyAllWorkspaces(c->xcontext->display, XtWindow(pu_frame));
}
示例#5
0
文件: alarm.c 项目: juddy/edcde
extern void 
mail_it(XtPointer client_data, XtIntervalId *interval_id, CSA_reminder_reference *r) {
	Calendar		*c = (Calendar *)client_data;
	int			hr;
	Lines			*lines = NULL, *l = NULL;
	Props			*p = (Props *)c->properties;
	Boolean			pm;
	DisplayType		dt = get_int_prop(p, CP_DEFAULTDISP);
	Dtcm_appointment	*appt;
	char			subbuf[BUFSIZ], bodybuf[BUFSIZ];
	char			datebuf[200], startbuf[100], stopbuf[100];
	char			whatbuf[BUFSIZ];
	char			*to;
	CSA_return_code		stat;
	Tick			start, stop;
	char			*addr_data = NULL;

	appt = allocate_appt_struct(appt_read,
				    c->general->version,
				    CSA_ENTRY_ATTR_START_DATE_I,
				    CSA_ENTRY_ATTR_SUMMARY_I,
				    CSA_ENTRY_ATTR_ORGANIZER_I,
				    CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
				    CSA_ENTRY_ATTR_END_DATE_I,
				    CSA_ENTRY_ATTR_MAIL_REMINDER_I,
				    NULL);

	stat = query_appt_struct(c->cal_handle, r->entry, appt);

	backend_err_msg(c->frame, c->calname, stat,
			((Props_pu *)c->properties_pu)->xm_error_pixmap);
	if (stat != CSA_SUCCESS) {
		free_appt_struct(&appt);
		return;
	}

	/* compose to field */
	if (appt->mail->value->item.reminder_value->reminder_data.data == NULL ||
	    (appt->mail->value->item.reminder_value->reminder_data.size == 0)) {
		/* empty recipient */
		if (debug)
			fprintf(stderr, "%s", catgets(c->DT_catd, 1, 1,
				"dtcm: empty recipient in mail reminder\n"));
		to = appt->author->value->item.calendar_user_value->user_name;
	} else {
		addr_data = calloc(appt->mail->value->item.reminder_value->reminder_data.size + 1, 1);
		strncpy(addr_data, (char *) appt->mail->value->item.reminder_value->reminder_data.data, appt->mail->value->item.reminder_value->reminder_data.size);
		to = addr_data;
	}

	/* compose subject field */
	lines = text_to_lines(appt->what->value->item.string_value, 5);
	sprintf(subbuf, catgets(c->DT_catd, 1, 2, "Reminder- %s"),
		(lines) ? lines->s : "\0");

	/* compose message body */
	_csa_iso8601_to_tick(appt->time->value->item.date_time_value, &start);
	format_tick(start, ORDER_MDY, SEPARATOR_SLASH, datebuf);

	if (showtime_set(appt) && !magic_time(start)) {
		hr = hour(start);
		pm = (dt == HOUR12 && !adjust_hour(&hr)) ? True : False;
		if (dt == HOUR12) {
			sprintf(startbuf, "%2d:%02d %s", hr, minute(start),
				pm ? "pm" :
				"am");
		} else {
			sprintf(startbuf, "%02d%02d", hr, minute(start));
		}
	} else
		startbuf[0] = '\0';

	if (showtime_set(appt) && !magic_time(start) && appt->end_time) {
		_csa_iso8601_to_tick(appt->end_time->value->\
			item.date_time_value, &stop);
		hr = hour(stop);
		pm = (dt == HOUR12 && !adjust_hour(&hr)) ? True : False;
		if (dt == HOUR12) {
			sprintf(stopbuf, "%2d:%02d %s", hr, minute(stop),
				pm ? catgets(c->DT_catd, 1, 3, "pm") :
				catgets(c->DT_catd, 1, 4, "am"));
		} else {
			sprintf(stopbuf, "%02d%02d", hr, minute(stop));
		}
	} else
		stopbuf[0] = '\0';

	if (l = lines) {
		sprintf(whatbuf, "%s\n", l->s);
		l = l->next;
	} else
		whatbuf[0] = '\0';

	while(l != NULL) {
		strcat(whatbuf, "\t\t");
		strcat(whatbuf, l->s);
		strcat(whatbuf, "\n");
		l = l->next;
	}
	if (lines)
		destroy_lines(lines);

	if (stopbuf[0] != '\0') {
		sprintf(bodybuf, catgets(c->DT_catd, 1, 7, "\n\n\t** Calendar Appointment **\n\n\tDate:\t%s\n\tStart:\t%s\n\tEnd:\t%s\n\tWhat:\t%s"),
			datebuf, startbuf, stopbuf, whatbuf);
	} else {
		sprintf(bodybuf, catgets(c->DT_catd, 1, 1100, "\n\n\t** Calendar To Do Item **\n\n\tDue Date:\t%s\n\tTime Due:\t%s\n\tWhat:\t\t%s"),
			datebuf, startbuf, whatbuf);
	}

	if (debug) {
		fprintf(stderr, "to = `%s`\n", to);
		fprintf(stderr, "subject = `%s`\n", subbuf);
		fprintf(stderr, "body = `%s`\n", bodybuf);
	}

	(void)submit_mail(to, subbuf, bodybuf);

	free_appt_struct(&appt);

	if (addr_data)
		free(addr_data);
}
示例#6
0
void
ApptDragStart(
        Widget          widget,
        XEvent          *event,
        Calendar        *calendar,
        EditorType      editor_type)
{
        static XtCallbackRec convertCBRec[] = { {ApptConvertCB, NULL},
                                                {NULL, NULL} };
        static XtCallbackRec dragFinishCBRec[] =  { {DragFinishCB, NULL},
                                                    {NULL, NULL} };
 
        Display        *display 	= XtDisplay(widget);
        DragContext     *context = calloc(sizeof(DragContext), 1);
	Editor		*e = (Editor *) calendar->editor;
	GEditor		*ge = (GEditor *) calendar->geditor;
	ToDo		*t = (ToDo *) calendar->todo;
	Dtcm_appointment        *appt;
	char		*apptstr;
	int		preDsswFlags, preRfpFlags;
 
        context->calendar = calendar;
        context->editor_type = editor_type;
 
        if (editor_type == SingleEditorIcon)
	{
                context->editor = (caddr_t) e;
		appt = allocate_appt_struct(appt_write, DATAVER_ARCHIVE, NULL);
		load_appt_defaults(appt, (Props *) calendar->properties);
		preDsswFlags = e->dsswFlags;
		preRfpFlags = e->rfpFlags;
		if (!dssw_form_flags_to_appt(&e->dssw, appt,
					     calendar->calname,
					     now(), &e->dsswFlags) ||
		    !rfp_form_flags_to_appt(&e->rfp, appt,
					    calendar->calname,
					    &e->rfpFlags) ||
		    (preDsswFlags != e->dsswFlags) ||
		    (preRfpFlags != e->rfpFlags))
		{
		  e->doing_drag = False;
		  free_appt_struct(&appt);
		  free(context);
		  return;
		}
	}
        else if (editor_type == GroupEditorIcon)
	{
                context->editor = (caddr_t) ge;
		appt = allocate_appt_struct(appt_write, DATAVER_ARCHIVE, NULL);
		load_appt_defaults(appt, (Props *) calendar->properties);
		preDsswFlags = ge->dsswFlags;
		preRfpFlags = ge->rfpFlags;
		if (!dssw_form_flags_to_appt(&ge->dssw, appt,
					     calendar->calname,
					     now(), &ge->dsswFlags) ||
		    !rfp_form_flags_to_appt(&ge->rfp, appt,
					    calendar->calname,
					    &ge->rfpFlags) ||
		    (preDsswFlags != ge->dsswFlags) ||
		    (preRfpFlags != ge->rfpFlags))
		{
		  ge->doing_drag = False;
		  free_appt_struct(&appt);
		  free(context);
		  return;
		}
	}
        else if (editor_type == TodoEditorIcon)
	{
                context->editor = (caddr_t) t;
		if (t->cal->general->version < DATAVER4)
		  appt = allocate_appt_struct(appt_write, DATAVER_ARCHIVE, 
			      CSA_ENTRY_ATTR_REFERENCE_IDENTIFIER_I,
			      CSA_ENTRY_ATTR_LAST_UPDATE_I,
			      CSA_ENTRY_ATTR_ORGANIZER_I,
			      CSA_ENTRY_ATTR_START_DATE_I,
			      CSA_ENTRY_ATTR_TYPE_I,
			      CSA_ENTRY_ATTR_CLASSIFICATION_I,
			      CSA_ENTRY_ATTR_END_DATE_I,
			      CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
			      CSA_ENTRY_ATTR_SUMMARY_I,
			      CSA_ENTRY_ATTR_STATUS_I,
			      CSA_X_DT_ENTRY_ATTR_REPEAT_TYPE_I,
			      CSA_X_DT_ENTRY_ATTR_REPEAT_TIMES_I,
			      CSA_X_DT_ENTRY_ATTR_REPEAT_INTERVAL_I,
			      CSA_X_DT_ENTRY_ATTR_REPEAT_OCCURRENCE_NUM_I,
			      CSA_ENTRY_ATTR_AUDIO_REMINDER_I,
			      CSA_ENTRY_ATTR_FLASHING_REMINDER_I,
			      CSA_ENTRY_ATTR_MAIL_REMINDER_I,
			      CSA_ENTRY_ATTR_POPUP_REMINDER_I,
			      NULL);
		else
		  appt = allocate_appt_struct(appt_write,
					      DATAVER_ARCHIVE, NULL); 

		dssw_form_to_todo(&t->dssw, appt, calendar->calname, now());
		preRfpFlags = t->rfpFlags;
		if (!rfp_form_flags_to_appt(&t->rfp, appt,
					    calendar->calname,
					    &t->rfpFlags) ||
		    (preRfpFlags != t->rfpFlags))
		{
		  t->doing_drag = False;
		  free_appt_struct(&appt);
		  free(context);
		  return;
		}
		appt->type->value->item.sint32_value = CSA_TYPE_TODO;
		appt->show_time->value->item.sint32_value = True;
		t->completed_val = 
		  XmToggleButtonGadgetGetState(t->completed_toggle);
		appt->state->value->item.sint32_value = 
		  (t->completed_val) ? 
		    CSA_STATUS_COMPLETED : CSA_X_DT_STATUS_ACTIVE;
	}
	else
	{
	  free(context);
	  return;
	}
	apptstr = parse_attrs_to_string(appt, (Props *)calendar->properties, 
					attrs_to_string(appt->attrs,
							appt->count));
	free_appt_struct(&appt);

	context->data = apptstr;

        GetIcon(calendar);
 
        convertCBRec[0].closure = (XtPointer)context;
        dragFinishCBRec[0].closure = (XtPointer)context;
 
        if (e->drag_icon == NULL) {
                e->drag_icon = CreateDragSourceIcon(widget, e->drag_bitmap,
						    e->drag_mask);
        }
 
        if (DtDndVaDragStart(widget, event, DtDND_BUFFER_TRANSFER, 1,
            	XmDROP_COPY, 
		convertCBRec, dragFinishCBRec,
		DtNsourceIcon,		e->drag_icon,
		NULL)
            == NULL) {
 
                printf(catgets(calendar->DT_catd, 1, 239,
			       "DragStart returned NULL.\n"));
        }
}
示例#7
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;
}