87 lines
1.4 KiB
C++
Executable File
87 lines
1.4 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include <algorithm>
|
|
#include "core/misc.h"
|
|
#include "funthread.h"
|
|
|
|
|
|
namespace Thread
|
|
{
|
|
|
|
FunThread::FunThread()
|
|
{
|
|
fun.url = L"thread";
|
|
}
|
|
|
|
|
|
void FunThread::SetTDb(TDb * ptdb)
|
|
{
|
|
tdb = ptdb;
|
|
}
|
|
|
|
void FunThread::SetThreadInfo(ThreadInfo * pthread_info)
|
|
{
|
|
thread_info = pthread_info;
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FunThread::HasAccess()
|
|
{
|
|
if( !cur->request->is_item )
|
|
return false;
|
|
|
|
if( system->mounts.pmount->type != thread_info->mount_type_thread )
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
void FunThread::PrepareThread(long file_id)
|
|
{
|
|
thread_info->Clear();
|
|
cur->request->status = tdb->GetAnswers(file_id, id_tab);
|
|
|
|
if( !id_tab.empty() )
|
|
{
|
|
DbItemQuery iq;
|
|
|
|
if( system->mounts.pmount->IsArg(thread_info->mount_par_thread, L"sort_desc") )
|
|
iq.sort_asc = false;
|
|
|
|
iq.WhereIdIn(id_tab);
|
|
iq.WhereType(Item::file);
|
|
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
|
|
|
db->GetItems(thread_info->item_tab, iq);
|
|
system->CheckAccessToItems(thread_info->item_tab);
|
|
|
|
thread_info->item_sort_tab.resize(thread_info->item_tab.size());
|
|
|
|
// thread_info.item_tab is already sorted (by the database)
|
|
for(size_t i=0 ; i<thread_info->item_tab.size() ; ++i)
|
|
thread_info->item_sort_tab[i] = &thread_info->item_tab[i];
|
|
}
|
|
}
|
|
|
|
|
|
void FunThread::MakeGet()
|
|
{
|
|
PrepareThread(cur->request->item.id);
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|