Ticket #195: noP2PWarnings.patch
| File noP2PWarnings.patch, 21.6 KB (added by valerio, 3 years ago) |
|---|
-
src/network/extra/p2pfragmenttracker.cpp
84 84 * @brief Return the identifier of the tracked message. 85 85 * @return The message identifier. 86 86 */ 87 unsigned longP2PFragmentTracker::getMessageID() const87 quint32 P2PFragmentTracker::getMessageID() const 88 88 { 89 89 return messageID_; 90 90 } … … 95 95 * @brief Return the number of bytes transferred. 96 96 * @returns Number of bytes transferred. 97 97 */ 98 unsigned longP2PFragmentTracker::getTransferredBytes() const98 quint32 P2PFragmentTracker::getTransferredBytes() const 99 99 { 100 100 // TODO: for KMess 1.6, remove this 101 101 // Just soo close before release don't assume transferredBytes_ will always be correct 102 102 103 unsigned longrealCount = 0;103 quint32 realCount = 0; 104 104 foreach( Range *range, ranges_ ) 105 105 { 106 106 realCount += ( range->end - range->start ); … … 124 124 * 125 125 * Resets the current state. 126 126 */ 127 void P2PFragmentTracker::initialize( unsigned long messageID, unsigned longtotalSize )127 void P2PFragmentTracker::initialize( quint32 messageID, quint32 totalSize ) 128 128 { 129 129 // Reset fields 130 130 messageID_ = messageID; … … 173 173 * @param messageID Message identifier to verify. 174 174 * @return Returns true if the tracker is initialized to receive parts of the given message ID. 175 175 */ 176 bool P2PFragmentTracker::isInitialized( unsigned longmessageID ) const176 bool P2PFragmentTracker::isInitialized( quint32 messageID ) const 177 177 { 178 178 return ( messageID_ == messageID ); 179 179 } … … 185 185 * @param offset The starting point of the fragment. 186 186 * @param size The length of the fragment. 187 187 */ 188 void P2PFragmentTracker::registerFragment( unsigned long offset, unsigned longsize )188 void P2PFragmentTracker::registerFragment( quint32 offset, quint32 size ) 189 189 { 190 190 // Calculate end, check unsafe values. 191 unsigned longnewEnd = offset + size;191 quint32 newEnd = offset + size; 192 192 if( newEnd > totalSize_ ) 193 193 { 194 194 newEnd = totalSize_; … … 316 316 { 317 317 while( nextRange != 0 && nextRange->start <= range->end ) 318 318 { 319 unsigned longrangeSize = ( nextRange->end - nextRange->start );319 quint32 rangeSize = ( nextRange->end - nextRange->start ); 320 320 transferredBytes_ -= rangeSize; 321 321 if( nextRange->end > range->end ) // last item has highest range 322 322 { -
src/network/extra/directconnectionbase.cpp
806 806 closeClientSocket(); 807 807 closeServerSocket(); 808 808 809 #warning Test how to respond to the various socket error codes.810 811 809 // Filter errors that happen when you've connected already. 812 810 switch( error ) 813 811 { -
src/network/extra/p2pfragmenttracker.h
39 39 // Output for debugging 40 40 QString getDebugMap() const; 41 41 // Return the message ID 42 unsigned longgetMessageID() const;42 quint32 getMessageID() const; 43 43 // Return the number of received bytes 44 unsigned longgetTransferredBytes() const;44 quint32 getTransferredBytes() const; 45 45 // Return whether the tracker is empty, no data added yet. 46 46 bool isEmpty() const; 47 47 // Return whether the tracker is initialized to receive a part for the given message ID. 48 bool isInitialized( unsigned longmessageID ) const;48 bool isInitialized( quint32 messageID ) const; 49 49 // Initialize to receive a new message 50 void initialize( unsigned long messageID, unsigned longtotalSize );50 void initialize( quint32 messageID, quint32 totalSize ); 51 51 // Return whether the fragment tracker is complete. 52 52 bool isComplete() const; 53 53 // Register the arrival of a new fragment. 54 void registerFragment( unsigned long offset, unsigned longsize );54 void registerFragment( quint32 offset, quint32 size ); 55 55 56 56 private: 57 57 /** … … 59 59 */ 60 60 struct Range 61 61 { 62 unsigned longstart;63 unsigned longend;62 quint32 start; 63 quint32 end; 64 64 }; 65 65 66 66 /// The identifier of the message being transferred 67 unsigned longmessageID_;67 quint32 messageID_; 68 68 /// The total size of the message. 69 unsigned longtotalSize_;69 quint32 totalSize_; 70 70 /// The total number of bytes transferred. 71 unsigned longtransferredBytes_;71 quint32 transferredBytes_; 72 72 /// The list of transferred ranges. 73 73 QList<Range*> ranges_; 74 74 }; -
src/network/applications/p2papplicationbase.cpp
1225 1225 // The current fragmented message should not be affected. 1226 1226 fragmentMessageID_ = nextMessageID_; 1227 1227 fragmentOffset_ = 0; 1228 fragmentTotalSize_ = dataSource->size();1228 fragmentTotalSize_ = (quint32) qAbs( dataSource->size() ); 1229 1229 1230 1230 // Inform the application list this application wants to send a file. 1231 1231 // It will call sendNextDataParts() each time the connection or switchboard can accept new packets. … … 1618 1618 QByteArray header( 48, 0x00 ); 1619 1619 1620 1620 // Determine the message ID 1621 unsigned longmessageID;1621 quint32 messageID; 1622 1622 if( nextMessageID_ == 0 ) 1623 1623 { 1624 1624 // We don't have a message ID set yet, we're acknowledging … … 1638 1638 } 1639 1639 1640 1640 // Determine the ack settings. 1641 unsigned longackTotalSize = 0;1642 unsigned longackSessionID = 0;1643 unsigned longackUniqueID = 0;1644 unsigned longackDataSize = 0;1641 quint32 ackTotalSize = 0; 1642 quint32 ackSessionID = 0; 1643 quint32 ackUniqueID = 0; 1644 quint32 ackDataSize = 0; 1645 1645 1646 1646 // New ack field schema seen with Windows Live Messenger: 1647 1647 if( ackType == P2PMessage::MSN_FLAG_ERROR ) … … 1793 1793 * @return Whether the message can be sent. If the socket would block, false is returned. 1794 1794 * This only occurs for direct connections connections. 1795 1795 */ 1796 bool P2PApplicationBase::sendP2PMessageImpl(const QByteArray &messageData, int flagField, P2PDataType footerCode, P2PMessageType messageType, unsigned longmessageID)1796 bool P2PApplicationBase::sendP2PMessageImpl(const QByteArray &messageData, int flagField, P2PDataType footerCode, P2PMessageType messageType, quint32 messageID) 1797 1797 { 1798 1798 #ifdef KMESSTEST 1799 1799 KMESS_ASSERT( messageData.size() <= 1202 ); … … 1840 1840 1841 1841 // Determine the message size: 1842 1842 // Internal trick: fragmentTotalSize_ is set by the caller if this is a splitted message. 1843 uintmessageSize = messageData.size();1844 ulongtotalSize;1845 ulongoffsetField;1843 quint32 messageSize = messageData.size(); 1844 quint32 totalSize; 1845 quint32 offsetField; 1846 1846 1847 1847 if( fragmentTotalSize_ == 0 ) 1848 1848 { … … 1859 1859 1860 1860 1861 1861 // Generate ack session identifier for this message 1862 unsigned longackSessionID = KMessShared::generateID();1862 quint32 ackSessionID = KMessShared::generateID(); 1863 1863 1864 1864 // Set session ID to zero when SLP messages are sent. 1865 unsigned longsessionID = getSessionID();1865 quint32 sessionID = getSessionID(); 1866 1866 if( flagField == 0 1867 1867 && footerCode == 0 // fixes all data transfers, like msnobjects and webcam. 1868 1868 && messageType != P2P_MSG_DATA_PREPARATION ) -
src/network/applications/p2papplication.cpp
283 283 * 284 284 * @return The 'SessionID' field from the SLP payload of the invitation message. 285 285 */ 286 unsigned longP2PApplication::getInvitationSessionID() const286 quint32 P2PApplication::getInvitationSessionID() const 287 287 { 288 288 return invitationSessionID_; 289 289 } … … 299 299 * 300 300 * @return The session ID field used in the binary P2P header. 301 301 */ 302 unsigned longP2PApplication::getSessionID() const302 quint32 P2PApplication::getSessionID() const 303 303 { 304 304 return sessionID_; 305 305 } … … 1686 1686 void P2PApplication::gotSlpSessionInvitation( const MimeMessage &slpMimeBody ) 1687 1687 { 1688 1688 // Read requested session id from the message 1689 invitationSessionID_ = slpMimeBody.getValue("SessionID").toU Long();1689 invitationSessionID_ = slpMimeBody.getValue("SessionID").toUInt(); 1690 1690 1691 1691 // Don't accept invites if we sent one. 1692 1692 if( ! isFirstMessageSent() && isUserStartedApp() ) … … 3103 3103 * @param appId The numeric app-Id value, which also identifies the application type. 3104 3104 * @param context The context field. 3105 3105 */ 3106 void P2PApplication::sendSlpSessionInvitation( ulongsessionID, const QString &eufGuid, const int appId, const QString &context )3106 void P2PApplication::sendSlpSessionInvitation( quint32 sessionID, const QString &eufGuid, const int appId, const QString &context ) 3107 3107 { 3108 3108 // Create the message 3109 3109 MimeMessage invitation; … … 3221 3221 /** 3222 3222 * Assign a fixed session ID (used for p2p ink transfers) 3223 3223 */ 3224 void P2PApplication::setDataCastSessionID( unsigned longsessionID )3224 void P2PApplication::setDataCastSessionID( quint32 sessionID ) 3225 3225 { 3226 3226 #ifdef KMESSTEST 3227 3227 KMESS_ASSERT( sessionID_ == 0 ); -
src/network/applications/p2papplicationbase.h
200 200 // Return the message ID used in the previous message received from the contact. 201 201 unsigned long getLastContactMessageID() const; 202 202 // Returns the session ID. 203 virtual unsigned longgetSessionID() const = 0;203 virtual quint32 getSessionID() const = 0; 204 204 // Parse a received message... (implements pure virtual method from base class) 205 205 void gotMessage(const P2PMessage &p2pMessage); 206 206 // Verify whether the application can handle the given ACK message. … … 368 368 struct UnAckedMessage 369 369 { 370 370 // Data for ACK message: 371 unsigned long dataSize;///< The sent data size.372 unsigned long messageID;///< The sent message ID.373 unsigned long totalSize;///< The sent total size.374 unsigned long sessionID;///< The sent session ID.375 unsigned long ackSessionID;///< The sent unique ID field.371 quint32 dataSize; ///< The sent data size. 372 quint32 messageID; ///< The sent message ID. 373 quint32 totalSize; ///< The sent total size. 374 quint32 sessionID; ///< The sent session ID. 375 quint32 ackSessionID; ///< The sent unique ID field. 376 376 uint sentTime; ///< The time the message was sent. 377 377 P2PMessageType messageType; ///< The meta type of the message. 378 378 unsigned int footerCode; ///< The message footer code. … … 395 395 // Send a P2P ACK message 396 396 void sendP2PAckImpl(int ackType = P2PMessage::MSN_FLAG_ACK, UnAckedMessage *originalMessageData = 0); 397 397 // Send a P2P message 398 bool sendP2PMessageImpl(const QByteArray &messageData, int flagField = 0, P2PDataType footerCode = P2P_TYPE_NEGOTIATION, P2PMessageType messageType = P2P_MSG_UNKNOWN, unsigned longmessageID = 0);398 bool sendP2PMessageImpl(const QByteArray &messageData, int flagField = 0, P2PDataType footerCode = P2P_TYPE_NEGOTIATION, P2PMessageType messageType = P2P_MSG_UNKNOWN, quint32 messageID = 0); 399 399 // Test if there are still unacked messages. 400 400 void testUnAckedMessages(bool sendError); 401 401 … … 417 417 // The type of data to send. 418 418 P2PDataType dataType_; 419 419 // Message ID, if we're sending "fragmented" content 420 unsigned longfragmentMessageID_;420 quint32 fragmentMessageID_; 421 421 // Message offset, if we're sending "fragmented" content 422 unsigned longfragmentOffset_;422 quint32 fragmentOffset_; 423 423 // Size of the message, if we're sending "fragmented" content 424 unsigned longfragmentTotalSize_;424 quint32 fragmentTotalSize_; 425 425 // Track the status of a fragmented message (incoming currently) 426 426 P2PFragmentTracker fragmentTracker_; 427 427 // The last incoming message. 428 428 UnAckedMessage lastIncomingMessage_; 429 429 // Message ID, updated each time a message has been sent 430 unsigned longnextMessageID_;430 quint32 nextMessageID_; 431 431 // The list of outgoing messages to be acked 432 432 QList<UnAckedMessage*> outgoingMessages_; 433 433 // True if an ACK was not sent yet. -
src/network/applications/p2papplication.h
127 127 // Returns the nonce that's being expected. 128 128 const QString & getNonce() const; 129 129 // Returns the session ID. 130 unsigned longgetSessionID() const;130 quint32 getSessionID() const; 131 131 // The user cancelled the session 132 132 virtual void userAborted(); 133 133 … … 141 141 // Return the content type read from the invitation message 142 142 const QString& getInvitationContentType() const; 143 143 // Return the session id read from the invitation message 144 unsigned longgetInvitationSessionID() const;144 quint32 getInvitationSessionID() const; 145 145 // Called when data is received 146 146 virtual void gotData(const P2PMessage &message); 147 147 // Called when all data is received, and the ack is sent. … … 153 153 // Send the data preparation ACK. 154 154 void sendDataPreparationAck(); 155 155 // Send the invitation for a normal session 156 void sendSlpSessionInvitation( ulongsessionID, const QString &eufGuid, const int appId, const QString &context );156 void sendSlpSessionInvitation( quint32 sessionID, const QString &eufGuid, const int appId, const QString &context ); 157 157 // Send the invitation for a direct connection. 158 158 void sendSlpTransferInvitation(); 159 159 // Send an SLP 200/OK message 160 160 void sendSlpOkMessage(const MimeMessage &message); 161 161 // Assign a fixed session ID (used for p2p ink transfers) 162 void setDataCastSessionID( unsigned longsessionID );162 void setDataCastSessionID( quint32 sessionID ); 163 163 // The user rejected the invitation 164 164 virtual void userRejected(); 165 165 … … 245 245 // CSeq field from the invitation message 246 246 int invitationCSeq_; 247 247 // SessionID field from the invitaiton message 248 unsigned longinvitationSessionID_;248 quint32 invitationSessionID_; 249 249 // The nonce for direct connections 250 250 QString nonce_; 251 251 // Session ID, identifies the session at MSNP2P level. 252 unsigned longsessionID_;252 quint32 sessionID_; 253 253 // True if the user needs to acknowledge the data preparation message. (doesn't send an ACK automatically) 254 254 bool userShouldAcknowledge_; 255 255 }; -
src/network/p2pmessage.cpp
50 50 51 51 52 52 // Retreives the current session ID. 53 unsigned longP2PMessage::getSessionID() const53 quint32 P2PMessage::getSessionID() const 54 54 { 55 55 return sessionID_; 56 56 } 57 57 58 58 // Retreives the current message ID. */ 59 unsigned longP2PMessage::getMessageID() const59 quint32 P2PMessage::getMessageID() const 60 60 { 61 61 return messageID_; 62 62 } 63 63 64 64 // Retreives the current message offset. 65 unsigned longP2PMessage::getDataOffset() const65 quint32 P2PMessage::getDataOffset() const 66 66 { 67 67 return dataOffset_; 68 68 } 69 69 70 70 // Retreives the current message size. 71 unsigned longP2PMessage::getDataSize() const71 quint32 P2PMessage::getDataSize() const 72 72 { 73 73 return dataSize_; 74 74 } 75 75 76 76 // Retreives the total message size. 77 unsigned longP2PMessage::getTotalSize() const77 quint32 P2PMessage::getTotalSize() const 78 78 { 79 79 return totalSize_; 80 80 } 81 81 82 82 // Retreives the current message size. 83 unsigned longP2PMessage::getFlags() const83 quint32 P2PMessage::getFlags() const 84 84 { 85 85 return flags_; 86 86 } 87 87 88 88 // Retrieves the ack session ID field. 89 unsigned longP2PMessage::getAckSessionID() const89 quint32 P2PMessage::getAckSessionID() const 90 90 { 91 91 return ackSessionID_; 92 92 } 93 93 94 94 // Retreives the ack unique ID field. 95 unsigned longP2PMessage::getAckUniqueID() const95 quint32 P2PMessage::getAckUniqueID() const 96 96 { 97 97 return ackUniqueID_; 98 98 } 99 99 100 100 // Retreives the ack data size field. 101 unsigned longP2PMessage::getAckDataSize() const101 quint32 P2PMessage::getAckDataSize() const 102 102 { 103 103 return ackDataSize_; 104 104 } … … 375 375 376 376 377 377 378 unsigned longP2PMessage::extractLongBytes(const char *data, const int offset)378 quint32 P2PMessage::extractLongBytes(const char *data, const int offset) 379 379 { 380 380 // Convert the bytes from network order to a long int. 381 381 return (((unsigned char) data[offset + 0] ) -
src/network/p2pmessage.h
54 54 55 55 public: // Accessors 56 56 // Retreives the current session ID. 57 unsigned longgetSessionID() const;57 quint32 getSessionID() const; 58 58 // Retreives the current message ID. 59 unsigned longgetMessageID() const;59 quint32 getMessageID() const; 60 60 // Retreives the current data message offset. 61 unsigned longgetDataOffset() const;61 quint32 getDataOffset() const; 62 62 // Retreives the current data message size. 63 unsigned longgetDataSize() const;63 quint32 getDataSize() const; 64 64 // Retreives the message flags. */ 65 unsigned longgetFlags() const;65 quint32 getFlags() const; 66 66 // Retreives the total message size. 67 unsigned longgetTotalSize() const;67 quint32 getTotalSize() const; 68 68 // Retrieves the ack message ID field. 69 unsigned longgetAckSessionID() const;69 quint32 getAckSessionID() const; 70 70 // Retreives the ack unique ID field. 71 unsigned longgetAckUniqueID() const;71 quint32 getAckUniqueID() const; 72 72 // Retreives the ack data size field. 73 unsigned longgetAckDataSize() const;73 quint32 getAckDataSize() const; 74 74 // Retreives the nonce field (for direct connection handshake. 75 75 QString getNonce() const; 76 76 … … 116 116 // Extracts the bytes from the data block. 117 117 static unsigned int extractBytes(const char *data, const int offset); 118 118 // Extracts the bytes from the data block. 119 static unsigned longextractLongBytes(const char *data, const int offset);119 static quint32 extractLongBytes(const char *data, const int offset); 120 120 // Extracts the nonce string from the data header. 121 121 static QString extractNonce(const char *data, const int offset = 32); 122 122 // Extracts an utf16 string from the data header. … … 132 132 QByteArray message_; 133 133 134 134 // Session ID identifying which (MSN-)SLP we're dealing with. 135 unsigned longsessionID_;135 quint32 sessionID_; 136 136 // Message ID identifying which message packet we're dealing with. 137 unsigned longmessageID_;137 quint32 messageID_; 138 138 // Message offset.. (message packets can be split) 139 unsigned longdataOffset_;139 quint32 dataOffset_; 140 140 // Message size.. 141 unsigned longdataSize_;141 quint32 dataSize_; 142 142 // Message flags. 143 unsigned longflags_;143 quint32 flags_; 144 144 // Total message size 145 unsigned longtotalSize_;145 quint32 totalSize_; 146 146 // Ack session id. 147 unsigned longackSessionID_;147 quint32 ackSessionID_; 148 148 // Ack Unique id. 149 unsigned longackUniqueID_;149 quint32 ackUniqueID_; 150 150 // Ack data size. 151 unsigned longackDataSize_;151 quint32 ackDataSize_; 152 152 }; 153 153 154 154 -
src/utils/kmessshared.cpp
203 203 * 204 204 * @return A random value between 4 and 4294967295. 205 205 */ 206 unsigned longKMessShared::generateID()206 quint32 KMessShared::generateID() 207 207 { 208 208 return (rand() & 0x00FFFFFC); 209 209 } -
src/utils/kmessshared.h
46 46 // Generate a random GUID. 47 47 static QString generateGUID(); 48 48 // Generate an random number to use as ID 49 static unsigned longgenerateID();49 static quint32 generateID(); 50 50 // Return the hash of a file name using the SHA1 algorithm 51 51 static QByteArray generateFileHash( const QString &fileName ); 52 52 // Converts a string with HTML to one with escaped entities
