Пример #1
0
void
main(int argc, char **argv)
{
	int		cnt, status = 0;
	char		*date = NULL, *view = NULL, *target = NULL,
			*start = NULL, *end = NULL, *repeat = NULL,
			*numrepeat = NULL, *what = NULL, *uname, *loc;
	Props		*p = NULL;
	CSA_entry_handle	*list;
	CSA_session_handle	c_handle;
	CSA_return_code		stat;
	CSA_calendar_user	csa_user;
	DisplayType		dt;
	int			version;
	char			date_str[256];
#ifdef FNS
	char		buf[256];
#endif

	init_time();
        _DtEnvControl(DT_ENV_SET); /* set up environment variables */
	setlocale(LC_ALL, "");
	DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
	cm_tty_load_props(&p);
	dt = get_int_prop(p, CP_DEFAULTDISP);
#ifdef FNS
	dtfns_init();
#endif

	if (argc > 1)
	{
		cm_args(argc,argv);		/* parse command line */
		if (cm_strlen(cm_target)) 
			target = cm_target;
		else
			target = cm_get_credentials();
#ifdef FNS
		if (cmfns_use_fns(p)) {
			cmfns_lookup_calendar(target, buf, sizeof(buf));
			target = buf;
		}
#endif
		uname = cm_target2name(target);
		loc = cm_target2location(target);

		csa_user.user_name = target;
		csa_user.user_type = 0;
		csa_user.calendar_user_extensions = NULL;
		csa_user.calendar_address = target;
		stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
		if (stat != CSA_SUCCESS) {
		  	char *format = cm_strdup(catgets(DT_catd, 1, 206, 
					   "\nCould not open calendar %s\n"));
			fprintf(stderr, format,
				target ? target : 
				catgets(DT_catd, 1, 209, "UNKNOWN"));
			free(format);
			free(uname);
			free(loc);
			exit(1);
		}
		version = get_data_version(c_handle);
		if (!cm_date[0])
        		format_tick(now(), get_int_prop(p, CP_DATEORDERING),
		    		    get_int_prop(p, CP_DATESEPARATOR), cm_date);
		if (cm_strlen(cm_date)) date = cm_date;
		if (cm_strlen(cm_view)) view = cm_view;
		if (cm_strlen(cm_start)) start = cm_start;

		if (!cm_end[0] && cm_start[0]) {
			format_time((int)cm_getdate(cm_start, NULL) + hrsec,
				    dt, cm_end);
		}

		if (cm_strlen(cm_end)) end = cm_end;
		if (cm_strlen(cm_repeatstr)) repeat = cm_repeatstr;
		if (cm_strlen(cm_for)) numrepeat = cm_for;
		if (cm_strlen(cm_what)) what = cm_what;
		if (!cm_appt_file[0])
			status = cm_tty_insert(DT_catd, c_handle, version, 
				      date, start, end, repeat, numrepeat,
				      what, NULL, p);
		else
			status = cm_tty_insert(DT_catd, c_handle, version, date,
				      start, end, repeat, numrepeat,
				      what, cm_appt_file, p);
	} else {
		prompt_for_insert(p);
		if (cm_strlen(cm_target)) target = cm_target;
		uname = cm_target2name(target);
		loc = cm_target2location(target);

		csa_user.user_name = target;
		csa_user.user_type = 0;
		csa_user.calendar_user_extensions = NULL;
		csa_user.calendar_address = target;
		stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
		if (stat !=CSA_SUCCESS) {
		  	char *format = cm_strdup(catgets(DT_catd, 1, 206, 
					   "\nCould not open calendar %s\n"));
			fprintf(stderr, format, 
				target ? target : 
				catgets(DT_catd, 1, 209, "UNKNOWN"));
			free(format);
			free(uname);
			free(loc);
			exit(1);
		}
		version = get_data_version(c_handle);
		if (cm_strlen(cm_date)) date = cm_date;
		if (cm_strlen(cm_view)) view = cm_view;
		if (cm_strlen(cm_start)) start = cm_start;
		if (cm_strlen(cm_end)) end = cm_end;
		if (cm_strlen(cm_repeatstr)) repeat = cm_repeatstr;
		if (cm_strlen(cm_for)) numrepeat = cm_for;
		if (cm_strlen(cm_what)) what = cm_what;
		status = cm_tty_insert(DT_catd, c_handle, version, date, 
			      start, end, repeat, numrepeat, what, NULL, p);
	}
	if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view, 
					&list, p)) > 0)
		csa_free(list);
	csa_logoff(c_handle, NULL);
	props_clean_up(p);
	free(p);
	free(uname);
	free(loc);
        exit(status);
}
Пример #2
0
int main(int argc, char **argv)
{
	int		cnt;
	char		index[10], *target = NULL, *date = NULL, *view = NULL,
			*uname, *loc;
	Props		*p = NULL;
	CSA_entry_handle	*list;
	CSA_session_handle	c_handle;
	CSA_return_code		stat;
	CSA_calendar_user	csa_user;
	int			version;
#ifdef FNS
	char		buf[256];
#endif

	init_time();
	setlocale(LC_ALL, "");
	_DtEnvControl(DT_ENV_SET); /* set up environment variables */
	DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
	cm_tty_load_props(&p);
	cm_args(argc,argv);		/* parse command line */
	target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();

#ifdef FNS
	dtfns_init();
	if (cmfns_use_fns(p)) {
		cmfns_lookup_calendar(target, buf, sizeof(buf));
		target = buf;
	}
#endif
	if (cm_strlen(cm_date)) date = cm_date;
	if (cm_strlen(cm_view)) view = cm_view;

	uname = cm_target2name(target);
	loc = cm_target2location(target);

	csa_user.user_name = target;
	csa_user.user_type = 0;
	csa_user.calendar_user_extensions = NULL;
	csa_user.calendar_address = target;
	stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);

	if (stat != CSA_SUCCESS) {
	  	char *format = strdup(catgets(DT_catd, 1, 188,
					   "\nCould not open calendar %s\n"));
		fprintf(stderr, format,
			target ? target : catgets(DT_catd, 1, 189, "UNKNOWN"));
		free(format);
		free(uname);
		free(loc);
		exit(1);
	}
	version = get_data_version(c_handle);

	while (!cm_index) {
		if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, 
					view, &list, p)) <= 0) {
			csa_logoff(c_handle, NULL);
			free(uname);
			free(loc);
			exit(0);
		}
		fprintf(stdout, catgets(DT_catd, 1, 190,
				       "Item to delete (number)? "));
		fgets(index, 9, stdin);
		fprintf(stdout,"\n\n");
		if (*index < '0' || *index > '9') {
			csa_free(list);
			break;
		}
		cm_index = atoi(index);
		if (cnt >= cm_index)
			cm_tty_delete(DT_catd, c_handle, version, 
				      cm_index - 1, list);
		memset(index, '\0', 10);
		csa_free(list);
		cm_index = 0;
	}

	csa_logoff(c_handle, NULL);
	props_clean_up(p);
	free(p);
	free(uname);
	free(loc);
	return 0;
}
Пример #3
0
static void
handle_animate_cb(
	Widget		dragContext,
	XtPointer	client_data,
	XtPointer	call_data)
{
        DtDndDropAnimateCallbackStruct *animateInfo = (DtDndDropAnimateCallbackStruct *)call_data;
	Calendar	*c;
	char		*data;
	int		size;
	FILE		*fp;
	int		i;
#if defined(FNS) && defined(FNS_DEMO)
	char		buf[256];
	char		addr_buf[256];
#endif

	c = (Calendar *)client_data;

	for (i = 0; i < animateInfo->dropData->numItems; i++) {
		switch(animateInfo->dropData->protocol) {
		case DtDND_FILENAME_TRANSFER:
			data = animateInfo->dropData->data.files[i];
	
#if defined(FNS) && defined(FNS_DEMO)
			if (cmfns_use_fns(c->properties) &&
			    cmfns_name_from_file(data, buf, sizeof(buf)) == 1) {
				/* 
				 * Looks like an HFS file has been dropped on us.
				 * Get the calendar service associated with the
				 * FNS name and browse it
				 */
				if (cmfns_lookup_calendar(buf,
						addr_buf, sizeof(addr_buf)) == 1) {
					
					switch_it(c, addr_buf, main_win);
					return;
				}
			}
#endif
			drag_load_proc(data, c);
			break;
		case DtDND_BUFFER_TRANSFER:
	
			/*
			 * Save data to a file so we can pass it to drag_load_proc().
			 */

#ifdef NOT
			strcpy(filename, "/tmp/cmXXXXXX");
			mktemp(filename);
#endif

			if (!dnd_filename[0]){
				return;
			}
	
#ifdef NOT
	
			if ((fp = fopen(dnd_filename, "w")) == 0) {
				return;
			}
	
			data = animateInfo->dropData->data.buffers[0].bp;
			size = animateInfo->dropData->data.buffers[0].size;
			fwrite(data, 1, size, fp);
			fclose(fp);
#endif
	
			drag_load_proc(dnd_filename, c);
	
			unlink(dnd_filename);
			dnd_filename[0] = NULL;
			break;
		default:
			return;
		}
	}

	return;
}
Пример #4
0
static void
handle_drop_cb(
	Widget		w,
	XtPointer	client_data,
	XtPointer	call_data)
{
	Display		*display = XtDisplay(w);
	DtDndDropCallbackStruct *transfer_info = (DtDndDropCallbackStruct *)call_data;
	Calendar	*c;
	char		filename[20];
	char		*data;
	int		size;
	FILE		*fp;
	int		i;
#if defined(FNS) && defined(FNS_DEMO)
	char		buf[256];
	char		addr_buf[256];
#endif

	c = (Calendar *)client_data;

	transfer_info->status = DtDND_SUCCESS;

	for (i = 0; i < transfer_info->dropData->numItems; i++) {
		switch(transfer_info->dropData->protocol) {
		case DtDND_FILENAME_TRANSFER:
			data = transfer_info->dropData->data.files[i];
	
#if defined(FNS) && defined(FNS_DEMO)
			if (cmfns_use_fns(c->properties) &&
			    cmfns_name_from_file(data, buf, sizeof(buf)) == 1) {
				/* 
				 * Looks like an HFS file has been dropped on us.
				 * Get the calendar service associated with the
				 * FNS name and browse it
				 */
				if (cmfns_lookup_calendar(buf,
						addr_buf, sizeof(addr_buf)) == 1) {
					
					switch_it(c, addr_buf, main_win);
					return;
				}
			}
#endif
	
			if (validate_dropped_appt(data, c) == False) {
				transfer_info->status = DtDND_FAILURE;
			}
			break;
		case DtDND_BUFFER_TRANSFER:
	
			/*
			 * Save data to a file so we can pass it to drag_load_proc().
			 */
			strcpy(dnd_filename, "/tmp/cmXXXXXX");
			mktemp(dnd_filename);
	
			if ((fp = fopen(dnd_filename, "w")) == 0) {
				transfer_info->status = DtDND_FAILURE;
				return;
			}
	
			data = transfer_info->dropData->data.buffers[0].bp;
			size = transfer_info->dropData->data.buffers[0].size;
			fwrite(data, 1, size, fp);
			fclose(fp);
	
			if (validate_dropped_appt(dnd_filename, c) == False) {
				unlink(dnd_filename);
				dnd_filename[0] = NULL;	
				transfer_info->status = DtDND_FAILURE;
			}
#ifdef NOT
			unlink(filename);
#endif
			break;
		default:
			transfer_info->status = DtDND_FAILURE;
			return;
		}
	}

	return;
}
Пример #5
0
int main(int argc, char **argv)
{
	int		cnt;
	char		*target = NULL, *date = NULL, *view = NULL,
			*uname, *loc;
	Props		*p = NULL;
	CSA_session_handle	c_handle;
	CSA_entry_handle	*list;
	CSA_return_code		stat;
	CSA_calendar_user	csa_user;
	int			version;
#ifdef FNS
	char		buf[256];
#endif

	init_time();
	_DtEnvControl(DT_ENV_SET); /* set up environment variables */
	setlocale(LC_ALL, "");
	DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
	cm_tty_load_props(&p);
	cm_args(argc,argv);		/* parse command line */

	target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();
#ifdef FNS
	dtfns_init();
	if (cmfns_use_fns(p)) {
		cmfns_lookup_calendar(target, buf, sizeof(buf));
		target = buf;
	}
#endif
	uname = cm_target2name(target);
	loc = cm_target2location(target);

	csa_user.user_name = target;
	csa_user.user_type = 0;
	csa_user.calendar_user_extensions = NULL;
	csa_user.calendar_address = target;
	stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);

	if (stat != CSA_SUCCESS) {
		char *format = cm_strdup(catgets(DT_catd, 1, 208, 
				   "\nCould not open calendar \"%s\"\n"));
		fprintf(stderr, format, 
			target ? target : catgets(DT_catd, 1, 209, "UNKNOWN"));
		free(format);
		free(uname);
		free(loc);
		exit(1);
	}
	version = get_data_version(c_handle);
	if (cm_strlen(cm_date)) date = cm_date;
	if (cm_strlen(cm_view)) view = cm_view;

	if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view, 
				 &list, p)) > 0)
		csa_free(list);
	csa_logoff(c_handle, NULL);
	props_clean_up(p);
	free(p);
	free(uname);
	free(loc);
	return 0;
}