Browse Source

fix minor switching bug introduced by 07ea2e

pull/723/head
dubslow 11 years ago
parent
commit
3dd15f0a5f
  1. 8
      src/core.cpp
  2. 4
      src/core.h
  3. 4
      src/coreav.cpp
  4. 3
      src/friendlist.cpp
  5. 2
      src/friendlist.h
  6. 2
      src/grouplist.cpp
  7. 2
      src/grouplist.h
  8. 20
      src/widget/widget.cpp
  9. 4
      src/widget/widget.h

8
src/core.cpp

@ -991,9 +991,9 @@ void Core::acceptFileRecvRequest(int friendId, int fileNum, QString path)
tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_ACCEPT, nullptr, 0); tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_ACCEPT, nullptr, 0);
} }
void Core::removeFriend(int friendId) void Core::removeFriend(int friendId, bool fake)
{ {
if (!tox) if (!tox || fake)
return; return;
if (tox_del_friend(tox, friendId) == -1) { if (tox_del_friend(tox, friendId) == -1) {
emit failedToRemoveFriend(friendId); emit failedToRemoveFriend(friendId);
@ -1003,9 +1003,9 @@ void Core::removeFriend(int friendId)
} }
} }
void Core::removeGroup(int groupId) void Core::removeGroup(int groupId, bool fake)
{ {
if (!tox) if (!tox || fake)
return; return;
tox_del_groupchat(tox, groupId); tox_del_groupchat(tox, groupId);
} }

4
src/core.h

@ -87,8 +87,8 @@ public slots:
void groupInviteFriend(int friendId, int groupId); void groupInviteFriend(int friendId, int groupId);
void createGroup(uint8_t type = TOX_GROUPCHAT_TYPE_AV); void createGroup(uint8_t type = TOX_GROUPCHAT_TYPE_AV);
void removeFriend(int friendId); void removeFriend(int friendId, bool fake = false);
void removeGroup(int groupId); void removeGroup(int groupId, bool fake = false);
void setStatus(Status status); void setStatus(Status status);
void setUsername(const QString& username); void setUsername(const QString& username);

4
src/coreav.cpp

@ -587,8 +587,8 @@ VideoSource *Core::getVideoSourceFromCall(int callNumber)
return &calls[callNumber].videoSource; return &calls[callNumber].videoSource;
} }
void Core::playGroupAudio(Tox* tox, int groupnumber, int friendgroupnumber, const int16_t* out_audio, void Core::playGroupAudio(Tox* /*tox*/, int /*groupnumber*/, int /*friendgroupnumber*/, const int16_t* out_audio,
unsigned out_audio_samples, uint8_t decoder_channels, unsigned audio_sample_rate, void* userdata) unsigned out_audio_samples, uint8_t decoder_channels, unsigned audio_sample_rate, void* /*userdata*/)
{ {
/// TODO: FIXME: Don't play groupchat audio on the main source! /// TODO: FIXME: Don't play groupchat audio on the main source!
/// We'll need some sort of call[] array but for groupchats, when that's done use this source /// We'll need some sort of call[] array but for groupchats, when that's done use this source

3
src/friendlist.cpp

@ -46,11 +46,12 @@ Friend* FriendList::findFriend(int friendId)
return nullptr; return nullptr;
} }
void FriendList::removeFriend(int friendId) void FriendList::removeFriend(int friendId, bool fake)
{ {
auto f_it = friendList.find(friendId); auto f_it = friendList.find(friendId);
if (f_it != friendList.end()) if (f_it != friendList.end())
{ {
if (!fake)
Settings::getInstance().removeFriendSettings(f_it.value()->getToxID()); Settings::getInstance().removeFriendSettings(f_it.value()->getToxID());
friendList.erase(f_it); friendList.erase(f_it);
} }

2
src/friendlist.h

@ -30,7 +30,7 @@ public:
static Friend* findFriend(int friendId); static Friend* findFriend(int friendId);
static Friend* findFriend(QString userId); static Friend* findFriend(QString userId);
static QList<Friend*> getAllFriends(); static QList<Friend*> getAllFriends();
static void removeFriend(int friendId); static void removeFriend(int friendId, bool fake = false);
static void clear(); static void clear();
private: private:

2
src/grouplist.cpp

@ -34,7 +34,7 @@ Group* GroupList::findGroup(int groupId)
return nullptr; return nullptr;
} }
void GroupList::removeGroup(int groupId) void GroupList::removeGroup(int groupId, bool /*fake*/)
{ {
for (int i=0; i<groupList.size(); i++) for (int i=0; i<groupList.size(); i++)
{ {

2
src/grouplist.h

@ -28,7 +28,7 @@ public:
GroupList(); GroupList();
static Group* addGroup(int groupId, const QString& name); static Group* addGroup(int groupId, const QString& name);
static Group* findGroup(int groupId); static Group* findGroup(int groupId);
static void removeGroup(int groupId); static void removeGroup(int groupId, bool fake = false);
public: public:
static QList<Group*> groupList; static QList<Group*> groupList;

20
src/widget/widget.cpp

@ -830,7 +830,7 @@ void Widget::onFriendRequestReceived(const QString& userId, const QString& messa
emit friendRequestAccepted(userId); emit friendRequestAccepted(userId);
} }
void Widget::removeFriend(Friend* f) void Widget::removeFriend(Friend* f, bool fake)
{ {
f->getFriendWidget()->setAsInactiveChatroom(); f->getFriendWidget()->setAsInactiveChatroom();
if (static_cast<GenericChatroomWidget*>(f->getFriendWidget()) == activeChatroomWidget) if (static_cast<GenericChatroomWidget*>(f->getFriendWidget()) == activeChatroomWidget)
@ -838,10 +838,10 @@ void Widget::removeFriend(Friend* f)
activeChatroomWidget = nullptr; activeChatroomWidget = nullptr;
onAddClicked(); onAddClicked();
} }
FriendList::removeFriend(f->getFriendID()); FriendList::removeFriend(f->getFriendID(), fake);
core->removeFriend(f->getFriendID()); core->removeFriend(f->getFriendID(), fake);
delete f; delete f;
if (ui->mainHead->layout()->isEmpty()) if (ui->mainHead->layout()->isEmpty()) // tux3: this should have covered the case of the bug you "fixed" 5 lines above
onAddClicked(); onAddClicked();
contactListWidget->hide(); contactListWidget->hide();
@ -850,16 +850,16 @@ void Widget::removeFriend(Friend* f)
void Widget::removeFriend(int friendId) void Widget::removeFriend(int friendId)
{ {
removeFriend(FriendList::findFriend(friendId)); removeFriend(FriendList::findFriend(friendId), false);
} }
void Widget::clearContactsList() void Widget::clearContactsList()
{ {
QList<Friend*> friends = FriendList::getAllFriends(); QList<Friend*> friends = FriendList::getAllFriends();
for (Friend* f : friends) for (Friend* f : friends)
removeFriend(f); removeFriend(f, true);
for (Group* g : GroupList::groupList) for (Group* g : GroupList::groupList)
removeGroup(g); removeGroup(g, true);
} }
void Widget::copyFriendIdToClipboard(int friendId) void Widget::copyFriendIdToClipboard(int friendId)
@ -945,7 +945,7 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
g->updatePeer(peernumber,core->getGroupPeerName(groupnumber, peernumber)); g->updatePeer(peernumber,core->getGroupPeerName(groupnumber, peernumber));
} }
void Widget::removeGroup(Group* g) void Widget::removeGroup(Group* g, bool fake)
{ {
g->widget->setAsInactiveChatroom(); g->widget->setAsInactiveChatroom();
if (static_cast<GenericChatroomWidget*>(g->widget) == activeChatroomWidget) if (static_cast<GenericChatroomWidget*>(g->widget) == activeChatroomWidget)
@ -953,8 +953,8 @@ void Widget::removeGroup(Group* g)
activeChatroomWidget = nullptr; activeChatroomWidget = nullptr;
onAddClicked(); onAddClicked();
} }
GroupList::removeGroup(g->groupId); GroupList::removeGroup(g->groupId, fake);
core->removeGroup(g->groupId); core->removeGroup(g->groupId, fake);
delete g; delete g;
if (ui->mainHead->layout()->isEmpty()) if (ui->mainHead->layout()->isEmpty())
onAddClicked(); onAddClicked();

4
src/widget/widget.h

@ -133,8 +133,8 @@ private:
void hideMainForms(); void hideMainForms();
virtual bool event(QEvent * e); virtual bool event(QEvent * e);
Group* createGroup(int groupId); Group* createGroup(int groupId);
void removeFriend(Friend* f); void removeFriend(Friend* f, bool fake = false);
void removeGroup(Group* g); void removeGroup(Group* g, bool fake = false);
QString askProfiles(); QString askProfiles();
QString detectProfile(); QString detectProfile();
QSystemTrayIcon *icon; QSystemTrayIcon *icon;

Loading…
Cancel
Save