Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/Tizen.System.Session/Session/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Tizen.System
/// <summary>
/// Provides methods to manage subsession users. Allows to register for events triggered by operations on subsession users.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public sealed class Session
{
/// <summary>
Expand All @@ -40,13 +40,13 @@ public sealed class Session
/// <summary>
/// Maximum length of any given user ID.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public const int MaxUserLength = 20;

/// <summary>
/// Special subsession ID, which is always present and does not represent any user.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public const string EmptyUser = "";

private static ConcurrentDictionary<int, Session> s_sessionInstances = new ConcurrentDictionary<int, Session>();
Expand Down Expand Up @@ -77,7 +77,7 @@ private Session(int sessionUID)
/// <remarks>
/// To ensure thread safety, explicit creation of Session object is not allowed.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public static Session GetInstance(int sessionUID)
{
if (!s_sessionInstances.ContainsKey(sessionUID))
Expand All @@ -88,7 +88,7 @@ public static Session GetInstance(int sessionUID)
/// <summary>
/// Gets session UID of this session object.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public int SessionUID { get; private set; }

/// <summary>
Expand All @@ -107,6 +107,7 @@ public static Session GetInstance(int sessionUID)
/// <exception cref="IOException">Internal error</exception>
/// <exception cref="UnauthorizedAccessException">Not permitted</exception>
/// <exception cref="NotSupportedException">Not supported</exception>
/// <returns>A read-only list of all subsession IDs for this session.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public IReadOnlyList<string> GetUsers()
{
Expand Down Expand Up @@ -137,6 +138,7 @@ public IReadOnlyList<string> GetUsers()
/// <exception cref="IOException">Internal error</exception>
/// <exception cref="UnauthorizedAccessException">Not permitted</exception>
/// <exception cref="NotSupportedException">Not supported</exception>
/// <returns>The currently active subsession user ID, or "" (EmptyUser) when no subsession is enabled.</returns>

@mbloch1 mbloch1 Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetCurrent and GetUsers are purposefully not exposed to the public API, because this is how it also looks like for the native C API. As far as I can tell this is because the use case is for things that only care about changes to sessions (think a "session changed from X to Y!" popup; or an installer that applies something to newly added sessions and performs cleanup for removed ones) without caring much about the current session or the list, such that the event listeners are sufficient.

[EditorBrowsable(EditorBrowsableState.Never)]
public string GetCurrentUser()
{
Expand Down Expand Up @@ -286,13 +288,13 @@ public Task SubsessionSwitchUserAsync(string userName)
/// <param name="subsessionEventArgs">Event argument of the event (obtained from said event)</param>
/// <remarks>
/// This method is assumed to be called from an event handler. You can only mark an event as completed
/// if you registered for in in the same process.
/// if you registered for it in the same process.
/// </remarks>
/// <exception cref="ArgumentException">Session UID of this object is invalid</exception>
/// <exception cref="IOException">Internal error</exception>
/// <exception cref="UnauthorizedAccessException">Not permitted</exception>
/// <exception cref="NotSupportedException">Not supported</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public void SubsessionEventMarkAsDone(SubsessionEventArgs subsessionEventArgs)
{
SessionError ret = Interop.Session.SubsessionEventWaitDone(subsessionEventArgs.SessionInfo);
Expand All @@ -318,7 +320,7 @@ private void OnAddUserWait(SubsessionEventInfoNative infoNative, IntPtr data)
/// <exception cref="IOException">Internal error</exception>
/// <exception cref="UnauthorizedAccessException">Not permitted</exception>
/// <exception cref="NotSupportedException">Not supported</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public event EventHandler<AddUserEventArgs> AddUserWait
{
add
Expand Down Expand Up @@ -360,7 +362,7 @@ private void OnRemoveUserWait(SubsessionEventInfoNative infoNative, IntPtr data)
/// <exception cref="IOException">Internal error</exception>
/// <exception cref="UnauthorizedAccessException">Not permitted</exception>
/// <exception cref="NotSupportedException">Not supported</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public event EventHandler<RemoveUserEventArgs> RemoveUserWait
{
add
Expand Down Expand Up @@ -402,7 +404,7 @@ private void OnSwitchUserWait(SubsessionEventInfoNative infoNative, IntPtr data)
/// <exception cref="IOException">Internal error</exception>
/// <exception cref="UnauthorizedAccessException">Not permitted</exception>
/// <exception cref="NotSupportedException">Not supported</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public event EventHandler<SwitchUserWaitEventArgs> SwitchUserWait
{
add
Expand Down Expand Up @@ -444,7 +446,7 @@ private void OnSwitchUserCompletion(SubsessionEventInfoNative infoNative, IntPtr
/// <exception cref="IOException">Internal error</exception>
/// <exception cref="UnauthorizedAccessException">Not permitted</exception>
/// <exception cref="NotSupportedException">Not supported</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public event EventHandler<SwitchUserCompletionEventArgs> SwitchUserCompleted
{
add
Expand Down
34 changes: 17 additions & 17 deletions src/Tizen.System.Session/Session/SessionEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ namespace Tizen.System
/// You can check the event type that was invoked by checking a type of event arguments
/// during runtime - they all derive from this base class.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public abstract class SubsessionEventArgs : EventArgs
{
/// <summary>
/// Session UID of the session invoking the event
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public int SessionUID { get; internal set; }

internal SubsessionEventInfoNative SessionInfo { get; set; }
Expand All @@ -50,13 +50,13 @@ internal SubsessionEventArgs(SubsessionEventInfoNative eventInfo)
/// <summary>
/// An event argument type for AddUserWait event type
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public class AddUserEventArgs : SubsessionEventArgs
{
/// <summary>
/// Added subsession user ID
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// </summary>
/// <since_tizen>14</since_tizen>
public string UserName { get; internal set; }

internal AddUserEventArgs(SubsessionEventInfoNative eventInfo)
Expand All @@ -75,13 +75,13 @@ internal AddUserEventArgs(SubsessionEventInfoNative eventInfo)
/// <summary>
/// An event argument type for RemoveUserWait event type
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public class RemoveUserEventArgs : SubsessionEventArgs
{
/// <summary>
/// Removed subsession user ID
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// </summary>
/// <since_tizen>14</since_tizen>
public string UserName { get; internal set; }

internal RemoveUserEventArgs(SubsessionEventInfoNative eventInfo)
Expand All @@ -99,25 +99,25 @@ internal RemoveUserEventArgs(SubsessionEventInfoNative eventInfo)
/// <summary>
/// A generic base class for Switch event types
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public abstract class SwitchUserEventArgs : SubsessionEventArgs
{
/// <summary>
/// ID of this switch operation
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// </summary>
/// <since_tizen>14</since_tizen>
public long SwitchID { get; internal set; }

/// <summary>
/// Active subsession user ID before this switch operation
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// </summary>
/// <since_tizen>14</since_tizen>
public string UserNamePrev { get; internal set; }

/// <summary>
/// Active subsession ID after this switch operation
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// </summary>
/// <since_tizen>14</since_tizen>
public string UserNameNext { get; internal set; }

internal SwitchUserEventArgs(SubsessionEventInfoNative eventInfo)
Expand All @@ -141,7 +141,7 @@ internal SwitchUserEventArgs(SubsessionEventInfoNative eventInfo)
/// <summary>
/// An event argument type for SwitchUserWait event type
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public class SwitchUserWaitEventArgs : SwitchUserEventArgs
{
internal SwitchUserWaitEventArgs(SubsessionEventInfoNative eventInfo) : base(eventInfo) { }
Expand All @@ -150,7 +150,7 @@ internal SwitchUserWaitEventArgs(SubsessionEventInfoNative eventInfo) : base(eve
/// <summary>
/// An event argument type for SwitchUserCompleted event type
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <since_tizen>14</since_tizen>
public class SwitchUserCompletionEventArgs : SwitchUserEventArgs
{
internal SwitchUserCompletionEventArgs(SubsessionEventInfoNative eventInfo) : base(eventInfo) { }
Expand Down
Loading