2009-10-01 00:31:20 +02:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2009-10-01 00:31:20 +02:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2009-10-01 00:31:20 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templatesnotify.h"
|
2010-12-06 01:25:46 +01:00
|
|
|
#include "core/plugin.h"
|
2011-01-25 12:54:46 +01:00
|
|
|
#include "core/misc.h"
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2010-09-13 01:33:27 +02:00
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
namespace TemplatesNotifyFunctions
|
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
Ezc::Functions<NotifyStream> ezc_functions;
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
// you can use this pointer in template functions (will be always valid)
|
2010-12-02 02:02:02 +01:00
|
|
|
NotifyUserMsg notify_user_msg;
|
|
|
|
NotifyMsg notify_msg;
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2011-01-25 12:54:46 +01:00
|
|
|
// name in qencoding
|
|
|
|
static std::string name_q;
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_file_added(Info & i)
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_FILE_ADD) != 0;
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
void notify_file_edited(Info & i)
|
2010-09-13 01:33:27 +02:00
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_FILE_EDIT) != 0;
|
2010-09-13 01:33:27 +02:00
|
|
|
}
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_file_deleted(Info & i)
|
2009-10-01 00:31:20 +02:00
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_FILE_DELETE) != 0;
|
|
|
|
}
|
|
|
|
|
2010-09-13 01:33:27 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_dir_added(Info & i)
|
|
|
|
{
|
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_DIR_ADD) != 0;
|
2009-10-01 00:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_thread_added(Info & i)
|
|
|
|
{
|
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_THREAD_ADD) != 0;
|
|
|
|
}
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_thread_replayed(Info & i)
|
2010-01-28 16:39:01 +01:00
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_THREAD_REPLAYED) != 0;
|
|
|
|
}
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_thread_post_changed(Info & i)
|
|
|
|
{
|
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_THREAD_POST_CHANGED) != 0;
|
2010-01-28 16:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-25 12:54:46 +01:00
|
|
|
void notify_to_email(Info & i)
|
2009-10-01 00:31:20 +02:00
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
i.out << notify_user_msg.email;
|
|
|
|
}
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2011-01-25 12:54:46 +01:00
|
|
|
void notify_to_name(Info & i)
|
2010-12-02 02:02:02 +01:00
|
|
|
{
|
2011-01-25 12:54:46 +01:00
|
|
|
QEncode(notify_user_msg.name, name_q);
|
|
|
|
i.out << name_q;
|
2009-10-01 00:31:20 +02:00
|
|
|
}
|
2010-12-02 02:02:02 +01:00
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_item_link(Info & i)
|
|
|
|
{
|
|
|
|
i.out << notify_msg.item_link;
|
|
|
|
}
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void notify_dir_link(Info & i)
|
2009-10-01 00:31:20 +02:00
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
i.out << notify_msg.dir_link;
|
2009-10-01 00:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-25 12:54:46 +01:00
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
void CreateFunctions()
|
2010-01-28 16:39:01 +01:00
|
|
|
{
|
2010-12-02 02:02:02 +01:00
|
|
|
ezc_functions.Clear();
|
|
|
|
|
|
|
|
ezc_functions.Insert("notify_file_added", notify_file_added);
|
|
|
|
ezc_functions.Insert("notify_file_edited", notify_file_edited);
|
|
|
|
ezc_functions.Insert("notify_file_deleted", notify_file_deleted);
|
|
|
|
ezc_functions.Insert("notify_dir_added", notify_dir_added);
|
|
|
|
|
|
|
|
ezc_functions.Insert("notify_thread_added", notify_thread_added);
|
|
|
|
ezc_functions.Insert("notify_thread_replayed", notify_thread_replayed);
|
|
|
|
ezc_functions.Insert("notify_thread_post_changed", notify_thread_post_changed);
|
|
|
|
|
2011-01-25 12:54:46 +01:00
|
|
|
ezc_functions.Insert("notify_to_email", notify_to_email);
|
|
|
|
ezc_functions.Insert("notify_to_name", notify_to_name);
|
2010-12-02 02:02:02 +01:00
|
|
|
ezc_functions.Insert("notify_item_link", notify_item_link);
|
|
|
|
ezc_functions.Insert("notify_dir_link", notify_dir_link);
|
2010-12-06 01:25:46 +01:00
|
|
|
|
|
|
|
plugin.Call(WINIX_NOTIFY_TEMPLATES_CREATEFUNCTIONS, &ezc_functions);
|
2010-01-28 16:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
} // namespace TemplatesNotifyFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|