mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Initial porting to the new Tox API
Builds and runs, but some features will be missing, may crash with an assert, or silently fail with broken QObject connections We're back in the game.
This commit is contained in:
parent
32237077c7
commit
228398d5de
448
src/core.cpp
448
src/core.cpp
File diff suppressed because it is too large
Load Diff
132
src/core.h
132
src/core.h
|
@ -22,6 +22,7 @@
|
|||
#include <QMutex>
|
||||
|
||||
#include <tox/tox.h>
|
||||
#include <tox/toxencryptsave.h>
|
||||
|
||||
#include "corestructs.h"
|
||||
#include "coreav.h"
|
||||
|
@ -60,8 +61,8 @@ public:
|
|||
QString getGroupPeerName(int groupId, int peerId) const; ///< Get the name of a peer of a group
|
||||
ToxID getGroupPeerToxID(int groupId, int peerId) const; ///< Get the ToxID of a peer of a group
|
||||
QList<QString> getGroupPeerNames(int groupId) const; ///< Get the names of the peers of a group
|
||||
QString getFriendAddress(int friendNumber) const; ///< Get the full address if known, or Tox ID of a friend
|
||||
QString getFriendUsername(int friendNumber) const; ///< Get the username of a friend
|
||||
QString getFriendAddress(uint32_t friendNumber) const; ///< Get the full address if known, or Tox ID of a friend
|
||||
QString getFriendUsername(uint32_t friendNumber) const; ///< Get the username of a friend
|
||||
bool hasFriendWithAddress(const QString &addr) const; ///< Check if we have a friend by address
|
||||
bool hasFriendWithPublicKey(const QString &pubkey) const; ///< Check if we have a friend by public key
|
||||
int joinGroupchat(int32_t friendNumber, uint8_t type, const uint8_t* pubkey,uint16_t length) const; ///< Accept a groupchat invite
|
||||
|
@ -93,37 +94,37 @@ public slots:
|
|||
|
||||
void acceptFriendRequest(const QString& userId);
|
||||
void requestFriendship(const QString& friendAddress, const QString& message);
|
||||
void groupInviteFriend(int friendId, int groupId);
|
||||
void groupInviteFriend(uint32_t friendId, int groupId);
|
||||
void createGroup(uint8_t type = TOX_GROUPCHAT_TYPE_AV);
|
||||
|
||||
void removeFriend(int friendId, bool fake = false);
|
||||
void removeFriend(uint32_t friendId, bool fake = false);
|
||||
void removeGroup(int groupId, bool fake = false);
|
||||
|
||||
void setStatus(Status status);
|
||||
void setUsername(const QString& username);
|
||||
void setStatusMessage(const QString& message);
|
||||
void setAvatar(uint8_t format, const QByteArray& data);
|
||||
void setAvatar(const QByteArray& data);
|
||||
|
||||
int sendMessage(int friendId, const QString& message);
|
||||
int sendMessage(uint32_t friendId, const QString& message);
|
||||
void sendGroupMessage(int groupId, const QString& message);
|
||||
void sendGroupAction(int groupId, const QString& message);
|
||||
void changeGroupTitle(int groupId, const QString& title);
|
||||
int sendAction(int friendId, const QString& action);
|
||||
void sendTyping(int friendId, bool typing);
|
||||
int sendAction(uint32_t friendId, const QString& action);
|
||||
void sendTyping(uint32_t friendId, bool typing);
|
||||
|
||||
void sendFile(int32_t friendId, QString Filename, QString FilePath, long long filesize);
|
||||
void cancelFileSend(int friendId, int fileNum);
|
||||
void cancelFileRecv(int friendId, int fileNum);
|
||||
void rejectFileRecvRequest(int friendId, int fileNum);
|
||||
void acceptFileRecvRequest(int friendId, int fileNum, QString path);
|
||||
void pauseResumeFileSend(int friendId, int fileNum);
|
||||
void pauseResumeFileRecv(int friendId, int fileNum);
|
||||
void sendFile(uint32_t friendId, QString Filename, QString FilePath, long long filesize);
|
||||
void cancelFileSend(uint32_t friendId, uint32_t fileNum);
|
||||
void cancelFileRecv(uint32_t friendId, uint32_t fileNum);
|
||||
void rejectFileRecvRequest(uint32_t friendId, uint32_t fileNum);
|
||||
void acceptFileRecvRequest(uint32_t friendId, uint32_t fileNum, QString path);
|
||||
void pauseResumeFileSend(uint32_t friendId, uint32_t fileNum);
|
||||
void pauseResumeFileRecv(uint32_t friendId, uint32_t fileNum);
|
||||
|
||||
void answerCall(int callId);
|
||||
void rejectCall(int callId);
|
||||
void hangupCall(int callId);
|
||||
void startCall(int friendId, bool video=false);
|
||||
void cancelCall(int callId, int friendId);
|
||||
void startCall(uint32_t friendId, bool video=false);
|
||||
void cancelCall(int callId, uint32_t friendId);
|
||||
|
||||
void micMuteToggle(int callId);
|
||||
void volMuteToggle(int callId);
|
||||
|
@ -151,23 +152,23 @@ signals:
|
|||
void blockingClearContacts();
|
||||
|
||||
void friendRequestReceived(const QString& userId, const QString& message);
|
||||
void friendMessageReceived(int friendId, const QString& message, bool isAction);
|
||||
void friendMessageReceived(uint32_t friendId, const QString& message, bool isAction);
|
||||
|
||||
void friendAdded(int friendId, const QString& userId);
|
||||
void friendAdded(uint32_t friendId, const QString& userId);
|
||||
|
||||
void friendStatusChanged(int friendId, Status status);
|
||||
void friendStatusMessageChanged(int friendId, const QString& message);
|
||||
void friendUsernameChanged(int friendId, const QString& username);
|
||||
void friendTypingChanged(int friendId, bool isTyping);
|
||||
void friendAvatarChanged(int friendId, const QPixmap& pic);
|
||||
void friendAvatarRemoved(int friendId);
|
||||
void friendStatusChanged(uint32_t friendId, Status status);
|
||||
void friendStatusMessageChanged(uint32_t friendId, const QString& message);
|
||||
void friendUsernameChanged(uint32_t friendId, const QString& username);
|
||||
void friendTypingChanged(uint32_t friendId, bool isTyping);
|
||||
void friendAvatarChanged(uint32_t friendId, const QPixmap& pic);
|
||||
void friendAvatarRemoved(uint32_t friendId);
|
||||
|
||||
void friendRemoved(int friendId);
|
||||
void friendRemoved(uint32_t friendId);
|
||||
|
||||
void friendLastSeenChanged(int friendId, const QDateTime& dateTime);
|
||||
void friendLastSeenChanged(uint32_t friendId, const QDateTime& dateTime);
|
||||
|
||||
void emptyGroupCreated(int groupnumber);
|
||||
void groupInviteReceived(int friendnumber, uint8_t type, QByteArray publicKey);
|
||||
void groupInviteReceived(uint32_t friendNumber, uint8_t type, QByteArray publicKey);
|
||||
void groupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction);
|
||||
void groupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||
void groupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
||||
|
@ -179,14 +180,14 @@ signals:
|
|||
void idSet(const QString& id);
|
||||
void selfAvatarChanged(const QPixmap& pic);
|
||||
|
||||
void messageSentResult(int friendId, const QString& message, int messageId);
|
||||
void messageSentResult(uint32_t friendId, const QString& message, int messageId);
|
||||
void groupSentResult(int groupId, const QString& message, int result);
|
||||
void actionSentResult(int friendId, const QString& action, int success);
|
||||
void actionSentResult(uint32_t friendId, const QString& action, int success);
|
||||
|
||||
void receiptRecieved(int friedId, int receipt);
|
||||
|
||||
void failedToAddFriend(const QString& userId, const QString& errorInfo = QString());
|
||||
void failedToRemoveFriend(int friendId);
|
||||
void failedToRemoveFriend(uint32_t friendId);
|
||||
void failedToSetUsername(const QString& username);
|
||||
void failedToSetStatusMessage(const QString& message);
|
||||
void failedToSetStatus(Status status);
|
||||
|
@ -207,45 +208,44 @@ signals:
|
|||
void fileTransferRemotePausedUnpaused(ToxFile file, bool paused);
|
||||
void fileTransferBrokenUnbroken(ToxFile file, bool broken);
|
||||
|
||||
void fileSendFailed(int FriendId, const QString& fname);
|
||||
void fileSendFailed(uint32_t friendId, const QString& fname);
|
||||
|
||||
void avInvite(int friendId, int callIndex, bool video);
|
||||
void avStart(int friendId, int callIndex, bool video);
|
||||
void avCancel(int friendId, int callIndex);
|
||||
void avEnd(int friendId, int callIndex);
|
||||
void avRinging(int friendId, int callIndex, bool video);
|
||||
void avStarting(int friendId, int callIndex, bool video);
|
||||
void avEnding(int friendId, int callIndex);
|
||||
void avRequestTimeout(int friendId, int callIndex);
|
||||
void avPeerTimeout(int friendId, int callIndex);
|
||||
void avMediaChange(int friendId, int callIndex, bool videoEnabled);
|
||||
void avCallFailed(int friendId);
|
||||
void avRejected(int friendId, int callIndex);
|
||||
void avInvite(uint32_t friendId, int callIndex, bool video);
|
||||
void avStart(uint32_t friendId, int callIndex, bool video);
|
||||
void avCancel(uint32_t friendId, int callIndex);
|
||||
void avEnd(uint32_t friendId, int callIndex);
|
||||
void avRinging(uint32_t friendId, int callIndex, bool video);
|
||||
void avStarting(uint32_t friendId, int callIndex, bool video);
|
||||
void avEnding(uint32_t friendId, int callIndex);
|
||||
void avRequestTimeout(uint32_t friendId, int callIndex);
|
||||
void avPeerTimeout(uint32_t friendId, int callIndex);
|
||||
void avMediaChange(uint32_t friendId, int callIndex, bool videoEnabled);
|
||||
void avCallFailed(uint32_t friendId);
|
||||
void avRejected(uint32_t friendId, int callIndex);
|
||||
|
||||
void videoFrameReceived(vpx_image* frame);
|
||||
|
||||
private:
|
||||
static void onFriendRequest(Tox* tox, const uint8_t* cUserId, const uint8_t* cMessage, uint16_t cMessageSize, void* core);
|
||||
static void onFriendMessage(Tox* tox, int friendId, const uint8_t* cMessage, uint16_t cMessageSize, void* core);
|
||||
static void onFriendNameChange(Tox* tox, int friendId, const uint8_t* cName, uint16_t cNameSize, void* core);
|
||||
static void onFriendTypingChange(Tox* tox, int friendId, uint8_t isTyping, void* core);
|
||||
static void onStatusMessageChanged(Tox* tox, int friendId, const uint8_t* cMessage, uint16_t cMessageSize, void* core);
|
||||
static void onUserStatusChanged(Tox* tox, int friendId, uint8_t userstatus, void* core);
|
||||
static void onConnectionStatusChanged(Tox* tox, int friendId, uint8_t status, void* core);
|
||||
static void onAction(Tox* tox, int friendId, const uint8_t* cMessage, uint16_t cMessageSize, void* core);
|
||||
static void onFriendRequest(Tox* tox, const uint8_t* cUserId, const uint8_t* cMessage, size_t cMessageSize, void* core);
|
||||
static void onFriendMessage(Tox* tox, uint32_t friendId, TOX_MESSAGE_TYPE type, const uint8_t* cMessage, size_t cMessageSize, void* core);
|
||||
static void onFriendNameChange(Tox* tox, uint32_t friendId, const uint8_t* cName, size_t cNameSize, void* core);
|
||||
static void onFriendTypingChange(Tox* tox, uint32_t friendId, bool isTyping, void* core);
|
||||
static void onStatusMessageChanged(Tox* tox, uint32_t friendId, const uint8_t* cMessage, size_t cMessageSize, void* core);
|
||||
static void onUserStatusChanged(Tox* tox, uint32_t friendId, TOX_USER_STATUS userstatus, void* core);
|
||||
static void onConnectionStatusChanged(Tox* tox, uint32_t friendId, TOX_CONNECTION status, void* core);
|
||||
static void onGroupAction(Tox* tox, int groupnumber, int peernumber, const uint8_t * action, uint16_t length, void* core);
|
||||
static void onGroupInvite(Tox *tox, int friendnumber, uint8_t type, const uint8_t *data, uint16_t length,void *userdata);
|
||||
static void onGroupInvite(Tox *tox, int32_t friendNumber, uint8_t type, const uint8_t *data, uint16_t length, void *userdata);
|
||||
static void onGroupMessage(Tox *tox, int groupnumber, int friendgroupnumber, const uint8_t * message, uint16_t length, void *userdata);
|
||||
static void onGroupNamelistChange(Tox *tox, int groupnumber, int peernumber, uint8_t change, void *userdata);
|
||||
static void onGroupTitleChange(Tox*, int groupnumber, int peernumber, const uint8_t* title, uint8_t len, void* _core);
|
||||
static void onFileSendRequestCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize,
|
||||
static void onFileSendRequestCallback(Tox *tox, uint32_t friendnumber, uint8_t filenumber, uint64_t filesize,
|
||||
const uint8_t *filename, uint16_t filename_length, void *userdata);
|
||||
static void onFileControlCallback(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
|
||||
static void onFileControlCallback(Tox *tox, uint32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
|
||||
uint8_t control_type, const uint8_t *data, uint16_t length, void *core);
|
||||
static void onFileDataCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length, void *userdata);
|
||||
static void onAvatarInfoCallback(Tox* tox, int32_t friendnumber, uint8_t format, uint8_t *hash, void *userdata);
|
||||
static void onAvatarDataCallback(Tox* tox, int32_t friendnumber, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t datalen, void *userdata);
|
||||
static void onReadReceiptCallback(Tox *tox, int32_t friendnumber, uint32_t receipt, void *core);
|
||||
static void onFileDataCallback(Tox *tox, uint32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length, void *userdata);
|
||||
static void onAvatarInfoCallback(Tox* tox, uint32_t friendnumber, uint8_t format, uint8_t *hash, void *userdata);
|
||||
static void onAvatarDataCallback(Tox* tox, uint32_t friendnumber, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t datalen, void *userdata);
|
||||
static void onReadReceiptCallback(Tox *tox, uint32_t friendnumber, uint32_t receipt, void *core);
|
||||
|
||||
static void onAvInvite(void* toxav, int32_t call_index, void* core);
|
||||
static void onAvStart(void* toxav, int32_t call_index, void* core);
|
||||
|
@ -259,7 +259,7 @@ private:
|
|||
|
||||
static void sendGroupCallAudio(int groupId, ToxAv* toxav);
|
||||
|
||||
static void prepareCall(int friendId, int callId, ToxAv *toxav, bool videoEnabled);
|
||||
static void prepareCall(uint32_t friendId, int callId, ToxAv *toxav, bool videoEnabled);
|
||||
static void cleanupCall(int callId);
|
||||
static void playCallAudio(void *toxav, int32_t callId, const int16_t *data, uint16_t samples, void *user_data); // Callback
|
||||
static void sendCallAudio(int callId, ToxAv* toxav);
|
||||
|
@ -269,16 +269,16 @@ private:
|
|||
|
||||
bool checkConnection();
|
||||
|
||||
bool loadConfiguration(QString path); // Returns false for a critical error, true otherwise
|
||||
QByteArray loadToxSave(QString path);
|
||||
bool loadEncryptedSave(QByteArray& data);
|
||||
void checkEncryptedHistory();
|
||||
void make_tox();
|
||||
void make_tox(QByteArray savedata);
|
||||
void loadFriends();
|
||||
|
||||
static void sendAllFileData(Core* core, ToxFile* file);
|
||||
static void removeFileFromQueue(bool sendQueue, int friendId, int fileId);
|
||||
static void removeFileFromQueue(bool sendQueue, uint32_t friendId, uint32_t fileId);
|
||||
|
||||
void checkLastOnline(int friendId);
|
||||
void checkLastOnline(uint32_t friendId);
|
||||
|
||||
void deadifyTox();
|
||||
|
||||
|
@ -302,14 +302,14 @@ private:
|
|||
QMutex fileSendMutex, messageSendMutex;
|
||||
bool ready;
|
||||
|
||||
uint8_t* pwsaltedkeys[PasswordType::ptCounter] = {nullptr}; // use the pw's hash as the "pw"
|
||||
TOX_PASS_KEY* pwsaltedkeys[PasswordType::ptCounter] = {nullptr}; // use the pw's hash as the "pw"
|
||||
|
||||
// Hack for reloading current profile if switching to an encrypted one fails.
|
||||
// Testing the passwords before killing the current profile is perfectly doable,
|
||||
// however it would require major refactoring;
|
||||
// the Core class as a whole also requires major refactoring (especially to support multiple IDs at once),
|
||||
// so I'm punting on this until then, when it would get fixed anyways
|
||||
uint8_t* backupkeys[PasswordType::ptCounter] = {nullptr};
|
||||
TOX_PASS_KEY* backupkeys[PasswordType::ptCounter] = {nullptr};
|
||||
QString* backupProfile = nullptr;
|
||||
void saveCurrentInformation();
|
||||
QString loadOldInformation();
|
||||
|
|
|
@ -39,7 +39,7 @@ bool Core::anyActiveCalls()
|
|||
return false;
|
||||
}
|
||||
|
||||
void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled)
|
||||
void Core::prepareCall(uint32_t friendId, int32_t callId, ToxAv* toxav, bool videoEnabled)
|
||||
{
|
||||
qDebug() << QString("Core: preparing call %1").arg(callId);
|
||||
calls[callId].callId = callId;
|
||||
|
@ -120,9 +120,9 @@ fail: // Centralized error handling
|
|||
return;
|
||||
}
|
||||
|
||||
void Core::answerCall(int callId)
|
||||
void Core::answerCall(int32_t callId)
|
||||
{
|
||||
int friendId = toxav_get_peer_id(toxav, callId, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, callId, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV answer peer ID";
|
||||
|
@ -152,23 +152,23 @@ void Core::answerCall(int callId)
|
|||
delete transSettings;
|
||||
}
|
||||
|
||||
void Core::hangupCall(int callId)
|
||||
void Core::hangupCall(int32_t callId)
|
||||
{
|
||||
qDebug() << QString("Core: hanging up call %1").arg(callId);
|
||||
calls[callId].active = false;
|
||||
toxav_hangup(toxav, callId);
|
||||
}
|
||||
|
||||
void Core::rejectCall(int callId)
|
||||
void Core::rejectCall(int32_t callId)
|
||||
{
|
||||
qDebug() << QString("Core: rejecting call %1").arg(callId);
|
||||
calls[callId].active = false;
|
||||
toxav_reject(toxav, callId, nullptr);
|
||||
}
|
||||
|
||||
void Core::startCall(int friendId, bool video)
|
||||
void Core::startCall(uint32_t friendId, bool video)
|
||||
{
|
||||
int callId;
|
||||
int32_t callId;
|
||||
ToxAvCSettings cSettings = av_DefaultSettings;
|
||||
cSettings.max_video_width = TOXAV_MAX_VIDEO_WIDTH;
|
||||
cSettings.max_video_height = TOXAV_MAX_VIDEO_HEIGHT;
|
||||
|
@ -204,14 +204,14 @@ void Core::startCall(int friendId, bool video)
|
|||
}
|
||||
}
|
||||
|
||||
void Core::cancelCall(int callId, int friendId)
|
||||
void Core::cancelCall(int32_t callId, uint32_t friendId)
|
||||
{
|
||||
qDebug() << QString("Core: Cancelling call with %1").arg(friendId);
|
||||
calls[callId].active = false;
|
||||
toxav_cancel(toxav, callId, friendId, nullptr);
|
||||
}
|
||||
|
||||
void Core::cleanupCall(int callId)
|
||||
void Core::cleanupCall(int32_t callId)
|
||||
{
|
||||
qDebug() << QString("Core: cleaning up call %1").arg(callId);
|
||||
calls[callId].active = false;
|
||||
|
@ -239,7 +239,7 @@ void Core::playCallAudio(void* toxav, int32_t callId, const int16_t *data, uint1
|
|||
playAudioBuffer(calls[callId].alSource, data, samples, dest.audio_channels, dest.audio_sample_rate);
|
||||
}
|
||||
|
||||
void Core::sendCallAudio(int callId, ToxAv* toxav)
|
||||
void Core::sendCallAudio(int32_t callId, ToxAv* toxav)
|
||||
{
|
||||
if (!calls[callId].active)
|
||||
return;
|
||||
|
@ -303,7 +303,7 @@ void Core::playCallVideo(void*, int32_t callId, const vpx_image_t* img, void *us
|
|||
calls[callId].videoSource.pushVPXFrame(img);
|
||||
}
|
||||
|
||||
void Core::sendCallVideo(int callId)
|
||||
void Core::sendCallVideo(int32_t callId)
|
||||
{
|
||||
if (!calls[callId].active || !calls[callId].videoEnabled)
|
||||
return;
|
||||
|
@ -333,7 +333,7 @@ void Core::sendCallVideo(int callId)
|
|||
calls[callId].sendVideoTimer->start();
|
||||
}
|
||||
|
||||
void Core::micMuteToggle(int callId)
|
||||
void Core::micMuteToggle(int32_t callId)
|
||||
{
|
||||
if (calls[callId].active)
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ void Core::micMuteToggle(int callId)
|
|||
}
|
||||
}
|
||||
|
||||
void Core::volMuteToggle(int callId)
|
||||
void Core::volMuteToggle(int32_t callId)
|
||||
{
|
||||
if (calls[callId].active)
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ void Core::onAvCancel(void* _toxav, int32_t callId, void* core)
|
|||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
|
||||
int friendId = toxav_get_peer_id(toxav, callId, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, callId, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV cancel";
|
||||
|
@ -379,7 +379,7 @@ void Core::onAvCancel(void* _toxav, int32_t callId, void* core)
|
|||
void Core::onAvReject(void* _toxav, int32_t callId, void* core)
|
||||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
int friendId = toxav_get_peer_id(toxav, callId, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, callId, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV reject";
|
||||
|
@ -395,7 +395,7 @@ void Core::onAvEnd(void* _toxav, int32_t call_index, void* core)
|
|||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
|
||||
int friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV end";
|
||||
|
@ -412,7 +412,7 @@ void Core::onAvRinging(void* _toxav, int32_t call_index, void* core)
|
|||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
|
||||
int friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV ringing";
|
||||
|
@ -435,7 +435,7 @@ void Core::onAvRequestTimeout(void* _toxav, int32_t call_index, void* core)
|
|||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
|
||||
int friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV request timeout";
|
||||
|
@ -452,7 +452,7 @@ void Core::onAvPeerTimeout(void* _toxav, int32_t call_index, void* core)
|
|||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
|
||||
int friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV peer timeout";
|
||||
|
@ -470,7 +470,7 @@ void Core::onAvInvite(void* _toxav, int32_t call_index, void* core)
|
|||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
|
||||
int friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV invite";
|
||||
|
@ -504,7 +504,7 @@ void Core::onAvStart(void* _toxav, int32_t call_index, void* core)
|
|||
{
|
||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||
|
||||
int friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
uint32_t friendId = toxav_get_peer_id(toxav, call_index, 0);
|
||||
if (friendId < 0)
|
||||
{
|
||||
qWarning() << "Core: Received invalid AV start";
|
||||
|
|
|
@ -19,8 +19,8 @@ struct ToxCall
|
|||
{
|
||||
ToxAvCSettings codecSettings;
|
||||
QTimer *sendAudioTimer, *sendVideoTimer;
|
||||
int callId;
|
||||
int friendId;
|
||||
int32_t callId;
|
||||
uint32_t friendId;
|
||||
bool videoEnabled;
|
||||
bool active;
|
||||
bool muteMic;
|
||||
|
|
|
@ -20,17 +20,18 @@
|
|||
|
||||
#include "core.h"
|
||||
#include "src/widget/gui.h"
|
||||
#include <tox/tox.h>
|
||||
#include <tox/toxencryptsave.h>
|
||||
#include "src/misc/settings.h"
|
||||
#include "misc/cstring.h"
|
||||
#include "historykeeper.h"
|
||||
#include <tox/tox.h>
|
||||
#include <tox/toxencryptsave.h>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSaveFile>
|
||||
#include <QFile>
|
||||
#include <QThread>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
void Core::setPassword(QString& password, PasswordType passtype, uint8_t* salt)
|
||||
{
|
||||
|
@ -38,26 +39,25 @@ void Core::setPassword(QString& password, PasswordType passtype, uint8_t* salt)
|
|||
if (password.isEmpty())
|
||||
return;
|
||||
|
||||
pwsaltedkeys[passtype] = new uint8_t[tox_pass_key_length()];
|
||||
pwsaltedkeys[passtype] = new TOX_PASS_KEY;
|
||||
|
||||
CString str(password);
|
||||
if (salt)
|
||||
tox_derive_key_with_salt(str.data(), str.size(), salt, pwsaltedkeys[passtype]);
|
||||
tox_derive_key_with_salt(str.data(), str.size(), salt, pwsaltedkeys[passtype], nullptr);
|
||||
else
|
||||
tox_derive_key_from_pass(str.data(), str.size(), pwsaltedkeys[passtype]);
|
||||
tox_derive_key_from_pass(str.data(), str.size(), pwsaltedkeys[passtype], nullptr);
|
||||
|
||||
password.clear();
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
void Core::useOtherPassword(PasswordType type)
|
||||
{
|
||||
clearPassword(type);
|
||||
pwsaltedkeys[type] = new uint8_t[tox_pass_key_length()];
|
||||
pwsaltedkeys[type] = new TOX_PASS_KEY;
|
||||
|
||||
PasswordType other = (type == ptMain) ? ptHistory : ptMain;
|
||||
|
||||
std::copy(pwsaltedkeys[other], pwsaltedkeys[other]+tox_pass_key_length(), pwsaltedkeys[type]);
|
||||
std::copy(pwsaltedkeys[other], pwsaltedkeys[other]+TOX_PASS_KEY_LENGTH, pwsaltedkeys[type]);
|
||||
}
|
||||
|
||||
void Core::clearPassword(PasswordType passtype)
|
||||
|
@ -71,13 +71,13 @@ void Core::saveCurrentInformation()
|
|||
{
|
||||
if (pwsaltedkeys[ptMain])
|
||||
{
|
||||
backupkeys[ptMain] = new uint8_t[tox_pass_key_length()];
|
||||
std::copy(pwsaltedkeys[ptMain], pwsaltedkeys[ptMain]+tox_pass_key_length(), backupkeys[ptMain]);
|
||||
backupkeys[ptMain] = new TOX_PASS_KEY;
|
||||
std::copy(pwsaltedkeys[ptMain], pwsaltedkeys[ptMain]+TOX_PASS_KEY_LENGTH, backupkeys[ptMain]);
|
||||
}
|
||||
if (pwsaltedkeys[ptHistory])
|
||||
{
|
||||
backupkeys[ptHistory] = new uint8_t[tox_pass_key_length()];
|
||||
std::copy(pwsaltedkeys[ptHistory], pwsaltedkeys[ptHistory]+tox_pass_key_length(), backupkeys[ptHistory]);
|
||||
backupkeys[ptHistory] = new TOX_PASS_KEY;
|
||||
std::copy(pwsaltedkeys[ptHistory], pwsaltedkeys[ptHistory]+TOX_PASS_KEY_LENGTH, backupkeys[ptHistory]);
|
||||
}
|
||||
backupProfile = new QString(Settings::getInstance().getCurrentProfile());
|
||||
}
|
||||
|
@ -107,23 +107,24 @@ QByteArray Core::encryptData(const QByteArray& data, PasswordType passtype)
|
|||
{
|
||||
if (!pwsaltedkeys[passtype])
|
||||
return QByteArray();
|
||||
uint8_t encrypted[data.size() + tox_pass_encryption_extra_length()];
|
||||
if (tox_pass_key_encrypt(reinterpret_cast<const uint8_t*>(data.data()), data.size(), pwsaltedkeys[passtype], encrypted) == -1)
|
||||
uint8_t encrypted[data.size() + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
if (!tox_pass_key_encrypt(reinterpret_cast<const uint8_t*>(data.data()), data.size(),
|
||||
pwsaltedkeys[passtype], encrypted, nullptr))
|
||||
{
|
||||
qWarning() << "Core::encryptData: encryption failed";
|
||||
return QByteArray();
|
||||
}
|
||||
return QByteArray(reinterpret_cast<char*>(encrypted), data.size() + tox_pass_encryption_extra_length());
|
||||
return QByteArray(reinterpret_cast<char*>(encrypted), data.size() + TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
|
||||
}
|
||||
|
||||
QByteArray Core::decryptData(const QByteArray& data, PasswordType passtype)
|
||||
{
|
||||
if (!pwsaltedkeys[passtype])
|
||||
return QByteArray();
|
||||
int sz = data.size() - tox_pass_encryption_extra_length();
|
||||
int sz = data.size() - TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
|
||||
uint8_t decrypted[sz];
|
||||
int decr_size = tox_pass_key_decrypt(reinterpret_cast<const uint8_t*>(data.data()), data.size(), pwsaltedkeys[passtype], decrypted);
|
||||
if (decr_size != sz)
|
||||
if (!tox_pass_key_decrypt(reinterpret_cast<const uint8_t*>(data.data()), data.size(),
|
||||
pwsaltedkeys[passtype], decrypted, nullptr))
|
||||
{
|
||||
qWarning() << "Core::decryptData: decryption failed";
|
||||
return QByteArray();
|
||||
|
@ -147,10 +148,10 @@ QByteArray Core::getSaltFromFile(QString filename)
|
|||
qWarning() << "Core: file" << filename << "doesn't exist";
|
||||
return QByteArray();
|
||||
}
|
||||
QByteArray data = file.read(tox_pass_encryption_extra_length());
|
||||
QByteArray data = file.read(TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
|
||||
file.close();
|
||||
|
||||
uint8_t *salt = new uint8_t[tox_pass_salt_length()];
|
||||
uint8_t *salt = new uint8_t[TOX_PASS_SALT_LENGTH];
|
||||
int err = tox_get_salt(reinterpret_cast<uint8_t *>(data.data()), salt);
|
||||
if (err)
|
||||
{
|
||||
|
@ -158,13 +159,15 @@ QByteArray Core::getSaltFromFile(QString filename)
|
|||
return QByteArray();
|
||||
}
|
||||
|
||||
QByteArray res = QByteArray::fromRawData(reinterpret_cast<const char*>(salt), tox_pass_salt_length());
|
||||
QByteArray res = QByteArray::fromRawData(reinterpret_cast<const char*>(salt), TOX_PASS_SALT_LENGTH);
|
||||
delete[] salt;
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Core::loadEncryptedSave(QByteArray& data)
|
||||
{
|
||||
assert(0);
|
||||
/*
|
||||
if (!Settings::getInstance().getEncryptTox())
|
||||
GUI::showWarning(tr("Encryption error"), tr("The .tox file is encrypted, but encryption was not checked, continuing regardless."));
|
||||
|
||||
|
@ -186,7 +189,7 @@ bool Core::loadEncryptedSave(QByteArray& data)
|
|||
else
|
||||
dialogtxt = a;
|
||||
|
||||
uint8_t salt[tox_pass_salt_length()];
|
||||
uint8_t salt[TOX_PASS_SALT_LENGTH];
|
||||
tox_get_salt(reinterpret_cast<uint8_t *>(data.data()), salt);
|
||||
|
||||
do
|
||||
|
@ -207,6 +210,7 @@ bool Core::loadEncryptedSave(QByteArray& data)
|
|||
|
||||
Settings::getInstance().setEncryptTox(true);
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
void Core::checkEncryptedHistory()
|
||||
|
@ -290,11 +294,15 @@ void Core::saveConfiguration(const QString& path)
|
|||
|
||||
qDebug() << "Core: writing tox_save to " << path;
|
||||
|
||||
uint32_t fileSize; bool encrypt = Settings::getInstance().getEncryptTox();
|
||||
uint32_t fileSize;
|
||||
bool encrypt = Settings::getInstance().getEncryptTox();
|
||||
if (encrypt)
|
||||
fileSize = tox_encrypted_size(tox);
|
||||
{
|
||||
qCritical() << "Encrypted saving not implemented!";
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
fileSize = tox_size(tox);
|
||||
fileSize = tox_get_savedata_size(tox);
|
||||
|
||||
if (fileSize > 0 && fileSize <= std::numeric_limits<int32_t>::max()) {
|
||||
uint8_t *data = new uint8_t[fileSize];
|
||||
|
@ -306,20 +314,24 @@ void Core::saveConfiguration(const QString& path)
|
|||
// probably zero chance event
|
||||
GUI::showWarning(tr("NO Password"), tr("Local file encryption is enabled, but there is no password! It will be disabled."));
|
||||
Settings::getInstance().setEncryptTox(false);
|
||||
tox_save(tox, data);
|
||||
tox_get_savedata(tox, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Encryption not implemented";
|
||||
exit(-1);
|
||||
/*
|
||||
int ret = tox_encrypted_key_save(tox, data, pwsaltedkeys[ptMain]);
|
||||
if (ret == -1)
|
||||
{
|
||||
qCritical() << "Core::saveConfiguration: encryption of save file failed!!!";
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
else
|
||||
tox_save(tox, data);
|
||||
tox_get_savedata(tox, data);
|
||||
|
||||
configurationFile.write(reinterpret_cast<char *>(data), fileSize);
|
||||
configurationFile.commit();
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include <QFile>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#define TOX_ID_LENGTH 2*TOX_FRIEND_ADDRESS_SIZE
|
||||
#define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE
|
||||
|
||||
ToxFile::ToxFile(int FileNum, int FriendId, QByteArray FileName, QString FilePath, FileDirection Direction)
|
||||
ToxFile::ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction)
|
||||
: fileNum(FileNum), friendId(FriendId), fileName{FileName}, filePath{FilePath}, file{new QFile(filePath)},
|
||||
bytesSent{0}, filesize{0}, status{STOPPED}, direction{Direction}, sendTimer{nullptr}
|
||||
{
|
||||
|
@ -78,5 +78,5 @@ void ToxID::clear()
|
|||
bool ToxID::isToxId(const QString& value)
|
||||
{
|
||||
const QRegularExpression hexRegExp("^[A-Fa-f0-9]+$");
|
||||
return value.length() == TOX_ID_LENGTH && value.contains(hexRegExp);
|
||||
return value.length() == TOX_HEX_ID_LENGTH && value.contains(hexRegExp);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ struct ToxFile
|
|||
};
|
||||
|
||||
ToxFile()=default;
|
||||
ToxFile(int FileNum, int FriendId, QByteArray FileName, QString FilePath, FileDirection Direction);
|
||||
ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction);
|
||||
~ToxFile(){}
|
||||
|
||||
bool operator==(const ToxFile& other) const;
|
||||
|
@ -67,8 +67,8 @@ struct ToxFile
|
|||
void setFilePath(QString path);
|
||||
bool open(bool write);
|
||||
|
||||
int fileNum;
|
||||
int friendId;
|
||||
uint32_t fileNum;
|
||||
uint32_t friendId;
|
||||
QByteArray fileName;
|
||||
QString filePath;
|
||||
QFile* file;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "src/core.h"
|
||||
#include "src/misc/settings.h"
|
||||
|
||||
Friend::Friend(int FriendId, const ToxID &UserId)
|
||||
Friend::Friend(uint32_t FriendId, const ToxID &UserId)
|
||||
: userName{Core::getInstance()->getPeerName(UserId)},
|
||||
userID{UserId}, friendId{FriendId}
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ const ToxID &Friend::getToxID() const
|
|||
return userID;
|
||||
}
|
||||
|
||||
int Friend::getFriendID() const
|
||||
uint32_t Friend::getFriendID() const
|
||||
{
|
||||
return friendId;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class Friend : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Friend(int FriendId, const ToxID &UserId);
|
||||
Friend(uint32_t FriendId, const ToxID &UserId);
|
||||
Friend(const Friend& other)=delete;
|
||||
~Friend();
|
||||
Friend& operator=(const Friend& other)=delete;
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
int getEventFlag() const;
|
||||
|
||||
const ToxID &getToxID() const;
|
||||
int getFriendID() const;
|
||||
uint32_t getFriendID() const;
|
||||
|
||||
void setStatus(Status s);
|
||||
Status getStatus() const;
|
||||
|
@ -57,7 +57,7 @@ signals:
|
|||
private:
|
||||
QString userAlias, userName;
|
||||
ToxID userID;
|
||||
int friendId;
|
||||
uint32_t friendId;
|
||||
int hasNewEvents;
|
||||
Status friendStatus;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
template <class T> class QList;
|
||||
template <class A, class B> class QHash;
|
||||
struct Friend;
|
||||
class Friend;
|
||||
class QString;
|
||||
struct ToxID;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#define RETRY_PEER_INFO_INTERVAL 500
|
||||
|
||||
struct Friend;
|
||||
class Friend;
|
||||
class GroupWidget;
|
||||
class GroupChatForm;
|
||||
struct ToxID;
|
||||
|
|
|
@ -72,7 +72,7 @@ QString CUserId::toString(const uint8_t* cUserId)
|
|||
|
||||
// CFriendAddress
|
||||
|
||||
const uint16_t CFriendAddress::SIZE{TOX_FRIEND_ADDRESS_SIZE};
|
||||
const uint16_t CFriendAddress::SIZE{TOX_ADDRESS_SIZE};
|
||||
|
||||
CFriendAddress::CFriendAddress(const QString &friendAddress) :
|
||||
CData(friendAddress, SIZE)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <QSqlError>
|
||||
|
||||
qint64 EncryptedDb::encryptedChunkSize = 4096;
|
||||
qint64 EncryptedDb::plainChunkSize = EncryptedDb::encryptedChunkSize - tox_pass_encryption_extra_length();
|
||||
qint64 EncryptedDb::plainChunkSize = EncryptedDb::encryptedChunkSize - TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
|
||||
|
||||
EncryptedDb::EncryptedDb(const QString &fname, QList<QString> initList) :
|
||||
PlainDb(":memory:", initList), fileName(fname)
|
||||
|
|
|
@ -47,6 +47,7 @@ void Nexus::start()
|
|||
qRegisterMetaType<vpx_image>("vpx_image");
|
||||
qRegisterMetaType<uint8_t>("uint8_t");
|
||||
qRegisterMetaType<uint16_t>("uint16_t");
|
||||
qRegisterMetaType<uint32_t>("uint32_t");
|
||||
qRegisterMetaType<const int16_t*>("const int16_t*");
|
||||
qRegisterMetaType<int32_t>("int32_t");
|
||||
qRegisterMetaType<int64_t>("int64_t");
|
||||
|
@ -119,8 +120,8 @@ void Nexus::start()
|
|||
connect(core, &Core::blockingClearContacts, widget, &Widget::clearContactsList, Qt::BlockingQueuedConnection);
|
||||
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
|
||||
|
||||
connect(core, SIGNAL(messageSentResult(int,QString,int)), widget, SLOT(onMessageSendResult(int,QString,int)));
|
||||
connect(core, SIGNAL(groupSentResult(int,QString,int)), widget, SLOT(onGroupSendResult(int,QString,int)));
|
||||
connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult);
|
||||
connect(core, &Core::groupSentResult, widget, &Widget::onGroupSendResult);
|
||||
|
||||
connect(widget, &Widget::statusSet, core, &Core::setStatus);
|
||||
connect(widget, &Widget::friendRequested, core, &Core::requestFriendship);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <QMap>
|
||||
#include "src/chatlog/chatmessage.h"
|
||||
|
||||
struct Friend;
|
||||
class Friend;
|
||||
class QTimer;
|
||||
|
||||
class OfflineMsgEngine : public QObject
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <tox/tox.h>
|
||||
#include <tox/toxdns.h>
|
||||
|
||||
#define TOX_ID_LENGTH 2*TOX_FRIEND_ADDRESS_SIZE
|
||||
#define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE
|
||||
|
||||
const ToxDNS::tox3_server ToxDNS::pinnedServers[]
|
||||
{
|
||||
|
@ -128,13 +128,13 @@ QString ToxDNS::queryTox1(const QString& record, bool silent)
|
|||
}
|
||||
|
||||
idx += 3;
|
||||
if (entry.length() < idx + static_cast<int>(TOX_ID_LENGTH)) {
|
||||
if (entry.length() < idx + static_cast<int>(TOX_HEX_ID_LENGTH)) {
|
||||
if (!silent)
|
||||
showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS"));
|
||||
return toxId;
|
||||
}
|
||||
|
||||
toxId = entry.mid(idx, TOX_ID_LENGTH);
|
||||
toxId = entry.mid(idx, TOX_HEX_ID_LENGTH);
|
||||
if (!ToxID::isToxId(toxId)) {
|
||||
if (!silent)
|
||||
showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS"));
|
||||
|
@ -201,7 +201,7 @@ QString ToxDNS::queryTox3(const tox3_server& server, const QString &record, bool
|
|||
|
||||
idx += 3;
|
||||
id = entry.mid(idx).toUtf8();
|
||||
uint8_t toxId[TOX_FRIEND_ADDRESS_SIZE];
|
||||
uint8_t toxId[TOX_ADDRESS_SIZE];
|
||||
toxIdSize = tox_decrypt_dns3_TXT(tox_dns3, toxId, (uint8_t*)id.data(), id.size(), request_id);
|
||||
if (toxIdSize < 0) // We can always fallback on tox1 if toxdns3 fails
|
||||
{
|
||||
|
|
|
@ -254,7 +254,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
|||
}
|
||||
}
|
||||
|
||||
void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
||||
void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -306,7 +306,7 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
|||
}
|
||||
}
|
||||
|
||||
void ChatForm::onAvStart(int FriendId, int CallId, bool video)
|
||||
void ChatForm::onAvStart(uint32_t FriendId, int CallId, bool video)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -357,7 +357,7 @@ void ChatForm::onAvStart(int FriendId, int CallId, bool video)
|
|||
startCounter();
|
||||
}
|
||||
|
||||
void ChatForm::onAvCancel(int FriendId, int)
|
||||
void ChatForm::onAvCancel(uint32_t FriendId, int)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -375,7 +375,7 @@ void ChatForm::onAvCancel(int FriendId, int)
|
|||
addSystemInfoMessage(tr("%1 stopped calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
void ChatForm::onAvEnd(int FriendId, int)
|
||||
void ChatForm::onAvEnd(uint32_t FriendId, int)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -390,7 +390,7 @@ void ChatForm::onAvEnd(int FriendId, int)
|
|||
netcam->hide();
|
||||
}
|
||||
|
||||
void ChatForm::onAvRinging(int FriendId, int CallId, bool video)
|
||||
void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -426,7 +426,7 @@ void ChatForm::onAvRinging(int FriendId, int CallId, bool video)
|
|||
addSystemInfoMessage(tr("Calling to %1").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
void ChatForm::onAvStarting(int FriendId, int CallId, bool video)
|
||||
void ChatForm::onAvStarting(uint32_t FriendId, int CallId, bool video)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -461,7 +461,7 @@ void ChatForm::onAvStarting(int FriendId, int CallId, bool video)
|
|||
startCounter();
|
||||
}
|
||||
|
||||
void ChatForm::onAvEnding(int FriendId, int)
|
||||
void ChatForm::onAvEnding(uint32_t FriendId, int)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -477,7 +477,7 @@ void ChatForm::onAvEnding(int FriendId, int)
|
|||
netcam->hide();
|
||||
}
|
||||
|
||||
void ChatForm::onAvRequestTimeout(int FriendId, int)
|
||||
void ChatForm::onAvRequestTimeout(uint32_t FriendId, int)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -493,7 +493,7 @@ void ChatForm::onAvRequestTimeout(int FriendId, int)
|
|||
netcam->hide();
|
||||
}
|
||||
|
||||
void ChatForm::onAvPeerTimeout(int FriendId, int)
|
||||
void ChatForm::onAvPeerTimeout(uint32_t FriendId, int)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -509,7 +509,7 @@ void ChatForm::onAvPeerTimeout(int FriendId, int)
|
|||
netcam->hide();
|
||||
}
|
||||
|
||||
void ChatForm::onAvRejected(int FriendId, int)
|
||||
void ChatForm::onAvRejected(uint32_t FriendId, int)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -526,7 +526,7 @@ void ChatForm::onAvRejected(int FriendId, int)
|
|||
netcam->hide();
|
||||
}
|
||||
|
||||
void ChatForm::onAvMediaChange(int FriendId, int CallId, bool video)
|
||||
void ChatForm::onAvMediaChange(uint32_t FriendId, int CallId, bool video)
|
||||
{
|
||||
if (FriendId != f->getFriendID() || CallId != callId)
|
||||
return;
|
||||
|
@ -601,7 +601,7 @@ void ChatForm::onCallTriggered()
|
|||
audioOutputFlag = true;
|
||||
callButton->disconnect();
|
||||
videoButton->disconnect();
|
||||
emit startCall(f->getFriendID());
|
||||
emit startCall(f->getFriendID(), false);
|
||||
}
|
||||
|
||||
void ChatForm::onVideoCallTriggered()
|
||||
|
@ -612,10 +612,10 @@ void ChatForm::onVideoCallTriggered()
|
|||
audioOutputFlag = true;
|
||||
callButton->disconnect();
|
||||
videoButton->disconnect();
|
||||
emit startVideoCall(f->getFriendID(), true);
|
||||
emit startCall(f->getFriendID(), true);
|
||||
}
|
||||
|
||||
void ChatForm::onAvCallFailed(int FriendId)
|
||||
void ChatForm::onAvCallFailed(uint32_t FriendId)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -737,7 +737,7 @@ void ChatForm::onVolMuteToggle()
|
|||
}
|
||||
}
|
||||
|
||||
void ChatForm::onFileSendFailed(int FriendId, const QString &fname)
|
||||
void ChatForm::onFileSendFailed(uint32_t FriendId, const QString &fname)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -745,7 +745,7 @@ void ChatForm::onFileSendFailed(int FriendId, const QString &fname)
|
|||
addSystemInfoMessage(tr("Failed to send file \"%1\"").arg(fname), ChatMessage::ERROR, QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
void ChatForm::onAvatarChange(int FriendId, const QPixmap &pic)
|
||||
void ChatForm::onAvatarChange(uint32_t FriendId, const QPixmap &pic)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
@ -787,7 +787,7 @@ void ChatForm::dropEvent(QDropEvent *ev)
|
|||
}
|
||||
}
|
||||
|
||||
void ChatForm::onAvatarRemoved(int FriendId)
|
||||
void ChatForm::onAvatarRemoved(uint32_t FriendId)
|
||||
{
|
||||
if (FriendId != f->getFriendID())
|
||||
return;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <QElapsedTimer>
|
||||
|
||||
|
||||
struct Friend;
|
||||
class Friend;
|
||||
class FileTransferInstance;
|
||||
class NetCamView;
|
||||
class QPixmap;
|
||||
|
@ -50,12 +50,11 @@ public:
|
|||
virtual void show(Ui::MainWindow &ui);
|
||||
|
||||
signals:
|
||||
void sendFile(int32_t friendId, QString, QString, long long);
|
||||
void startCall(int friendId);
|
||||
void startVideoCall(int friendId, bool video);
|
||||
void sendFile(uint32_t friendId, QString, QString, long long);
|
||||
void startCall(uint32_t FriendId, bool video);
|
||||
void answerCall(int callId);
|
||||
void hangupCall(int callId);
|
||||
void cancelCall(int callId, int friendId);
|
||||
void cancelCall(int callId, uint32_t FriendId);
|
||||
void rejectCall(int callId);
|
||||
void micMuteToggle(int callId);
|
||||
void volMuteToggle(int callId);
|
||||
|
@ -64,22 +63,22 @@ signals:
|
|||
public slots:
|
||||
void startFileSend(ToxFile file);
|
||||
void onFileRecvRequest(ToxFile file);
|
||||
void onAvInvite(int FriendId, int CallId, bool video);
|
||||
void onAvStart(int FriendId, int CallId, bool video);
|
||||
void onAvCancel(int FriendId, int CallId);
|
||||
void onAvEnd(int FriendId, int CallId);
|
||||
void onAvRinging(int FriendId, int CallId, bool video);
|
||||
void onAvStarting(int FriendId, int CallId, bool video);
|
||||
void onAvEnding(int FriendId, int CallId);
|
||||
void onAvRequestTimeout(int FriendId, int CallId);
|
||||
void onAvPeerTimeout(int FriendId, int CallId);
|
||||
void onAvMediaChange(int FriendId, int CallId, bool video);
|
||||
void onAvCallFailed(int FriendId);
|
||||
void onAvRejected(int FriendId, int CallId);
|
||||
void onAvInvite(uint32_t FriendId, int CallId, bool video);
|
||||
void onAvStart(uint32_t FriendId, int CallId, bool video);
|
||||
void onAvCancel(uint32_t FriendId, int CallId);
|
||||
void onAvEnd(uint32_t FriendId, int CallId);
|
||||
void onAvRinging(uint32_t FriendId, int CallId, bool video);
|
||||
void onAvStarting(uint32_t FriendId, int CallId, bool video);
|
||||
void onAvEnding(uint32_t FriendId, int CallId);
|
||||
void onAvRequestTimeout(uint32_t FriendId, int CallId);
|
||||
void onAvPeerTimeout(uint32_t FriendId, int CallId);
|
||||
void onAvMediaChange(uint32_t FriendId, int CallId, bool video);
|
||||
void onAvCallFailed(uint32_t FriendId);
|
||||
void onAvRejected(uint32_t FriendId, int CallId);
|
||||
void onMicMuteToggle();
|
||||
void onVolMuteToggle();
|
||||
void onAvatarChange(int FriendId, const QPixmap& pic);
|
||||
void onAvatarRemoved(int FriendId);
|
||||
void onAvatarChange(uint32_t FriendId, const QPixmap& pic);
|
||||
void onAvatarRemoved(uint32_t FriendId);
|
||||
|
||||
private slots:
|
||||
void onSendTriggered();
|
||||
|
@ -91,7 +90,7 @@ private slots:
|
|||
void onHangupCallTriggered();
|
||||
void onCancelCallTriggered();
|
||||
void onRejectCallTriggered();
|
||||
void onFileSendFailed(int FriendId, const QString &fname);
|
||||
void onFileSendFailed(uint32_t FriendId, const QString &fname);
|
||||
void onLoadHistory();
|
||||
void onUpdateTime();
|
||||
void onEnableCallButtons();
|
||||
|
|
|
@ -60,8 +60,8 @@ public:
|
|||
ChatLog* getChatLog() const;
|
||||
|
||||
signals:
|
||||
void sendMessage(int, QString);
|
||||
void sendAction(int, QString);
|
||||
void sendMessage(uint32_t, QString);
|
||||
void sendAction(uint32_t, QString);
|
||||
void chatAreaCleared();
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -214,22 +214,7 @@ void ProfileForm::onAvatarClicked()
|
|||
pic.save(&buffer, "PNG");
|
||||
buffer.close();
|
||||
|
||||
if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
|
||||
{
|
||||
pic = pic.scaled(64,64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
bytes.clear();
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
pic.save(&buffer, "PNG");
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
|
||||
{
|
||||
GUI::showError(tr("Error"), tr("This image is too big"));
|
||||
return;
|
||||
}
|
||||
|
||||
Nexus::getCore()->setAvatar(TOX_AVATAR_FORMAT_PNG, bytes);
|
||||
Nexus::getCore()->setAvatar(bytes);
|
||||
}
|
||||
|
||||
void ProfileForm::onLoadClicked()
|
||||
|
|
|
@ -87,7 +87,7 @@ void FriendListWidget::onGroupchatPositionChanged(bool top)
|
|||
}
|
||||
}
|
||||
|
||||
void FriendListWidget::moveWidget(QWidget *w, Status s, int hasNewEvents)
|
||||
void FriendListWidget::moveWidget(QWidget *w, Status s)
|
||||
{
|
||||
QVBoxLayout* l = getFriendLayout(s);
|
||||
l->removeWidget(w);
|
||||
|
|
|
@ -37,7 +37,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void onGroupchatPositionChanged(bool top);
|
||||
void moveWidget(QWidget *w, Status s, int hasNewEvents);
|
||||
void moveWidget(QWidget *w, Status s);
|
||||
|
||||
private:
|
||||
QHash<int, QVBoxLayout*> layouts;
|
||||
|
|
|
@ -580,7 +580,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
//qDebug() << "Widget: Adding friend with id" << userId;
|
||||
ToxID userToxId = ToxID::fromString(userId);
|
||||
Friend* newfriend = FriendList::addFriend(friendId, userToxId);
|
||||
contactListWidget->moveWidget(newfriend->getFriendWidget(),Status::Offline,0);
|
||||
contactListWidget->moveWidget(newfriend->getFriendWidget(),Status::Offline);
|
||||
|
||||
Core* core = Nexus::getCore();
|
||||
connect(newfriend, &Friend::displayedNameChanged, contactListWidget, &FriendListWidget::moveWidget);
|
||||
|
@ -589,17 +589,16 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
connect(newfriend->getFriendWidget(), SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
||||
connect(newfriend->getFriendWidget(), SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
|
||||
connect(newfriend->getFriendWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newfriend->getChatForm(), SLOT(focusInput()));
|
||||
connect(newfriend->getChatForm(), SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
|
||||
connect(newfriend->getChatForm(), &GenericChatForm::sendMessage, core, &Core::sendMessage);
|
||||
connect(newfriend->getChatForm(), &GenericChatForm::sendAction, core, &Core::sendAction);
|
||||
connect(newfriend->getChatForm(), SIGNAL(sendFile(int32_t, QString, QString, long long)), core, SLOT(sendFile(int32_t, QString, QString, long long)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(rejectCall(int)), core, SLOT(rejectCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(startCall(int)), core, SLOT(startCall(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(startVideoCall(int,bool)), core, SLOT(startCall(int,bool)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(micMuteToggle(int)), core, SLOT(micMuteToggle(int)));
|
||||
connect(newfriend->getChatForm(), SIGNAL(volMuteToggle(int)), core, SLOT(volMuteToggle(int)));
|
||||
connect(newfriend->getChatForm(), &ChatForm::sendFile, core, &Core::sendFile);
|
||||
connect(newfriend->getChatForm(), &ChatForm::answerCall, core, &Core::answerCall);
|
||||
connect(newfriend->getChatForm(), &ChatForm::hangupCall, core, &Core::hangupCall);
|
||||
connect(newfriend->getChatForm(), &ChatForm::rejectCall, core, &Core::rejectCall);
|
||||
connect(newfriend->getChatForm(), &ChatForm::startCall, core, &Core::startCall);
|
||||
connect(newfriend->getChatForm(), &ChatForm::cancelCall, core, &Core::cancelCall);
|
||||
connect(newfriend->getChatForm(), &ChatForm::micMuteToggle, core, &Core::micMuteToggle);
|
||||
connect(newfriend->getChatForm(), &ChatForm::volMuteToggle, core, &Core::volMuteToggle);
|
||||
connect(newfriend->getChatForm(), &ChatForm::aliasChanged, newfriend->getFriendWidget(), &FriendWidget::setAlias);
|
||||
connect(core, &Core::fileReceiveRequested, newfriend->getChatForm(), &ChatForm::onFileRecvRequest);
|
||||
connect(core, &Core::avInvite, newfriend->getChatForm(), &ChatForm::onAvInvite);
|
||||
|
@ -651,11 +650,11 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
|
|||
{
|
||||
if (f->getStatus() == Status::Offline)
|
||||
{
|
||||
contactListWidget->moveWidget(f->getFriendWidget(), Status::Online, f->getEventFlag());
|
||||
contactListWidget->moveWidget(f->getFriendWidget(), Status::Online);
|
||||
}
|
||||
else if (status == Status::Offline)
|
||||
{
|
||||
contactListWidget->moveWidget(f->getFriendWidget(), Status::Offline, f->getEventFlag());
|
||||
contactListWidget->moveWidget(f->getFriendWidget(), Status::Offline);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -999,8 +998,8 @@ Group *Widget::createGroup(int groupId)
|
|||
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
||||
connect(newgroup->getGroupWidget(), SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
||||
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->getChatForm(), SLOT(focusInput()));
|
||||
connect(newgroup->getChatForm(), SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
|
||||
connect(newgroup->getChatForm(), SIGNAL(sendAction(int,QString)), core, SLOT(sendGroupAction(int,QString)));
|
||||
connect(newgroup->getChatForm(), &GroupChatForm::sendMessage, core, &Core::sendGroupMessage);
|
||||
connect(newgroup->getChatForm(), &GroupChatForm::sendAction, core, &Core::sendGroupAction);
|
||||
connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
||||
return newgroup;
|
||||
}
|
||||
|
@ -1139,7 +1138,7 @@ void Widget::setStatusBusy()
|
|||
Nexus::getCore()->setStatus(Status::Busy);
|
||||
}
|
||||
|
||||
void Widget::onMessageSendResult(int friendId, const QString& message, int messageId)
|
||||
void Widget::onMessageSendResult(uint32_t friendId, const QString& message, int messageId)
|
||||
{
|
||||
Q_UNUSED(message)
|
||||
Q_UNUSED(messageId)
|
||||
|
|
|
@ -35,7 +35,7 @@ class MainWindow;
|
|||
|
||||
class GenericChatroomWidget;
|
||||
class Group;
|
||||
struct Friend;
|
||||
class Friend;
|
||||
class QSplitter;
|
||||
class VideoSurface;
|
||||
class QMenu;
|
||||
|
@ -104,6 +104,7 @@ public slots:
|
|||
void onFriendUsernameChanged(int friendId, const QString& username);
|
||||
void onFriendMessageReceived(int friendId, const QString& message, bool isAction);
|
||||
void onFriendRequestReceived(const QString& userId, const QString& message);
|
||||
void onMessageSendResult(uint32_t friendId, const QString& message, int messageId);
|
||||
void onReceiptRecieved(int friendId, int receipt);
|
||||
void onEmptyGroupCreated(int groupId);
|
||||
void onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray invite);
|
||||
|
@ -111,6 +112,7 @@ public slots:
|
|||
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||
void onGroupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
||||
void onGroupPeerAudioPlaying(int groupnumber, int peernumber);
|
||||
void onGroupSendResult(int groupId, const QString& message, int result);
|
||||
void playRingtone();
|
||||
void onFriendTypingChanged(int friendId, bool isTyping);
|
||||
void nextContact();
|
||||
|
@ -140,8 +142,6 @@ private slots:
|
|||
void setStatusOnline();
|
||||
void setStatusAway();
|
||||
void setStatusBusy();
|
||||
void onMessageSendResult(int friendId, const QString& message, int messageId);
|
||||
void onGroupSendResult(int groupId, const QString& message, int result);
|
||||
void onIconClick(QSystemTrayIcon::ActivationReason);
|
||||
void onUserAwayCheck();
|
||||
void onEventIconTick();
|
||||
|
|
Loading…
Reference in New Issue
Block a user