void WorkQueue::HandleComplete(int Limit) { // handle all complete tasks int Handled = 0; while (Handled < Limit) { Task * task = GetFinishTask(); if (!task) { return; } // call complete task->Complete(); task->Recycle(); Handled++; } }
Task* TaskFS::FileToTask(entry_ref theEntryRef) { Task* newTask =new Task(); //needed for the "attribute stuff BFile theFile(&theEntryRef,B_READ_ONLY); //needed to get out the name BEntry theEntry(&theEntryRef); bool completed; char name[B_FILE_NAME_LENGTH]; BString taskListID; BString notes; uint32 priority; time_t due; BString id; BString url; //maby do a check if everything went ok and only if so set the values theFile.ReadAttr("META:completed",B_BOOL_TYPE, 0, &completed, sizeof(completed)); theEntry.GetName(name); theFile.ReadAttrString("META:tasks",&taskListID); theFile.ReadAttrString("META:notes",¬es); theFile.ReadAttr("META:priority", B_UINT32_TYPE, 0, &priority, sizeof(priority)); theFile.ReadAttr("META:due", B_TIME_TYPE, 0, &due, sizeof(due)); theFile.ReadAttrString("META:task_id", &id); theFile.ReadAttrString("META:task_url",&url); //** find TaskList from ID// TaskList *newTaskList = new TaskList(""); newTaskList->SetID(taskListID); newTask->Complete(completed); newTask->SetTitle(BString(name)); newTask->SetTaskList(newTaskList); newTask->SetNotes(notes); newTask->SetPriority(priority); newTask->SetDueTime(due); newTask->SetID(id); newTask->SetURL(url); BMessage *msg = new BMessage(); msg->AddPointer("task",newTask); Looper()->SendNotices(ADD_TASK,msg); return newTask; }