Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
S
scom
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
scom
Commits
eb80fc78
Kaydet (Commit)
eb80fc78
authored
Haz 08, 2008
tarafından
Bahadır Kandemir
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Get process locale and translate strings properly
üst
62820176
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
3 deletions
+86
-3
CMakeLists.txt
comar/CMakeLists.txt
+2
-1
dbus.h
comar/include/dbus.h
+2
-1
process.h
comar/include/process.h
+1
-0
utility.h
comar/include/utility.h
+2
-0
csl.c
comar/src/csl.c
+6
-1
dbus.c
comar/src/dbus.c
+40
-0
process.c
comar/src/process.c
+3
-0
utility.c
comar/src/utility.c
+30
-0
No files found.
comar/CMakeLists.txt
Dosyayı görüntüle @
eb80fc78
...
...
@@ -62,7 +62,8 @@ SET (SOURCES src/main.c
SET
(
LIBS python2.5
dbus-1
polkit-dbus
db
)
db
proc
)
# Include standard headers
INCLUDE_DIRECTORIES
(
include/
...
...
comar/include/dbus.h
Dosyayı görüntüle @
eb80fc78
...
...
@@ -7,11 +7,12 @@
** option) any later version. Please read the COPYING file.
*/
#include <dbus/dbus.h>
#include <Python.h>
#include <dbus/dbus.h>
void
dbus_send
(
DBusMessage
*
reply
);
void
dbus_signal
(
const
char
*
path
,
const
char
*
interface
,
const
char
*
name
,
PyObject
*
obj
);
void
dbus_method_call
(
DBusMessage
*
msg
,
DBusConnection
*
conn
);
void
dbus_listen
();
void
dbus_app_methods
(
const
char
*
interface
,
const
char
*
path
,
const
char
*
method
);
char
*
dbus_caller_locale
(
DBusMessage
*
msg
);
comar/include/process.h
Dosyayı görüntüle @
eb80fc78
...
...
@@ -21,6 +21,7 @@ struct Proc {
// parent info
struct
ProcChild
parent
;
const
char
*
desc
;
const
char
*
locale
;
// children info
int
nr_children
;
int
max_children
;
...
...
comar/include/utility.h
Dosyayı görüntüle @
eb80fc78
...
...
@@ -17,3 +17,5 @@ char *load_file(const char *fname, int *sizeptr);
int
save_file
(
const
char
*
fname
,
const
char
*
buffer
,
size_t
size
);
unsigned
long
time_diff
(
struct
timeval
*
start
,
struct
timeval
*
end
);
char
*
get_proc_lang
(
pid_t
pid
);
comar/src/csl.c
Dosyayı görüntüle @
eb80fc78
...
...
@@ -44,7 +44,12 @@ c_i18n(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"O!"
,
&
PyDict_Type
,
&
dict
))
return
NULL
;
ret
=
PyDict_GetItemString
(
dict
,
"en"
);
if
(
my_proc
.
locale
)
{
ret
=
PyDict_GetItemString
(
dict
,
my_proc
.
locale
);
}
else
{
ret
=
PyDict_GetItemString
(
dict
,
"en"
);
}
Py_INCREF
(
ret
);
return
ret
;
}
...
...
comar/src/dbus.c
Dosyayı görüntüle @
eb80fc78
...
...
@@ -156,6 +156,46 @@ dbus_signal(const char *path, const char *interface, const char *name, PyObject
dbus_send
(
msg
);
}
//! Get locale of caller
char
*
dbus_caller_locale
(
DBusMessage
*
msg
)
{
const
char
*
sender
=
dbus_message_get_sender
(
msg
);
DBusError
err
;
DBusConnection
*
conn
;
PolKitContext
*
polkit_ctx
;
PolKitCaller
*
polkit_clr
;
PolKitError
*
perr
;
dbus_error_init
(
&
err
);
conn
=
dbus_bus_get_private
(
DBUS_BUS_SYSTEM
,
&
err
);
if
(
dbus_error_is_set
(
&
err
))
{
log_error
(
"Unable to open connection to query CK: %s
\n
"
,
err
.
message
);
dbus_error_free
(
&
err
);
return
NULL
;
}
polkit_ctx
=
polkit_context_new
();
if
(
!
polkit_context_init
(
polkit_ctx
,
&
perr
))
{
log_error
(
"Unable to initialize PK context: %s
\n
"
,
polkit_error_get_error_message
(
perr
));
polkit_error_free
(
perr
);
return
NULL
;
}
polkit_clr
=
polkit_caller_new_from_dbus_name
(
conn
,
sender
,
&
err
);
if
(
dbus_error_is_set
(
&
err
))
{
log_error
(
"Unable to get caller info: %s
\n
"
,
err
.
message
);
dbus_error_free
(
&
err
);
return
NULL
;
}
pid_t
pid
;
polkit_caller_get_pid
(
polkit_clr
,
&
pid
);
return
get_proc_lang
(
pid
);
}
//! Creates a message from Python object and sends
static
void
dbus_reply_object
(
PyObject
*
obj
)
...
...
comar/src/process.c
Dosyayı görüntüle @
eb80fc78
...
...
@@ -7,6 +7,7 @@
** option) any later version. Please read the COPYING file.
*/
#include <Python.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
...
...
@@ -21,6 +22,7 @@
#include <time.h>
#include "cfg.h"
#include "dbus.h"
#include "log.h"
#include "process.h"
...
...
@@ -318,6 +320,7 @@ proc_fork(void (*child_func)(void), const char *desc, DBusConnection *bus_conn,
my_proc
.
parent
.
to
=
fdr
[
1
];
my_proc
.
parent
.
pid
=
getppid
();
my_proc
.
desc
=
desc
;
my_proc
.
locale
=
dbus_caller_locale
(
bus_msg
);
my_proc
.
bus_conn
=
bus_conn
;
my_proc
.
bus_msg
=
bus_msg
;
handle_signals
();
...
...
comar/src/utility.c
Dosyayı görüntüle @
eb80fc78
...
...
@@ -13,9 +13,39 @@
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
#include <proc/readproc.h>
#include "utility.h"
//! Returns locale of a process
char
*
get_proc_lang
(
pid_t
pid
)
{
pid_t
pids
[
2
];
pids
[
0
]
=
pid
;
pids
[
1
]
=
0
;
proc_t
proc
;
PROCTAB
*
ptp
;
int
i
=
0
;
char
*
lang
=
NULL
;
ptp
=
openproc
(
PROC_FILLENV
|
PROC_PID
,
pids
);
while
(
readproc
(
ptp
,
&
proc
))
{
while
(
proc
.
environ
[
++
i
])
{
if
(
strncmp
(
proc
.
environ
[
i
-
1
],
"LANG"
,
4
)
==
0
)
{
lang
=
strsub
(
proc
.
environ
[
i
-
1
],
5
,
7
);
goto
out
;
}
}
}
out:
closeproc
(
ptp
);
return
lang
;
}
//! Returns part of a string
char
*
strsub
(
const
char
*
str
,
int
start
,
int
end
)
...
...
Write
Preview
Markdown
is supported
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