utils.cpp: Set FD_CLOEXEC on lock file
[skype-call-recorder.git] / call.h
blob55fca8abfc24f528d0f4d30ff3698d0f0b1b1bdc
1 /*
2 Skype Call Recorder
3 Copyright (C) 2008 jlh (jlh at gmx dot ch)
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2 of the License, version 3 of
8 the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 The GNU General Public License version 2 is included with the source of
20 this program under the file name COPYING. You can also get a copy on
21 http://www.fsf.org/
24 #ifndef CALL_H
25 #define CALL_H
27 #include <QObject>
28 #include <QString>
29 #include <QByteArray>
30 #include <QMap>
31 #include <QSet>
32 #include <QPointer>
33 #include <QDateTime>
35 #include "common.h"
37 class QStringList;
38 class Skype;
39 class AudioFileWriter;
40 class QTcpServer;
41 class QTcpSocket;
42 class LegalInformationDialog;
44 typedef int CallID;
46 class Call : public QObject {
47 Q_OBJECT
48 public:
49 Call(QObject *, Skype *, CallID);
50 ~Call();
51 void startRecording(bool = false);
52 void stopRecording(bool = true);
53 bool okToDelete() const;
54 void setStatus(const QString &);
55 QString getStatus() const { return status; }
56 bool statusDone() const;
57 bool statusActive() const;
58 CallID getID() const { return id; }
59 void removeFile();
60 void hideConfirmation(int);
62 signals:
63 void startedCall(int, const QString &);
64 void stoppedCall(int);
65 void startedRecording(int);
66 void stoppedRecording(int);
67 void showLegalInformation();
69 private:
70 QString constructFileName() const;
71 QString constructCommentTag() const;
72 void mixToMono(long);
73 void setShouldRecord();
74 void ask();
76 private:
77 Skype *skype;
78 CallID id;
79 QString status;
80 QString skypeName;
81 QString displayName;
82 AudioFileWriter *writer;
83 bool isRecording;
84 int channelMode;
85 int shouldRecord;
86 QString fileName;
87 QPointer<QObject> confirmation;
88 QDateTime timeStartRecording;
90 QTcpServer *serverLocal, *serverRemote;
91 QTcpSocket *socketLocal, *socketRemote;
92 QByteArray bufferLocal, bufferRemote;
93 QByteArray bufferMono;
95 private slots:
96 void acceptLocal();
97 void acceptRemote();
98 void readLocal();
99 void readRemote();
100 void checkConnections();
101 long padBuffers();
102 void tryToWrite(bool = false);
103 void confirmRecording();
104 void denyRecording();
106 private: // moc gets confused without this private:
107 DISABLE_COPY_AND_ASSIGNMENT(Call);
110 class CallHandler : public QObject {
111 Q_OBJECT
112 public:
113 CallHandler(QObject *, Skype *);
114 ~CallHandler();
115 void callCmd(const QStringList &);
117 signals:
118 // note that {start,stop}Recording signals are not guaranteed to always
119 // happen within a {start,stop}Call block. Especially,
120 // stoppedRecording will usually happen *after* stoppedCall
121 void startedCall(int, const QString &);
122 void stoppedCall(int);
123 void startedRecording(int);
124 void stoppedRecording(int);
126 public slots:
127 void startRecording(int);
128 void stopRecording(int);
129 void stopRecordingAndDelete(int);
131 private slots:
132 void showLegalInformation();
134 private:
135 void prune();
137 private:
138 typedef QMap<CallID, Call *> CallMap;
139 typedef QSet<CallID> CallSet;
141 CallMap calls;
142 CallSet ignore;
143 Skype *skype;
144 QPointer<LegalInformationDialog> legalInformationDialog;
146 DISABLE_COPY_AND_ASSIGNMENT(CallHandler);
149 #endif