summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
AgeCommit message (Collapse)Author
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-11LibCore: Add line iterators to IODeviceAnotherTest
2021-01-11Vector: Implement `find`, `find_if`, `find_first_matching` in terms of โ†ตLenny Maiorani
`AK::find*` Problem: - The implementation of `find` is coupled to the implementation of `Vector`. - `Vector::find` takes the predicate by value which might be expensive. Solution: - Decouple the implementation of `find` from `Vector` by using a generic `find` algorithm. - Change the name of `find` with a predicate to `find_if` so that a binding reference can be used and the predicate can be forwarded to avoid copies. - Change all the `find(pred)` call sites to use `find_if`.
2021-01-10LibCore: Use OSError in get_password() return typeAndreas Kling
2021-01-10LibCore: get_password() now removes the trailing '\n' read by getline()Emanuele Torre
This avoids unintentionally adding a newline character at the end of user passwords when they are set using passwd(1). I also fixed these two issues: - The return value of getline() was being saved in an `int` variable instead of in a `ssize_t` variable; I replaced the `int` keyword with `auto` to fix this issue. - Prior to this patch, get_password() could potentially return tcsetattr()'s errno instead of getline()'s errno in case of an error. We now make sure it always returns the right errno in case of an error.
2021-01-10LibCore: Don't try to unlink stale sockets in /tmp/rpc/Andreas Kling
This was very obviously racy and would only succeed if we already own the socket anyway. (And if we do, we can bind to it without unlinking!) Work towards #4876.
2021-01-10SystemServer+LibCore: Move /tmp/rpc/ directory creation to SystemServerAndreas Kling
This doesn't solve half of the problems with /tmp/rpc, but this way we can at least make it sticky instead of having it fully world-writable and owned by whoever was the first to bind an RPC socket.
2021-01-10Everywhere: Convert a bunch of dbgprintf() to dbgln()Andreas Kling
2021-01-09LibCore: Harden signal handling code to be called in global destrcutorsTom
Move some more complex globals into a Singleton, which allows it being used from global destructors. It solves problems where some global variables, such as HashMaps may already be deleted, triggering crashes trying to use them.
2021-01-09LibCore: Allow adding/removing signal handlers while handling signalsTom
This allows adding and removing of asynchronous signal handlers while executing signal handlers, even if it is for the same signal that is being handled right now.
2021-01-09Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything: The modifications in this commit were automatically made using the following command: find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09AK: Add Formatter<FormatString> as helper class.asynts
2021-01-09LibCore+passwd+su+Base: Add /etc/shadow to hide hashes from users :^)Andreas Kling
This patch moves the user account password hashes from /etc/passwd, where they were world-readable, to /etc/shadow, where only root can access them. The Core::Account class is extended to support both authentication against, and modification of /etc/shadow. The default password for "anon" as of this commit is "foo" :^)
2021-01-09LibCore: Don't auto-accept events that hit bubbling limitAndreas Kling
We were using the "accept" flag on the event to break out of the bubbling loop, but this had lasting consequences since all events that bubbled too far came out looking as if someone had accepted them. If an event is ignored by everyone, it should appear ignored.
2021-01-04LibCore: Make Core::Object::property() constAndreas Kling
2021-01-03LibCore: Allow caching and reusing the ProcFS file descriptorsTom
Because ProcFS will refresh the data upon seek to 0, we can re-use the same file descriptor. This saves us from having to open it every time, but it also reduces the odds that we are unable to open a new file descriptor due to low memory conditions.
2021-01-03LibCore: Report error condition when reading process statistics failedTom
2021-01-03LibCore: Add a way to check if a property is readonlyAnotherTest
2021-01-01LibCore: Remove Core::Object::is_widget() in favor of RTTIAndreas Kling
2021-01-01LibCore: Remove some hand-rolled type information from Core::ObjectAndreas Kling
Both is_action() and is_window() can be answered by RTTI.
2021-01-01LibCore: Add typed find_child and find_descendant helpers to ObjectAndrew Kaster
These look a lot like the parallel functionality in GUI::Widget :). These use dynamic_cast now, to make use of that RTTI we just added.
2020-12-30AK+Format: Remove TypeErasedFormatParams& from format function.asynts
2020-12-30ProtocolServer: Stream the downloaded data if possibleAnotherTest
This patchset makes ProtocolServer stream the downloads to its client (LibProtocol), and as such changes the download API; a possible download lifecycle could be as such: notation = client->server:'>', server->client:'<', pipe activity:'*' ``` > StartDownload(GET, url, headers, {}) < Response(0, fd 8) * {data, 1024b} < HeadersBecameAvailable(0, response_headers, 200) < DownloadProgress(0, 4K, 1024) * {data, 1024b} * {data, 1024b} < DownloadProgress(0, 4K, 2048) * {data, 1024b} < DownloadProgress(0, 4K, 1024) < DownloadFinished(0, true, 4K) ``` Since managing the received file descriptor is a pain, LibProtocol implements `Download::stream_into(OutputStream)`, which can be used to stream the download into any given output stream (be it a file, or memory, or writing stuff with a delay, etc.). Also, as some of the users of this API require all the downloaded data upfront, LibProtocol also implements `set_should_buffer_all_input()`, which causes the download instance to buffer all the data until the download is complete, and to call the `on_buffered_download_finish` hook.
2020-12-30LibGUI: Register a whole bunch of properties in various widgetsAnotherTest
2020-12-30LibGUI+LibCore: Remove the GUI::SizePolicy enumAndreas Kling
2020-12-29LibCore: Add REGISTER_TEXT_ALIGNMENT_PROPERTY macroLinus Groh
2020-12-29LibCore: Add REGISTER_ENUM_PROPERTY macroLinus Groh
This can be used to register a property that maps enum values to certain strings, e.g. REGISTER_ENUM_PROPERTY( property_name, getter, setter, Enum, { Enum::Foo, "Foo" }, { Enum::Bar, "Bar" }); Also use it for REGISTER_SIZE_POLICY_PROPERTY :^)
2020-12-28LibCore: Make Core::Timer::create_single_shot() create a stopped timerAndreas Kling
None of the code using this actually expected the timer to fire right away, but they would instead call start() on it once they were ready to accept a timer fire. Let's make the API behave the way its clients believed it did. :^)
2020-12-27LibCore: Add Object::remove_all_children()Linus Groh
2020-12-27Kernel: Remove the per-process icon_id and sys$set_process_icon()Andreas Kling
This was a goofy kernel API where you could assign an icon_id (int) to a process which referred to a global shbuf with a 16x16 icon bitmap inside it. Instead of this, programs that want to display a process icon now retrieve it from the process executable instead.
2020-12-27Kernel: Expose process executable paths in /proc/allAndreas Kling
2020-12-23LibCore: Stop logging that a Core::Socket has disconnected in receive()Andreas Kling
This is perfectly normal and nothing we need to inform about.
2020-12-22LibCore: Rename identifiers that can clash with libc macros (#4127)ร‰rico Nogueira Rolim
POSIX allows the default streams (stdin, stdout and stderr) to be macros, which means that on such systems (musl libc is one) building Lagom will fail due to the File::std*() names. Also fix any files that use these identifiers.
2020-12-21Kernel: Improve time keeping and dramatically reduce interrupt loadTom
This implements a number of changes related to time: * If a HPET is present, it is now used only as a system timer, unless the Local APIC timer is used (in which case the HPET timer will not trigger any interrupts at all). * If a HPET is present, the current time can now be as accurate as the chip can be, independently from the system timer. We now query the HPET main counter for the current time in CPU #0's system timer interrupt, and use that as a base line. If a high precision time is queried, that base line is used in combination with quering the HPET timer directly, which should give a much more accurate time stamp at the expense of more overhead. For faster time stamps, the more coarse value based on the last interrupt will be returned. This also means that any missed interrupts should not cause the time to drift. * The default system interrupt rate is reduced to about 250 per second. * Fix calculation of Thread CPU usage by using the amount of ticks they used rather than the number of times a context switch happened. * Implement CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE and use it for most cases where precise timestamps are not needed.
2020-12-18LibCore: UDPServer::bind: Replace bind failure assert() with perror()Brendan Coles
2020-12-16LibCore: Expose some Socket properties to make then inspectableConrad Pankoff
2020-12-14LibCore: Add DirectoryWatcherItamar
DirectoryWatcher is a wrapper around watch_file, and can be used to watch for changes in directories.
2020-12-14Loader: Stabilize loader & Use shared libraries everywhere :^)Itamar
The dynamic loader is now stable enough to be used everywhere in the system - so this commit does just that. No More .a Files, Long Live .so's!
2020-12-13LibCore: Make IODevice::read_line() return a StringAndreas Kling
Almost everyone using this API actually wanted String instead of a ByteBuffer anyway, and there were a bunch of slightly different ways clients would convert to String. Let's just cut out all the confusion and make it return String. :^)
2020-12-06LibCore: Offer to display a general descriptionBen Wiederhake
2020-11-30LibCore: Don't wait for negative amount of timeTom
2020-11-29LibCore: Reduce debug spam from successful gzip decodingAndreas Kling
2020-11-29LibCore: Do not try to null-terminate a ByteBuffer in read_line()AnotherTest
That's just silly :) Also fix that one use of read_line() which assumes it will null-terminated in mount.cpp (this would've blown up if the IODevice was at EOF and had a line with the same size as max_size).
2020-11-24LibCore: Make `guess_mime_type_based_on_filename()' recognise CSV filesAnotherTest
2020-11-15Everywhere: Add missing <AK/ByteBuffer.h> includesAndreas Kling
All of these files were getting ByteBuffer.h from someone else and then using it. Let's include it explicitly.
2020-11-12InputFileStream: Incorrectly defaulted constructorLenny Maiorani
Problem: - The default constructor is is deleted because NonnullRefPtr has no default constructor and there is a member variable of that type, but the function is set as `= default`. Solution: - Remove the code because the function is actually deleted implicitly.
2020-11-10AK: Make RefPtr, NonnullRefPtr, WeakPtr thread safeTom
This makes most operations thread safe, especially so that they can safely be used in the Kernel. This includes obtaining a strong reference from a weak reference, which now requires an explicit call to WeakPtr::strong_ref(). Another major change is that Weakable::make_weak_ref() may require the explicit target type. Previously we used reinterpret_cast in WeakPtr, assuming that it can be properly converted. But WeakPtr does not necessarily have the knowledge to be able to do this. Instead, we now ask the class itself to deliver a WeakPtr to the type that we want. Also, WeakLink is no longer specific to a target type. The reason for this is that we want to be able to safely convert e.g. WeakPtr<T> to WeakPtr<U>, and before this we just reinterpret_cast the internal WeakLink<T> to WeakLink<U>, which is a bold assumption that it would actually produce the correct code. Instead, WeakLink now operates on just a raw pointer and we only make those constructors/operators available if we can verify that it can be safely cast. In order to guarantee thread safety, we now use the least significant bit in the pointer for locking purposes. This also means that only properly aligned pointers can be used.
2020-11-09AK: Rename new_out to out and new_warn to warn.asynts