winix/plugins/thread/funthread.cpp

91 lines
1.5 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( !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();
//request->status = tdb->GetThreadByFileId(file_id, thread);
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);
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];
}
system->CheckAccessToItems(thread_info->item_tab);
}
void FunThread::MakeGet()
{
PrepareThread(request->item.id);
}
} // namespace