@@ -142,11 +142,23 @@ bool Server::process(Connection &conn, QDataStream &in, QDataStream &out)
142142 case 0x04 :
143143 return getUserProfile (conn, in, out);
144144
145+ case 0x05 :
146+ return deleteFriend (conn, in, out);
147+
145148 case 0x06 :
146149 return addFriend (conn, in, out);
147150
148151 case 0x07 :
149152 return getFriendIPAndPort (conn, in, out);
153+
154+ case 0xE0 :
155+ return modifyFriendDisplayName (conn, in, out);
156+
157+ case 0xE1 :
158+ return modifyPassword (conn, in, out);
159+
160+ case 0xE2 :
161+ return modifyUserProfile (conn, in, out);
150162 }
151163 return true ;
152164}
@@ -292,6 +304,45 @@ bool Server::getFriendIPAndPort(Connection &conn, QDataStream &in, QDataStream &
292304 return true ;
293305}
294306
307+ bool Server::deleteFriend (Connection &conn, QDataStream &in, QDataStream &out)
308+ {
309+ quint32 uid;
310+
311+ in >> uid;
312+ out << db.removeFriend (conn.account , uid);
313+ return true ;
314+ }
315+
316+ bool Server::modifyFriendDisplayName (Connection &conn, QDataStream &in, QDataStream &out)
317+ {
318+ quint32 uid;
319+ QString displayName;
320+
321+ in >> uid >> displayName;
322+ out << db.modifyFriendDisplayName (conn.account , uid, displayName);
323+ return true ;
324+ }
325+
326+ bool Server::modifyPassword (Connection &conn, QDataStream &in, QDataStream &out)
327+ {
328+ QString password;
329+
330+ in >> password;
331+ password = QCryptographicHash::hash (password.toUtf8 (), QCryptographicHash::Sha1).toHex ();
332+ out << db.modifyPassword (conn.account , password);
333+ return true ;
334+ }
335+
336+ bool Server::modifyUserProfile (Connection &conn, QDataStream &in, QDataStream &out)
337+ {
338+ User user;
339+
340+ in >> user.nickname >> user.gender >> user.address ;
341+ user.id = conn.account ;
342+ out << db.modifyUserProfile (user);
343+ return true ;
344+ }
345+
295346void Server::clientDisconnected ()
296347{
297348 QTcpSocket *socket;
0 commit comments