/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa * All rights reserved. * */ #include "createthread.h" #include "functions.h" #include "functions/functions.h" namespace Thread { CreateThread::CreateThread() { fun.url = L"createthread"; } void CreateThread::SetTDb(TDb * ptdb) { tdb = ptdb; } void CreateThread::SetThreadInfo(ThreadInfo * pthread_info) { thread_info = pthread_info; } // returning true if we can create a thread in the current directory bool CreateThread::HasAccess() { if( cur->request->is_item || !system->HasWriteAccess(*cur->request->dir_tab.back()) ) return false; if( system->mounts.pmount->type != thread_info->mount_type_thread ) return false; return true; } void CreateThread::MakePost() { cur->request->item.Clear(); functions->ReadItem(cur->request->item, Item::file); functions->SetUser(cur->request->item); functions->PrepareUrl(cur->request->item); cur->request->item.parent_id = cur->request->dir_tab.back()->id; cur->request->item.privileges = 0644; // !! tymczasowo if( functions->CheckAbuse() ) return; cur->request->status = system->AddFile(cur->request->item); if( cur->request->status == WINIX_ERR_OK ) { thread.Clear(); thread.file_id = cur->request->item.id; cur->request->status = tdb->AddThread(thread); } if( cur->request->status == WINIX_ERR_OK ) { log << log2 << "CreateThread: added a new thread" << logend; system->RedirectTo(cur->request->item); } else { log << log1 << "CreateThread: problem with adding a new thread, error code: " << cur->request->status << logend; } } } // namespace