/* * 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( request->is_item || !system->HasWriteAccess(*request->dir_tab.back()) ) return false; if( system->mounts.pmount->type != thread_info->mount_type_thread ) return false; return true; } void CreateThread::MakePost() { request->item.Clear(); functions->ReadItem(request->item, Item::file); functions->SetUser(request->item); functions->PrepareUrl(request->item); request->item.parent_id = request->dir_tab.back()->id; request->item.privileges = 0644; // !! tymczasowo if( functions->CheckAbuse() ) return; request->status = system->AddFile(request->item); if( request->status == WINIX_ERR_OK ) { thread.Clear(); thread.file_id = request->item.id; request->status = tdb->AddThread(thread); } if( request->status == WINIX_ERR_OK ) { log << log2 << "CreateThread: added a new thread" << logend; system->RedirectTo(request->item); } else { log << log1 << "CreateThread: problem with adding a new thread, error code: " << request->status << logend; } } } // namespace