Skip to content

Commit 8daec63

Browse files
committed
[APPFW] Implement Team Application C# Interface
- Implement Interop, Wrapper Class to implement C# Team Application - Add OnCreate Error Handling - When the application start, TeamManager will hold the application instance to guarantee the object alive until exit. - Implement TeamViewApplication Signed-off-by: Jihoi Kim <jihoi.kim@samsung.com>
1 parent 3cb24e1 commit 8daec63

28 files changed

Lines changed: 4376 additions & 0 deletions
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2026 Samsung Electronics Co., Ltd All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the License);
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an AS IS BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using System;
18+
using System.IO;
19+
using System.Runtime.InteropServices;
20+
21+
namespace Tizen.Applications
22+
{
23+
internal static class CultureInfoHelper
24+
{
25+
private const string _pathCultureInfoIni = "/usr/share/dotnet.tizen/framework/i18n/CultureInfo.ini";
26+
private static bool _fileExists = File.Exists(_pathCultureInfoIni);
27+
28+
public static string GetCultureName(string locale)
29+
{
30+
if (!_fileExists)
31+
{
32+
return string.Empty;
33+
}
34+
35+
IntPtr dictionary = Interop.LibIniParser.Load(_pathCultureInfoIni);
36+
if (dictionary == IntPtr.Zero)
37+
{
38+
return string.Empty;
39+
}
40+
41+
string cultureName = string.Empty;
42+
#pragma warning disable CA1308
43+
string key = "CultureInfo:" + locale.ToLowerInvariant();
44+
#pragma warning restore CA1308
45+
IntPtr value = Interop.LibIniParser.GetString(dictionary, key, IntPtr.Zero);
46+
if (value != IntPtr.Zero)
47+
{
48+
cultureName = Marshal.PtrToStringAnsi(value);
49+
}
50+
51+
Interop.LibIniParser.FreeDict(dictionary);
52+
return cultureName;
53+
}
54+
}
55+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2026 Samsung Electronics Co., Ltd All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the License);
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an AS IS BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using System;
18+
using System.Collections.Concurrent;
19+
20+
namespace Tizen.Applications
21+
{
22+
internal static class GSourceManager
23+
{
24+
private static readonly GSourceContext _tizenContext = new GSourceContext();
25+
private static readonly GSourceContext _tizenUIContext = new GSourceContext();
26+
private static readonly Interop.Glib.GSourceFunc _wrapperHandler = new Interop.Glib.GSourceFunc(Handler);
27+
28+
public static void Post(Action action)
29+
{
30+
IntPtr context = IntPtr.Zero;
31+
var sourceContext = context == IntPtr.Zero ? _tizenContext : _tizenUIContext;
32+
sourceContext.Post(action, context, _wrapperHandler);
33+
}
34+
35+
private static bool Handler(IntPtr userData)
36+
{
37+
var sourceContext = userData == IntPtr.Zero ? _tizenContext : _tizenUIContext;
38+
return sourceContext.ProcessQueue();
39+
}
40+
}
41+
42+
internal class GSourceContext
43+
{
44+
private readonly ConcurrentQueue<Action> _actionQueue = new ConcurrentQueue<Action>();
45+
private readonly object _lock = new object();
46+
private IntPtr _source = IntPtr.Zero;
47+
48+
public void Post(Action action, IntPtr context, Interop.Glib.GSourceFunc handler)
49+
{
50+
_actionQueue.Enqueue(action);
51+
52+
lock (_lock)
53+
{
54+
if (_source != IntPtr.Zero)
55+
{
56+
return;
57+
}
58+
59+
_source = Interop.Glib.IdleSourceNew();
60+
Interop.Glib.SourceSetCallback(_source, handler, context, IntPtr.Zero);
61+
_ = Interop.Glib.SourceAttach(_source, context);
62+
Interop.Glib.SourceUnref(_source);
63+
}
64+
}
65+
66+
public bool ProcessQueue()
67+
{
68+
if (_actionQueue.TryDequeue(out var action))
69+
{
70+
action?.Invoke();
71+
}
72+
73+
lock (_lock)
74+
{
75+
if (!_actionQueue.IsEmpty)
76+
{
77+
return true;
78+
}
79+
80+
_source = IntPtr.Zero;
81+
}
82+
83+
return false;
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)