Ticket #195: noP2PWarnings.patch

File noP2PWarnings.patch, 21.6 KB (added by valerio, 3 years ago)

Patch to fix the last compiler warnings. Tested locally with 7mb file and md5sum.

  • src/network/extra/p2pfragmenttracker.cpp

     
    8484 * @brief  Return the identifier of the tracked message. 
    8585 * @return  The message identifier. 
    8686 */ 
    87 unsigned long P2PFragmentTracker::getMessageID() const 
     87quint32 P2PFragmentTracker::getMessageID() const 
    8888{ 
    8989  return messageID_; 
    9090} 
     
    9595 * @brief  Return the number of bytes transferred. 
    9696 * @returns Number of bytes transferred. 
    9797 */ 
    98 unsigned long P2PFragmentTracker::getTransferredBytes() const 
     98quint32 P2PFragmentTracker::getTransferredBytes() const 
    9999{ 
    100100  // TODO: for KMess 1.6, remove this 
    101101  // Just soo close before release don't assume transferredBytes_ will always be correct 
    102102 
    103   unsigned long realCount = 0; 
     103  quint32 realCount = 0; 
    104104  foreach( Range *range, ranges_ ) 
    105105  { 
    106106    realCount += ( range->end - range->start ); 
     
    124124 * 
    125125 * Resets the current state. 
    126126 */ 
    127 void P2PFragmentTracker::initialize( unsigned long messageID, unsigned long totalSize ) 
     127void P2PFragmentTracker::initialize( quint32 messageID, quint32 totalSize ) 
    128128{ 
    129129  // Reset fields 
    130130  messageID_        = messageID; 
     
    173173 * @param  messageID  Message identifier to verify. 
    174174 * @return  Returns true if the tracker is initialized to receive parts of the given message ID. 
    175175 */ 
    176 bool P2PFragmentTracker::isInitialized( unsigned long messageID ) const 
     176bool P2PFragmentTracker::isInitialized( quint32 messageID ) const 
    177177{ 
    178178  return ( messageID_ == messageID ); 
    179179} 
     
    185185 * @param  offset  The starting point of the fragment. 
    186186 * @param  size    The length of the fragment. 
    187187 */ 
    188 void P2PFragmentTracker::registerFragment( unsigned long offset, unsigned long size ) 
     188void P2PFragmentTracker::registerFragment( quint32 offset, quint32 size ) 
    189189{ 
    190190  // Calculate end, check unsafe values. 
    191   unsigned long newEnd  = offset + size; 
     191  quint32 newEnd  = offset + size; 
    192192  if( newEnd > totalSize_ ) 
    193193  { 
    194194    newEnd = totalSize_; 
     
    316316    { 
    317317      while( nextRange != 0 && nextRange->start <= range->end ) 
    318318      { 
    319         unsigned long rangeSize = ( nextRange->end - nextRange->start ); 
     319        quint32 rangeSize = ( nextRange->end - nextRange->start ); 
    320320        transferredBytes_ -= rangeSize; 
    321321        if( nextRange->end > range->end ) // last item has highest range 
    322322        { 
  • src/network/extra/directconnectionbase.cpp

     
    806806  closeClientSocket(); 
    807807  closeServerSocket(); 
    808808 
    809 #warning  Test how to respond to the various socket error codes. 
    810  
    811809  // Filter errors that happen when you've connected already. 
    812810  switch( error ) 
    813811  { 
  • src/network/extra/p2pfragmenttracker.h

     
    3939    // Output for debugging 
    4040    QString              getDebugMap() const; 
    4141    // Return the message ID 
    42     unsigned long        getMessageID() const; 
     42    quint32              getMessageID() const; 
    4343    // Return the number of received bytes 
    44     unsigned long        getTransferredBytes() const; 
     44    quint32              getTransferredBytes() const; 
    4545    // Return whether the tracker is empty, no data added yet. 
    4646    bool                 isEmpty() const; 
    4747    // Return whether the tracker is initialized to receive a part for the given message ID. 
    48     bool                 isInitialized( unsigned long messageID ) const; 
     48    bool                 isInitialized( quint32 messageID ) const; 
    4949    // Initialize to receive a new message 
    50     void                 initialize( unsigned long messageID, unsigned long totalSize ); 
     50    void                 initialize( quint32 messageID, quint32 totalSize ); 
    5151    // Return whether the fragment tracker is complete. 
    5252    bool                 isComplete() const; 
    5353    // Register the arrival of a new fragment. 
    54     void                 registerFragment( unsigned long offset, unsigned long size ); 
     54    void                 registerFragment( quint32 offset, quint32 size ); 
    5555 
    5656  private: 
    5757    /** 
     
    5959     */ 
    6060    struct Range 
    6161    { 
    62       unsigned long start; 
    63       unsigned long end; 
     62      quint32 start; 
     63      quint32 end; 
    6464    }; 
    6565 
    6666    /// The identifier of the message being transferred 
    67     unsigned long        messageID_; 
     67    quint32              messageID_; 
    6868    /// The total size of the message. 
    69     unsigned long        totalSize_; 
     69    quint32              totalSize_; 
    7070    /// The total number of bytes transferred. 
    71     unsigned long        transferredBytes_; 
     71    quint32              transferredBytes_; 
    7272    /// The list of transferred ranges. 
    7373    QList<Range*>        ranges_; 
    7474}; 
  • src/network/applications/p2papplicationbase.cpp

     
    12251225  // The current fragmented message should not be affected. 
    12261226  fragmentMessageID_ = nextMessageID_; 
    12271227  fragmentOffset_    = 0; 
    1228   fragmentTotalSize_ = dataSource->size(); 
     1228  fragmentTotalSize_ = (quint32) qAbs( dataSource->size() ); 
    12291229 
    12301230  // Inform the application list this application wants to send a file. 
    12311231  // It will call sendNextDataParts() each time the connection or switchboard can accept new packets. 
     
    16181618  QByteArray header( 48, 0x00 ); 
    16191619 
    16201620  // Determine the message ID 
    1621   unsigned long messageID; 
     1621  quint32 messageID; 
    16221622  if( nextMessageID_ == 0 ) 
    16231623  { 
    16241624    // We don't have a message ID set yet, we're acknowledging 
     
    16381638  } 
    16391639 
    16401640  // Determine the ack settings. 
    1641   unsigned long ackTotalSize = 0; 
    1642   unsigned long ackSessionID = 0; 
    1643   unsigned long ackUniqueID  = 0; 
    1644   unsigned long ackDataSize  = 0; 
     1641  quint32 ackTotalSize = 0; 
     1642  quint32 ackSessionID = 0; 
     1643  quint32 ackUniqueID  = 0; 
     1644  quint32 ackDataSize  = 0; 
    16451645 
    16461646  // New ack field schema seen with Windows Live Messenger: 
    16471647  if( ackType == P2PMessage::MSN_FLAG_ERROR ) 
     
    17931793 * @return               Whether the message can be sent. If the socket would block, false is returned. 
    17941794 *                       This only occurs for direct connections connections. 
    17951795 */ 
    1796 bool P2PApplicationBase::sendP2PMessageImpl(const QByteArray &messageData, int flagField, P2PDataType footerCode, P2PMessageType messageType, unsigned long messageID) 
     1796bool P2PApplicationBase::sendP2PMessageImpl(const QByteArray &messageData, int flagField, P2PDataType footerCode, P2PMessageType messageType, quint32 messageID) 
    17971797{ 
    17981798#ifdef KMESSTEST 
    17991799  KMESS_ASSERT( messageData.size() <= 1202 ); 
     
    18401840 
    18411841  // Determine the message size: 
    18421842  // Internal trick: fragmentTotalSize_ is set by the caller if this is a splitted message. 
    1843   uint messageSize = messageData.size(); 
    1844   ulong totalSize; 
    1845   ulong offsetField; 
     1843  quint32 messageSize = messageData.size(); 
     1844  quint32 totalSize; 
     1845  quint32 offsetField; 
    18461846 
    18471847  if( fragmentTotalSize_ == 0 ) 
    18481848  { 
     
    18591859 
    18601860 
    18611861  // Generate ack session identifier for this message 
    1862   unsigned long ackSessionID = KMessShared::generateID(); 
     1862  quint32 ackSessionID = KMessShared::generateID(); 
    18631863 
    18641864  // Set session ID to zero when SLP messages are sent. 
    1865   unsigned long sessionID = getSessionID(); 
     1865  quint32 sessionID = getSessionID(); 
    18661866  if( flagField  == 0 
    18671867  &&  footerCode == 0      // fixes all data transfers, like msnobjects and webcam. 
    18681868  &&  messageType != P2P_MSG_DATA_PREPARATION ) 
  • src/network/applications/p2papplication.cpp

     
    283283 * 
    284284 * @return The 'SessionID' field from the SLP payload of the invitation message. 
    285285 */ 
    286 unsigned long P2PApplication::getInvitationSessionID() const 
     286quint32 P2PApplication::getInvitationSessionID() const 
    287287{ 
    288288  return invitationSessionID_; 
    289289} 
     
    299299 * 
    300300 * @return The session ID field used in the binary P2P header. 
    301301 */ 
    302 unsigned long P2PApplication::getSessionID() const 
     302quint32 P2PApplication::getSessionID() const 
    303303{ 
    304304  return sessionID_; 
    305305} 
     
    16861686void P2PApplication::gotSlpSessionInvitation( const MimeMessage &slpMimeBody ) 
    16871687{ 
    16881688  // Read requested session id from the message 
    1689   invitationSessionID_ = slpMimeBody.getValue("SessionID").toULong(); 
     1689  invitationSessionID_ = slpMimeBody.getValue("SessionID").toUInt(); 
    16901690 
    16911691  // Don't accept invites if we sent one. 
    16921692  if( ! isFirstMessageSent() && isUserStartedApp() ) 
     
    31033103 * @param  appId      The numeric app-Id value, which also identifies the application type. 
    31043104 * @param  context    The context field. 
    31053105 */ 
    3106 void P2PApplication::sendSlpSessionInvitation( ulong sessionID, const QString &eufGuid, const int appId, const QString &context ) 
     3106void P2PApplication::sendSlpSessionInvitation( quint32 sessionID, const QString &eufGuid, const int appId, const QString &context ) 
    31073107{ 
    31083108  // Create the message 
    31093109  MimeMessage invitation; 
     
    32213221/** 
    32223222 * Assign a fixed session ID (used for p2p ink transfers) 
    32233223 */ 
    3224 void P2PApplication::setDataCastSessionID( unsigned long sessionID ) 
     3224void P2PApplication::setDataCastSessionID( quint32 sessionID ) 
    32253225{ 
    32263226#ifdef KMESSTEST 
    32273227  KMESS_ASSERT( sessionID_ == 0 ); 
  • src/network/applications/p2papplicationbase.h

     
    200200    // Return the message ID used in the previous message received from the contact. 
    201201    unsigned long          getLastContactMessageID() const; 
    202202    // Returns the session ID. 
    203     virtual unsigned long  getSessionID() const = 0; 
     203    virtual quint32        getSessionID() const = 0; 
    204204    // Parse a received message... (implements pure virtual method from base class) 
    205205    void                   gotMessage(const P2PMessage &p2pMessage); 
    206206    // Verify whether the application can handle the given ACK message. 
     
    368368    struct UnAckedMessage 
    369369    { 
    370370      // 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. 
    376376      uint           sentTime;     ///< The time the message was sent. 
    377377      P2PMessageType messageType;  ///< The meta type of the message. 
    378378      unsigned int   footerCode;   ///< The message footer code. 
     
    395395    // Send a P2P ACK message 
    396396    void                   sendP2PAckImpl(int ackType = P2PMessage::MSN_FLAG_ACK, UnAckedMessage *originalMessageData = 0); 
    397397    // Send a P2P message 
    398     bool                   sendP2PMessageImpl(const QByteArray &messageData, int flagField = 0, P2PDataType footerCode = P2P_TYPE_NEGOTIATION, P2PMessageType messageType = P2P_MSG_UNKNOWN, unsigned long messageID = 0); 
     398    bool                   sendP2PMessageImpl(const QByteArray &messageData, int flagField = 0, P2PDataType footerCode = P2P_TYPE_NEGOTIATION, P2PMessageType messageType = P2P_MSG_UNKNOWN, quint32 messageID = 0); 
    399399    // Test if there are still unacked messages. 
    400400    void                   testUnAckedMessages(bool sendError); 
    401401 
     
    417417    // The type of data to send. 
    418418    P2PDataType            dataType_; 
    419419    // Message ID, if we're sending "fragmented" content 
    420     unsigned long          fragmentMessageID_; 
     420    quint32                fragmentMessageID_; 
    421421    // Message offset, if we're sending "fragmented" content 
    422     unsigned long          fragmentOffset_; 
     422    quint32                fragmentOffset_; 
    423423    // Size of the message, if we're sending "fragmented" content 
    424     unsigned long          fragmentTotalSize_; 
     424    quint32                fragmentTotalSize_; 
    425425    // Track the status of a fragmented message (incoming currently) 
    426426    P2PFragmentTracker     fragmentTracker_; 
    427427    // The last incoming message. 
    428428    UnAckedMessage         lastIncomingMessage_; 
    429429    // Message ID, updated each time a message has been sent 
    430     unsigned long          nextMessageID_; 
     430    quint32                nextMessageID_; 
    431431    // The list of outgoing messages to be acked 
    432432    QList<UnAckedMessage*> outgoingMessages_; 
    433433    // True if an ACK was not sent yet. 
  • src/network/applications/p2papplication.h

     
    127127    // Returns the nonce that's being expected. 
    128128    const QString &        getNonce() const; 
    129129    // Returns the session ID. 
    130     unsigned long          getSessionID() const; 
     130    quint32                getSessionID() const; 
    131131    // The user cancelled the session 
    132132    virtual void           userAborted(); 
    133133 
     
    141141    // Return the content type read from the invitation message 
    142142    const QString&         getInvitationContentType() const; 
    143143    // Return the session id read from the invitation message 
    144     unsigned long          getInvitationSessionID() const; 
     144    quint32                getInvitationSessionID() const; 
    145145    // Called when data is received 
    146146    virtual void           gotData(const P2PMessage &message); 
    147147    // Called when all data is received, and the ack is sent. 
     
    153153    // Send the data preparation ACK. 
    154154    void                   sendDataPreparationAck(); 
    155155    // Send the invitation for a normal session 
    156     void                   sendSlpSessionInvitation( ulong sessionID, const QString &eufGuid, const int appId, const QString &context ); 
     156    void                   sendSlpSessionInvitation( quint32 sessionID, const QString &eufGuid, const int appId, const QString &context ); 
    157157    // Send the invitation for a direct connection. 
    158158    void                   sendSlpTransferInvitation(); 
    159159    // Send an SLP 200/OK message 
    160160    void                   sendSlpOkMessage(const MimeMessage &message); 
    161161    // Assign a fixed session ID (used for p2p ink transfers) 
    162     void                   setDataCastSessionID( unsigned long sessionID ); 
     162    void                   setDataCastSessionID( quint32 sessionID ); 
    163163    // The user rejected the invitation 
    164164    virtual void           userRejected(); 
    165165 
     
    245245    // CSeq field from the invitation message 
    246246    int                    invitationCSeq_; 
    247247    // SessionID field from the invitaiton message 
    248     unsigned long          invitationSessionID_; 
     248    quint32                invitationSessionID_; 
    249249    // The nonce for direct connections 
    250250    QString                nonce_; 
    251251    // Session ID, identifies the session at MSNP2P level. 
    252     unsigned long          sessionID_; 
     252    quint32                sessionID_; 
    253253    // True if the user needs to acknowledge the data preparation message. (doesn't send an ACK automatically) 
    254254    bool                   userShouldAcknowledge_; 
    255255}; 
  • src/network/p2pmessage.cpp

     
    5050 
    5151 
    5252// Retreives the current session ID. 
    53 unsigned long P2PMessage::getSessionID() const 
     53quint32 P2PMessage::getSessionID() const 
    5454{ 
    5555  return sessionID_; 
    5656} 
    5757 
    5858// Retreives the current message ID. */ 
    59 unsigned long P2PMessage::getMessageID() const 
     59quint32 P2PMessage::getMessageID() const 
    6060{ 
    6161  return messageID_; 
    6262} 
    6363 
    6464// Retreives the current message offset. 
    65 unsigned long P2PMessage::getDataOffset() const 
     65quint32 P2PMessage::getDataOffset() const 
    6666{ 
    6767  return dataOffset_; 
    6868} 
    6969 
    7070// Retreives the current message size. 
    71 unsigned long P2PMessage::getDataSize() const 
     71quint32 P2PMessage::getDataSize() const 
    7272{ 
    7373  return dataSize_; 
    7474} 
    7575 
    7676// Retreives the total message size. 
    77 unsigned long P2PMessage::getTotalSize() const 
     77quint32 P2PMessage::getTotalSize() const 
    7878{ 
    7979  return totalSize_; 
    8080} 
    8181 
    8282// Retreives the current message size. 
    83 unsigned long P2PMessage::getFlags() const 
     83quint32 P2PMessage::getFlags() const 
    8484{ 
    8585  return flags_; 
    8686} 
    8787 
    8888// Retrieves the ack session ID field. 
    89 unsigned long P2PMessage::getAckSessionID() const 
     89quint32 P2PMessage::getAckSessionID() const 
    9090{ 
    9191  return ackSessionID_; 
    9292} 
    9393 
    9494// Retreives the ack unique ID field. 
    95 unsigned long P2PMessage::getAckUniqueID() const 
     95quint32 P2PMessage::getAckUniqueID() const 
    9696{ 
    9797  return ackUniqueID_; 
    9898} 
    9999 
    100100// Retreives the ack data size field. 
    101 unsigned long P2PMessage::getAckDataSize() const 
     101quint32 P2PMessage::getAckDataSize() const 
    102102{ 
    103103  return ackDataSize_; 
    104104} 
     
    375375 
    376376 
    377377 
    378 unsigned long P2PMessage::extractLongBytes(const char *data, const int offset) 
     378quint32 P2PMessage::extractLongBytes(const char *data, const int offset) 
    379379{ 
    380380  // Convert the bytes from network order to a long int. 
    381381  return (((unsigned char) data[offset + 0]      ) 
  • src/network/p2pmessage.h

     
    5454 
    5555public:    // Accessors 
    5656  // Retreives the current session ID. 
    57   unsigned long        getSessionID() const; 
     57  quint32              getSessionID() const; 
    5858  // Retreives the current message ID. 
    59   unsigned long        getMessageID() const; 
     59  quint32              getMessageID() const; 
    6060  // Retreives the current data message offset. 
    61   unsigned long        getDataOffset() const; 
     61  quint32              getDataOffset() const; 
    6262  // Retreives the current data message size. 
    63   unsigned long        getDataSize() const; 
     63  quint32              getDataSize() const; 
    6464  // Retreives the message flags. */ 
    65   unsigned long        getFlags() const; 
     65  quint32              getFlags() const; 
    6666  // Retreives the total message size. 
    67   unsigned long        getTotalSize() const; 
     67  quint32              getTotalSize() const; 
    6868  // Retrieves the ack message ID field. 
    69   unsigned long        getAckSessionID() const; 
     69  quint32              getAckSessionID() const; 
    7070  // Retreives the ack unique ID field. 
    71   unsigned long        getAckUniqueID() const; 
     71  quint32              getAckUniqueID() const; 
    7272  // Retreives the ack data size field. 
    73   unsigned long        getAckDataSize() const; 
     73  quint32              getAckDataSize() const; 
    7474  // Retreives the nonce field (for direct connection handshake. 
    7575  QString              getNonce() const; 
    7676 
     
    116116  // Extracts the bytes from the data block. 
    117117  static unsigned int  extractBytes(const char *data, const int offset); 
    118118  // Extracts the bytes from the data block. 
    119   static unsigned long extractLongBytes(const char *data, const int offset); 
     119  static quint32      extractLongBytes(const char *data, const int offset); 
    120120  // Extracts the nonce string from the data header. 
    121121  static QString       extractNonce(const char *data, const int offset = 32); 
    122122  // Extracts an utf16 string from the data header. 
     
    132132  QByteArray           message_; 
    133133 
    134134  // Session ID identifying which (MSN-)SLP we're dealing with. 
    135   unsigned long        sessionID_; 
     135  quint32              sessionID_; 
    136136  // Message ID identifying which message packet we're dealing with. 
    137   unsigned long        messageID_; 
     137  quint32              messageID_; 
    138138  // Message offset.. (message packets can be split) 
    139   unsigned long        dataOffset_; 
     139  quint32              dataOffset_; 
    140140  // Message size.. 
    141   unsigned long        dataSize_; 
     141  quint32              dataSize_; 
    142142  // Message flags. 
    143   unsigned long        flags_; 
     143  quint32              flags_; 
    144144  // Total message size 
    145   unsigned long        totalSize_; 
     145  quint32              totalSize_; 
    146146  // Ack session id. 
    147   unsigned long        ackSessionID_; 
     147  quint32              ackSessionID_; 
    148148  // Ack Unique id. 
    149   unsigned long        ackUniqueID_; 
     149  quint32              ackUniqueID_; 
    150150  // Ack data size. 
    151   unsigned long        ackDataSize_; 
     151  quint32              ackDataSize_; 
    152152}; 
    153153 
    154154 
  • src/utils/kmessshared.cpp

     
    203203 * 
    204204 * @return A random value between 4 and 4294967295. 
    205205 */ 
    206 unsigned long KMessShared::generateID() 
     206quint32 KMessShared::generateID() 
    207207{ 
    208208  return (rand() & 0x00FFFFFC); 
    209209} 
  • src/utils/kmessshared.h

     
    4646    // Generate a random GUID. 
    4747    static QString         generateGUID(); 
    4848    // Generate an random number to use as ID 
    49     static unsigned long   generateID(); 
     49    static quint32         generateID(); 
    5050    // Return the hash of a file name using the SHA1 algorithm 
    5151    static QByteArray      generateFileHash( const QString &fileName ); 
    5252    // Converts a string with HTML to one with escaped entities