moved winix directories to winixdsubdirectory
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1028 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
297
winixd/plugins/export/init.cpp
Normal file
297
winixd/plugins/export/init.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/plugin.h"
|
||||
#include "exportthread.h"
|
||||
#include "exportinfo.h"
|
||||
#include "edb.h"
|
||||
#include "funexport.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
extern "C" void Init(PluginInfo &);
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
|
||||
const wchar_t plugin_name[] = L"export";
|
||||
int mount_par_export_conf = -1;
|
||||
ExportThread export_thread;
|
||||
EDb edb;
|
||||
ExportInfo export_info;
|
||||
FunExport fun_export;
|
||||
|
||||
|
||||
|
||||
void AddWinixFunctions(PluginInfo & info)
|
||||
{
|
||||
info.functions->Add(fun_export);
|
||||
}
|
||||
|
||||
|
||||
void AddMountParams(PluginInfo & info)
|
||||
{
|
||||
using TemplatesFunctions::system;
|
||||
|
||||
mount_par_export_conf = system->mounts.AddMountPar(L"export_conf");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FstabChanged(PluginInfo & info)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void InitPlugin(PluginInfo & info)
|
||||
{
|
||||
export_thread.SetBaseUrl(info.config->base_url);
|
||||
|
||||
info.system->thread_manager.Add(&export_thread, L"export");
|
||||
|
||||
export_info.ReadExportDirs();
|
||||
}
|
||||
|
||||
|
||||
void SendDir(PluginInfo & info)
|
||||
{
|
||||
const Item * dir = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( dir )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendDir(*dir);
|
||||
export_info.SendAllFilesFromDir(dir->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SendFileAdded(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_IMAGE && info.config->image_resize )
|
||||
{
|
||||
// there'll be a next message WINIX_IMAGE_RESIZED
|
||||
log << log4 << "Export: image will be resized, waiting..." << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendFile(*item);
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SendFileChanged(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendFile(*item);
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SendFileCopied(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
{
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
export_info.SendFile(*item);
|
||||
export_info.SendFile(*item, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SendFileResized(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendFile(*item);
|
||||
export_info.SendDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SendFileThumb(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendFile(*item, true);
|
||||
export_info.SendDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SendFilePrepareMove(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileRemoved(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ProcessRequest(PluginInfo & info)
|
||||
{
|
||||
if( info.cur->request->function == &info.functions->fun_reload )
|
||||
{
|
||||
if( info.cur->request->IsParam(L"export") )
|
||||
export_info.ReadExportDirs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace Export;
|
||||
|
||||
edb.SetConn(info.db->GetConn());
|
||||
edb.LogQueries(info.config->log_db_query);
|
||||
edb.SetDirs(&info.system->dirs);
|
||||
export_info.SetSystem(info.system);
|
||||
export_info.SetConfig(info.config);
|
||||
export_info.SetEDb(&edb);
|
||||
export_info.SetDb(info.db);
|
||||
export_info.SetExportThread(&export_thread);
|
||||
|
||||
fun_export.SetExportInfo(&export_info);
|
||||
|
||||
|
||||
// plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
|
||||
plugin.Assign(WINIX_ADD_MOUNTS, AddMountParams);
|
||||
// plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged);
|
||||
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddWinixFunctions);
|
||||
|
||||
plugin.Assign(WINIX_FILE_ADDED, SendFileAdded);
|
||||
plugin.Assign(WINIX_FILE_CHANGED, SendFileChanged);
|
||||
plugin.Assign(WINIX_CREATED_THUMB, SendFileThumb);
|
||||
plugin.Assign(WINIX_IMAGE_RESIZED, SendFileResized);
|
||||
|
||||
plugin.Assign(WINIX_FILE_PREPARE_TO_MOVE, SendFilePrepareMove);
|
||||
plugin.Assign(WINIX_FILE_MOVED, SendFileCopied);
|
||||
plugin.Assign(WINIX_FILE_COPIED, SendFileCopied);
|
||||
|
||||
plugin.Assign(WINIX_DIR_CONTENT_SORTED, SendDir);
|
||||
plugin.Assign(WINIX_FILE_REMOVED, FileRemoved);
|
||||
|
||||
plugin.Assign(WINIX_PROCESS_REQUEST, ProcessRequest);
|
||||
|
||||
plugin.Assign(WINIX_PLUGIN_INIT, InitPlugin);
|
||||
|
||||
|
||||
|
||||
|
||||
info.p1 = (void*)(plugin_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
Reference in New Issue
Block a user