winix/notify/templatesnotify.cpp

148 lines
2.5 KiB
C++
Raw Normal View History

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
*
*/
#include "templatesnotify.h"
#include "core/plugin.h"
#include "core/misc.h"
namespace TemplatesNotifyFunctions
{
Ezc::Functions<NotifyStream> ezc_functions;
// you can use this pointer in template functions (will be always valid)
NotifyUserMsg notify_user_msg;
NotifyMsg notify_msg;
// name in qencoding
static std::string name_q;
void notify_file_added(Info & i)
{
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_FILE_ADD) != 0;
}
void notify_file_edited(Info & i)
{
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_FILE_EDIT) != 0;
}
void notify_file_deleted(Info & i)
{
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_FILE_DELETE) != 0;
}
void notify_dir_added(Info & i)
{
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_DIR_ADD) != 0;
}
void notify_thread_added(Info & i)
{
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_THREAD_ADD) != 0;
}
void notify_thread_replayed(Info & i)
{
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_THREAD_REPLAYED) != 0;
}
void notify_thread_post_changed(Info & i)
{
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_THREAD_POST_CHANGED) != 0;
}
void notify_to_email(Info & i)
{
i.out << notify_user_msg.email;
}
void notify_to_name(Info & i)
{
QEncode(notify_user_msg.name, name_q);
i.out << name_q;
}
void notify_item_link(Info & i)
{
i.out << notify_msg.item_link;
}
void notify_dir_link(Info & i)
{
i.out << notify_msg.dir_link;
}
void CreateFunctions()
{
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);
ezc_functions.Insert("notify_to_email", notify_to_email);
ezc_functions.Insert("notify_to_name", notify_to_name);
ezc_functions.Insert("notify_item_link", notify_item_link);
ezc_functions.Insert("notify_dir_link", notify_dir_link);
plugin.Call(WINIX_NOTIFY_TEMPLATES_CREATEFUNCTIONS, &ezc_functions);
}
} // namespace TemplatesNotifyFunctions