File: mail.h

package info (click to toggle)
vdr-plugin-epgsearch 1.0.1~beta6%2Bgit20150211-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,780 kB
  • ctags: 2,325
  • sloc: ansic: 23,325; perl: 1,330; sh: 609; makefile: 197
file content (125 lines) | stat: -rw-r--r-- 4,107 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*                                                                  -*- c++ -*-
Copyright (C) 2004-2013 Christian Wieninger

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

The author can be reached at cwieninger@gmx.de

The project's page is at http://winni.vdr-developer.org/epgsearch
*/

#ifndef __EPGSEARCH_MAIL_H
#define __EPGSEARCH_MAIL_H

#include <string>
#include <set>

#include <vdr/thread.h>
#include <vdr/plugin.h>
#include "conflictcheck.h"

using std::string;
using std::set;

// --- cMailNotifier --------------------------------------------------------
class cMailNotifier
{
 protected:
    string subject;
    string body;

    bool SendMailViaSendmail();
    bool SendMailViaScript();
    bool SendMail(bool force=false);
    bool ExecuteMailScript(string ScriptArgs);
 public:
    string scriptReply;

    cMailNotifier() {}
    cMailNotifier(string Subject, string Body);
    bool TestMailAccount(string MailAddressTo, string MailAddress, string MailServer, string AuthUser, string AuthPass);
    static string LoadTemplate(const string& templtype);
    static string GetTemplValue(const string& templ, const string& entry);

    static string MailCmd;
};

class cMailTimerNotification
{
  friend class cMailUpdateNotifier;
    tEventID eventID;
    tChannelID channelID;
    uint timerMod;

 protected:
    virtual const cEvent* GetEvent() const;

 public:
 cMailTimerNotification(tEventID EventID, tChannelID ChannelID, uint TimerMod = tmNoChange)
   : eventID(EventID), channelID(ChannelID), timerMod(TimerMod) {}
    virtual bool operator< (const cMailTimerNotification &N) const;
    virtual string Format(const string& templ) const;
};

class cMailDelTimerNotification
{
  friend class cMailUpdateNotifier;
    time_t start;
    tChannelID channelID;
 public:
    string formatted;

    cMailDelTimerNotification(cTimer* t, const cEvent* pEvent, const string& templ);
    cMailDelTimerNotification(const string& Formatted, tChannelID ChannelID, time_t Start);
    bool operator< (const cMailDelTimerNotification &N) const;
    string Format(const string& templ) const { return formatted; }
};

class cMailAnnounceEventNotification : public cMailTimerNotification
{
  friend class cMailUpdateNotifier;
  int searchextID;
 public:
 cMailAnnounceEventNotification(tEventID EventID, tChannelID ChannelID, int SearchExtID)
   : cMailTimerNotification(EventID, ChannelID), searchextID(SearchExtID) {}
    string Format(const string& templ) const;
};

class cMailUpdateNotifier : public cMailNotifier
{
    set<cMailTimerNotification> newTimers;
    set<cMailTimerNotification> modTimers;
    set<cMailDelTimerNotification> delTimers;
    set<cMailAnnounceEventNotification> announceEvents;

    string mailTemplate;
 public:
    cMailUpdateNotifier();
    void AddNewTimerNotification(tEventID EventID, tChannelID ChannelID);
    void AddModTimerNotification(tEventID EventID, tChannelID ChannelID, uint timerMod = tmNoChange);
    void AddRemoveTimerNotification(cTimer* t, const cEvent* e = NULL);
    void AddRemoveTimerNotification(const string& Formatted, tChannelID ChannelID, time_t Start);
    void AddAnnounceEventNotification(tEventID EventID, tChannelID ChannelID, int SearchExtID);
    void SendUpdateNotifications();
};

class cMailConflictNotifier : public cMailNotifier
{
 public:
    void SendConflictNotifications(cConflictCheck& conflictcheck);
};

#endif