Index: src/network/extra/p2pfragmenttracker.cpp
===================================================================
--- src/network/extra/p2pfragmenttracker.cpp	(revisione 3979)
+++ src/network/extra/p2pfragmenttracker.cpp	(copia locale)
@@ -84,7 +84,7 @@
  * @brief  Return the identifier of the tracked message.
  * @return  The message identifier.
  */
-unsigned long P2PFragmentTracker::getMessageID() const
+quint32 P2PFragmentTracker::getMessageID() const
 {
   return messageID_;
 }
@@ -95,12 +95,12 @@
  * @brief  Return the number of bytes transferred.
  * @returns Number of bytes transferred.
  */
-unsigned long P2PFragmentTracker::getTransferredBytes() const
+quint32 P2PFragmentTracker::getTransferredBytes() const
 {
   // TODO: for KMess 1.6, remove this
   // Just soo close before release don't assume transferredBytes_ will always be correct
 
-  unsigned long realCount = 0;
+  quint32 realCount = 0;
   foreach( Range *range, ranges_ )
   {
     realCount += ( range->end - range->start );
@@ -124,7 +124,7 @@
  *
  * Resets the current state.
  */
-void P2PFragmentTracker::initialize( unsigned long messageID, unsigned long totalSize )
+void P2PFragmentTracker::initialize( quint32 messageID, quint32 totalSize )
 {
   // Reset fields
   messageID_        = messageID;
@@ -173,7 +173,7 @@
  * @param  messageID  Message identifier to verify.
  * @return  Returns true if the tracker is initialized to receive parts of the given message ID.
  */
-bool P2PFragmentTracker::isInitialized( unsigned long messageID ) const
+bool P2PFragmentTracker::isInitialized( quint32 messageID ) const
 {
   return ( messageID_ == messageID );
 }
@@ -185,10 +185,10 @@
  * @param  offset  The starting point of the fragment.
  * @param  size    The length of the fragment.
  */
-void P2PFragmentTracker::registerFragment( unsigned long offset, unsigned long size )
+void P2PFragmentTracker::registerFragment( quint32 offset, quint32 size )
 {
   // Calculate end, check unsafe values.
-  unsigned long newEnd  = offset + size;
+  quint32 newEnd  = offset + size;
   if( newEnd > totalSize_ )
   {
     newEnd = totalSize_;
@@ -316,7 +316,7 @@
     {
       while( nextRange != 0 && nextRange->start <= range->end )
       {
-        unsigned long rangeSize = ( nextRange->end - nextRange->start );
+        quint32 rangeSize = ( nextRange->end - nextRange->start );
         transferredBytes_ -= rangeSize;
         if( nextRange->end > range->end ) // last item has highest range
         {
Index: src/network/extra/directconnectionbase.cpp
===================================================================
--- src/network/extra/directconnectionbase.cpp	(revisione 3979)
+++ src/network/extra/directconnectionbase.cpp	(copia locale)
@@ -806,8 +806,6 @@
   closeClientSocket();
   closeServerSocket();
 
-#warning  Test how to respond to the various socket error codes.
-
   // Filter errors that happen when you've connected already.
   switch( error )
   {
Index: src/network/extra/p2pfragmenttracker.h
===================================================================
--- src/network/extra/p2pfragmenttracker.h	(revisione 3979)
+++ src/network/extra/p2pfragmenttracker.h	(copia locale)
@@ -39,19 +39,19 @@
     // Output for debugging
     QString              getDebugMap() const;
     // Return the message ID
-    unsigned long        getMessageID() const;
+    quint32              getMessageID() const;
     // Return the number of received bytes
-    unsigned long        getTransferredBytes() const;
+    quint32              getTransferredBytes() const;
     // Return whether the tracker is empty, no data added yet.
     bool                 isEmpty() const;
     // Return whether the tracker is initialized to receive a part for the given message ID.
-    bool                 isInitialized( unsigned long messageID ) const;
+    bool                 isInitialized( quint32 messageID ) const;
     // Initialize to receive a new message
-    void                 initialize( unsigned long messageID, unsigned long totalSize );
+    void                 initialize( quint32 messageID, quint32 totalSize );
     // Return whether the fragment tracker is complete.
     bool                 isComplete() const;
     // Register the arrival of a new fragment.
-    void                 registerFragment( unsigned long offset, unsigned long size );
+    void                 registerFragment( quint32 offset, quint32 size );
 
   private:
     /**
@@ -59,16 +59,16 @@
      */
     struct Range
     {
-      unsigned long start;
-      unsigned long end;
+      quint32 start;
+      quint32 end;
     };
 
     /// The identifier of the message being transferred
-    unsigned long        messageID_;
+    quint32              messageID_;
     /// The total size of the message.
-    unsigned long        totalSize_;
+    quint32              totalSize_;
     /// The total number of bytes transferred.
-    unsigned long        transferredBytes_;
+    quint32              transferredBytes_;
     /// The list of transferred ranges.
     QList<Range*>        ranges_;
 };
Index: src/network/applications/p2papplicationbase.cpp
===================================================================
--- src/network/applications/p2papplicationbase.cpp	(revisione 3979)
+++ src/network/applications/p2papplicationbase.cpp	(copia locale)
@@ -1225,7 +1225,7 @@
   // The current fragmented message should not be affected.
   fragmentMessageID_ = nextMessageID_;
   fragmentOffset_    = 0;
-  fragmentTotalSize_ = dataSource->size();
+  fragmentTotalSize_ = (quint32) qAbs( dataSource->size() );
 
   // Inform the application list this application wants to send a file.
   // It will call sendNextDataParts() each time the connection or switchboard can accept new packets.
@@ -1618,7 +1618,7 @@
   QByteArray header( 48, 0x00 );
 
   // Determine the message ID
-  unsigned long messageID;
+  quint32 messageID;
   if( nextMessageID_ == 0 )
   {
     // We don't have a message ID set yet, we're acknowledging
@@ -1638,10 +1638,10 @@
   }
 
   // Determine the ack settings.
-  unsigned long ackTotalSize = 0;
-  unsigned long ackSessionID = 0;
-  unsigned long ackUniqueID  = 0;
-  unsigned long ackDataSize  = 0;
+  quint32 ackTotalSize = 0;
+  quint32 ackSessionID = 0;
+  quint32 ackUniqueID  = 0;
+  quint32 ackDataSize  = 0;
 
   // New ack field schema seen with Windows Live Messenger:
   if( ackType == P2PMessage::MSN_FLAG_ERROR )
@@ -1793,7 +1793,7 @@
  * @return               Whether the message can be sent. If the socket would block, false is returned.
  *                       This only occurs for direct connections connections.
  */
-bool P2PApplicationBase::sendP2PMessageImpl(const QByteArray &messageData, int flagField, P2PDataType footerCode, P2PMessageType messageType, unsigned long messageID)
+bool P2PApplicationBase::sendP2PMessageImpl(const QByteArray &messageData, int flagField, P2PDataType footerCode, P2PMessageType messageType, quint32 messageID)
 {
 #ifdef KMESSTEST
   KMESS_ASSERT( messageData.size() <= 1202 );
@@ -1840,9 +1840,9 @@
 
   // Determine the message size:
   // Internal trick: fragmentTotalSize_ is set by the caller if this is a splitted message.
-  uint messageSize = messageData.size();
-  ulong totalSize;
-  ulong offsetField;
+  quint32 messageSize = messageData.size();
+  quint32 totalSize;
+  quint32 offsetField;
 
   if( fragmentTotalSize_ == 0 )
   {
@@ -1859,10 +1859,10 @@
 
 
   // Generate ack session identifier for this message
-  unsigned long ackSessionID = KMessShared::generateID();
+  quint32 ackSessionID = KMessShared::generateID();
 
   // Set session ID to zero when SLP messages are sent.
-  unsigned long sessionID = getSessionID();
+  quint32 sessionID = getSessionID();
   if( flagField  == 0
   &&  footerCode == 0      // fixes all data transfers, like msnobjects and webcam.
   &&  messageType != P2P_MSG_DATA_PREPARATION )
Index: src/network/applications/p2papplication.cpp
===================================================================
--- src/network/applications/p2papplication.cpp	(revisione 3979)
+++ src/network/applications/p2papplication.cpp	(copia locale)
@@ -283,7 +283,7 @@
  *
  * @return The 'SessionID' field from the SLP payload of the invitation message.
  */
-unsigned long P2PApplication::getInvitationSessionID() const
+quint32 P2PApplication::getInvitationSessionID() const
 {
   return invitationSessionID_;
 }
@@ -299,7 +299,7 @@
  *
  * @return The session ID field used in the binary P2P header.
  */
-unsigned long P2PApplication::getSessionID() const
+quint32 P2PApplication::getSessionID() const
 {
   return sessionID_;
 }
@@ -1686,7 +1686,7 @@
 void P2PApplication::gotSlpSessionInvitation( const MimeMessage &slpMimeBody )
 {
   // Read requested session id from the message
-  invitationSessionID_ = slpMimeBody.getValue("SessionID").toULong();
+  invitationSessionID_ = slpMimeBody.getValue("SessionID").toUInt();
 
   // Don't accept invites if we sent one.
   if( ! isFirstMessageSent() && isUserStartedApp() )
@@ -3103,7 +3103,7 @@
  * @param  appId      The numeric app-Id value, which also identifies the application type.
  * @param  context    The context field.
  */
-void P2PApplication::sendSlpSessionInvitation( ulong sessionID, const QString &eufGuid, const int appId, const QString &context )
+void P2PApplication::sendSlpSessionInvitation( quint32 sessionID, const QString &eufGuid, const int appId, const QString &context )
 {
   // Create the message
   MimeMessage invitation;
@@ -3221,7 +3221,7 @@
 /**
  * Assign a fixed session ID (used for p2p ink transfers)
  */
-void P2PApplication::setDataCastSessionID( unsigned long sessionID )
+void P2PApplication::setDataCastSessionID( quint32 sessionID )
 {
 #ifdef KMESSTEST
   KMESS_ASSERT( sessionID_ == 0 );
Index: src/network/applications/p2papplicationbase.h
===================================================================
--- src/network/applications/p2papplicationbase.h	(revisione 3979)
+++ src/network/applications/p2papplicationbase.h	(copia locale)
@@ -200,7 +200,7 @@
     // Return the message ID used in the previous message received from the contact.
     unsigned long          getLastContactMessageID() const;
     // Returns the session ID.
-    virtual unsigned long  getSessionID() const = 0;
+    virtual quint32        getSessionID() const = 0;
     // Parse a received message... (implements pure virtual method from base class)
     void                   gotMessage(const P2PMessage &p2pMessage);
     // Verify whether the application can handle the given ACK message.
@@ -368,11 +368,11 @@
     struct UnAckedMessage
     {
       // Data for ACK message:
-      unsigned long  dataSize;     ///< The sent data size.
-      unsigned long  messageID;    ///< The sent message ID.
-      unsigned long  totalSize;    ///< The sent total size.
-      unsigned long  sessionID;    ///< The sent session ID.
-      unsigned long  ackSessionID; ///< The sent unique ID field.
+      quint32  dataSize;           ///< The sent data size.
+      quint32  messageID;          ///< The sent message ID.
+      quint32  totalSize;          ///< The sent total size.
+      quint32  sessionID;          ///< The sent session ID.
+      quint32  ackSessionID;       ///< The sent unique ID field.
       uint           sentTime;     ///< The time the message was sent.
       P2PMessageType messageType;  ///< The meta type of the message.
       unsigned int   footerCode;   ///< The message footer code.
@@ -395,7 +395,7 @@
     // Send a P2P ACK message
     void                   sendP2PAckImpl(int ackType = P2PMessage::MSN_FLAG_ACK, UnAckedMessage *originalMessageData = 0);
     // Send a P2P message
-    bool                   sendP2PMessageImpl(const QByteArray &messageData, int flagField = 0, P2PDataType footerCode = P2P_TYPE_NEGOTIATION, P2PMessageType messageType = P2P_MSG_UNKNOWN, unsigned long messageID = 0);
+    bool                   sendP2PMessageImpl(const QByteArray &messageData, int flagField = 0, P2PDataType footerCode = P2P_TYPE_NEGOTIATION, P2PMessageType messageType = P2P_MSG_UNKNOWN, quint32 messageID = 0);
     // Test if there are still unacked messages.
     void                   testUnAckedMessages(bool sendError);
 
@@ -417,17 +417,17 @@
     // The type of data to send.
     P2PDataType            dataType_;
     // Message ID, if we're sending "fragmented" content
-    unsigned long          fragmentMessageID_;
+    quint32                fragmentMessageID_;
     // Message offset, if we're sending "fragmented" content
-    unsigned long          fragmentOffset_;
+    quint32                fragmentOffset_;
     // Size of the message, if we're sending "fragmented" content
-    unsigned long          fragmentTotalSize_;
+    quint32                fragmentTotalSize_;
     // Track the status of a fragmented message (incoming currently)
     P2PFragmentTracker     fragmentTracker_;
     // The last incoming message.
     UnAckedMessage         lastIncomingMessage_;
     // Message ID, updated each time a message has been sent
-    unsigned long          nextMessageID_;
+    quint32                nextMessageID_;
     // The list of outgoing messages to be acked
     QList<UnAckedMessage*> outgoingMessages_;
     // True if an ACK was not sent yet.
Index: src/network/applications/p2papplication.h
===================================================================
--- src/network/applications/p2papplication.h	(revisione 3979)
+++ src/network/applications/p2papplication.h	(copia locale)
@@ -127,7 +127,7 @@
     // Returns the nonce that's being expected.
     const QString &        getNonce() const;
     // Returns the session ID.
-    unsigned long          getSessionID() const;
+    quint32                getSessionID() const;
     // The user cancelled the session
     virtual void           userAborted();
 
@@ -141,7 +141,7 @@
     // Return the content type read from the invitation message
     const QString&         getInvitationContentType() const;
     // Return the session id read from the invitation message
-    unsigned long          getInvitationSessionID() const;
+    quint32                getInvitationSessionID() const;
     // Called when data is received
     virtual void           gotData(const P2PMessage &message);
     // Called when all data is received, and the ack is sent.
@@ -153,13 +153,13 @@
     // Send the data preparation ACK.
     void                   sendDataPreparationAck();
     // Send the invitation for a normal session
-    void                   sendSlpSessionInvitation( ulong sessionID, const QString &eufGuid, const int appId, const QString &context );
+    void                   sendSlpSessionInvitation( quint32 sessionID, const QString &eufGuid, const int appId, const QString &context );
     // Send the invitation for a direct connection.
     void                   sendSlpTransferInvitation();
     // Send an SLP 200/OK message
     void                   sendSlpOkMessage(const MimeMessage &message);
     // Assign a fixed session ID (used for p2p ink transfers)
-    void                   setDataCastSessionID( unsigned long sessionID );
+    void                   setDataCastSessionID( quint32 sessionID );
     // The user rejected the invitation
     virtual void           userRejected();
 
@@ -245,11 +245,11 @@
     // CSeq field from the invitation message
     int                    invitationCSeq_;
     // SessionID field from the invitaiton message
-    unsigned long          invitationSessionID_;
+    quint32                invitationSessionID_;
     // The nonce for direct connections
     QString                nonce_;
     // Session ID, identifies the session at MSNP2P level.
-    unsigned long          sessionID_;
+    quint32                sessionID_;
     // True if the user needs to acknowledge the data preparation message. (doesn't send an ACK automatically)
     bool                   userShouldAcknowledge_;
 };
Index: src/network/p2pmessage.cpp
===================================================================
--- src/network/p2pmessage.cpp	(revisione 3979)
+++ src/network/p2pmessage.cpp	(copia locale)
@@ -50,55 +50,55 @@
 
 
 // Retreives the current session ID.
-unsigned long P2PMessage::getSessionID() const
+quint32 P2PMessage::getSessionID() const
 {
   return sessionID_;
 }
 
 // Retreives the current message ID. */
-unsigned long P2PMessage::getMessageID() const
+quint32 P2PMessage::getMessageID() const
 {
   return messageID_;
 }
 
 // Retreives the current message offset.
-unsigned long P2PMessage::getDataOffset() const
+quint32 P2PMessage::getDataOffset() const
 {
   return dataOffset_;
 }
 
 // Retreives the current message size.
-unsigned long P2PMessage::getDataSize() const
+quint32 P2PMessage::getDataSize() const
 {
   return dataSize_;
 }
 
 // Retreives the total message size.
-unsigned long P2PMessage::getTotalSize() const
+quint32 P2PMessage::getTotalSize() const
 {
   return totalSize_;
 }
 
 // Retreives the current message size.
-unsigned long P2PMessage::getFlags() const
+quint32 P2PMessage::getFlags() const
 {
   return flags_;
 }
 
 // Retrieves the ack session ID field.
-unsigned long P2PMessage::getAckSessionID() const
+quint32 P2PMessage::getAckSessionID() const
 {
   return ackSessionID_;
 }
 
 // Retreives the ack unique ID field.
-unsigned long P2PMessage::getAckUniqueID() const
+quint32 P2PMessage::getAckUniqueID() const
 {
   return ackUniqueID_;
 }
 
 // Retreives the ack data size field.
-unsigned long P2PMessage::getAckDataSize() const
+quint32 P2PMessage::getAckDataSize() const
 {
   return ackDataSize_;
 }
@@ -375,7 +375,7 @@
 
 
 
-unsigned long P2PMessage::extractLongBytes(const char *data, const int offset)
+quint32 P2PMessage::extractLongBytes(const char *data, const int offset)
 {
   // Convert the bytes from network order to a long int.
   return (((unsigned char) data[offset + 0]      )
Index: src/network/p2pmessage.h
===================================================================
--- src/network/p2pmessage.h	(revisione 3979)
+++ src/network/p2pmessage.h	(copia locale)
@@ -54,23 +54,23 @@
 
 public:    // Accessors
   // Retreives the current session ID.
-  unsigned long        getSessionID() const;
+  quint32              getSessionID() const;
   // Retreives the current message ID.
-  unsigned long        getMessageID() const;
+  quint32              getMessageID() const;
   // Retreives the current data message offset.
-  unsigned long        getDataOffset() const;
+  quint32              getDataOffset() const;
   // Retreives the current data message size.
-  unsigned long        getDataSize() const;
+  quint32              getDataSize() const;
   // Retreives the message flags. */
-  unsigned long        getFlags() const;
+  quint32              getFlags() const;
   // Retreives the total message size.
-  unsigned long        getTotalSize() const;
+  quint32              getTotalSize() const;
   // Retrieves the ack message ID field.
-  unsigned long        getAckSessionID() const;
+  quint32              getAckSessionID() const;
   // Retreives the ack unique ID field.
-  unsigned long        getAckUniqueID() const;
+  quint32              getAckUniqueID() const;
   // Retreives the ack data size field.
-  unsigned long        getAckDataSize() const;
+  quint32              getAckDataSize() const;
   // Retreives the nonce field (for direct connection handshake.
   QString              getNonce() const;
 
@@ -116,7 +116,7 @@
   // Extracts the bytes from the data block.
   static unsigned int  extractBytes(const char *data, const int offset);
   // Extracts the bytes from the data block.
-  static unsigned long extractLongBytes(const char *data, const int offset);
+  static quint32       extractLongBytes(const char *data, const int offset);
   // Extracts the nonce string from the data header.
   static QString       extractNonce(const char *data, const int offset = 32);
   // Extracts an utf16 string from the data header.
@@ -132,23 +132,23 @@
   QByteArray           message_;
 
   // Session ID identifying which (MSN-)SLP we're dealing with.
-  unsigned long        sessionID_;
+  quint32              sessionID_;
   // Message ID identifying which message packet we're dealing with.
-  unsigned long        messageID_;
+  quint32              messageID_;
   // Message offset.. (message packets can be split)
-  unsigned long        dataOffset_;
+  quint32              dataOffset_;
   // Message size..
-  unsigned long        dataSize_;
+  quint32              dataSize_;
   // Message flags.
-  unsigned long        flags_;
+  quint32              flags_;
   // Total message size
-  unsigned long        totalSize_;
+  quint32              totalSize_;
   // Ack session id.
-  unsigned long        ackSessionID_;
+  quint32              ackSessionID_;
   // Ack Unique id.
-  unsigned long        ackUniqueID_;
+  quint32              ackUniqueID_;
   // Ack data size.
-  unsigned long        ackDataSize_;
+  quint32              ackDataSize_;
 };
 
 
Index: src/utils/kmessshared.cpp
===================================================================
--- src/utils/kmessshared.cpp	(revisione 3979)
+++ src/utils/kmessshared.cpp	(copia locale)
@@ -203,7 +203,7 @@
  *
  * @return A random value between 4 and 4294967295.
  */
-unsigned long KMessShared::generateID()
+quint32 KMessShared::generateID()
 {
   return (rand() & 0x00FFFFFC);
 }
Index: src/utils/kmessshared.h
===================================================================
--- src/utils/kmessshared.h	(revisione 3979)
+++ src/utils/kmessshared.h	(copia locale)
@@ -46,7 +46,7 @@
     // Generate a random GUID.
     static QString         generateGUID();
     // Generate an random number to use as ID
-    static unsigned long   generateID();
+    static quint32         generateID();
     // Return the hash of a file name using the SHA1 algorithm
     static QByteArray      generateFileHash( const QString &fileName );
     // Converts a string with HTML to one with escaped entities

