utils/makerpm: Fix building of RPMs
[skype-call-recorder.git] / call.h
blobd925ce60db2e36c09441f52a2cceec07e71950f1
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>
34 #include <QTime>
35 #include <QFile>
37 #include "common.h"
39 class QStringList;
40 class Skype;
41 class AudioFileWriter;
42 class QTcpServer;
43 class QTcpSocket;
44 class LegalInformationDialog;
46 typedef int CallID;
48 class AutoSync {
49 public:
50 AutoSync(int, long);
51 ~AutoSync();
52 void add(long);
53 long getSync();
54 void reset();
56 private:
57 long *delays;
58 int size;
59 int index;
60 long sum;
61 qint64 sum2;
62 long precision;
63 int suppress;
65 DISABLE_COPY_AND_ASSIGNMENT(AutoSync);
68 class Call : public QObject {
69 Q_OBJECT
70 public:
71 Call(QObject *, Skype *, CallID);
72 ~Call();
73 void startRecording(bool = false);
74 void stopRecording(bool = true);
75 bool okToDelete() const;
76 void setStatus(const QString &);
77 QString getStatus() const { return status; }
78 bool statusDone() const;
79 bool statusActive() const;
80 CallID getID() const { return id; }
81 void removeFile();
82 void hideConfirmation(int);
84 signals:
85 void startedCall(int, const QString &);
86 void stoppedCall(int);
87 void startedRecording(int);
88 void stoppedRecording(int);
89 void showLegalInformation();
91 private:
92 QString constructFileName() const;
93 QString constructCommentTag() const;
94 void mixToMono(long);
95 void mixToStereo(long, int);
96 void setShouldRecord();
97 void ask();
98 void doSync(long);
100 private:
101 Skype *skype;
102 CallID id;
103 QString status;
104 QString skypeName;
105 QString displayName;
106 AudioFileWriter *writer;
107 bool isRecording;
108 int stereo;
109 int stereoMix;
110 int shouldRecord;
111 QString fileName;
112 QPointer<QObject> confirmation;
113 QDateTime timeStartRecording;
115 QTime syncTime;
116 QFile syncFile;
117 AutoSync sync;
119 QTcpServer *serverLocal, *serverRemote;
120 QTcpSocket *socketLocal, *socketRemote;
121 QByteArray bufferLocal, bufferRemote;
123 private slots:
124 void acceptLocal();
125 void acceptRemote();
126 void readLocal();
127 void readRemote();
128 void checkConnections();
129 long padBuffers();
130 void tryToWrite(bool = false);
131 void confirmRecording();
132 void denyRecording();
134 private: // moc gets confused without this private:
135 DISABLE_COPY_AND_ASSIGNMENT(Call);
138 class CallHandler : public QObject {
139 Q_OBJECT
140 public:
141 CallHandler(QObject *, Skype *);
142 ~CallHandler();
143 void callCmd(const QStringList &);
145 signals:
146 // note that {start,stop}Recording signals are not guaranteed to always
147 // happen within a {start,stop}Call block. Especially,
148 // stoppedRecording will usually happen *after* stoppedCall
149 void startedCall(int, const QString &);
150 void stoppedCall(int);
151 void startedRecording(int);
152 void stoppedRecording(int);
154 public slots:
155 void startRecording(int);
156 void stopRecording(int);
157 void stopRecordingAndDelete(int);
159 private slots:
160 void showLegalInformation();
162 private:
163 void prune();
165 private:
166 typedef QMap<CallID, Call *> CallMap;
167 typedef QSet<CallID> CallSet;
169 CallMap calls;
170 CallSet ignore;
171 Skype *skype;
172 QPointer<LegalInformationDialog> legalInformationDialog;
174 DISABLE_COPY_AND_ASSIGNMENT(CallHandler);
177 #endif