Rename callgui.cpp -> gui.cpp and merge about.cpp into it
[skype-call-recorder.git] / call.h
blob7842c4ad46080605e30ebc9c9b794fd6fb2b2318
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 class QStringList;
36 class Skype;
37 class AudioFileWriter;
38 class QTcpServer;
39 class QTcpSocket;
40 class LegalInformationDialog;
42 typedef int CallID;
44 class Call : public QObject {
45 Q_OBJECT
46 public:
47 Call(QObject *, Skype *, CallID);
48 ~Call();
49 void startRecording(bool = false);
50 void stopRecording(bool = true);
51 bool okToDelete() const;
52 void setStatus(const QString &);
53 QString getStatus() const { return status; }
54 bool statusDone() const;
55 bool statusActive() const;
56 CallID getID() const { return id; }
57 void removeFile();
58 void hideConfirmation(int);
60 signals:
61 void startedCall(int, const QString &);
62 void stoppedCall(int);
63 void startedRecording(int);
64 void stoppedRecording(int);
65 void showLegalInformation();
67 private:
68 QString constructFileName() const;
69 QString constructCommentTag() const;
70 void mixToMono(long);
71 void setShouldRecord();
72 void ask();
74 private:
75 Skype *skype;
76 CallID id;
77 QString status;
78 QString skypeName;
79 QString displayName;
80 AudioFileWriter *writer;
81 bool isRecording;
82 int channelMode;
83 int shouldRecord;
84 QString fileName;
85 QPointer<QObject> confirmation;
86 QDateTime timeStartRecording;
88 QTcpServer *serverLocal, *serverRemote;
89 QTcpSocket *socketLocal, *socketRemote;
90 QByteArray bufferLocal, bufferRemote;
91 QByteArray bufferMono;
93 private slots:
94 void acceptLocal();
95 void acceptRemote();
96 void readLocal();
97 void readRemote();
98 void checkConnections();
99 long padBuffers();
100 void tryToWrite(bool = false);
101 void confirmRecording();
102 void denyRecording();
104 private:
105 // disabled
106 Call(const Call &);
107 Call &operator=(const 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;
147 #endif