2009-10-01 00:31:20 +02:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2018-11-21 12:03:53 +01:00
|
|
|
* Copyright (c) 2008-2018, Tomasz Sowa
|
2009-10-01 00:31:20 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2009-10-01 00:31:20 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templatesnotify.h"
|
2011-01-25 12:54:46 +01:00
|
|
|
#include "core/misc.h"
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
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
|
|
|
|
|
|
|
|
2014-10-19 23:20:09 +02: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-26 13:45:38 +01:00
|
|
|
static std::string qencode_tmp;
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
void fil_qencode(Info & i)
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
2011-01-26 13:45:38 +01:00
|
|
|
// QEncode can be used in other threads
|
|
|
|
QEncode(i.in.Str(), qencode_tmp);
|
|
|
|
i.out << qencode_tmp;
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
void notify_add(Info & i)
|
2010-09-13 01:33:27 +02:00
|
|
|
{
|
2011-01-26 13:45:38 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_ADD) != 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
|
|
|
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
void notify_edit(Info & i)
|
2009-10-01 00:31:20 +02:00
|
|
|
{
|
2011-01-26 13:45:38 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_EDIT) != 0;
|
2010-12-02 02:02:02 +01:00
|
|
|
}
|
|
|
|
|
2010-09-13 01:33:27 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
void notify_delete(Info & i)
|
2010-12-02 02:02:02 +01:00
|
|
|
{
|
2011-01-26 13:45:38 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_DELETE) != 0;
|
2009-10-01 00:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
void notify_reply(Info & i)
|
2010-12-02 02:02:02 +01:00
|
|
|
{
|
2011-01-26 13:45:38 +01:00
|
|
|
i.res = (notify_msg.code & WINIX_NOTIFY_CODE_REPLY) != 0;
|
2010-12-02 02:02:02 +01:00
|
|
|
}
|
2009-10-01 00:31:20 +02: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-26 13:45:38 +01:00
|
|
|
i.out << notify_user_msg.name;
|
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();
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
ezc_functions.Insert("fil_qencode", fil_qencode);
|
2010-12-02 02:02:02 +01:00
|
|
|
|
2014-10-19 23:20:09 +02:00
|
|
|
/*
|
|
|
|
* IMPROVE ME
|
|
|
|
* now we are able to read from a Space struct and these functions can be removed
|
|
|
|
* and we can use directly a Space struct
|
|
|
|
* (copy those functions here from normal templates)
|
|
|
|
*/
|
2011-01-26 13:45:38 +01:00
|
|
|
ezc_functions.Insert("notify_add", notify_add);
|
|
|
|
ezc_functions.Insert("notify_edit", notify_edit);
|
|
|
|
ezc_functions.Insert("notify_delete", notify_delete);
|
|
|
|
ezc_functions.Insert("notify_reply", notify_reply);
|
2010-12-02 02:02:02 +01:00
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
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);
|
2010-01-28 16:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
} // namespace TemplatesNotifyFunctions
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
2010-01-28 16:39:01 +01:00
|
|
|
|