utils/snapshot: Don't remove utils/syncviewer from snapshots
[skype-call-recorder.git] / call.h
blobc8c0f5fbb3da9f4babd9862bf8780f1b4780c61e
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 setShouldRecord();
96 void ask();
97 void doSync(long);
99 private:
100 Skype *skype;
101 CallID id;
102 QString status;
103 QString skypeName;
104 QString displayName;
105 AudioFileWriter *writer;
106 bool isRecording;
107 int channelMode;
108 int shouldRecord;
109 QString fileName;
110 QPointer<QObject> confirmation;
111 QDateTime timeStartRecording;
113 QTime syncTime;
114 QFile syncFile;
115 AutoSync sync;
117 QTcpServer *serverLocal, *serverRemote;
118 QTcpSocket *socketLocal, *socketRemote;
119 QByteArray bufferLocal, bufferRemote;
120 QByteArray bufferMono;
122 private slots:
123 void acceptLocal();
124 void acceptRemote();
125 void readLocal();
126 void readRemote();
127 void checkConnections();
128 long padBuffers();
129 void tryToWrite(bool = false);
130 void confirmRecording();
131 void denyRecording();
133 private: // moc gets confused without this private:
134 DISABLE_COPY_AND_ASSIGNMENT(Call);
137 class CallHandler : public QObject {
138 Q_OBJECT
139 public:
140 CallHandler(QObject *, Skype *);
141 ~CallHandler();
142 void callCmd(const QStringList &);
144 signals:
145 // note that {start,stop}Recording signals are not guaranteed to always
146 // happen within a {start,stop}Call block. Especially,
147 // stoppedRecording will usually happen *after* stoppedCall
148 void startedCall(int, const QString &);
149 void stoppedCall(int);
150 void startedRecording(int);
151 void stoppedRecording(int);
153 public slots:
154 void startRecording(int);
155 void stopRecording(int);
156 void stopRecordingAndDelete(int);
158 private slots:
159 void showLegalInformation();
161 private:
162 void prune();
164 private:
165 typedef QMap<CallID, Call *> CallMap;
166 typedef QSet<CallID> CallSet;
168 CallMap calls;
169 CallSet ignore;
170 Skype *skype;
171 QPointer<LegalInformationDialog> legalInformationDialog;
173 DISABLE_COPY_AND_ASSIGNMENT(CallHandler);
176 #endif