added: notifications to users' emails
(core/notify.h core/notify.cpp)
templatesnotify directory
all notifications are managed by a second thread
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@512 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
76
core/notify.h
Executable file
76
core/notify.h
Executable file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslunotify
|
||||
#define headerfilecmslunotify
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "../templatesnotify/templatesnotify.h"
|
||||
|
||||
|
||||
#define CMSLU_NOTIFY_ITEM_ADD 1
|
||||
#define CMSLU_NOTIFY_ITEM_EDIT 2
|
||||
#define CMSLU_NOTIFY_ITEM_DELETE 4
|
||||
#define CMSLU_NOTIFY_DIR_ADD 8
|
||||
|
||||
|
||||
|
||||
class Notify
|
||||
{
|
||||
public:
|
||||
|
||||
Notify();
|
||||
~Notify();
|
||||
|
||||
bool Init(const std::string & tdir);
|
||||
|
||||
/*
|
||||
this method added an item to our special pool
|
||||
the pool is used by a second thread
|
||||
*/
|
||||
void ItemChanged(int notify_code);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static void * ThreadRoutine(void * arg);
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
static void CheckQueue();
|
||||
static void SendEmail(NotifyMsg & n);
|
||||
static void SendEmail(const std::string & email);
|
||||
static void SendEmail(const std::string & email, const std::string & message);
|
||||
static void SendMessage(FILE * sendmail, const std::string & message);
|
||||
void CreateItemDir(std::string & dir, bool clear = true);
|
||||
void CreateItemLink(std::string & link);
|
||||
|
||||
pthread_t thread;
|
||||
pthread_mutex_t mutex;
|
||||
NotifyMsg n;
|
||||
|
||||
|
||||
/*
|
||||
objects accessed by the second thread
|
||||
*/
|
||||
std::list<NotifyMsg> notify_pool;
|
||||
static Notify * obj;
|
||||
std::string command;
|
||||
std::string templates_dir;
|
||||
TemplatesNotify templates_notify;
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern Notify notify;
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user