Commit Graph

15420 Commits

Author SHA1 Message Date
Chun-wei Fan
b397f4652b glib-sections.txt: Add g_win32_check_windows_version()
https://bugzilla.gnome.org/show_bug.cgi?id=741895
2015-01-27 12:22:29 +08:00
Chun-wei Fan
220ea77591 gwin32: Add g_win32_check_windows_version() API
This adds a public API where one can use to see whether the running version
of Windows where the code is run is at least the specified version, service
pack level, and the type (non-server, server, any) of the running Windows
OS.

This API is done as:
-GetVersion()/GetVersionEx() changed in the way they work since Windows 8.1
 [1][2], so a newer mechanism to check the version of the running Windows
 operating system is needed.  MSDN also states that GetVersion() might be
 further changed or removed after Windows 8.1.  This provides a wrapper for
 VerfyVersionInfo() as well in GLib for most cases, which was recommended
 in place of g_win32_get_windows_version() for more detailed Windows
 version checking.
-Provides an OS-level functionality check, for those that we don't need to
 venture into GetProcAddress(), and also to determine system API behavior
 changes due to differences in OS versions.

Also added a note for the g_win32_get_windows_version() API that since the
behavior of GetVersion() which it uses, is changed since Windows 8.1, users
of the API should be aware.

[1]:
http://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724451%28v=vs.85%29.aspx
[2]:
http://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724451%28v=vs.85%29.aspx

https://bugzilla.gnome.org/show_bug.cgi?id=741895
2015-01-27 12:21:58 +08:00
Chun-wei Fan
9f141cd50d gio/Makefile.am: Fix MSVC Project Generation
We need to filter out gnetworkmonitornm.c in the MSVC Projects, as that is
UNIX-only code.
2015-01-21 16:38:32 +08:00
Ryan Lortie
862580f0c2 kqueue backend: port to new GLocalFileMonitor API
This is the bare minimal effort.  This seems not to crash immediately,
but it definitely needs some better testing.

The backend is not in good shape.  It could use some serious work.
2015-01-16 18:55:48 -05:00
Ryan Lortie
0ebbf60bf0 GPollFileMonitor: use thread default main context
Attach the GPollFileMonitor to the thread default main context instead
of the global default.

This matches the behaviour of the other file monitors.
2015-01-16 18:55:48 -05:00
Ryan Lortie
bf5b55bf7a inotify: simplify "boredom" algorithm
The rules are now very simple: if we wake up and it's not interesting
then we sleep for a given amount of time (100ms) before checking again.

Also: introduce a smarter mechanism for getting all of the events
currently in the buffer.
2015-01-16 18:55:48 -05:00
Ryan Lortie
54ca2ad94e inotify: implement the "boredom" algorithm
Also: add a hashtable for move pairing
2015-01-16 18:55:33 -05:00
Ryan Lortie
272c3fc710 inotify: plumb "interesting" through 2015-01-16 18:55:33 -05:00
Ryan Lortie
8220d6cead GFileMonitorSource: return "interesting" value
Return an "interesting" boolean from the event handler function on
GFileMonitorSource.

An event was "interesting" if it will result in a signal actually being
dispatched to the user.  It is "uninteresting" if it only hit an
already-dirty rate limiter.

We will use this information to do some backing off in the backends when
faced with a flood of uninteresting events.
2015-01-16 18:55:33 -05:00
Ryan Lortie
5f28cb4b46 GFileMonitor: send final CHANGED on CHANGES_DONE
CHANGES_DONE would delete the pending change record, ignoring the dirty
flag.  That means that a rate-limited CHANGED event would effectively be
dropped.  Fix up that inconsistency by reporting the CHANGED before the
CHANGES_DONE if the dirty bit was set.
2015-01-16 18:55:33 -05:00
Ryan Lortie
9b49073f01 GFileMonitor: get rid of APPEARED events
We could accomplish what we want by simply reporting CREATED directly
followed by CHANGES_DONE.

We may want to add back _APPEARED some day and allow people to opt into
it separately via a GFileMonitorFlag if they really care about the
distinction.  It would certainly be nicer to allow the backends to
report this case with a distinct event type and have GFileMonitorSource
do the right thing.
2015-01-16 18:55:33 -05:00
Ryan Lortie
9620e043d8 GFileMonitor: add APPEARED event
...and try to send it for some common cases in inotify.

We're now abusing the WATCH_MOVES flag as a general "opt-in to new API".
That's bad.
2015-01-16 18:55:33 -05:00
Chun-wei Fan
a3bfeef2d3 giomodule.c: Include Some Forgotten Headers
The headers are used for G_TYPE_INITABLE and
G_NETWORK_MONITOR_EXTENSION_POINT_NAME, which led to undefined variables
if not included...
2015-01-16 18:55:33 -05:00
Ryan Lortie
f90709ea39 start on 'gio' tool 2015-01-16 18:55:33 -05:00
Ryan Lortie
9a7838dbd5 substantially rework file monitors
Remove all event merging and dispatch logic from GFileMonitor.  The only
implementation of GFileMonitor outside of glib is in gvfs and it already
does these things properly.

Get rid of GLocalDirectoryMonitor.  We will use a single class,
GLocalFileMonitor, for both directory and file monitoring.  This will
prevent every single backend from having to create two objects
separately (eg: ginotifydirectorymonitor.c and ginotifyfilemonitor.c).

Introduce GFileMonitorSource as a thread-safe cross-context dispatch
mechanism.  Put it in GLocalFileMonitor.  All backends will be expected
to dispatch via the source and not touch the GFileMonitor object at all
from the worker thread.

Remove all construct properties from GLocalFileMonitor and remove the
"context" construct property from GFileMonitor.  All backends must now
get the information about what file to monitor from the ->start() call
which is mandatory to implement.

Remove the implementation of rate limiting in GFileMonitor and add an
implementation in GLocalFileMonitor.  gvfs never did anything with this
anyway, but if it wanted to, it would have to implement it for itself.
This was done in order to get the rate_limit field into the
GFileMonitorSource so that it could be safely accessed from the worker
thread.

Add a couple of extra utility functions to GLocalFile so that we can
skip some memory copies (and skip the gvfs detection logic when choosing
which backend to use).  Expose the pre-existing "is_remote"
functionality.

With the "is_remote" functionality exposed, we can now move all
functions for creating local file monitors to a proper location in
glocalfilemonitor.c

Port the inotify backend to adjust to the changes above.  None of the
other backends are ported yet.

This mega-commit is a work in progress -- it should probably be broken
up.
2015-01-16 18:55:33 -05:00
Ryan Lortie
00b245d7b3 inotify: rewrite inotify-kernel
Remove the hardwired 1 second event queue logic from inotify-kernel and
replace it with something vastly less complicated.

Events are now reported as soon as is possible instead of after a delay.

We still must delay IN_MOVED_FROM events in order to look for the
matching IN_MOVED_TO events, and since we want to report events in order
this means that events behind those events can also be delayed.  We
limit ourselves, however:

 - no more than 100 events can be delayed at a time

 - no event can be delayed by more than 10ms

https://bugzilla.gnome.org/show_bug.cgi?id=627285
2015-01-16 18:55:33 -05:00
Ryan Lortie
c534be156c Make GContextSpecificSource internally "public"
Expose GContextSpecificSource so that things in GIO can use it directly.

Add support for a user_data area in the struct which will be helpful for
some intended use cases.

Also expose a way to emit a signal directly on a single source without
having to go through the group.
2015-01-16 18:55:33 -05:00
Ryan Lortie
34680b7527 GContextSpecificGroup: support for complex signals
Add support for non-VOID__VOID signals to GContextSpecificGroup.

We keep the VOID__VOID case as a special optimised case by usual the
usual bit-stealing tricks.
2015-01-16 18:55:33 -05:00
Ryan Lortie
43f525f535 Make GUnixMountMonitor per-context
GUnixMountMonitor was not threadsafe before.  It was a global singleton
which emitted signals in the first thread that happened to construct it.

Move it to a per-context singleton model where each GMainContext gets
its own GUnixMountMonitor.  Monitor for the changes from the GLib worker
thread and dispatch the results to each context with an active monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:33 -05:00
Ryan Lortie
ba0a3c81dd gunixmounts: move GUnixMountMonitor code
Move this code to the correct part of the file.

While we're at it, drop an unused #define MOUNT_POLL_INTERVAL.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Ryan Lortie
01836de077 gunixmounts.c: add fold markers
This is a large file with a lot of very complicated code in it.  Add
some fold markers to make things a bit more manageable.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Ryan Lortie
e5424fa145 Deprecate g_unix_mount_monitor_set_rate_limit()
Deprecate g_unix_mount_monitor_set_rate_limit() and turn it into a
no-op.

This function doesn't behave as advertised.  It only controls rate
limiting for filesystem-based monitors.  It has no impact over reporting
mount changes on Linux, for example, because those are based on polling
for changes in /proc (which doesn't use filesystem monitors).  It also
has no impact on Mac OS because a library interface is used there.

This was added in https://bugzilla.gnome.org/show_bug.cgi?id=521946 in
order to be used by HAL, which is effectively dead.  udisks no longer
uses this code at all.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Ryan Lortie
265c1660e9 Rename g_unix_mount_monitor_new() to _get()
This is a singleton, but we have a function called _new() to get it.
What's worse is that the documentation makes no mention of this, and
actually specifically says that a new monitor will be created each time.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Ryan Lortie
b7204bf64e GAppInfoMonitor: port to GContextSpecificGroup
https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Ryan Lortie
23bd6d3058 Add internal helper GContextSpecificGroup
Add a new internal helper called GContextSpecificGroup.

This is a mechanism for helping to maintain a group of context-specific
monitor objects (eg: GAppInfoMonitor, GUnixMountMonitor).

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Ryan Lortie
795d1deb02 Add g_main_context_ensure_is_owner()
This new function is intended to be used for verifying that operations
on objects that belong to a given main context are only made from valid
places.

The usual rule is that the operations must be performed while the main
context is acquired, but an exception is made for the global default
main context so that things can be set up before running the main loop.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Ryan Lortie
9459934928 GThread: add internal "debug name" helper
Add an internal function to get the name of a thread for display in
debugging messages.  We support reporting "the main thread" for the
thread that our ctor got run in (which is almost definitely what most
people would consider to be 'the main thread').

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-01-16 18:55:32 -05:00
Philip Withnall
9114923db2 ggettext: Include an example of setlocale() and friends in the i18n docs
Include an example main() function, and include a link to the gettext
manual’s section on integrating gettext with build systems.

That should work as a complete reference for how to add i18n support to
an application.

https://bugzilla.gnome.org/show_bug.cgi?id=742972
2015-01-15 14:22:25 +00:00
Paolo Borelli
7a8ef00aae Avoid warning when using G_STMT_END macro with MSVC
Workaround found on
http://cnicholson.net/2009/03/stupid-c-tricks-dowhile0-and-c4127/

https://bugzilla.gnome.org/show_bug.cgi?id=742851
2015-01-14 16:21:00 +01:00
Paolo Borelli
432476355b Use G_STMT_START/END in gslice.h 2015-01-14 16:21:00 +01:00
Paolo Borelli
be0c9e507a Use G_STMT_START/END in gtestutils 2015-01-14 16:21:00 +01:00
Philip Withnall
70e2630f5a gsettings: Fix a typo in the GSettings documentation
https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-01-14 10:53:04 +00:00
Matthias Clasen
b1e5b0e733 Bump version
So that early adopters of new api have a version to target.
2015-01-13 16:54:59 -05:00
Iain Lane
f7be461601 gnetworkmonitornm: Check if network-manager is running
We were asking for properties on NM's dbus interface, but if NM is not
running then there won't be any. Check if the name has an owner before
doing anything to it.

https://bugzilla.gnome.org/show_bug.cgi?id=741653
2015-01-13 12:11:06 +01:00
Ryan Lortie
84a1efeabd configure.ac: reject 'universal' builds
AC_C_BIGENDIAN can return 'universal' as the result in the case that we
are trying to do a universal build on Mac OS.  This has to be opted into
explicitly by using multiple -arch CFLAGS.

Previously, we detected this result and fell back to doing our own check
based on the endianness of the build machine, hardcoding that.  This
means that universal builds might successfully build, but the binaries
would never actually run correctly on the 'opposite' arch.

This check was added because of a bug in the intial implementation of
this detection in autoconf, which was inappropriately identifying
non-macos compilers as 'universal'.  That was hitting ppc64 systems.
See https://bugzilla.redhat.com/show_bug.cgi?id=449944 for more info.

Commit b0e687ef42e21b1eb7af18c4eaebcd41b0bd5632 in autoconf ("Limit
AC_C_BIGENDIAN univeral checks to Mac OS X") solved this issue in 2008,
so let's remove our workaround.  For good measure, if we detect
"universal" in the result, error out.

https://bugzilla.gnome.org/show_bug.cgi?id=742548
2015-01-10 18:00:02 -05:00
Rafael Ferreira
12b5eff6dc Updated Brazilian Portuguese translation 2015-01-09 01:49:13 +00:00
Chun-wei Fan
1632d5716e Win32: Update Pre-configured Config Headers
Update config.h.win32.in and glibconfig.h.win32.in so that they will be
in-line with the ones that are produced with configure.ac, for use on
Windows builds.

Thanks to Philip Withnall for pointing out the changes needed to update
glibconfig.h.win32.in in bug 727829.
2015-01-07 09:59:47 +08:00
Timm Bäder
327d35ed41 gnetworkmonitornm: Prevent crash
g_dbus_proxy_get_cached_property_names can return NULL if there are no
cached properties, so don't try to access them in that case.
2015-01-05 11:51:46 +01:00
TingPing
aa4e2d4dc3 Fix GContentType usage
https://bugzilla.gnome.org/show_bug.cgi?id=734946
2015-01-04 22:09:37 -05:00
Matthias Clasen
48293bb47d Fix a typo 2014-12-23 19:49:41 -05:00
Erick Pérez Castellanos
8344bf1179 Fix document typo
This one was making syntax highlighting fail.
2014-12-22 11:02:08 -05:00
Matthias Clasen
30abc73c1a Silence the build some more 2014-12-20 21:32:53 -05:00
Thomas Haller
c447bc7f93 gobject: don't use G_STRLOC in G_OBJECT_WARN_INVALID_PSPEC() macro
Using G_STRLOC ends up embedding unique strings of the form
__FILE__:__LINE__ in the compiled binary. We can avoid these
by passing __FILE__ and __LINE__ separately when constructing
the warning text.
This probably reduces the size of the binary as __FILE__ is
likely already contained as string otherwise.

Note that for GCC 2.x this changes behavior because G_STRLOC
also contained __PRETTY_FUNCTION__.

https://bugzilla.gnome.org/show_bug.cgi?id=741654
2014-12-18 15:02:16 +01:00
Philip Withnall
d951db4236 gobject: Add g_set_object() convenience function to set GObject pointers
Along the same lines as g_clear_object(), g_set_object() is a
convenience function to update a GObject pointer, handling reference
counting transparently and correctly.

Specifically, it handles the case where a pointer is set to its current
value. If handled naïvely, that could result in the object instance
being finalised. In the following code, that happens when
(my_obj == new_value) and the object has a single reference:
    g_clear_object (&my_obj);
    my_obj = g_object_ref (new_value);

It also simplifies boilerplate code such as set_property()
implementations, which are otherwise long and boring.

Test cases included.

https://bugzilla.gnome.org/show_bug.cgi?id=741589
2014-12-18 11:32:56 +00:00
Philip Chimento
4f3ab40c04 gfile: Explain nonobvious use of my_error
In g_file_make_directory_with_parents(), the my_error variable is used
for several different purposes throughout the whole function, not all of
which are obvious. This explains the situation with some comments.

https://bugzilla.gnome.org/show_bug.cgi?id=719455
2014-12-18 02:02:53 -05:00
Philip Chimento
44372f4dd0 gfile: Use g_error_matches
Make proper use of g_error_matches() instead of comparing only error codes.

https://bugzilla.gnome.org/show_bug.cgi?id=719455
2014-12-18 02:02:53 -05:00
Philip Chimento
5a7db3015a gfile: make_directory_with_parents race condition
A race condition could cause g_file_make_directory_with_parents() to
fail with G_IO_ERROR_EXISTS despite the requested directory not
existing.

https://bugzilla.gnome.org/show_bug.cgi?id=719455
2014-12-18 02:02:53 -05:00
Daniel Mustieles
388e0d576f Updated Spanish translation 2014-12-17 12:31:29 +01:00
Philip Withnall
e98a5828d3 docs: Remove a mention of g_clear_object() being atomic
It is no longer atomic.

https://bugzilla.gnome.org/show_bug.cgi?id=741589
2014-12-16 17:11:11 +00:00
Matthias Clasen
924f269763 2.43.2 2.43.2 2014-12-15 13:17:15 -05:00