Add words about adding support for a new OS
Add a skel file (task-manager-skel.c) and make it possible in the build-env to build the task manager with this file (--with-skel).
This commit is contained in:
39
README.OS-implementation
Normal file
39
README.OS-implementation
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
If you are reading this file it's good news, it may imply you are interested in coding, but
|
||||||
|
maybe even into adding support for a new operating system.
|
||||||
|
|
||||||
|
The bare minimum to implement can be copied from the file src/task-manager-skel.c, knowing
|
||||||
|
the existing implementations can serve as good examples. All the needed headers are declared
|
||||||
|
inside the file src/task-manager.h.
|
||||||
|
|
||||||
|
If you have trouble to add compilation to the build-env (autotools) you can run the
|
||||||
|
configure script (./autogen.sh or ./configure) with the flag --with-skel and put your
|
||||||
|
modifications inside the task-manager-skel.c file directly.
|
||||||
|
|
||||||
|
When done, send a patch to Bugzilla (bugzilla.xfce.org).
|
||||||
|
|
||||||
|
Some tips
|
||||||
|
---------
|
||||||
|
|
||||||
|
You may cache values, declare 'static <TYPE> <VARIABLE>' under the includes for global
|
||||||
|
access, or inside functions for local access.
|
||||||
|
|
||||||
|
You may need a local function to calculate the CPU usage in percent for the system and/or
|
||||||
|
the processes, for this have a look at the function get_cpu_percent() from the linux and
|
||||||
|
solaris files.
|
||||||
|
|
||||||
|
The refresh rate can be different than one second, make sure the CPU keeps correct by
|
||||||
|
changing it.
|
||||||
|
|
||||||
|
Implementing the function pid_is_sleeping() is needed to show either the signal Stop or
|
||||||
|
Continue inside the graphical interface.
|
||||||
|
|
||||||
|
The function get_task_list provides an empty but initialized GArray pointer as argument that
|
||||||
|
just has to be filled in with the current list of tasks.
|
||||||
|
|
||||||
|
If there are information you are unable to provide because unexistent on the system, fill in
|
||||||
|
these values with 0. A good example is the swap (sometimes because there is no swap set,
|
||||||
|
doesn't mean we have to show swap information), when the total equals to zero it is hidden
|
||||||
|
from the interface. The same can be applied to some of the CPU (system or user may be
|
||||||
|
useless) and memory information (buffer and/or cache may be left out).
|
||||||
|
|
||||||
|
That's it!
|
||||||
@@ -65,10 +65,21 @@ dnl *** Check for required packages ***
|
|||||||
dnl ***********************************
|
dnl ***********************************
|
||||||
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.12.0])
|
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.12.0])
|
||||||
|
|
||||||
|
dnl ***********************************
|
||||||
|
dnl ********** Check for skel *********
|
||||||
|
dnl ***********************************
|
||||||
|
AC_ARG_WITH([skel],
|
||||||
|
AC_HELP_STRING([--with-skel], [build with task-manager-skel.c]),
|
||||||
|
[ac_skel="$withval"],
|
||||||
|
[ac_skel=no])
|
||||||
|
|
||||||
dnl ***********************************
|
dnl ***********************************
|
||||||
dnl ******* Check for OS family *******
|
dnl ******* Check for OS family *******
|
||||||
dnl ***********************************
|
dnl ***********************************
|
||||||
case "$target_os" in
|
if test x"$ac_skel" = x"yes"; then
|
||||||
|
ac_os_implementation="skel"
|
||||||
|
else
|
||||||
|
case "$target_os" in
|
||||||
freebsd*)
|
freebsd*)
|
||||||
ac_os_implementation="freebsd"
|
ac_os_implementation="freebsd"
|
||||||
AC_CHECK_LIB([kvm], [kvm_openfiles])
|
AC_CHECK_LIB([kvm], [kvm_openfiles])
|
||||||
@@ -95,7 +106,8 @@ case "$target_os" in
|
|||||||
AC_MSG_CHECKING([for OS implementation])
|
AC_MSG_CHECKING([for OS implementation])
|
||||||
AC_MSG_ERROR([no OS implementation for $target_os is available])
|
AC_MSG_ERROR([no OS implementation for $target_os is available])
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
AC_MSG_CHECKING([for OS implementation])
|
AC_MSG_CHECKING([for OS implementation])
|
||||||
AC_MSG_RESULT([$ac_os_implementation])
|
AC_MSG_RESULT([$ac_os_implementation])
|
||||||
|
|
||||||
@@ -103,6 +115,7 @@ AM_CONDITIONAL([OS_FREEBSD], [test x"$ac_os_implementation" = x"freebsd"])
|
|||||||
AM_CONDITIONAL([OS_BSD], [test x"$ac_os_implementation" = x"bsd"])
|
AM_CONDITIONAL([OS_BSD], [test x"$ac_os_implementation" = x"bsd"])
|
||||||
AM_CONDITIONAL([OS_SOLARIS], [test x"$ac_os_implementation" = x"solaris"])
|
AM_CONDITIONAL([OS_SOLARIS], [test x"$ac_os_implementation" = x"solaris"])
|
||||||
AM_CONDITIONAL([OS_LINUX], [test x"$ac_os_implementation" = x"linux"])
|
AM_CONDITIONAL([OS_LINUX], [test x"$ac_os_implementation" = x"linux"])
|
||||||
|
AM_CONDITIONAL([OS_SKEL], [test x"$ac_os_implementation" = x"skel"])
|
||||||
|
|
||||||
dnl ***********************************
|
dnl ***********************************
|
||||||
dnl *** Check for debugging support ***
|
dnl *** Check for debugging support ***
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ endif
|
|||||||
if OS_LINUX
|
if OS_LINUX
|
||||||
xfce4_taskmanager_SOURCES += task-manager-linux.c
|
xfce4_taskmanager_SOURCES += task-manager-linux.c
|
||||||
endif
|
endif
|
||||||
|
if OS_SKEL
|
||||||
|
xfce4_taskmanager_SOURCES += task-manager-skel.c
|
||||||
|
endif
|
||||||
|
|
||||||
if MAINTAINER_MODE
|
if MAINTAINER_MODE
|
||||||
BUILT_SOURCES = process-window_ui.h
|
BUILT_SOURCES = process-window_ui.h
|
||||||
|
|||||||
87
src/task-manager-skel.c
Normal file
87
src/task-manager-skel.c
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) <YEAR> <AUTHOR> <EMAIL>
|
||||||
|
*
|
||||||
|
* <LICENCE, BELOW IS GPL2+ AS EXAMPLE>
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Add includes for system functions needed */
|
||||||
|
/* Example:
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "task-manager.h"
|
||||||
|
|
||||||
|
/* Cache some values */
|
||||||
|
/* Example:
|
||||||
|
static gushort _cpu_count = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64 *memory_cache, guint64 *memory_buffers, guint64 *swap_total, guint64 *swap_free)
|
||||||
|
{
|
||||||
|
*memory_total = 0;
|
||||||
|
*memory_free = 0;
|
||||||
|
*memory_cache = 0;
|
||||||
|
*memory_buffers = 0;
|
||||||
|
*swap_total = 0;
|
||||||
|
*swap_free = 0;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
|
||||||
|
{
|
||||||
|
*cpu_user = *cpu_system = 0.0;
|
||||||
|
*cpu_count = 0; /*_cpu_count;*/
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
get_task_details (guint pid, Task *task)
|
||||||
|
{
|
||||||
|
g_snprintf (task->name, 256, "foo");
|
||||||
|
g_snprintf (task->cmdline, 1024, "foo -bar");
|
||||||
|
g_snprintf (task->uid_name, 256, "baz");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
get_task_list (GArray *task_list)
|
||||||
|
{
|
||||||
|
guint pid;
|
||||||
|
Task task = { 0 };
|
||||||
|
|
||||||
|
//while (/* read all PIDs */)
|
||||||
|
{
|
||||||
|
// if (/* pid is valid */)
|
||||||
|
{
|
||||||
|
if (get_task_details (pid, &task))
|
||||||
|
{
|
||||||
|
g_array_append_val (task_list, task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
pid_is_sleeping (guint pid)
|
||||||
|
{
|
||||||
|
/* Read state of PID @pid... */
|
||||||
|
|
||||||
|
return FALSE; /* (state == sleeping) ? TRUE : FALSE;*/
|
||||||
|
}
|
||||||
|
|
||||||
@@ -38,27 +38,6 @@ struct _Task
|
|||||||
gshort prio;
|
gshort prio;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Enumerations of virtual values between the interface and the OS implementation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
XTM_SIGNAL_TERMINATE = 0,
|
|
||||||
XTM_SIGNAL_STOP,
|
|
||||||
XTM_SIGNAL_CONTINUE,
|
|
||||||
XTM_SIGNAL_KILL,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
XTM_PRIORITY_VERY_LOW = 0,
|
|
||||||
XTM_PRIORITY_LOW,
|
|
||||||
XTM_PRIORITY_NORMAL,
|
|
||||||
XTM_PRIORITY_HIGH,
|
|
||||||
XTM_PRIORITY_VERY_HIGH,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OS specific implementation.
|
* OS specific implementation.
|
||||||
*/
|
*/
|
||||||
@@ -94,6 +73,23 @@ void xtm_task_manager_update_model (XtmTaskManager *manager);
|
|||||||
* Helper functions.
|
* Helper functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
XTM_SIGNAL_TERMINATE = 0,
|
||||||
|
XTM_SIGNAL_STOP,
|
||||||
|
XTM_SIGNAL_CONTINUE,
|
||||||
|
XTM_SIGNAL_KILL,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
XTM_PRIORITY_VERY_LOW = 0,
|
||||||
|
XTM_PRIORITY_LOW,
|
||||||
|
XTM_PRIORITY_NORMAL,
|
||||||
|
XTM_PRIORITY_HIGH,
|
||||||
|
XTM_PRIORITY_VERY_HIGH,
|
||||||
|
};
|
||||||
|
|
||||||
void get_owner_uid (guint *owner_uid, gchar **owner_uid_name);
|
void get_owner_uid (guint *owner_uid, gchar **owner_uid_name);
|
||||||
gchar * get_hostname ();
|
gchar * get_hostname ();
|
||||||
gboolean send_signal_to_pid (guint pid, gint signal);
|
gboolean send_signal_to_pid (guint pid, gint signal);
|
||||||
|
|||||||
Reference in New Issue
Block a user