Esempio n. 1
0
void EditStatus_AddEntry(struct Box_s *pbox, char *name, BOOL away)
{
	struct editstatusdata_s *data = pbox->boxdata;
	struct Box_s *entry, *subbox;
	struct editstatusentrydata_s *entrydata = malloc(sizeof(*entrydata));
	
	entry = Box_Create(0, 0, pbox->w - 2 * 8 - 32, 3 * 8, BOX_VISIBLE | BOX_TRANSPARENT);
	entry->OnSizeWidth = Box_OnSizeWidth_Stretch;

	subbox = Box_Create(3 * 8 + 16, (entry->h - 16) / 2, entry->w - 3 * 8 - 16 - 13 - 16 - 5, 16, BOX_VISIBLE | BOX_TRANSPARENT);
	subbox->OnSizeWidth = Box_OnSizeWidth_Stretch;
	subbox->fgcol = TabFG1;
	Box_SetText(subbox, name);
	Box_AddChild(entry, subbox);

	subbox = Button_Create((entry->w) - 13 - 16, (entry->h - 13) / 2, 13, 13, BOX_VISIBLE | BOX_TRANSPARENT);
	subbox->img = ImageMgr_GetImage("deleteIcon.png");
	subbox->OnSizeWidth = Box_OnSizeWidth_StickRight;
	Button_SetOnButtonHit(subbox, EditStatusEntry_Remove);
	Button_SetTooltipText(subbox, _("Delete"));
	Box_AddChild(entry, subbox);

	entrydata->name = strdup(name);

	if (away)
	{
		entrydata->away = TRUE;
		subbox = Box_Create(16, (entry->h - 16) / 2, 16, 16, BOX_VISIBLE | BOX_TRANSPARENT);
		subbox->img = ImageMgr_GetSubImage("presenceAway", "PresenceIcons.png", 48, 0, 16, 16);
		Box_AddChild(entry, subbox);
		
		List_AddEntry(data->list, name, _("Away"), entry);
		StatusList_Add(&(data->awaylist), SSTAT_AWAY, name);
	}
	else
	{
		entrydata->away = FALSE;
		subbox = Box_Create(16, (entry->h - 16) / 2, 16, 16, BOX_VISIBLE | BOX_TRANSPARENT);
		subbox->img = ImageMgr_GetSubImage("presenceAvailable", "PresenceIcons.png", 16, 0, 16, 16);
		Box_AddChild(entry, subbox);
				
		List_AddEntry(data->list, name, _("Available"), entry);
		StatusList_Add(&(data->availlist), SSTAT_AVAILABLE, name);
	}

	entry->boxdata = entrydata;

	List_RedoEntries(data->list);
	Box_Repaint(data->list);
}
Esempio n. 2
0
void EditCustomTimes_AddEntry(struct Box_s *pbox, char *name, struct tcpair_s *tcp)
{
	struct editcustomtimesdata_s *data = pbox->boxdata;
	struct Box_s *entry, *subbox;
	struct editcustomtimesentrydata_s *entrydata = malloc(sizeof(*entrydata));
	
	entry = Box_Create(0, 0, pbox->w - 2 * 8 - 32, 3 * 8, BOX_VISIBLE | BOX_TRANSPARENT);
	entry->OnSizeWidth = Box_OnSizeWidth_Stretch;
	entry->OnLButtonDblClk = EditCustomTimesEntry_OnEditEntry;

	subbox = Box_Create(3 * 8 + 16, (entry->h - 16) / 2, entry->w - 3 * 8, 16, BOX_VISIBLE | BOX_TRANSPARENT);
	subbox->fgcol = TabFG1;
	Box_SetText(subbox, name);
	Box_AddChild(entry, subbox);

	subbox = Button_Create((entry->w) - 13 - 16, (entry->h - 13) / 2, 13, 13, BOX_VISIBLE | BOX_TRANSPARENT);
	subbox->img = ImageMgr_GetImage("deleteIcon.png");
	subbox->OnSizeWidth = Box_OnSizeWidth_StickRight;
	Button_SetOnButtonHit(subbox, EditCustomTimesEntry_Remove);
	Box_AddChild(entry, subbox);

	entrydata->name = strdup(name);
	entrydata->wtc = Info_DupeTimeControl(tcp->white);
	entrydata->btc = Info_DupeTimeControl(tcp->black);

	entry->boxdata = entrydata;

	List_AddEntry(data->list, name, NULL, entry);

	List_RedoEntries(data->list);
	Box_Repaint(data->list);
}
FileSystemError
RegisterMount(char *path, uint64_t pid) {

	char *offset = NULL;
	FileSystemObject *r = NULL;
	FileSystemError err = SetupEntry(path, &r, &offset);
	if(err != FileSystemError_None)
		return err;

	if(r->ObjectType != FileSystemObjectType_Directory)
		return FileSystemError_PathInvalid;

	FileSystemObject *dir = malloc(sizeof(FileSystemObject));
	if(dir == NULL)
		return FileSystemError_AllocationFailed;

	dir->ObjectType = FileSystemObjectType_MountPoint;
	strcpy(dir->Name, offset);
	dir->TargetPID = pid;
	dir->Parent = r;
	
	if(List_AddEntry(r->Children, dir) != ListError_None)
		return free(dir), FileSystemError_AllocationFailed;

	return FileSystemError_None;
}
FileSystemError
CreateFile(char *path, FileHandlers *handlers) {

	char *offset = NULL;
	FileSystemObject *r = NULL;
	FileSystemError err = SetupEntry(path, &r, &offset);
	if(err != FileSystemError_None)
		return err;

	if(r->ObjectType != FileSystemObjectType_Directory)
		return FileSystemError_PathInvalid;

	FileSystemObject *dir = malloc(sizeof(FileSystemObject));
	if(dir == NULL)
		return FileSystemError_AllocationFailed;

	dir->ObjectType = FileSystemObjectType_File;
	strcpy(dir->Name, offset);
	dir->handlers = handlers;
	dir->Parent = r;

	if(List_AddEntry(r->Children, dir) != ListError_None)
		return free(dir), FileSystemError_AllocationFailed;

	return FileSystemError_None;
}
uint64_t
AllocateFileDescriptor(int flags, int mode, uint64_t hash, FileSystemObject *m) {
	uint64_t fd = ++fd_base;

	FileDescriptor *desc = malloc(sizeof(FileDescriptor));
	if(desc == NULL)
		return -1;

	desc->fd = fd;
	desc->flags = flags;
	desc->mode = mode;
	desc->hash = hash;
	desc->obj = m;

	if(List_AddEntry(fds, desc) != ListError_None)
		return free(desc), -1;

	return fd;
}