Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
pan
Commits
365e2875
Commit
365e2875
authored
Dec 03, 2011
by
Heinrich Müller
Browse files
glib fixes for 2.31.3 :
https://bugzilla.gnome.org/show_bug.cgi?id=665289
reverted gio, doesn't work with win32, perhaps later... bla
parent
5ea1d0ed
Changes
16
Hide whitespace changes
Inline
Side-by-side
configure.in
View file @
365e2875
...
...
@@ -44,7 +44,7 @@ dnl
dnl GtkSpell is optional: GTKSPELL_REQUIRED refers to the minimum version
dnl needed if you want to build Pan with spellchecking in the Post window.
GLIB_REQUIRED=2.
14.0
GLIB_REQUIRED=2.
28.6
GMIME_REQUIRED=2.4.0
GTK_REQUIRED=2.16.0
GTK3_REQUIRED=3.0.0
...
...
pan/data-impl/data-impl.cc
View file @
365e2875
...
...
@@ -24,7 +24,7 @@
#include
<config.h>
extern
"C"
{
#include
<glib/gi18n.h>
#include
<glib
/gfileutils
.h>
// for g_build_filename
#include
<glib.h>
// for g_build_filename
}
#include
<pan/general/debug.h>
#include
<pan/general/file-util.h>
...
...
pan/data/article-cache.h
View file @
365e2875
...
...
@@ -23,7 +23,7 @@
#include
<map>
#include
<vector>
extern
"C"
{
#include
<glib
/gtypes
.h>
// for guint64
#include
<glib.h>
// for guint64
}
#include
<pan/general/string-view.h>
#include
<pan/general/quark.h>
...
...
pan/general/file-util.h
View file @
365e2875
...
...
@@ -25,7 +25,7 @@
extern
"C"
{
#include
<stddef.h>
#include
<stdio.h>
#include
<glib
/gtypes
.h>
#include
<glib.h>
#include
<glib/gstdio.h>
}
#include
<pan/general/string-view.h>
...
...
pan/general/locking.h
View file @
365e2875
...
...
@@ -22,7 +22,7 @@
#ifndef _Mutex_h_
#define _Mutex_h_
#include
<glib
/gthread
.h>
#include
<glib.h>
namespace
pan
{
...
...
pan/general/macros.h
View file @
365e2875
...
...
@@ -62,12 +62,11 @@
extern
"C"
{
#include
<glibconfig.h>
// get the version
#include
<glib/gutils.h>
// get GLIB_CHECK_VERSION
#include
<glib.h>
// pick up g_assert()
#if GLIB_CHECK_VERSION(2,16,0)
#include
<glib
/gtestutils
.h>
#include
<glib.h>
#else
#include
<glib/gmessages.h>
#endif
...
...
pan/general/time-elapsed.h
View file @
365e2875
#ifndef __Time_Elapsed_h__
#define __Time_Elapsed_h__
#include
<glib/gtypes.h>
// for GTimeVal
#include
<glib/gmain.h>
// for g_get_current_time
#include
<glib/gtimer.h>
// for GUSEC_PER_SEC
#include
<glib.h>
namespace
pan
{
...
...
pan/general/worker-pool.cc
View file @
365e2875
...
...
@@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include
<cassert>
#include
<glib
/gmain
.h>
// for g_idle_add
#include
<glib.h>
// for g_idle_add
#include
<pan/general/debug.h>
#include
<pan/general/macros.h>
#include
"worker-pool.h"
...
...
pan/general/worker-pool.h
View file @
365e2875
...
...
@@ -24,8 +24,7 @@
#define _Worker_Pool_H_
#include
<set>
#include
<glib/gtypes.h>
#include
<glib/gthreadpool.h>
#include
<glib.h>
namespace
pan
{
...
...
pan/gui/pan.cc
View file @
365e2875
...
...
@@ -522,7 +522,7 @@ main (int argc, char *argv[])
///////////// DBUS
/// TODO : make it work with win32
Pan
pan
(
data
,
queue
,
cache
,
prefs
,
group_prefs
);
#ifndef G_OS_WIN32
pan_dbus_init
(
&
pan
);
...
...
pan/gui/render-bytes.cc
View file @
365e2875
#include
<glib
/gutils
.h>
// g_snprintf
#include
<glib.h>
// g_snprintf
#include
"render-bytes.h"
namespace
pan
...
...
pan/gui/render-bytes.h
View file @
365e2875
#ifndef RENDER_BYTES_H
#define RENDER_BYTES_H
#include
<glib
/gtypes
.h>
#include
<glib.h>
namespace
pan
{
extern
char
*
render_bytes
(
guint64
);
}
...
...
pan/tasks/socket-impl-gio.cc
View file @
365e2875
...
...
@@ -32,7 +32,6 @@
extern
"C"
{
#include
<unistd.h>
#include
<glib/gi18n.h>
#include
<gio/gio.h>
}
#include
<pan/general/file-util.h>
...
...
@@ -40,6 +39,51 @@ extern "C" {
#include
<pan/general/macros.h>
#include
<pan/general/worker-pool.h>
#ifdef G_OS_WIN32
// this #define is necessary for mingw
#define _WIN32_WINNT 0x0501
#include
<ws2tcpip.h>
#undef gai_strerror
/*
#define gai_strerror(i) gai_strerror_does_not_link (i)
static const char*
gai_strerror_does_not_link (int errval)
{
static char buf[32];
g_snprintf (buf, sizeof(buf), "Winsock error %d", errval);
return buf;
}
*/
static
const
char
*
get_last_error
(
int
err
)
{
const
char
*
msg
=
0
;
switch
(
err
)
{
case
WSANOTINITIALISED
:
msg
=
"No successful WSAStartup call yet."
;
break
;
case
WSAENETDOWN
:
msg
=
"The network subsystem has failed."
;
break
;
case
WSAEADDRINUSE
:
msg
=
"Fully qualified address already bound"
;
break
;
case
WSAEADDRNOTAVAIL
:
msg
=
"The specified address is not a valid address for this computer."
;
break
;
case
WSAEFAULT
:
msg
=
"Error in socket address"
;
break
;
case
WSAEINPROGRESS
:
msg
=
"A call is already in progress"
;
break
;
case
WSAEINVAL
:
msg
=
"The socket is already bound to an address."
;
break
;
case
WSAENOBUFS
:
msg
=
"Not enough buffers available, too many connections."
;
break
;
case
WSAENOTSOCK
:
msg
=
"The descriptor is not a socket."
;
break
;
case
11001
:
msg
=
"Host not found"
;
break
;
default:
msg
=
"Connect failed"
;
}
return
msg
;
}
#else
#include
<signal.h>
#include
<sys/types.h>
#include
<sys/socket.h>
#include
<netinet/in.h>
#include
<netdb.h>
#include
<arpa/inet.h>
#define closesocket(fd) close(fd)
#endif
#include
<pan/general/debug.h>
#include
<pan/general/log.h>
#include
<pan/general/string-view.h>
...
...
@@ -50,39 +94,184 @@ using namespace pan;
namespace
{
const
unsigned
int
TIMEOUT_SECS
(
30
);
}
typedef
int
(
*
t_getaddrinfo
)(
const
char
*
,
const
char
*
,
const
struct
addrinfo
*
,
struct
addrinfo
**
);
t_getaddrinfo
p_getaddrinfo
(
0
);
namespace
{
typedef
void
(
*
t_freeaddrinfo
)(
struct
addrinfo
*
);
t_freeaddrinfo
p_freeaddrinfo
(
0
);
void
ensure_module_inited
(
void
)
{
static
bool
inited
(
false
);
if
(
!
inited
)
{
p_freeaddrinfo
=
NULL
;
p_getaddrinfo
=
NULL
;
#ifdef G_OS_WIN32
WSADATA
wsaData
;
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsaData
);
char
sysdir
[
MAX_PATH
],
path
[
MAX_PATH
+
8
];
if
(
GetSystemDirectory
(
sysdir
,
MAX_PATH
)
!=
0
)
{
HMODULE
lib
=
NULL
;
FARPROC
pfunc
=
NULL
;
const
char
*
libs
[]
=
{
"ws2_32"
,
"wship6"
,
NULL
};
for
(
const
char
**
p
=
libs
;
*
p
!=
NULL
;
++
p
)
{
g_snprintf
(
path
,
MAX_PATH
+
8
,
"%s
\\
%s"
,
sysdir
,
*
p
);
lib
=
LoadLibrary
(
path
);
if
(
!
lib
)
continue
;
pfunc
=
GetProcAddress
(
lib
,
"getaddrinfo"
);
if
(
!
pfunc
)
{
FreeLibrary
(
lib
);
lib
=
NULL
;
continue
;
}
p_getaddrinfo
=
reinterpret_cast
<
t_getaddrinfo
>
(
pfunc
);
pfunc
=
GetProcAddress
(
lib
,
"freeaddrinfo"
);
if
(
!
pfunc
)
{
FreeLibrary
(
lib
);
lib
=
NULL
;
p_getaddrinfo
=
NULL
;
continue
;
}
p_freeaddrinfo
=
reinterpret_cast
<
t_freeaddrinfo
>
(
pfunc
);
break
;
}
}
#else
p_freeaddrinfo
=::
freeaddrinfo
;
p_getaddrinfo
=::
getaddrinfo
;
#endif
inited
=
true
;
}
}
GIOChannel
*
create_channel
(
const
StringView
&
host_in
,
int
port
,
std
::
string
&
setme_err
)
{
GIOChannel
*
channel
(
0
)
;
int
err
;
int
sockfd
;
#ifndef G_OS_WIN32
signal
(
SIGPIPE
,
SIG_IGN
);
#endif
// get an addrinfo for the host
const
std
::
string
host
(
host_in
.
str
,
host_in
.
len
);
char
portbuf
[
32
],
hpbuf
[
255
];
g_snprintf
(
portbuf
,
sizeof
(
portbuf
),
"%d"
,
port
);
g_snprintf
(
hpbuf
,
sizeof
(
hpbuf
),
"%s:%s"
,
host_in
.
str
,
portbuf
);
g_snprintf
(
hpbuf
,
sizeof
(
hpbuf
),
"%s:%s"
,
host_in
.
str
,
portbuf
);
#ifdef G_OS_WIN32 // windows might not have getaddrinfo...
if
(
!
p_getaddrinfo
)
{
struct
hostent
*
ans
=
isalpha
(
host
[
0
])
?
gethostbyname
(
host
.
c_str
())
:
gethostbyaddr
(
host
.
c_str
(),
host
.
size
(),
AF_INET
);
err
=
WSAGetLastError
();
if
(
err
||
!
ans
)
{
setme_err
=
get_last_error
(
err
);
return
0
;
}
// try opening the socket
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
/*IPPROTO_TCP*/
);
if
(
sockfd
<
0
)
return
0
;
// Try connecting
int
i
=
0
;
err
=
-
1
;
struct
sockaddr_in
server
;
memset
(
&
server
,
0
,
sizeof
(
struct
sockaddr_in
));
while
(
err
&&
ans
->
h_addr_list
[
i
])
{
char
*
addr
=
ans
->
h_addr_list
[
i
];
memcpy
(
&
server
.
sin_addr
,
addr
,
ans
->
h_length
);
server
.
sin_family
=
AF_INET
;
server
.
sin_port
=
htons
(
port
);
++
i
;
err
=
connect
(
sockfd
,(
struct
sockaddr
*
)
&
server
,
sizeof
(
server
));
}
GSocketClient
*
client
=
g_socket_client_new
();
g_return_val_if_fail
(
client
,
0
);
if
(
err
)
{
closesocket
(
sockfd
);
setme_err
=
get_last_error
(
err
);
return
0
;
}
}
else
#endif // #ifdef G_OS_WIN32 ...
{
errno
=
0
;
struct
addrinfo
hints
;
memset
(
&
hints
,
0
,
sizeof
(
struct
addrinfo
));
hints
.
ai_flags
=
0
;
hints
.
ai_family
=
0
;
hints
.
ai_socktype
=
SOCK_STREAM
;
struct
addrinfo
*
ans
;
err
=
p_getaddrinfo
(
host
.
c_str
(),
portbuf
,
&
hints
,
&
ans
);
if
(
err
!=
0
)
{
char
buf
[
512
];
snprintf
(
buf
,
sizeof
(
buf
),
_
(
"Error connecting to
\"
%s
\"
"
),
hpbuf
);
setme_err
=
buf
;
if
(
errno
)
{
setme_err
+=
" ("
;
setme_err
+=
file
::
pan_strerror
(
errno
);
setme_err
+=
")"
;
}
return
0
;
}
GSocketConnection
*
conn
=
g_socket_client_connect_to_host
(
client
,
hpbuf
,
119
,
0
,
NULL
);
g_return_val_if_fail
(
conn
,
0
);
// try to open a socket on any ipv4 or ipv6 addresses we found
errno
=
0
;
sockfd
=
-
1
;
for
(
struct
addrinfo
*
walk
(
ans
);
walk
&&
sockfd
<
0
;
walk
=
walk
->
ai_next
)
{
// only use ipv4 or ipv6 addresses
if
((
walk
->
ai_family
!=
PF_INET
)
&&
(
walk
->
ai_family
!=
PF_INET6
))
continue
;
// try to create a socket...
sockfd
=
::
socket
(
walk
->
ai_family
,
walk
->
ai_socktype
,
walk
->
ai_protocol
);
if
(
sockfd
<
0
)
continue
;
// and make a connection
if
(
::
connect
(
sockfd
,
walk
->
ai_addr
,
walk
->
ai_addrlen
)
<
0
)
{
closesocket
(
sockfd
);
sockfd
=
-
1
;
}
}
GSocket
*
g
(
g_socket_connection_get_socket
(
conn
));
g_return_val_if_fail
(
g
,
0
);
// cleanup
p_freeaddrinfo
(
ans
);
}
int
sockfd
=
g_socket_get_fd
(
g
);
// create the giochannel...
if
(
sockfd
<
0
)
{
char
buf
[
512
];
snprintf
(
buf
,
sizeof
(
buf
),
_
(
"Error connecting to
\"
%s
\"
"
),
hpbuf
);
setme_err
=
buf
;
if
(
errno
)
{
setme_err
+=
" ("
;
setme_err
+=
file
::
pan_strerror
(
errno
);
setme_err
+=
")"
;
}
return
0
;
}
GIOChannel
*
channel
(
0
);
#ifndef G_OS_WIN32
channel
=
g_io_channel_unix_new
(
sockfd
);
g_io_channel_set_flags
(
channel
,
G_IO_FLAG_NONBLOCK
,
NULL
);
...
...
@@ -93,7 +282,6 @@ namespace
g_io_channel_set_encoding
(
channel
,
NULL
,
NULL
);
g_io_channel_set_buffered
(
channel
,
true
);
g_io_channel_set_line_term
(
channel
,
"
\n
"
,
1
);
return
channel
;
}
}
...
...
@@ -318,7 +506,7 @@ GIOChannelSocket :: gio_func (GIOChannel * channel,
* could be a bug in gcc 4.2.1.
*/
/*if (_abort_flag) _listener->on_socket_abort (this);
else*/
if
(
result
==
IO_ERR
)
_listener
->
on_socket_error
(
this
);
else*/
if
(
result
==
IO_ERR
)
_listener
->
on_socket_error
(
this
);
else
if
(
result
==
IO_READ
)
set_watch_mode
(
READ_NOW
);
else
if
(
result
==
IO_WRITE
)
set_watch_mode
(
WRITE_NOW
);
}
...
...
@@ -326,6 +514,10 @@ GIOChannelSocket :: gio_func (GIOChannel * channel,
return
false
;
// set_watch_now(IGNORE) cleared the tag that called this func
}
namespace
{
const
unsigned
int
TIMEOUT_SECS
(
30
);
}
void
GIOChannelSocket
::
set_watch_mode
(
WatchMode
mode
)
...
...
@@ -404,6 +596,8 @@ GIOChannelSocket :: Creator :: create_socket (const StringView & host,
WorkerPool
&
threadpool
,
Listener
*
listener
)
{
ensure_module_inited
();
ThreadWorker
*
w
=
new
ThreadWorker
(
host
,
port
,
listener
);
threadpool
.
push_work
(
w
,
w
,
true
);
}
pan/tasks/socket-impl-gio.h
View file @
365e2875
...
...
@@ -21,8 +21,7 @@
#define __SocketGIO_h__
#include
<string>
#include
<glib/giochannel.h>
#include
<glib/gstring.h>
#include
<glib.h>
#include
<pan/tasks/socket.h>
namespace
pan
...
...
pan/usenet-utils/mime-utils.h
View file @
365e2875
...
...
@@ -21,7 +21,7 @@
#define _UtilMime_h_
#include
<vector>
#include
<glib
/gtypes
.h>
#include
<glib.h>
#include
<gmime/gmime-filter.h>
#include
<gmime/gmime-stream.h>
#include
<gmime/gmime-message.h>
...
...
pan/usenet-utils/text-massager.cc
View file @
365e2875
...
...
@@ -25,7 +25,6 @@
extern
"C"
{
#include
<glib/gi18n.h>
}
#include
<glib/gunicode.h>
#include
"text-massager.h"
#include
<pan/general/log.h>
using
namespace
pan
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment