2010-08-10 18:12:50 +02:00
|
|
|
/*
|
|
|
|
* 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"
|
2011-01-20 19:37:51 +01:00
|
|
|
#include "functions/functions.h"
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
namespace Thread
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
CreateThread::CreateThread()
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
fun.url = L"createthread";
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
void CreateThread::SetTDb(TDb * ptdb)
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
2011-01-20 19:37:51 +01:00
|
|
|
tdb = ptdb;
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
void CreateThread::SetThreadInfo(ThreadInfo * pthread_info)
|
2010-08-18 00:32:47 +02:00
|
|
|
{
|
2011-01-20 19:37:51 +01:00
|
|
|
thread_info = pthread_info;
|
2010-08-18 00:32:47 +02:00
|
|
|
}
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
// 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()) )
|
2010-08-10 18:12:50 +02:00
|
|
|
return false;
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
if( system->mounts.pmount->type != thread_info->mount_type_thread )
|
|
|
|
return false;
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CreateThread::MakePost()
|
|
|
|
{
|
2011-01-20 19:37:51 +01:00
|
|
|
request->item.Clear();
|
|
|
|
functions->ReadItem(request->item, Item::file);
|
2010-08-10 18:12:50 +02:00
|
|
|
functions->SetUser(request->item);
|
2011-01-20 19:37:51 +01:00
|
|
|
functions->PrepareUrl(request->item);
|
|
|
|
request->item.parent_id = request->dir_tab.back()->id;
|
|
|
|
request->item.privileges = 0644; // !! tymczasowo
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
if( functions->CheckAbuse() )
|
2010-08-10 18:12:50 +02:00
|
|
|
return;
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
request->status = system->AddFile(request->item);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
if( request->status == WINIX_ERR_OK )
|
|
|
|
{
|
2011-01-20 19:37:51 +01:00
|
|
|
thread.Clear();
|
|
|
|
thread.file_id = request->item.id;
|
|
|
|
request->status = tdb->AddThread(thread);
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
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;
|
|
|
|
}
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|