⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 link.c

📁 个人日程管理系统
💻 C
字号:
/* -*-Mode:C; tab-width:4; indent-tabs-mode:t; c-file-style:"stroustrup";-*- */// $Id: link.c,v 1.23 2003/11/04 02:15:42 rick_price Exp $#include "MemoDB.h"#include "xb.h"#include "AddressDB.h"#include "MemoMain.h"#include "link.h"#include "task.h"#include "flat.h"#include "progect.h"#include "progectdb.h"#include "progectRsc.h"/*************************************************************************** ** LinkMaster support functions  **************************************************************************/// TODO://   1.Multiple link///**************************************************************************** * Name : CheckLinkMaster * Desc : Check to LinkMaster is available * Parm :  * Out  : true if available, otherwise false. * Auth : seagull, 22.09.2000 JST ***************************************************************************/static Boolean CheckLinkMaster(void){	if (! LinkCheck())	{		MessageBox(StrLinkMasterIsNotAvailable);		return false;	}	return true;} // static Boolean CheckLinkMaster(void)/**************************************************************************** * Name : PublishToLinkMaster * Desc : Publish bookbark to LinkMaster * Parm :  * 			-> database pointer * 			-> index of the task * Out  :  * Auth : seagull, 22.09.2000 JST ***************************************************************************/void PublishToLinkMaster(DmOpenRef dbP, UInt16 index){	if (CheckLinkMaster())	{		Char* desc = TaskGetDescription(dbP, index);		LinkSimpleType* p = LinkSimpleNew(dbP, index, desc);		MemPtrFree(desc);		// NOTE: LinkSimpleNew need index. that gots unique id from index.		LinkPublish((LinkInfoPtr)p);	}} // void PublishToLinkMaster(DmOpenPref dpP, UInt16 index)/**************************************************************************** * Name : RequestLinkViaLinkMaster * Desc : Request link info * Parm :  * 			-> database pointer * 			-> index of the task * Out  :  * Auth : seagull, 22.09.2000 JST ***************************************************************************/void RequestLinkViaLinkMaster(Char const* dbName, UInt16 index){	if (CheckLinkMaster())	{		LinkSimplePtr info = MemPtrNew(sizeof(LinkSimpleType));		info->creator = CREATOR;		DmRecordInfo(gdbP, index, NULL, &info->record_id, NULL);		SafeCopy(info->db_name, dbName,dmDBNameLength);		LinkRequest((LinkInfoPtr)info);	}} // void RequestLinkViaLinkMaster(Char const* dbName, UInt16 index)/**************************************************************************** * Name : SetLinkMasterLink * Desc : Store link info into record. * Parm :  * 			-> LinkInfo of this task * 			-> LinkInfo of target info. * Out  :  * Auth : seagull, 22.09.2000 JST * Mod  : lb, 26.09.2000 * 			- use of task functions to modify format of task ***************************************************************************/void SetLinkMasterLink(LinkSimplePtr p1, LinkInfoPtr p2){	UInt16 index;	TaskFormatType format;	DmFindRecordByID(gdbP, p1->record_id, &index);	// NOTE: currently the subkey is must be zero.	TaskSetExtraChunk(gdbP, index, Extra_Link_LinkMaster, 0,					  p2, sizeof(LinkInfoType));	// Turn ON hasLink bit.	// same using task functions	format = TaskGetFormat(gdbP, index);	format.hasLink = true;	TaskSetFormat(gdbP, index, format);} // void SetLinkMasterLink(LinkSimplePtr p1, LinkInfoPtr p2)/**************************************************************************** * Name : FollowLinkViaLinkMaster * Desc : fllow link master link * Parm :  * 			-> database name * 			-> uniq index * Out  :  * Auth : seagull, 22.09.2000 JST ***************************************************************************/void FollowLinkViaLinkMaster(UInt16 index){	LinkInfoType info;	UInt16 size = sizeof(info);	if (TaskGetExtraChunk(gdbP, index, Extra_Link_LinkMaster, 0x00,						  &info, &size) == pgOK && 		size == sizeof(info))	{		LinkFollow(&info);	}} // void FollowLinkViaLinkMaster(Char dbname, UInt16 index)/**************************************************************************** * Name : RemoveLinkViaLinkMaster * Desc : remove link info * Parm :  * 			-> uniq index * Out  :  * Auth : seagull, 22.09.2000 JST * mod  : lb, 2001-12-03 * 		fix bug causing crash when removing XB in 0.23 * 		was due to format being modified in TaskRemoveXC and reset after it ***************************************************************************/void RemoveLinkViaLinkMaster(UInt16 index){	TaskFormatType format = TaskGetFormat(gdbP, index);	if (format.hasLink)	{		TaskRemoveExtraChunk(gdbP, index, Extra_Link_LinkMaster, 0);		// Turn OFF hasLink bit (reget format, because TaskRemoveExtraChunk		// can change it !!!)		format = TaskGetFormat(gdbP, index);		format.hasLink = false;		TaskSetFormat(gdbP, index, format);	}} // void RemoveLinkViaLinkMaster(UInt16 index)/**************************************************************************** * Name : ExportToMemo * Desc : export a project to MemoPad files * In   : database * Auth : lb, 21.09.2000 ***************************************************************************/pgErr ExportToMemo(DmOpenRef dbP, MemoExportOptionsType options){	#define predesc 100	Char *buffer; // to store the text to export	MemoItemType memo;	UInt16 cnt = 0, i;	UInt16 numRec = PgNumRecords(dbP), offset = 0;	UInt16 index = numRec, tab, level;	Err err;	DmOpenRef memoDB;	UInt16 memoNb = 1;	buffer = MemPtrNew(memoMaxLength);	SafeCopy(buffer, &gCurrentPrefs.openDBName[5],memoMaxLength);	offset = StrLen(&gCurrentPrefs.openDBName[5]);	buffer[offset++] = (Char)chrLineFeed;	cnt = offset;	// for each record	for (i = 1; i < numRec; i++)	{		Char* desc;		// skip it if it's done and we don't want done tasks		if (!options.exportDone && 			(TaskGetCompleted(dbP, i) == 10))		{			continue;		}		// skip it if it's not a terminal and we just want terminals		if (options.exportFlat && !FlatFilter(dbP, i))		{			continue;		}		level = TaskGetLevel(dbP, i) - 1;		desc = TaskGetDescription(dbP, i);		cnt += StrLen(desc) + level;		// control the length		if (cnt >= memoMaxLength - predesc)		{			// begin new memo			buffer[offset] = '\0';			// memorize it			err = MemoGetDatabase (&memoDB, dmModeReadWrite);			if (err)			{				DEBUG1("Can't open memo database");				return pgError;			}			memo.note = buffer;			err = MemoNewRecord (memoDB, &memo, &index);			if (err)			{				DEBUG1("Can't create a new memo");				return pgError;			}			DmCloseDatabase(memoDB);			// reinit buffer			SafeCopy(buffer, &gCurrentPrefs.openDBName[5],memoMaxLength);			offset = StrLen(&gCurrentPrefs.openDBName[5]);			buffer[offset++] = ' ';			buffer[offset++] = '(';			StrIToA(gDebugVal, ++memoNb);			SafeCopy(&buffer[offset], gDebugVal,memoMaxLength-offset);			offset += StrLen(gDebugVal);			buffer[offset++] = ')';			buffer[offset++] = (Char)chrLineFeed;			cnt = offset;		}		// indent if not flat view		if (!options.exportFlat)		{			for (tab = 1; tab <= level; tab++)			{				buffer[offset++] = chrHorizontalTabulation;			}		}		// export progress		if (options.exportProgress)		{			UInt8 progress = TaskGetCompleted(dbP, i);			ItemType type = TaskGetType(dbP, i);			if (type == actionType)			{				if (progress == ACTION_DONE)				{					SafeCopy(&buffer[offset], "[x] ",memoMaxLength-offset);				}				else				{					SafeCopy(&buffer[offset], "[ ] ",memoMaxLength-offset);				}				offset += 4;			}			else			{				buffer[offset++] = '[';				StrIToA(gDebugVal, progress * 10);				SafeCopy(&buffer[offset], gDebugVal,memoMaxLength-offset);				offset += StrLen(gDebugVal);				buffer[offset++] = '%';				buffer[offset++] = ']';				buffer[offset++] = ' ';			}		}		// export priority		if (options.exportPriority)		{			UInt8 priority = TaskGetPriority(dbP, i);			if (priority > 0 && priority < 6)			{				buffer[offset++] = '[';				buffer[offset++] = priority + '0';				buffer[offset++] = ']';				buffer[offset++] = ' ';			}		}		// export due date		if (options.exportDueDate)		{			DateType date = TaskGetDueDate(dbP, i);			if (date.month != 0)			{				DateToAscii(date.month, date.day, 					date.year + YEAR_OFFSET, gDateFormat, gDebugVal);				buffer[offset++] = '(';				SafeCopy(&buffer[offset], gDebugVal,memoMaxLength-offset);				offset += StrLen(&buffer[offset]);				buffer[offset++] = ')';				buffer[offset++] = ' ';							}		}		// copy the description		SafeCopy(&buffer[offset], desc,memoMaxLength-offset);		MemPtrFree(desc);		offset += StrLen(&buffer[offset]);		// new line		buffer[offset] = (Char)chrLineFeed;		offset++;		cnt = offset;	}	buffer[offset] = '\0';	// memorize it	err = MemoGetDatabase (&memoDB, dmModeReadWrite);	if (err)	{		DEBUG1("Can't open memo database");		return pgError;	}	memo.note = buffer;	MemoNewRecord (memoDB, &memo, &index);	DmCloseDatabase(memoDB);	MemPtrFree(buffer);		return pgOK;} // pgErr ExportToMemo(DmOpenRef dbP, MemoExportOptionsType options)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -