Fix language getting reset to system default on saving preferences
[amule.git] / src / AsyncDNS.cpp
blob5dd9eb22804a6f7e9bb39d6fe4171727fe63061d
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2008 Angel Vidal ( kry@amule.org )
5 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
7 //
8 // Any parts of this program derived from the xMule, lMule or eMule project,
9 // or contributed by third-party developers are copyrighted by their
10 // respective authors.
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "AsyncDNS.h" // Interface declaration
29 #include "InternalEvents.h" // Needed for wxEVT_*
30 #include "NetworkFunctions.h" // Needed for StringHosttoUint32
31 #include "Logger.h"
34 CAsyncDNS::CAsyncDNS(const wxChar* ipName, DnsSolveType type, wxEvtHandler* handler, void* socket)
35 : wxThread(wxTHREAD_DETACHED)
37 m_type = type;
38 m_ipName = ipName;
39 m_socket = socket;
40 m_handler = handler;
44 wxThread::ExitCode CAsyncDNS::Entry()
46 uint32 result = StringHosttoUint32(m_ipName);
47 uint32 event_id = 0;
48 void* event_data = NULL;
50 switch (m_type) {
51 case DNS_UDP:
52 event_id = wxEVT_CORE_UDP_DNS_DONE;
53 event_data = m_socket;
54 break;
55 case DNS_SOURCE:
56 event_id = wxEVT_CORE_SOURCE_DNS_DONE;
57 event_data = NULL;
58 break;
59 case DNS_SERVER_CONNECT:
60 event_id = wxEVT_CORE_SERVER_DNS_DONE;
61 event_data = m_socket;
62 break;
63 default:
64 AddLogLineN(wxT("WRONG TYPE ID ON ASYNC DNS SOLVING!!!"));
67 if (event_id) {
68 CMuleInternalEvent evt(event_id);
69 evt.SetExtraLong(result);
70 evt.SetClientData(event_data);
71 wxPostEvent(m_handler,evt);
74 return NULL;
76 // File_checked_for_headers