~ubuntu-branches/ubuntu/precise/konversation/precise-updates

« back to all changes in this revision

Viewing changes to src/dcc/transfersend.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-17 09:50:41 UTC
  • mfrom: (1.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091217095041-k5ssvxm2u8wgf0ll
Tags: 1.2.1+git20091217-0ubuntu1
* New upstream git snapshot:
  - Refresh all patches
  - Update initial Indicator patch to apply properly.
  - Remove docs and locale files from the install manifest; they aren't
    present in git snapshots. We will uncomment them for official (pre)
    releases with tarballs from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <KInputDialog>
37
37
#include <KAuthorized>
38
38
 
39
 
#include <stdlib.h>
40
 
#include <sys/types.h>
41
 
#include <netinet/in.h>
42
 
#include <sys/socket.h>
43
 
#ifndef Q_CC_MSVC
44
 
#   include <net/if.h>
45
 
#   include <sys/ioctl.h>
46
 
#   ifdef HAVE_STROPTS_H
47
 
#       include <stropts.h>
48
 
#   endif
49
 
#endif
50
 
#include <arpa/inet.h>
51
 
 
52
39
using namespace Konversation::UPnP;
53
40
 
54
41
namespace Konversation
166
153
 
167
154
            if ( Preferences::self()->dccIPv4Fallback() )
168
155
            {
169
 
                QHostAddress ip(m_ownIp);
170
 
                if (ip.protocol() == QAbstractSocket::IPv6Protocol)
171
 
                {
172
 
        #ifndef Q_WS_WIN
173
 
                    /* This is fucking ugly but there is no KDE way to do this yet :| -cartman */
174
 
                    struct ifreq ifr;
175
 
                    const QByteArray addressBa = Preferences::self()->dccIPv4FallbackIface().toAscii();
176
 
                    const char* address = addressBa.constData();
177
 
                    int sock = socket(AF_INET, SOCK_DGRAM, 0);
178
 
                    strncpy( ifr.ifr_name, address, IF_NAMESIZE );
179
 
                    ifr.ifr_addr.sa_family = AF_INET;
180
 
                    if ( ioctl( sock, SIOCGIFADDR, &ifr ) >= 0 )
181
 
                    {
182
 
                        struct sockaddr_in sock;
183
 
                        memcpy(&sock, &ifr.ifr_addr, sizeof(ifr.ifr_addr));
184
 
                        m_ownIp = inet_ntoa(sock.sin_addr);
185
 
                    }
186
 
                    kDebug() << "Falling back to IPv4 address " << m_ownIp;
187
 
        #endif
188
 
                }
 
156
                m_ownIp = DCC::DccCommon::ipv6FallbackAddress(m_ownIp);
189
157
            }
190
158
 
191
159
            m_fastSend = Preferences::self()->dccFastSend();
401
369
            m_sendSocket = m_serverSocket->nextPendingConnection();
402
370
            if ( !m_sendSocket )
403
371
            {
404
 
                failed( i18n( "Could not accept the connection (socket error.)" ) );
 
372
                failed( i18n( "Could not accept the connection (socket error)." ) );
405
373
                return;
406
374
            }
407
375
            connect( m_sendSocket, SIGNAL( error ( QAbstractSocket::SocketError ) ), this, SLOT( slotGotSocketError( QAbstractSocket::SocketError ) ));