added a special thread for making thumbnails (thumb.h thumb.cpp)

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@700 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-12-11 22:55:48 +00:00
parent e854fe3681
commit 5d09eb149c
39 changed files with 706 additions and 289 deletions

View File

@@ -240,7 +240,7 @@ Error Db::AddItemIntoItem(Item & item)
query.Clear();
query << R("insert into core.item (user_id, modification_user_id, group_id, privileges, "
"date_creation, date_modification, type, parent_id, content_id, file_path, file_fs, file_type, "
"default_item, subject, guest_name, template, url) values (")
"has_thumb, default_item, subject, guest_name, template, url) values (")
<< item.user_id
<< item.modification_user_id
<< item.group_id
@@ -253,6 +253,7 @@ Error Db::AddItemIntoItem(Item & item)
<< item.file_path
<< item.file_fs
<< item.file_type
<< static_cast<int>(item.has_thumb)
<< item.default_item
<< item.subject
<< item.guest_name
@@ -347,7 +348,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
query.Clear();
query << R("update core.item set (user_id, modification_user_id, group_id, privileges, "
"date_creation, date_modification, type, default_item, parent_id, subject, "
"guest_name, file_path, file_fs, file_type, template");
"guest_name, file_path, file_fs, file_type, has_thumb, template");
if( with_url )
query << R(", url");
@@ -367,6 +368,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
<< item.file_path
<< item.file_fs
<< item.file_type
<< static_cast<int>(item.has_thumb)
<< item.html_template;
if( with_url )
@@ -628,7 +630,7 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
if( iq.sel_url ) query << R(" ,url");
if( iq.sel_type ) query << R(" ,type");
if( iq.sel_default_item ) query << R(" ,default_item");
if( iq.sel_file ) query << R(" ,file_path, file_fs, file_type");
if( iq.sel_file ) query << R(" ,file_path, file_fs, file_type, has_thumb");
if( iq.sel_html_template ) query << R(" ,template");
}
@@ -1040,7 +1042,7 @@ return result;
Error Db::EditFileById(Item & item, long id)
Error Db::EditFileById(const Item & item, long id)
{
PGresult * r = 0;
Error result = WINIX_ERR_OK;
@@ -1048,10 +1050,11 @@ Error Db::EditFileById(Item & item, long id)
try
{
query.Clear();
query << R("update core.item set (file_path, file_fs, file_type) = (")
query << R("update core.item set (file_path, file_fs, file_type, has_thumb) = (")
<< item.file_path
<< item.file_fs
<< item.file_type
<< static_cast<int>(item.has_thumb)
<< R(") where id=") << id << R(";");
r = AssertQuery(query);
@@ -1069,6 +1072,34 @@ return result;
Error Db::EditHasThumbById(bool has_thumb, long id)
{
PGresult * r = 0;
Error result = WINIX_ERR_OK;
try
{
query.Clear();
query << R("update core.item set (has_thumb) = (")
<< static_cast<int>(has_thumb)
<< R(") where id=") << id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_COMMAND_OK);
}
catch(const Error & e)
{
result = e;
}
ClearResult(r);
return result;
}
Error Db::DelDirById(long id)
{
Error result = WINIX_ERR_OK;

View File

@@ -63,7 +63,8 @@ public:
bool GetPriv(Item & item, long id);
Error EditPrivById(Item & item, long id);
Error EditParentUrlById(Item & item, long id);
Error EditFileById(Item & item, long id); // file_path, file_fs, file_type
Error EditFileById(const Item & item, long id); // file_path, file_fs, file_type
Error EditHasThumbById(bool has_thumb, long id);
Error DelDirById(long id);
Error EditSubjectById(Item & item, long id);

View File

@@ -168,6 +168,11 @@ int DbBase::AssertValueInt(PGresult * r, int row, int col)
}
bool DbBase::AssertValueBool(PGresult * r, int row, int col)
{
return strtol( AssertValue(r, row, col), 0, 10 ) != 0;
}
unsigned long DbBase::AssertValueULong(PGresult * r, int row, int col)
{

View File

@@ -41,6 +41,7 @@ public:
static void AssertValueWide(PGresult * r, int row, int col, std::wstring & result);
static long AssertValueLong(PGresult * r, int row, int col);
static int AssertValueInt(PGresult * r, int row, int col);
static bool AssertValueBool(PGresult * r, int row, int col);
static unsigned long AssertValueULong(PGresult * r, int row, int col);
static unsigned int AssertValueUInt(PGresult * r, int row, int col);
static tm AssertValueTm(PGresult * r, int row, int col);

View File

@@ -35,6 +35,7 @@ void DbItemColumns::SetColumns(PGresult * r)
file_path = PQfnumber(r, "file_path");
file_fs = PQfnumber(r, "file_fs");
file_type = PQfnumber(r, "file_type");
has_thumb = PQfnumber(r, "has_thumb");
}
@@ -61,6 +62,7 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
if( file_path != -1 ) item.file_path = DbBase::AssertValueWide(r, row, file_path);
if( file_fs != -1 ) item.file_fs = DbBase::AssertValueInt(r, row, file_fs);
if( file_type != -1 ) item.file_type = DbBase::AssertValueInt(r, row, file_type);
if( has_thumb != -1 ) item.has_thumb = DbBase::AssertValueBool(r, row, has_thumb);
}

View File

@@ -39,7 +39,8 @@ struct DbItemColumns
int file_path;
int file_fs;
int file_type;
int has_thumb;
void SetColumns(PGresult * r);
void SetItem(PGresult * r, long row, Item & item);
};

View File

@@ -30,7 +30,7 @@ struct DbItemQuery
bool sel_url; // url
bool sel_type; // type (dir, file, none)
bool sel_default_item; // default_item
bool sel_file; // file_path, file_fs, file_type
bool sel_file; // file_path, file_fs, file_type, has_thumb
bool sel_html_template; // template
bool where_id; //